Skip to content

Commit

Permalink
Fix vertx/reactive
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle Thorpe committed Oct 4, 2023
1 parent e87e370 commit 42e3839
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 51 deletions.
16 changes: 8 additions & 8 deletions crnk-integration-examples/dagger-vertx-example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ public interface AppComponent {

// void inject(MyFragment fragment);
// void inject(MyService service);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<AsyncResult<Boolean>> 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));
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -35,7 +35,7 @@ public void start() {


vertx = Vertx.vertx(options);
vertx.deployVerticle(vehicle, completionHandler);
vertx.deployVerticle(vehicle);
waitSubject.blockingGet();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -39,8 +39,8 @@ public Mono<HttpRequestContext> onRequest(Mono<HttpRequestContext> 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<User> userSingle = RxJava2Adapter.singleToMono(rxAuthProvider.rxAuthenticate(jsonObject));
io.vertx.rxjava3.ext.auth.AuthProvider rxAuthProvider = io.vertx.rxjava3.ext.auth.AuthProvider.newInstance(authProvider);
Mono<User> userSingle = RxJava3Adapter.singleToMono(rxAuthProvider.rxAuthenticate(jsonObject));
return userSingle.doOnNext(user -> request.getQueryContext().setAttribute(USER_CONTEXT_ATTRIBUTE, user)).map(user -> request);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion crnk-setup/crnk-setup-servlet/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
9 changes: 4 additions & 5 deletions crnk-setup/crnk-setup-vertx/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -83,7 +83,7 @@ public byte[] getRequestBody() {

@Override
public String getMethod() {
return serverRequest.rawMethod();
return serverRequest.method().toString();
}

@Override
Expand Down

0 comments on commit 42e3839

Please sign in to comment.