[jboss-cvs] Picketlink SVN: r1310 - in idm/trunk: picketlink-idm-ldap/src/main/java/org/picketlink/idm/impl/store/ldap and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Oct 20 07:24:11 EDT 2011


Author: bdaw
Date: 2011-10-20 07:24:10 -0400 (Thu, 20 Oct 2011)
New Revision: 1310

Modified:
   idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/repository/FallbackIdentityStoreRepository.java
   idm/trunk/picketlink-idm-ldap/src/main/java/org/picketlink/idm/impl/store/ldap/LDAPIdentityStoreImpl.java
Log:
- allow LDAP store to return members as part of role searches
- sum object count when LDAP is used

Modified: idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/repository/FallbackIdentityStoreRepository.java
===================================================================
--- idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/repository/FallbackIdentityStoreRepository.java	2011-10-19 18:22:17 UTC (rev 1309)
+++ idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/repository/FallbackIdentityStoreRepository.java	2011-10-20 11:24:10 UTC (rev 1310)
@@ -617,6 +617,11 @@
 
       int result = 0;
 
+      if (!targetStores.contains(defaultIdentityStore))
+      {
+         targetStores.add(defaultIdentityStore);
+      }
+
       for (IdentityStore targetStore : targetStores)
       {
          IdentityStoreInvocationContext targetCtx = resolveInvocationContext(targetStore, invocationCtx);
@@ -840,10 +845,17 @@
 
       Collection<IdentityStore> mappedStores = getConfiguredIdentityStores();
 
+      if (!mappedStores.contains(defaultIdentityStore))
+      {
+         mappedStores.add(defaultIdentityStore);
+      }
+
       for (IdentityStore mappedStore : mappedStores)
       {
+         IdentityStoreInvocationContext targetCtx = resolveInvocationContext(mappedStore, invocationCxt);
+
          count += mappedStore.getIdentityObjectCount(
-            invocationCxt,
+            targetCtx,
             identity,
             relationshipType,
             parent,
@@ -869,10 +881,18 @@
 
       Collection<IdentityStore> mappedStores = getConfiguredIdentityStores();
 
+      if (!mappedStores.contains(defaultIdentityStore))
+      {
+         mappedStores.add(defaultIdentityStore);
+      }
+
       for (IdentityStore mappedStore : mappedStores)
       {
+
+         IdentityStoreInvocationContext targetCtx = resolveInvocationContext(mappedStore, ctx);
+
          count += mappedStore.getIdentityObjectCount(
-            ctx,
+            targetCtx,
             identity,
             relationshipType,
             excludes,
@@ -1226,15 +1246,21 @@
 
       for (IdentityStore mappedStore : mappedStores)
       {
-         count += mappedStore.getRelationshipsCount(
-            ctx,
-            identity,
-            type,
-            parent,
-            named,
-            name,
-            searchCriteria
-         );
+         IdentityStoreInvocationContext storeCtx = resolveInvocationContext(mappedStore, ctx);
+
+
+         if (hasIdentityObject(storeCtx, mappedStore, identity))
+         {
+            count += mappedStore.getRelationshipsCount(
+               storeCtx,
+               identity,
+               type,
+               parent,
+               named,
+               name,
+               searchCriteria
+            );
+         }
       }
 
       return count;
@@ -1256,16 +1282,17 @@
          // For any IdentityStore that supports named relationships...
          for (IdentityStore identityStore : configuredIdentityStores)
          {
-            if (relationshipType.getName() != null &&
-               !identityStore.getSupportedFeatures().getSupportedRelationshipTypes().contains(relationshipType.getName()))
-            {
-               continue;
-            }
+//            if (relationshipType.getName() != null &&
+//               !identityStore.getSupportedFeatures().getSupportedRelationshipTypes().contains(relationshipType.getName()))
+//            {
+//               continue;
+//            }
 
             IdentityStoreInvocationContext storeCtx = resolveInvocationContext(identityStore, ctx);
 
-            if ((!named || (named && identityStore.getSupportedFeatures().isNamedRelationshipsSupported()))
-               && hasIdentityObject(storeCtx, identityStore, identity))
+            //if ((!named || (named && identityStore.getSupportedFeatures().isNamedRelationshipsSupported()))
+            //   && hasIdentityObject(storeCtx, identityStore, identity))
+            if (hasIdentityObject(storeCtx, identityStore, identity))
             {
                relationships.addAll(identityStore.
                   resolveRelationships(storeCtx, identity, relationshipType, parent, named, name, criteria));

Modified: idm/trunk/picketlink-idm-ldap/src/main/java/org/picketlink/idm/impl/store/ldap/LDAPIdentityStoreImpl.java
===================================================================
--- idm/trunk/picketlink-idm-ldap/src/main/java/org/picketlink/idm/impl/store/ldap/LDAPIdentityStoreImpl.java	2011-10-19 18:22:17 UTC (rev 1309)
+++ idm/trunk/picketlink-idm-ldap/src/main/java/org/picketlink/idm/impl/store/ldap/LDAPIdentityStoreImpl.java	2011-10-20 11:24:10 UTC (rev 1310)
@@ -31,6 +31,7 @@
 import org.picketlink.idm.impl.model.ldap.LDAPIdentityObjectRelationshipImpl;
 import org.picketlink.idm.impl.store.FeaturesMetaDataImpl;
 import org.picketlink.idm.impl.types.SimpleIdentityObject;
+import org.picketlink.idm.impl.types.SimpleIdentityObjectRelationshipType;
 import org.picketlink.idm.spi.cache.IdentityStoreCacheProvider;
 import org.picketlink.idm.spi.configuration.IdentityStoreConfigurationContext;
 import org.picketlink.idm.spi.configuration.metadata.IdentityObjectAttributeMetaData;
@@ -110,6 +111,10 @@
 
    public static final String MEMBERSHIP_TYPE = "JBOSS_IDENTITY_MEMBERSHIP";
 
+   public static final String ROLE_TYPE = "JBOSS_IDENTITY_ROLE";
+
+   public static final String ROLE_TYPE_MEMBER = "member";
+
    private FeaturesMetaData supportedFeatures;
 
    LDAPIdentityStoreConfiguration configuration;
@@ -1175,7 +1180,6 @@
             });
       }
 
-
       if (relationshipType != null && !relationshipType.getName().equals(MEMBERSHIP_TYPE))
       {
          throw new IdentityException("This store implementation supports only '" + MEMBERSHIP_TYPE +"' relationship type");
@@ -1590,8 +1594,14 @@
             });
       }
 
-      if (type == null || !type.getName().equals(MEMBERSHIP_TYPE))
+
+      if (type == null || (type.getName().equals(ROLE_TYPE) && (name == null || name.equalsIgnoreCase(ROLE_TYPE_MEMBER))))
       {
+         type = new SimpleIdentityObjectRelationshipType(MEMBERSHIP_TYPE);
+      }
+
+      if (!type.getName().equals(MEMBERSHIP_TYPE))
+      {
          throw new IdentityException("This store implementation supports only '" + MEMBERSHIP_TYPE +"' relationship type");
       }
 
@@ -2237,6 +2247,11 @@
             });
       }
 
+      if (relationshipType == null)
+      {
+         relationshipType = new SimpleIdentityObjectRelationshipType(MEMBERSHIP_TYPE);
+      }
+
       if (relationshipType != null && !relationshipType.getName().equals(MEMBERSHIP_TYPE))
       {
          throw new IdentityException("This store implementation supports only '" + MEMBERSHIP_TYPE +"' relationship type");



More information about the jboss-cvs-commits mailing list