private CompletionStage<AuthenticationResponse> enhance(Subject subject, AuthenticationResponse previousResponse) { String username = subject.principal().getName(); List<? extends Grant> grants = roleCache.computeValue(username, () -> getGrantsFromServer(username)) .orElse(CollectionsHelper.listOf()); AuthenticationResponse.Builder builder = AuthenticationResponse.builder(); builder.user(buildSubject(subject, grants)); previousResponse.service().ifPresent(builder::service); previousResponse.description().ifPresent(builder::description); builder.requestHeaders(previousResponse.requestHeaders()); AuthenticationResponse response = builder.build(); return CompletableFuture.completedFuture(response); }
/** * Provider has authenticated the request and created a user and service Subject. * * @param user Subject of the current user * @param service Subject of the current service * @return AuthenticationResponse with information filled */ public static AuthenticationResponse success(Subject user, Subject service) { return builder().status(SecurityStatus.SUCCESS) .user(user) .service(service) .build(); }
/** * Provider has authenticated the request and created a user Subject. * * @param subject Subject of the current user * @return AuthenticationResponse with information filled */ public static AuthenticationResponse success(Subject subject) { return builder().status(SecurityStatus.SUCCESS).user(subject).build(); }