String value = formData.getFirst(credential.getType());
if (value == null)
{
return false;
}
UserCredential userCredential = userCredentials.getFirst(credential.getType());
if (userCredential == null)
{
logger.warn("Missing required user credential");
return false;
}
if (userCredential.isHashed())
{
value = hash(value);
}
if (!value.equals(userCredential.getValue()))
{
logger.warn("Credential mismatch");
return false;
}
}
else
{
if (credential.getType().equals(RequiredCredentialRepresentation.CALLER_PRINCIPAL))
{
List<UserCredential> principals = userCredentials.get(RequiredCredentialRepresentation.CALLER_PRINCIPAL);
if (principals == null) return false;
boolean found = false;
for (UserCredential userCredential : principals)
{
if (userCredential.getValue().equals(securityContext.getUserPrincipal().getName()))
{
found = true;
break;
}
}