[seam-commits] Seam SVN: r13304 - in modules/security/trunk/impl/src/main/java/org/jboss/seam/security: management and 1 other directory.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Fri Jun 25 00:50:50 EDT 2010


Author: shane.bryzak at jboss.com
Date: 2010-06-25 00:50:50 -0400 (Fri, 25 Jun 2010)
New Revision: 13304

Modified:
   modules/security/trunk/impl/src/main/java/org/jboss/seam/security/jaas/SeamLoginModule.java
   modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java
Log:
got end to end authentication working.. yeah!!!


Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/jaas/SeamLoginModule.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/jaas/SeamLoginModule.java	2010-06-25 04:36:50 UTC (rev 13303)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/jaas/SeamLoginModule.java	2010-06-25 04:50:50 UTC (rev 13304)
@@ -91,11 +91,12 @@
             
             if (success)
             {
-               for (Role role : identityManager.getImpliedRoles(username))
-               {
-                  idCallback.getIdentity().addRole(role.getRoleType().getName(), 
-                        role.getGroup().getName(), role.getGroup().getGroupType());
-               }
+               // TODO implement role population
+               //for (Role role : identityManager.getImpliedRoles(username))
+               //{
+                 // idCallback.getIdentity().addRole(role.getRoleType().getName(), 
+                   //     role.getGroup().getName(), role.getGroup().getGroupType());
+               //}
             }
             
             return success;

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 04:36:50 UTC (rev 13303)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java	2010-06-25 04:50:50 UTC (rev 13304)
@@ -959,19 +959,21 @@
    }
 
    public IdentityObjectRelationship createRelationship(
-         IdentityStoreInvocationContext invocationCxt,
+         IdentityStoreInvocationContext invocationCtx,
          IdentityObject fromIdentity, IdentityObject toIdentity,
          IdentityObjectRelationshipType relationshipType,
          String relationshipName, boolean createNames) throws IdentityException
    {
       try
       {
+         EntityManager em = getEntityManager(invocationCtx);
+         
          Object relationship = relationshipClass.newInstance();
          
          modelProperties.get(PROPERTY_RELATIONSHIP_FROM).setValue(relationship, 
-               lookupIdentity(fromIdentity));
+               lookupIdentity(fromIdentity, em));
          modelProperties.get(PROPERTY_RELATIONSHIP_TO).setValue(relationship,
-               lookupIdentity(toIdentity));
+               lookupIdentity(toIdentity, em));
          
          Property<Object> type = modelProperties.get(PROPERTY_RELATIONSHIP_TYPE);
          if (String.class.equals(modelProperties.get(PROPERTY_RELATIONSHIP_TYPE).getJavaClass()))
@@ -997,11 +999,24 @@
       }
    }
    
-   protected Object lookupIdentity(IdentityObject obj)
+   protected Object lookupIdentity(IdentityObject obj, EntityManager em)
    {
-      // TODO implement
-      return null;
+      Property<?> identityNameProp = modelProperties.get(PROPERTY_IDENTITY_NAME);
       
+      CriteriaBuilder builder = em.getCriteriaBuilder();
+      CriteriaQuery<?> criteria = builder.createQuery(identityClass);
+      Root<?> root = criteria.from(identityClass);
+      
+      List<Predicate> predicates = new ArrayList<Predicate>();
+      predicates.add(builder.equal(root.get(identityNameProp.getName()), obj.getName()));
+      
+      // TODO add criteria for identity type
+      
+      criteria.where(predicates.toArray(new Predicate[0]));
+      
+      Query q = em.createQuery(criteria);
+      
+      return q.getSingleResult();
    }
    
    protected Object lookupRelationshipType(IdentityObjectRelationshipType relationshipType)
@@ -1270,7 +1285,8 @@
          Root<?> root = criteria.from(credentialClass);
          
          List<Predicate> predicates = new ArrayList<Predicate>();
-         predicates.add(builder.equal(root.get(credentialIdentity.getName()), lookupIdentity(identityObject)));
+         predicates.add(builder.equal(root.get(credentialIdentity.getName()), 
+               lookupIdentity(identityObject, em)));
          
          criteria.where(predicates.toArray(new Predicate[0]));
          



More information about the seam-commits mailing list