public static io.vertx.rxjava.ext.web.handler.ChainAuthHandler create() { io.vertx.rxjava.ext.web.handler.ChainAuthHandler ret = io.vertx.rxjava.ext.web.handler.ChainAuthHandler.newInstance(io.vertx.ext.web.handler.ChainAuthHandler.create()); return ret; }
public static io.vertx.rxjava.ext.web.handler.ChainAuthHandler create() { io.vertx.rxjava.ext.web.handler.ChainAuthHandler ret = io.vertx.rxjava.ext.web.handler.ChainAuthHandler.newInstance(io.vertx.ext.web.handler.ChainAuthHandler.create()); return ret; }
@Override public void setUp() throws Exception { super.setUp(); JsonObject authConfig = new JsonObject().put("properties_path", "classpath:login/loginusers.properties"); AuthProvider authProvider = ShiroAuth.create(vertx, new ShiroAuthOptions().setType(ShiroAuthRealmType.PROPERTIES).setConfig(authConfig)); // create a chain chain = ChainAuthHandler.create(); chain .append(JWTAuthHandler.create(null)) .append(BasicAuthHandler.create(authProvider)) .append(RedirectAuthHandler.create(authProvider)); router.route().handler(SessionHandler.create(LocalSessionStore.create(vertx))); router.route().handler(chain); router.route().handler(ctx -> ctx.response().end()); }
/** * Two mode for handler supported. * * @param cliffes Cliff in zero system. * @return Auth Handler that will be mount to vertx router. */ private AuthHandler create(final Vertx vertx, final Set<Cliff> cliffes) { AuthHandler resultHandler = null; if (Values.ONE < cliffes.size()) { // 1 < handler final ChainAuthHandler chain = ChainAuthHandler.create(); Observable.fromIterable(cliffes) .map(item -> this.bolt.mount(vertx, item)) .subscribe(chain::append).dispose(); resultHandler = chain; } else { // 1 = handler if (!cliffes.isEmpty()) { final Cliff cliff = cliffes.iterator().next(); resultHandler = this.bolt.mount(vertx, cliff); } } return resultHandler; } }
/** * Two mode for handler supported. * * @param cliffes Cliff in zero system. * @return Auth Handler that will be mount to vertx router. */ private AuthHandler create(final Vertx vertx, final Set<Cliff> cliffes) { AuthHandler resultHandler = null; if (Values.ONE < cliffes.size()) { // 1 < handler final ChainAuthHandler chain = ChainAuthHandler.create(); Observable.fromIterable(cliffes) .map(item -> this.bolt.mount(vertx, item)) .subscribe(chain::append).dispose(); resultHandler = chain; } else { // 1 = handler if (!cliffes.isEmpty()) { final Cliff cliff = cliffes.iterator().next(); resultHandler = this.bolt.mount(vertx, cliff); } } return resultHandler; } }
@Override protected void addRoutes(final Router router) { if (getConfig().isAuthenticationRequired()) { final ChainAuthHandler authHandler = ChainAuthHandler.create(); authHandler.append(new X509AuthHandler( new TenantServiceBasedX509Authentication(getTenantServiceClient(), tracer), Optional.ofNullable(clientCertAuthProvider).orElse( new X509AuthProvider(getCredentialsServiceClient(), getConfig(), tracer)))); authHandler.append(new HonoBasicAuthHandler( Optional.ofNullable(usernamePasswordAuthProvider).orElse( new UsernamePasswordAuthProvider(getCredentialsServiceClient(), getConfig(), tracer)), getConfig().getRealm(), tracer)); addTelemetryApiRoutes(router, authHandler); addEventApiRoutes(router, authHandler); addCommandResponseRoutes(router, authHandler); } else { LOG.warn("device authentication has been disabled"); LOG.warn("any device may publish data on behalf of all other devices"); addTelemetryApiRoutes(router, null); addEventApiRoutes(router, null); addCommandResponseRoutes(router, null); } }
@Override public void setUp() throws Exception { super.setUp(); JsonObject authConfig = new JsonObject().put("properties_path", "classpath:login/loginusers.properties"); AuthProvider authProvider = ShiroAuth.create(vertx, new ShiroAuthOptions().setType(ShiroAuthRealmType.PROPERTIES).setConfig(authConfig)); // create a chain chain = ChainAuthHandler.create(); chain .append(JWTAuthHandler.create(null)) .append(BasicAuthHandler.create(authProvider)) .append(RedirectAuthHandler.create(authProvider)); router.route().handler(SessionHandler.create(LocalSessionStore.create(vertx))); router.route().handler(chain); router.route().handler(ctx -> ctx.response().end()); }