Skip to content

Commit

Permalink
Vert.x 4 update (#1438)
Browse files Browse the repository at this point in the history
* Vert.x 4 Update
  • Loading branch information
udovidio authored Oct 7, 2022
1 parent 2ab7b24 commit a9ee2fd
Show file tree
Hide file tree
Showing 94 changed files with 4,180 additions and 623 deletions.
2 changes: 1 addition & 1 deletion .jenkins/run-splits.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ fi
echo "Running tests: $tests"
jacoco=$2
echo "Using jacoco: $jacoco"
time mvn -fae -Dsurefire.excludedGroups=com.gentics.mesh.test.category.FailingTests,com.gentics.mesh.test.category.ClusterTests -Dmaven.javadoc.skip=true -Dskip.cluster.tests=true -Dmaven.test.failure.ignore=true -Dmesh.container.image.prefix=docker.apa-it.at/ -B -e -pl '!demo/default,!doc,!performance-tests' test -Dtest=$tests -DfailIfNoTests=false -Djacoco.skip=$jacoco | ts "$3 [%Y-%m-%d %H:%M:%S]"
time mvn -fae -Dsurefire.excludedGroups=com.gentics.mesh.test.category.FailingTests,com.gentics.mesh.test.category.ClusterTests -Dmaven.javadoc.skip=true -Dskip.cluster.tests=true -Dskip.vertx-hazelcast=true -Dmaven.test.failure.ignore=true -Dmesh.container.image.prefix=docker.apa-it.at/ -B -e -pl '!demo/default,!doc,!performance-tests' test -Dtest=$tests -DfailIfNoTests=false -Djacoco.skip=$jacoco | ts "$3 [%Y-%m-%d %H:%M:%S]"
3 changes: 3 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ icon:plus[] Core: The OrientDB database as been updated to version 3.2.10.

icon:plus[] Rest: The new endpoints `/api/v2/.../rolePermissions` allow getting, granting and revoking permissions on entities for multiple roles in a single request.

icon:plus[] Core: The core Vert.x library was updated to version `4.3.2`.


[[v1.9.3]]
== 1.9.3 (22.09.2022)

Expand Down
11 changes: 6 additions & 5 deletions Jenkinsfile.split
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ stage("Setup Build Environment") {
echo "Setup of GPG"
sh "gpg --no-tty --batch --import /mnt/credentials/gpg/gpg-public-key.asc"
sh "gpg --no-tty --batch --import /mnt/credentials/gpg/gpg-secret-key.asc"
withCredentials([usernamePassword(credentialsId: 'gentics.gpg', usernameVariable: 'gpgKeyName', passwordVariable: 'gpgKeyPass')]) {
sh "mvn -ff -B -U -Dmaven.javadoc.skip=true -Dskip.test-plugins=false -Dskip.cluster.tests=true -Dgpg.skip=false -DskipTests ${extraFlags} clean install"
withCredentials([usernamePassword(credentialsId: 'repo.gentics.com', usernameVariable: 'repoUsername', passwordVariable: 'repoPassword'),
usernamePassword(credentialsId: 'gentics.gpg', usernameVariable: 'gpgKeyName', passwordVariable: 'gpgKeyPass')]) {
sh "mvn -ff -B -U -Dmaven.javadoc.skip=true -Dskip.test-plugins=false -Dskip.cluster.tests=true -Dskip.vertx-hazelcast=true -Dgpg.skip=false -DskipTests ${extraFlags} clean install"
}
} else {
echo "Omitted since we don't execute tests"
Expand Down Expand Up @@ -116,7 +117,7 @@ stage("Setup Build Environment") {
} else {
sshagent(["git"]) {
try {
sh "mvn -fae -Dsurefire.excludedGroups=com.gentics.mesh.test.category.FailingTests,com.gentics.mesh.test.category.ClusterTests -Dmaven.javadoc.skip=true -Dskip.cluster.tests=true -Dmaven.test.failure.ignore=true -Dmesh.container.image.prefix=docker.apa-it.at/ -B -U -e -pl '!ferma,!demo/default,!doc,!performance-tests' clean install"
sh "mvn -fae -Dsurefire.excludedGroups=com.gentics.mesh.test.category.FailingTests,com.gentics.mesh.test.category.ClusterTests -Dmaven.javadoc.skip=true -Dskip.cluster.tests=true -Dskip.vertx-hazelcast=true -Dmaven.test.failure.ignore=true -Dmesh.container.image.prefix=docker.apa-it.at/ -B -U -e -pl '!ferma,!demo/default,!doc,!performance-tests' clean install"
} finally {
step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/*.xml'])
}
Expand All @@ -131,7 +132,7 @@ stage("Setup Build Environment") {
if (Boolean.valueOf(params.runUnstableTests)) {
sshagent(["git"]) {
try {
sh "mvn -fae -Dsurefire.groups=com.gentics.mesh.test.category.FailingTests -Dmaven.javadoc.skip=true -Dskip.cluster.tests=true -Dmaven.test.failure.ignore=true -Dmesh.container.image.prefix=docker.apa-it.at/ -B -e -pl '!ferma,!demo/default,!doc,!performance-tests' test -DfailIfNoTests=false"
sh "mvn -fae -Dsurefire.groups=com.gentics.mesh.test.category.FailingTests -Dmaven.javadoc.skip=true -Dskip.cluster.tests=true -Dskip.vertx-hazelcast=true -Dmaven.test.failure.ignore=true -Dmesh.container.image.prefix=docker.apa-it.at/ -B -e -pl '!ferma,!demo/default,!doc,!performance-tests' test -DfailIfNoTests=false"
} finally {
step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/*.xml'])
}
Expand Down Expand Up @@ -218,7 +219,7 @@ stage("Setup Build Environment") {
node("mesh-performance-worker-11") {
try {
unstash 'project'
sh "mvn -B -U clean package -pl '!doc,!demo/default,!server' -Dskip.unit.tests=true -Dskip.cluster.tests=true -Dskip.performance.tests=false -Dmaven.test.failure.ignore=true -Dmesh.container.image.prefix=docker.apa-it.at/"
sh "mvn -B -U clean package -pl '!doc,!demo/default,!server' -Dskip.unit.tests=true -Dskip.cluster.tests=true -Dskip.vertx-hazelcast=true -Dskip.performance.tests=false -Dmaven.test.failure.ignore=true -Dmesh.container.image.prefix=docker.apa-it.at/"
} finally {
step([$class: 'JUnitResultArchiver', testResults: '**/target/*.performance.xml'])
deleteDir()
Expand Down
4 changes: 4 additions & 0 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>

<dependency>
<groupId>com.github.stefanbirkner</groupId>
Expand Down
9 changes: 8 additions & 1 deletion bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<hazelcast.version>3.12.8</hazelcast.version>
<jackson.version>2.13.2</jackson.version>
<jackson-databind.version>2.13.2</jackson-databind.version>
<netty.version>4.1.72.Final</netty.version>
<netty.version>4.1.78.Final</netty.version>
<tika.version>1.26</tika.version>
<aws.sdk.version>2.16.83</aws.sdk.version>
<snakeyaml.version>1.30</snakeyaml.version>
Expand Down Expand Up @@ -497,6 +497,13 @@
<version>2.6.0</version>
</dependency>

<!-- Vertx Hazelcast cluster manager -->
<dependency>
<groupId>com.gentics.mesh</groupId>
<artifactId>hazelcast3-cluster-manager</artifactId>
<version>${project.version}</version>
</dependency>

<!-- Mesh Test Internals -->
<dependency>
<groupId>com.gentics.mesh</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
import io.vertx.core.AsyncResult;
import io.vertx.core.Handler;
import io.vertx.core.http.HttpServerRequest;
import io.vertx.core.json.JsonObject;
import io.vertx.core.logging.Logger;
import io.vertx.core.logging.LoggerFactory;
import io.vertx.ext.auth.User;
import io.vertx.ext.web.RoutingContext;
import io.vertx.ext.web.handler.impl.AuthHandlerImpl;
import io.vertx.ext.web.handler.impl.AuthenticationHandlerImpl;

/**
* Auth handler which will deal with anonymous auth handling. This handler will only auth the user if anonymous auth is enabled and the request does not contain
* any auth header.
*/
@Singleton
public class MeshAnonymousAuthHandler extends AuthHandlerImpl implements MeshAuthHandler {
public class MeshAnonymousAuthHandler extends AuthenticationHandlerImpl<MeshJWTAuthProvider> implements MeshAuthHandler {

public static final String ANONYMOUS_USERNAME = "anonymous";

Expand All @@ -45,7 +45,7 @@ public MeshAnonymousAuthHandler(MeshJWTAuthProvider authProvider, MeshOptions op
}

@Override
public void parseCredentials(RoutingContext arg0, Handler<AsyncResult<JsonObject>> arg1) {
public void authenticate(RoutingContext routingContext, Handler<AsyncResult<User>> handler) {
// Not needed for this handler
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import io.vertx.ext.auth.User;
import io.vertx.ext.web.RoutingContext;
import io.vertx.ext.web.handler.AuthHandler;
import io.vertx.ext.web.handler.AuthenticationHandler;

/**
* Common interface all all custom Gentics Mesh Auth handlers.
* Common interface all custom Gentics Mesh Auth handlers.
*/
public interface MeshAuthHandler extends AuthHandler {
public interface MeshAuthHandler extends AuthenticationHandler {

/**
* Finish the request with code 401.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,23 @@

import io.vertx.core.AsyncResult;
import io.vertx.core.Handler;
import io.vertx.core.http.Cookie;
import io.vertx.core.http.HttpServerRequest;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import io.vertx.core.logging.Logger;
import io.vertx.core.logging.LoggerFactory;
import io.vertx.ext.auth.User;
import io.vertx.ext.web.Cookie;
import io.vertx.ext.web.RoutingContext;
import io.vertx.ext.web.handler.JWTAuthHandler;
import io.vertx.ext.web.handler.impl.AuthHandlerImpl;
import io.vertx.ext.web.handler.impl.AuthenticationHandlerImpl;

/**
* This class extends the Vert.x AuthHandler, so that it also works when the token is set as a cookie.
* This class extends the Vert.x AuthenticationHandlerImpl, so that it also works when the token is set as a cookie.
*
* Central authentication handler for mesh. All requests to secured resources must pass this handler.
*/
@Singleton
public class MeshJWTAuthHandler extends AuthHandlerImpl implements JWTAuthHandler, MeshAuthHandler {
public class MeshJWTAuthHandler extends AuthenticationHandlerImpl<MeshJWTAuthProvider> implements JWTAuthHandler, MeshAuthHandler {

private static final Logger log = LoggerFactory.getLogger(MeshJWTAuthHandler.class);

Expand All @@ -56,24 +55,6 @@ public MeshJWTAuthHandler(MeshJWTAuthProvider authProvider, MeshOptions meshOpti
options = new JsonObject();
}

@Override
public JWTAuthHandler setAudience(List<String> audience) {
options.put("audience", new JsonArray(audience));
return this;
}

@Override
public JWTAuthHandler setIssuer(String issuer) {
options.put("issuer", issuer);
return this;
}

@Override
public JWTAuthHandler setIgnoreExpiration(boolean ignoreExpiration) {
options.put("ignoreExpiration", ignoreExpiration);
return this;
}

@Override
public void handle(RoutingContext context) {
handle(context, false);
Expand All @@ -97,7 +78,7 @@ public void handle(RoutingContext context, boolean ignoreDecodeErrors) {
}

@Override
public void parseCredentials(RoutingContext arg0, Handler<AsyncResult<JsonObject>> arg1) {
public void authenticate(RoutingContext routingContext, Handler<AsyncResult<User>> handler) {
// Not needed for this handler
}

Expand Down Expand Up @@ -155,7 +136,7 @@ private void handleJWTAuth(RoutingContext context, boolean ignoreDecodeErrors) {
}

// 4. Authenticate the found token using JWT
JsonObject authInfo = new JsonObject().put("jwt", token).put("options", options);
JsonObject authInfo = new JsonObject().put("token", token).put("options", options);
authProvider.authenticateJWT(authInfo, res -> {

// Authentication was successful.
Expand Down Expand Up @@ -189,4 +170,18 @@ private void handleJWTAuth(RoutingContext context, boolean ignoreDecodeErrors) {
});
}

@Override
public JWTAuthHandler scopeDelimiter(String s) {
return this;
}

@Override
public JWTAuthHandler withScope(String s) {
return this;
}

@Override
public JWTAuthHandler withScopes(List<String> list) {
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import javax.inject.Inject;
import javax.inject.Singleton;

import com.gentics.mesh.auth.handler.MeshJWTAuthHandler;
import io.vertx.core.http.Cookie;
import io.vertx.ext.auth.authentication.AuthenticationProvider;
import org.apache.commons.lang.NotImplementedException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
Expand Down Expand Up @@ -36,7 +39,6 @@
import io.vertx.ext.auth.User;
import io.vertx.ext.auth.jwt.JWTAuth;
import io.vertx.ext.auth.jwt.JWTAuthOptions;
import io.vertx.ext.web.Cookie;

/**
* Central mesh authentication provider which will handle JWT.
Expand All @@ -46,7 +48,7 @@
*
*/
@Singleton
public class MeshJWTAuthProvider implements AuthProvider, JWTAuth {
public class MeshJWTAuthProvider implements AuthenticationProvider, JWTAuth {

private static final Logger log = LoggerFactory.getLogger(MeshJWTAuthProvider.class);

Expand Down Expand Up @@ -131,6 +133,11 @@ public String generateToken(JsonObject claims, JWTOptions options) {
throw new NotImplementedException();
}

@Override
public String generateToken(JsonObject jsonObject) {
throw new NotImplementedException();
}

/**
* Authenticates the user and returns a JWToken if successful.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,21 @@

import com.gentics.mesh.cache.EventAwareCache;
import com.gentics.mesh.etc.config.MeshOptions;
import com.gentics.mesh.event.EventBusStore;
import com.gentics.mesh.metric.MetricsService;

import io.vertx.core.Vertx;

/**
* Factory for {@link EventAwareCache} instances.
*/
@Singleton
public class EventAwareCacheFactory {

private final Vertx vertx;
private final EventBusStore eventBusStore;
private final MeshOptions meshOptions;
private final MetricsService metricsService;

@Inject
public EventAwareCacheFactory(Vertx vertx, MeshOptions meshOptions, MetricsService metricsService) {
this.vertx = vertx;
public EventAwareCacheFactory(EventBusStore eventBusStore, MeshOptions meshOptions, MetricsService metricsService) {
this.eventBusStore = eventBusStore;
this.meshOptions = meshOptions;
this.metricsService = metricsService;
}
Expand All @@ -35,7 +33,7 @@ public EventAwareCacheFactory(Vertx vertx, MeshOptions meshOptions, MetricsServi
*/
public <K, V> EventAwareCacheImpl.Builder<K, V> builder() {
return new EventAwareCacheImpl.Builder<K, V>()
.vertx(vertx)
.eventBusStore(eventBusStore)
.meshOptions(meshOptions)
.setMetricsService(metricsService);
}
Expand Down
Loading

0 comments on commit a9ee2fd

Please sign in to comment.