HibernateIdentityObject hibernateObject = safeGet(ctx, identityObject);
if (supportedFeatures.isCredentialSupported(hibernateObject.getIdentityType(),credential.getType()))
{
HibernateIdentityObjectCredential hibernateCredential = null;
hibernateCredential = (HibernateIdentityObjectCredential)getHibernateSession(ctx).
createQuery(HibernateIdentityObjectCredential.findIdentityObjectCredentialByIOAndTypeNAme).
setParameter("typeName", credential.getType().getName()).
setParameter("identityObject", hibernateObject).uniqueResult();
if (hibernateCredential == null)
{
return false;
}
// Handle generic impl
Object value = null;
if (credential.getEncodedValue() != null)
{
value = credential.getEncodedValue();
}
else
{
//TODO: support for empty password should be configurable
value = credential.getValue();
}
if (value instanceof String && hibernateCredential.getTextValue() != null)
{
return value.toString().equals(hibernateCredential.getTextValue());
}
else if (value instanceof byte[] && hibernateCredential.getBinaryValue() != null)
{
return Arrays.equals((byte[])value, hibernateCredential.getBinaryValue());
}
else
{
throw new IdentityException("Not supported credential value: " + value.getClass());
}