/** * Constructor for a VALID result. * * @param callerName Name of the validated caller * @param groups Groups associated with the caller from the identity store */ public CredentialValidationResult(String callerName, Set<String> groups) { this(new CallerPrincipal(callerName), groups); }
public static AuthStatus fromAuthenticationStatus(AuthenticationStatus authenticationStatus) { switch (authenticationStatus) { case NOT_DONE: case SUCCESS: return AuthStatus.SUCCESS; case SEND_FAILURE: return AuthStatus.SEND_FAILURE; case SEND_CONTINUE: return AuthStatus.SEND_CONTINUE; default: throw new IllegalStateException("Unhandled status:" + authenticationStatus.name()); } }
@Override public Set<String> getCallerGroups(CredentialValidationResult validationResult) { Set<String> result = groupsPerCaller.get(validationResult.getCallerPrincipal().getName()); if (result == null) { result = emptySet(); } return result; }
public CredentialValidationResult validate(UsernamePasswordCredential usernamePasswordCredential) { Credentials credentials = callerToCredentials.get(usernamePasswordCredential.getCaller()); if (credentials != null && usernamePasswordCredential.getPassword().compareTo(credentials.password())) { return new CredentialValidationResult( new CallerPrincipal(credentials.callerName()), new HashSet<>(asList(credentials.groups())) ); } return INVALID_RESULT; }
/** * Create the JWT using CredentialValidationResult received from * IdentityStoreHandler * * @param result the result from validation of UsernamePasswordCredential * @param context * @return the AuthenticationStatus to notify the container */ private AuthenticationStatus createToken(CredentialValidationResult result, HttpMessageContext context) { if (!isRememberMe(context)) { String jwt = tokenProvider.createToken(result.getCallerPrincipal().getName(), result.getCallerGroups(), false); context.getResponse().setHeader(AUTHORIZATION_HEADER, BEARER + jwt); } return context.notifyContainerAboutLogin(result.getCallerPrincipal(), result.getCallerGroups()); }
@Override public String generateLoginToken(CallerPrincipal callerPrincipal, Set<String> groups) { return tokenProvider.createToken(callerPrincipal.getName(), groups, true); }
public Optional<Application> findCallerApplication() { Set<Principal> principals = securityContext.getPrincipalsByType(Principal.class); return principals.stream() .filter(this::isApplicationRestrictionGroup) .map(this::getRestrictedApplicationId) .findAny() .flatMap(applicationQueryService::findActiveApplicationById); }
public CredentialValidationResult validate(UsernamePasswordCredential usernamePasswordCredential) { Credentials credentials = callerToCredentials.get(usernamePasswordCredential.getCaller()); if (credentials != null && usernamePasswordCredential.getPassword().compareTo(credentials.password())) { return new CredentialValidationResult( new CallerPrincipal(credentials.callerName()), new HashSet<>(asList(credentials.groups())) ); } return INVALID_RESULT; }
/** * Constructor for a VALID result. * * @param callerName Name of the validated caller */ public CredentialValidationResult(String callerName) { this(new CallerPrincipal(callerName), null); }
public static AuthStatus fromAuthenticationStatus(AuthenticationStatus authenticationStatus) { switch (authenticationStatus) { case NOT_DONE: case SUCCESS: return AuthStatus.SUCCESS; case SEND_FAILURE: return AuthStatus.SEND_FAILURE; case SEND_CONTINUE: return AuthStatus.SEND_CONTINUE; default: throw new IllegalStateException("Unhandled status:" + authenticationStatus.name()); } }
/** * Constructor for a VALID result. * * @param callerName Name of the validated caller */ public CredentialValidationResult(String callerName) { this(new CallerPrincipal(callerName), null); }
/** * Constructor for a VALID result. * * @param storeId Identity store unique ID * @param callerName Name of the validated caller * @param callerDn Caller's LDAP DN (distinguished name) * @param callerUniqueId Caller's unique identifier from the identity store * @param groups Groups associated with the caller from the identity store */ public CredentialValidationResult(String storeId, String callerName, String callerDn, String callerUniqueId, Set<String> groups) { this(storeId, new CallerPrincipal(callerName), callerDn, callerUniqueId, groups); }
/** * Constructor for a VALID result. * * @param storeId Identity store unique ID * @param callerName Name of the validated caller * @param callerDn Caller's LDAP DN (distinguished name) * @param callerUniqueId Caller's unique identifier from the identity store * @param groups Groups associated with the caller from the identity store */ public CredentialValidationResult(String storeId, String callerName, String callerDn, String callerUniqueId, Set<String> groups) { this(storeId, new CallerPrincipal(callerName), callerDn, callerUniqueId, groups); }
/** * Constructor for a VALID result. * * @param callerName Name of the validated caller * @param groups Groups associated with the caller from the identity store */ public CredentialValidationResult(String callerName, Set<String> groups) { this(new CallerPrincipal(callerName), groups); }
/** * Constructor for a VALID result. * * @param callerName Name of the validated caller * @param groups Groups associated with the caller from the identity store */ public CredentialValidationResult(String callerName, Set<String> groups) { this(new CallerPrincipal(callerName), groups); }
/** * Constructor for a VALID result. * * @param callerName Name of the validated caller */ public CredentialValidationResult(String callerName) { this(new CallerPrincipal(callerName), null); }
/** * Constructor for a VALID result. * * @param callerName Name of the validated caller */ public CredentialValidationResult(String callerName) { this(new CallerPrincipal(callerName), null); }
/** * Constructor for a VALID result. * * @param callerName Name of the validated caller * @param groups Groups associated with the caller from the identity store */ public CredentialValidationResult(String callerName, Set<String> groups) { this(new CallerPrincipal(callerName), groups); }
/** * Constructor for a VALID result. * * @param storeId Identity store unique ID * @param callerName Name of the validated caller * @param callerDn Caller's LDAP DN (distinguished name) * @param callerUniqueId Caller's unique identifier from the identity store * @param groups Groups associated with the caller from the identity store */ public CredentialValidationResult(String storeId, String callerName, String callerDn, String callerUniqueId, Set<String> groups) { this(storeId, new CallerPrincipal(callerName), callerDn, callerUniqueId, groups); }
/** * Constructor for a VALID result. * * @param storeId Identity store unique ID * @param callerName Name of the validated caller * @param callerDn Caller's LDAP DN (distinguished name) * @param callerUniqueId Caller's unique identifier from the identity store * @param groups Groups associated with the caller from the identity store */ public CredentialValidationResult(String storeId, String callerName, String callerDn, String callerUniqueId, Set<String> groups) { this(storeId, new CallerPrincipal(callerName), callerDn, callerUniqueId, groups); }