use of com.disney.http.auth.BasicAuthorization in project groovity by disney.
the class BasicVerifierImpl method doVerifyInternal.
@Override
protected VerifierResult doVerifyInternal(ServerAuthorizationRequest request) {
VerifierResult result = new VerifierResult();
List<String> basicAuth = request.getHeaders(AUTHORIZATION_HEADER);
if (basicAuth == null || basicAuth.isEmpty()) {
challenge(result, ERROR_MISSING_CREDENTIALS);
return result;
}
BasicAuthorization auth;
try {
auth = new BasicAuthorization(basicAuth.get(0));
} catch (Exception e) {
challenge(result, e.getMessage());
return result;
}
for (int i = 0; i < passwordCheckers.size(); i++) {
PasswordChecker checker = passwordCheckers.get(i);
if (checker.check(auth.getUsername(), auth.getPassword())) {
result.setAuthenticated(true);
result.setPrincipal(new AuthenticatedPrincipal(auth.getUsername()));
return result;
}
}
challenge(result, ERROR_UNKNOWN_CREDENTIALS);
return result;
}
Aggregations