use of io.vertx.ext.web.handler.impl.ScopedAuthentication in project vertx-web by vert-x3.
the class AuthenticationHandlersStore method resolveHandlers.
private List<AuthenticationHandler> resolveHandlers(Map.Entry<String, Object> e, boolean failOnNotFound) {
List<AuthenticationHandler> authenticationHandlers;
if (failOnNotFound) {
authenticationHandlers = Optional.ofNullable(this.securityHandlers.get(e.getKey())).orElseThrow(() -> RouterBuilderException.createMissingSecurityHandler(e.getKey()));
} else {
authenticationHandlers = Optional.ofNullable(this.securityHandlers.get(e.getKey())).orElse(Collections.emptyList());
}
// Some scopes are defines, we need to configure them in OAuth2Handlers
if (e.getValue() instanceof JsonArray && ((JsonArray) e.getValue()).size() != 0) {
List<String> scopes = ((JsonArray) e.getValue()).stream().map(v -> (String) v).collect(Collectors.toList());
for (int i = 0; i < authenticationHandlers.size(); i++) {
if (authenticationHandlers.get(i) instanceof ScopedAuthentication<?>) {
ScopedAuthentication<?> scopedHandler = (ScopedAuthentication<?>) authenticationHandlers.get(i);
// this mutates the state, so we replace the list with an updated handler
AuthenticationHandler updatedHandler = scopedHandler.withScopes(scopes);
authenticationHandlers.set(i, updatedHandler);
}
}
}
return authenticationHandlers;
}
Aggregations