[seam-commits] Seam SVN: r13306 - modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Fri Jun 25 07:50:37 EDT 2010
Author: shane.bryzak at jboss.com
Date: 2010-06-25 07:50:36 -0400 (Fri, 25 Jun 2010)
New Revision: 13306
Modified:
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java
Log:
more credential validation stuff
Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java 2010-06-25 06:11:26 UTC (rev 13305)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java 2010-06-25 11:50:36 UTC (rev 13306)
@@ -1318,11 +1318,12 @@
criteria.where(predicates.toArray(new Predicate[0]));
- Query q = em.createQuery(criteria);
- List<?> results = q.getResultList();
+ List<?> results = em.createQuery(criteria).getResultList();
if (results.isEmpty()) return false;
+ // TODO this only supports plain text passwords
+
for (Object result : results)
{
Object val = credentialValue.getValue(result);
@@ -1332,10 +1333,25 @@
// or they're stored in the identity class
else
{
+ Property<?> identityNameProp = modelProperties.get(PROPERTY_IDENTITY_NAME);
+ CriteriaBuilder builder = em.getCriteriaBuilder();
+ CriteriaQuery<?> criteria = builder.createQuery(credentialValue.getDeclaringClass());
+
+ Root<?> root = criteria.from(credentialValue.getDeclaringClass());
+
+ List<Predicate> predicates = new ArrayList<Predicate>();
+ predicates.add(builder.equal(root.get(identityNameProp.getName()),
+ identityObject.getName()));
+
+ criteria.where(predicates.toArray(new Predicate[0]));
+
+ Object result = em.createQuery(criteria).getSingleResult();
+
+ Object val = credentialValue.getValue(result);
+ if (val.equals(credential.getValue())) return true;
}
-
- // TODO Auto-generated method stub
+
return false;
}
More information about the seam-commits
mailing list