Java Code Examples for javax.security.enterprise.identitystore.CredentialValidationResult#NOT_VALIDATED_RESULT

The following examples show how to use javax.security.enterprise.identitystore.CredentialValidationResult#NOT_VALIDATED_RESULT . 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: CustomInMemoryIdentityStore.java    From blog-tutorials with MIT License 5 votes vote down vote up
@Override
public CredentialValidationResult validate(Credential credential) {

    UsernamePasswordCredential login = (UsernamePasswordCredential) credential;

    if (login.getCaller().equals("[email protected]") && login.getPasswordAsString().equals("ADMIN1234")) {
        return new CredentialValidationResult("admin", new HashSet<>(Arrays.asList("ADMIN")));
    } else if (login.getCaller().equals("[email protected]") && login.getPasswordAsString().equals("USER1234")) {
        return new CredentialValidationResult("user", new HashSet<>(Arrays.asList("USER")));
    } else {
        return CredentialValidationResult.NOT_VALIDATED_RESULT;
    }
}
 
Example 2
Source File: UserIdentityStore.java    From javaee8-cookbook with Apache License 2.0 5 votes vote down vote up
@Override
public CredentialValidationResult validate(Credential credential) {
    if (credential instanceof UsernamePasswordCredential) {
        return validate((UsernamePasswordCredential) credential);
    }

    return CredentialValidationResult.NOT_VALIDATED_RESULT;
}
 
Example 3
Source File: TomEEDefaultIdentityStore.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Override
public CredentialValidationResult validate(final Credential credential) {
    if (credential instanceof UsernamePasswordCredential) {
        final UsernamePasswordCredential usernamePasswordCredential = (UsernamePasswordCredential) credential;
        return Optional.ofNullable(userDatabase.findUser(usernamePasswordCredential.getCaller()))
                       .filter(user -> user.getPassword().equals(usernamePasswordCredential.getPasswordAsString()))
                       .map(user -> new CredentialValidationResult(user.getUsername(), getUserRoles(user)))
                       .orElse(CredentialValidationResult.INVALID_RESULT);
    }

    return CredentialValidationResult.NOT_VALIDATED_RESULT;
}