From 42e38399d3844872e7110b01dd4f3ac14ca62307 Mon Sep 17 00:00:00 2001 From: Kyle Thorpe Date: Wed, 4 Oct 2023 10:17:55 -0400 Subject: [PATCH] Fix vertx/reactive --- .../dagger-vertx-example/build.gradle | 16 +++++++-------- .../io/crnk/example/vertx/AppComponent.java | 2 +- .../java/io/crnk/example/vertx/AppModule.java | 20 +------------------ .../java/io/crnk/example/vertx/AppServer.java | 4 ++-- .../io/crnk/example/vertx/CrnkVerticle.java | 4 ++-- .../example/vertx/VertxSecurityProvider.java | 8 ++++---- .../build.gradle | 2 +- .../security/InMemoryIdentityManager.java | 6 +++++- crnk-setup/crnk-setup-servlet/build.gradle | 2 +- crnk-setup/crnk-setup-vertx/build.gradle | 9 ++++----- .../io/crnk/setup/vertx/CrnkVertxHandler.java | 8 ++++---- .../vertx/internal/VertxRequestContext.java | 6 +++--- 12 files changed, 36 insertions(+), 51 deletions(-) diff --git a/crnk-integration-examples/dagger-vertx-example/build.gradle b/crnk-integration-examples/dagger-vertx-example/build.gradle index 4929f3bd5..9905af5e8 100644 --- a/crnk-integration-examples/dagger-vertx-example/build.gradle +++ b/crnk-integration-examples/dagger-vertx-example/build.gradle @@ -16,9 +16,8 @@ configurations { buildscript { dependencies { - classpath "net.ltgt.gradle:gradle-apt-plugin:0.15" - - classpath 'net.sf.proguard:proguard-gradle:6.0.3' + classpath "net.ltgt.gradle:gradle-apt-plugin:0.21" + classpath 'net.sf.proguard:proguard-gradle:6.2.2' } } @@ -46,19 +45,20 @@ dependencies { implementation 'org.hibernate:hibernate-core-jakarta:5.6.15.Final' implementation 'com.h2database:h2:1.4.187' - implementation 'io.vertx:vertx-auth-common:3.7.1' + implementation 'io.vertx:vertx-auth-common:4.4.5' + implementation 'io.projectreactor.addons:reactor-adapter:3.5.1' + - // add in the future + // add in the future // implementation project(':crnk-meta') // implementation project(':crnk-operations') // implementation project(':crnk-ui') - // implementation project(':crnk-validation') implementation 'ch.qos.logback:logback-classic:1.2.3' implementation 'jakarta.inject:jakarta.inject-api:2.0.1' - implementation 'com.google.dagger:dagger:2.16' + implementation 'com.google.dagger:dagger:2.48' - annotationProcessor 'com.google.dagger:dagger-compiler:2.16' + annotationProcessor 'com.google.dagger:dagger-compiler:2.48' } // https://github.com/immutables/immutables/issues/134 issues with incremental compilation diff --git a/crnk-integration-examples/dagger-vertx-example/src/main/java/io/crnk/example/vertx/AppComponent.java b/crnk-integration-examples/dagger-vertx-example/src/main/java/io/crnk/example/vertx/AppComponent.java index 3b33e10b4..e2e7f6123 100644 --- a/crnk-integration-examples/dagger-vertx-example/src/main/java/io/crnk/example/vertx/AppComponent.java +++ b/crnk-integration-examples/dagger-vertx-example/src/main/java/io/crnk/example/vertx/AppComponent.java @@ -14,4 +14,4 @@ public interface AppComponent { // void inject(MyFragment fragment); // void inject(MyService service); -} \ No newline at end of file +} diff --git a/crnk-integration-examples/dagger-vertx-example/src/main/java/io/crnk/example/vertx/AppModule.java b/crnk-integration-examples/dagger-vertx-example/src/main/java/io/crnk/example/vertx/AppModule.java index 52e6bdb19..a83c07ab6 100644 --- a/crnk-integration-examples/dagger-vertx-example/src/main/java/io/crnk/example/vertx/AppModule.java +++ b/crnk-integration-examples/dagger-vertx-example/src/main/java/io/crnk/example/vertx/AppModule.java @@ -9,11 +9,8 @@ import io.crnk.security.ResourcePermission; import io.crnk.security.SecurityConfig; import io.crnk.security.SecurityModule; -import io.vertx.core.AsyncResult; import io.vertx.core.Future; -import io.vertx.core.Handler; import io.vertx.core.json.JsonObject; -import io.vertx.ext.auth.AbstractUser; import io.vertx.ext.auth.AuthProvider; import io.vertx.ext.auth.User; @@ -55,23 +52,8 @@ public VertxSecurityProvider securityProvider(AuthProvider authProvider) { @Singleton public AuthProvider authProvider() { return (authInfo, resultHandler) -> { - User user = new AbstractUser() { - @Override - protected void doIsPermitted(String permission, Handler> resultHandler) { - resultHandler.handle(Future.succeededFuture(true)); - } + User user = User.create(new JsonObject().put("name", "john doe")); - @Override - public JsonObject principal() { - JsonObject object = new JsonObject(); - return object.put("name", "john doe"); - } - - @Override - public void setAuthProvider(AuthProvider authProvider) { - - } - }; resultHandler.handle(Future.succeededFuture(user)); }; } diff --git a/crnk-integration-examples/dagger-vertx-example/src/main/java/io/crnk/example/vertx/AppServer.java b/crnk-integration-examples/dagger-vertx-example/src/main/java/io/crnk/example/vertx/AppServer.java index 971164a76..ab7e18fe7 100644 --- a/crnk-integration-examples/dagger-vertx-example/src/main/java/io/crnk/example/vertx/AppServer.java +++ b/crnk-integration-examples/dagger-vertx-example/src/main/java/io/crnk/example/vertx/AppServer.java @@ -1,6 +1,6 @@ package io.crnk.example.vertx; -import io.reactivex.subjects.SingleSubject; +import io.reactivex.rxjava3.subjects.SingleSubject; import io.vertx.core.AsyncResult; import io.vertx.core.Handler; import io.vertx.core.Vertx; @@ -35,7 +35,7 @@ public void start() { vertx = Vertx.vertx(options); - vertx.deployVerticle(vehicle, completionHandler); + vertx.deployVerticle(vehicle); waitSubject.blockingGet(); } diff --git a/crnk-integration-examples/dagger-vertx-example/src/main/java/io/crnk/example/vertx/CrnkVerticle.java b/crnk-integration-examples/dagger-vertx-example/src/main/java/io/crnk/example/vertx/CrnkVerticle.java index fe3e021fc..914de42b6 100644 --- a/crnk-integration-examples/dagger-vertx-example/src/main/java/io/crnk/example/vertx/CrnkVerticle.java +++ b/crnk-integration-examples/dagger-vertx-example/src/main/java/io/crnk/example/vertx/CrnkVerticle.java @@ -4,8 +4,8 @@ import io.crnk.core.module.SimpleModule; import io.crnk.core.repository.ResourceRepository; import io.crnk.setup.vertx.CrnkVertxHandler; -import io.vertx.reactivex.core.AbstractVerticle; -import io.vertx.reactivex.core.http.HttpServer; +import io.vertx.rxjava3.core.AbstractVerticle; +import io.vertx.rxjava3.core.http.HttpServer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/crnk-integration-examples/dagger-vertx-example/src/main/java/io/crnk/example/vertx/VertxSecurityProvider.java b/crnk-integration-examples/dagger-vertx-example/src/main/java/io/crnk/example/vertx/VertxSecurityProvider.java index 1dc1296d4..95098d1b9 100644 --- a/crnk-integration-examples/dagger-vertx-example/src/main/java/io/crnk/example/vertx/VertxSecurityProvider.java +++ b/crnk-integration-examples/dagger-vertx-example/src/main/java/io/crnk/example/vertx/VertxSecurityProvider.java @@ -7,8 +7,8 @@ import io.crnk.setup.vertx.CrnkRequestInterceptor; import io.vertx.core.json.JsonObject; import io.vertx.ext.auth.AuthProvider; -import io.vertx.reactivex.ext.auth.User; -import reactor.adapter.rxjava.RxJava2Adapter; +import io.vertx.rxjava3.ext.auth.User; +import reactor.adapter.rxjava.RxJava3Adapter; import reactor.core.publisher.Mono; public class VertxSecurityProvider implements SecurityProvider, CrnkRequestInterceptor { @@ -39,8 +39,8 @@ public Mono onRequest(Mono mono) { return mono.flatMap(request -> { JsonObject jsonObject = new JsonObject(); jsonObject.put("name", "john doe"); - io.vertx.reactivex.ext.auth.AuthProvider rxAuthProvider = io.vertx.reactivex.ext.auth.AuthProvider.newInstance(authProvider); - Mono userSingle = RxJava2Adapter.singleToMono(rxAuthProvider.rxAuthenticate(jsonObject)); + io.vertx.rxjava3.ext.auth.AuthProvider rxAuthProvider = io.vertx.rxjava3.ext.auth.AuthProvider.newInstance(authProvider); + Mono userSingle = RxJava3Adapter.singleToMono(rxAuthProvider.rxAuthenticate(jsonObject)); return userSingle.doOnNext(user -> request.getQueryContext().setAttribute(USER_CONTEXT_ATTRIBUTE, user)).map(user -> request); }); } diff --git a/crnk-integration-examples/openliberty-microprofile-example/build.gradle b/crnk-integration-examples/openliberty-microprofile-example/build.gradle index 29902f048..9f42a3dd7 100644 --- a/crnk-integration-examples/openliberty-microprofile-example/build.gradle +++ b/crnk-integration-examples/openliberty-microprofile-example/build.gradle @@ -17,7 +17,7 @@ buildscript { dependencies { // provided dependencies - providedCompile 'jakarta.platform:jakarta.jakartaee-api:8.0.0' + providedCompile 'jakarta.platform:jakarta.jakartaee-api:10.0.0' providedCompile 'org.eclipse.microprofile:microprofile:4.0.1' implementation project(':crnk-setup:crnk-setup-rs') diff --git a/crnk-security/src/test/java/io/crnk/security/InMemoryIdentityManager.java b/crnk-security/src/test/java/io/crnk/security/InMemoryIdentityManager.java index a70f29e7e..9e6192916 100644 --- a/crnk-security/src/test/java/io/crnk/security/InMemoryIdentityManager.java +++ b/crnk-security/src/test/java/io/crnk/security/InMemoryIdentityManager.java @@ -21,11 +21,16 @@ public class InMemoryIdentityManager { private HashLoginService loginService; + private UserStore userStore; + private String realm = "myrealm"; public InMemoryIdentityManager() { + userStore = new UserStore(); + loginService = new HashLoginService(); loginService.setName(realm); + loginService.setUserStore(userStore); securityHandler = new ConstraintSecurityHandler(); securityHandler.setAuthenticator(new BasicAuthenticator()); @@ -45,7 +50,6 @@ public InMemoryIdentityManager() { } public void addUser(String userId, String password, String... roles) { - UserStore userStore = new UserStore(); userStore.addUser(userId, Credential.getCredential(password), roles); loginService.setUserStore(userStore); } diff --git a/crnk-setup/crnk-setup-servlet/build.gradle b/crnk-setup/crnk-setup-servlet/build.gradle index 290b571ef..94c269164 100644 --- a/crnk-setup/crnk-setup-servlet/build.gradle +++ b/crnk-setup/crnk-setup-servlet/build.gradle @@ -12,7 +12,7 @@ dependencies { testImplementation project(':crnk-reactive') testImplementation project(':crnk-test') testImplementation project(':crnk-client') - testImplementation group: 'org.reflections', name: 'reflections', version: '0.9.9' + testImplementation group: 'org.reflections', name: 'reflections', version: '0.10.2' testImplementation 'jakarta.servlet:jakarta.servlet-api:6.0.0' testImplementation 'org.springframework.boot:spring-boot-starter-web:6.0.12' diff --git a/crnk-setup/crnk-setup-vertx/build.gradle b/crnk-setup/crnk-setup-vertx/build.gradle index afd3ddddc..35b2650b2 100644 --- a/crnk-setup/crnk-setup-vertx/build.gradle +++ b/crnk-setup/crnk-setup-vertx/build.gradle @@ -4,11 +4,10 @@ plugins { } dependencies { - implementation project(':crnk-core') - implementation project(':crnk-reactive') - implementation 'io.vertx:vertx-rx-java2:3.7.1' - - implementation 'io.projectreactor.addons:reactor-adapter:3.2.3.RELEASE' + api project(':crnk-core') + api project(':crnk-reactive') + api 'io.vertx:vertx-rx-java3:4.4.5' + api 'io.projectreactor.addons:reactor-adapter:3.5.1' compileOnly 'org.slf4j:slf4j-api:2.0.9' diff --git a/crnk-setup/crnk-setup-vertx/src/main/java/io/crnk/setup/vertx/CrnkVertxHandler.java b/crnk-setup/crnk-setup-vertx/src/main/java/io/crnk/setup/vertx/CrnkVertxHandler.java index 20f31385b..b1563ee05 100644 --- a/crnk-setup/crnk-setup-vertx/src/main/java/io/crnk/setup/vertx/CrnkVertxHandler.java +++ b/crnk-setup/crnk-setup-vertx/src/main/java/io/crnk/setup/vertx/CrnkVertxHandler.java @@ -10,11 +10,11 @@ import io.crnk.reactive.internal.MonoResult; import io.crnk.setup.vertx.internal.VertxModule; import io.crnk.setup.vertx.internal.VertxRequestContext; -import io.reactivex.subjects.SingleSubject; +import io.reactivex.rxjava3.subjects.SingleSubject; import io.vertx.core.Handler; -import io.vertx.reactivex.core.buffer.Buffer; -import io.vertx.reactivex.core.http.HttpServerRequest; -import io.vertx.reactivex.core.http.HttpServerResponse; +import io.vertx.rxjava3.core.buffer.Buffer; +import io.vertx.rxjava3.core.http.HttpServerRequest; +import io.vertx.rxjava3.core.http.HttpServerResponse; import org.reactivestreams.Publisher; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/crnk-setup/crnk-setup-vertx/src/main/java/io/crnk/setup/vertx/internal/VertxRequestContext.java b/crnk-setup/crnk-setup-vertx/src/main/java/io/crnk/setup/vertx/internal/VertxRequestContext.java index 2b382d8db..6f8a892d4 100644 --- a/crnk-setup/crnk-setup-vertx/src/main/java/io/crnk/setup/vertx/internal/VertxRequestContext.java +++ b/crnk-setup/crnk-setup-vertx/src/main/java/io/crnk/setup/vertx/internal/VertxRequestContext.java @@ -10,8 +10,8 @@ import io.crnk.core.engine.http.HttpResponse; import io.crnk.core.engine.internal.utils.PreconditionUtil; import io.crnk.core.engine.internal.utils.UrlUtils; -import io.vertx.reactivex.core.MultiMap; -import io.vertx.reactivex.core.http.HttpServerRequest; +import io.vertx.rxjava3.core.MultiMap; +import io.vertx.rxjava3.core.http.HttpServerRequest; public class VertxRequestContext extends DefaultHttpRequestContextBase { @@ -83,7 +83,7 @@ public byte[] getRequestBody() { @Override public String getMethod() { - return serverRequest.rawMethod(); + return serverRequest.method().toString(); } @Override