public CredentialValidationResult validate(UsernamePasswordCredential usernamePasswordCredential) { DataSource dataSource = getDataSource(); List<String> passwords = executeQuery( dataSource, dataBaseIdentityStoreDefinition.callerQuery(), usernamePasswordCredential.getCaller() ); if (passwords.isEmpty()) { return INVALID_RESULT; } if (hashAlgorithm.verify(usernamePasswordCredential.getPassword().getValue(), passwords.get(0))) { Set<String> groups = emptySet(); if (validationTypes.contains(ValidationType.PROVIDE_GROUPS)) { groups = new HashSet<>(executeQuery(dataSource, dataBaseIdentityStoreDefinition.groupsQuery(), usernamePasswordCredential.getCaller())); } return new CredentialValidationResult(new CallerPrincipal(usernamePasswordCredential.getCaller()), groups); } return INVALID_RESULT; }
public CredentialValidationResult validate(UsernamePasswordCredential usernamePasswordCredential) { DataSource dataSource = getDataSource(); List<String> passwords = executeQuery( dataSource, dataBaseIdentityStoreDefinition.callerQuery(), usernamePasswordCredential.getCaller() ); if (passwords.isEmpty()) { return INVALID_RESULT; } if (hashAlgorithm.verify(usernamePasswordCredential.getPassword().getValue(), passwords.get(0))) { Set<String> groups = emptySet(); if (validationTypes.contains(ValidationType.PROVIDE_GROUPS)) { groups = new HashSet<>(executeQuery(dataSource, dataBaseIdentityStoreDefinition.groupsQuery(), usernamePasswordCredential.getCaller())); } return new CredentialValidationResult(new CallerPrincipal(usernamePasswordCredential.getCaller()), groups); } return INVALID_RESULT; }