[seam-commits] Seam SVN: r13305 - in modules/security/trunk: examples/idmconsole/src/main/webapp/WEB-INF/templates and 1 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Fri Jun 25 02:11:27 EDT 2010


Author: shane.bryzak at jboss.com
Date: 2010-06-25 02:11:26 -0400 (Fri, 25 Jun 2010)
New Revision: 13305

Modified:
   modules/security/trunk/examples/idmconsole/src/main/webapp/WEB-INF/templates/default.xhtml
   modules/security/trunk/examples/idmconsole/src/main/webapp/home.xhtml
   modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java
Log:
add credential type criteria to validateCredential()


Modified: modules/security/trunk/examples/idmconsole/src/main/webapp/WEB-INF/templates/default.xhtml
===================================================================
--- modules/security/trunk/examples/idmconsole/src/main/webapp/WEB-INF/templates/default.xhtml	2010-06-25 04:50:50 UTC (rev 13304)
+++ modules/security/trunk/examples/idmconsole/src/main/webapp/WEB-INF/templates/default.xhtml	2010-06-25 06:11:26 UTC (rev 13305)
@@ -11,41 +11,13 @@
    <h:body>
       <div id="container">
          <div id="content">
-            <div id="sidebar">
-               <h3>Find out more</h3>
-               <p>
-                  Explore JavaServer Faces.
-               </p>
-               <ul>
-                  <li><a href="http://www.javaserverfaces.org">JSF community site</a></li>
-               </ul>
-               <p>
-                  Learn more about Java EE 6 and the extensions provided by Weld and Seam.
-               </p>
-               <ul>
-                  <li><a href="http://seamframework.org/Weld/JSR299AndWeldOverview">Overview</a></li>
-                  <li><a href="http://seamframework.org">Project site</a></li>
-                  <li><a href="http://seamframework.org/Documentation/SeamDocumentation#H-WeldReferenceDocumentation">Documentation</a></li>
-                  <li><a href="http://seamframework.org/Community/Forums">User forums</a></li>
-                  <li><a href="http://seamframework.org/Community/MailingLists">Mailing lists</a></li>
-                  <li><a href="https://jira.jboss.org/jira/browse/WELD">Issue tracker</a></li>
-               </ul>
-               <p>
-                  If you have an add-on, please <a href="http://seamframework.org/Community/Forums">let us know</a> and
-                  consider <a href="http://seamframework.org/Community/Contribute">contributing</a> it back to the
-                  community!
-               </p>
-            </div>
+
             <ui:insert name="content">
                [Template content will be inserted here]
             </ui:insert>
          </div>
          <div id="footer">
             <h:graphicImage value="/resources/gfx/weld.png" alt="Weld logo"/>
-            <p>
-               This project was generated from a Maven archetype maintained by the Weld team.<br/>
-               Weld is the reference implementation of CDI, released under the Apache License, Version 2.0.<br/>
-            </p>
          </div>
       </div>
    </h:body>

Modified: modules/security/trunk/examples/idmconsole/src/main/webapp/home.xhtml
===================================================================
--- modules/security/trunk/examples/idmconsole/src/main/webapp/home.xhtml	2010-06-25 04:50:50 UTC (rev 13304)
+++ modules/security/trunk/examples/idmconsole/src/main/webapp/home.xhtml	2010-06-25 06:11:26 UTC (rev 13305)
@@ -6,7 +6,7 @@
    template="/WEB-INF/templates/default.xhtml">
   <ui:define name="content">
     <h2>Identity Management Console</h2>
-    <p>This example demonstrates Seam's identity management features.</p>
+    <p>This example demonstrates Seam's identity management features, backed by PicketLink IDM.</p>
     
     <h:form id="loginForm" rendered="#{not identity.loggedIn}">
       <h:messages id="messages" globalOnly="true"/>

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:50:50 UTC (rev 13304)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java	2010-06-25 06:11:26 UTC (rev 13305)
@@ -1014,9 +1014,22 @@
       
       criteria.where(predicates.toArray(new Predicate[0]));
       
-      Query q = em.createQuery(criteria);
+      return em.createQuery(criteria).getSingleResult();
+   }
+   
+   protected Object lookupCredentialType(String name, EntityManager em)
+   {
+      Property<?> credentialTypeNameProp = modelProperties.get(PROPERTY_CREDENTIAL_TYPE_NAME);
       
-      return q.getSingleResult();
+      CriteriaBuilder builder = em.getCriteriaBuilder();
+      CriteriaQuery<?> criteria = builder.createQuery(credentialTypeNameProp.getDeclaringClass());
+      Root<?> root = criteria.from(credentialTypeNameProp.getDeclaringClass());
+      
+      List<Predicate> predicates = new ArrayList<Predicate>();
+      predicates.add(builder.equal(root.get(credentialTypeNameProp.getName()), name));      
+      criteria.where(predicates.toArray(new Predicate[0]));
+
+      return em.createQuery(criteria).getSingleResult();
    }
    
    protected Object lookupRelationshipType(IdentityObjectRelationshipType relationshipType)
@@ -1279,6 +1292,7 @@
       if (credentialClass != null)
       {
          Property<?> credentialIdentity = modelProperties.get(PROPERTY_CREDENTIAL_IDENTITY);
+         Property<?> credentialType = modelProperties.get(PROPERTY_CREDENTIAL_TYPE);
          
          CriteriaBuilder builder = em.getCriteriaBuilder();
          CriteriaQuery<?> criteria = builder.createQuery(credentialClass);
@@ -1288,6 +1302,20 @@
          predicates.add(builder.equal(root.get(credentialIdentity.getName()), 
                lookupIdentity(identityObject, em)));
          
+         if (credentialType != null)
+         {
+            if (String.class.equals(credentialType.getJavaClass()))
+            {
+               predicates.add(builder.equal(root.get(credentialType.getName()),
+                     credential.getType().getName()));
+            }
+            else
+            {
+               predicates.add(builder.equal(root.get(credentialType.getName()),
+                     lookupCredentialType(credential.getType().getName(), em)));
+            }
+         }
+         
          criteria.where(predicates.toArray(new Predicate[0]));
          
          Query q = em.createQuery(criteria);



More information about the seam-commits mailing list