io.vertx.ext.web.handler.BasicAuthHandler Java Examples
The following examples show how to use
io.vertx.ext.web.handler.BasicAuthHandler.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SwaggerAuthHandlerFactory.java From vertx-swagger with Apache License 2.0 | 5 votes |
private AuthHandler getAuthHandler(String name) { AuthHandler authHandler = this.authHandlers.get(name); if (authHandler != null) { return authHandler; } AuthProvider authProvider = getAuthProviderFactory().getAuthProviderByName(name); if (authProvider == null) { return null; } SecuritySchemeDefinition securityScheme = this.securitySchemes.get(name); if(securityScheme != null) { switch (securityScheme.getType()) { case "apiKey": ApiKeyAuthDefinition apiKeyAuthDefinition = (ApiKeyAuthDefinition) securityScheme; Location apiKeyLocation = Location.valueOf(apiKeyAuthDefinition.getIn().name()); authHandler = ApiKeyAuthHandler.create(authProvider, apiKeyLocation, apiKeyAuthDefinition.getName()); break; case "basic": authHandler = BasicAuthHandler.create(authProvider); break; case "oauth2": vertxLogger.warn("OAuth2 authentication has not been implemented yet!"); break; default: vertxLogger.warn("SecurityScheme is not authorized : " + securityScheme.getType()); break; } if (authHandler != null) { this.authHandlers.put(name, authHandler); } } else { vertxLogger.warn("No securityScheme definition in swagger file for auth provider: " + name); } return authHandler; }
Example #2
Source File: AuthenticationFactory.java From nubes with Apache License 2.0 | 5 votes |
public AuthenticationFactory(Config config) { this.config = config; authHandlers = new EnumMap<>(AuthMethod.class); authHandlers.put(BASIC, BasicAuthHandler::create); authHandlers.put(JWT, auth -> JWTAuthHandler.create((JWTAuth)config.getAuthProvider())); authHandlers.put(API_TOKEN, CheckTokenHandler::new); }
Example #3
Source File: AuthConfig.java From festival with Apache License 2.0 | 4 votes |
@Singleton @Named public AuthHandler authHandler(AuthProvider authProvider) { return BasicAuthHandler.create(authProvider); }
Example #4
Source File: AuthConfig.java From festival with Apache License 2.0 | 4 votes |
@Singleton @Named public AuthHandler authHandler(AuthProvider authProvider) { return BasicAuthHandler.create(authProvider); }
Example #5
Source File: HttpTermServer.java From vertx-shell with Apache License 2.0 | 4 votes |
@Override public TermServer listen(Handler<AsyncResult<Void>> listenHandler) { Charset charset = Charset.forName(options.getCharset()); boolean createServer = false; if (router == null) { createServer = true; router = Router.router(vertx); } if (options.getAuthOptions() != null) { authProvider = ShellAuth.load(vertx, options.getAuthOptions()); } if (options.getSockJSPath() != null && options.getSockJSHandlerOptions() != null) { if (authProvider != null) { AuthenticationHandler basicAuthHandler = BasicAuthHandler.create(authProvider); router.route(options.getSockJSPath()).handler(basicAuthHandler); } Buffer inputrc = Helper.loadResource(vertx.fileSystem(), options.getIntputrc()); if (inputrc == null) { if (listenHandler != null) { listenHandler.handle(Future.failedFuture("Could not load inputrc from " + options.getIntputrc())); } return this; } Keymap keymap = new Keymap(new ByteArrayInputStream(inputrc.getBytes())); SockJSHandler sockJSHandler = SockJSHandler.create(vertx, options.getSockJSHandlerOptions()); sockJSHandler.socketHandler(new SockJSTermHandlerImpl(vertx, charset, keymap).termHandler(termHandler)); router.route(options.getSockJSPath()).handler(sockJSHandler); } if (options.getVertsShellJsResource() != null) { router.get("/vertxshell.js").handler(ctx -> ctx.response().putHeader("Content-Type", "application/javascript").end(options.getVertsShellJsResource())); } if (options.getTermJsResource() != null) { router.get("/term.js").handler(ctx -> ctx.response().putHeader("Content-Type", "application/javascript").end(options.getTermJsResource())); } if (options.getShellHtmlResource() != null) { router.get("/shell.html").handler(ctx -> ctx.response().putHeader("Content-Type", "text/html").end(options.getShellHtmlResource())); } if (createServer) { server = vertx.createHttpServer(options); server.requestHandler(router); server.listen(ar -> { if (listenHandler != null) { if (ar.succeeded()) { listenHandler.handle(Future.succeededFuture()); } else { listenHandler.handle(Future.failedFuture(ar.cause())); } } }); } else { if (listenHandler != null) { listenHandler.handle(Future.succeededFuture()); } } return this; }