[picketlink-commits] Picketlink SVN: r734 - in idm/trunk: assembly and 21 other directories.

picketlink-commits at lists.jboss.org picketlink-commits at lists.jboss.org
Fri Feb 4 16:28:41 EST 2011


Author: bdaw
Date: 2011-02-04 16:28:40 -0500 (Fri, 04 Feb 2011)
New Revision: 734

Added:
   idm/trunk/picketlink-idm-testsuite/src/test/java/org/picketlink/idm/impl/store/ldap/ManyLDAPStoresTestCase.java
Modified:
   idm/trunk/assembly/pom.xml
   idm/trunk/example/auth-simple/pom.xml
   idm/trunk/example/auth/pom.xml
   idm/trunk/example/simple/pom.xml
   idm/trunk/integration/deployer/pom.xml
   idm/trunk/integration/jboss5/pom.xml
   idm/trunk/integration/pom.xml
   idm/trunk/parent/pom.xml
   idm/trunk/picketlink-idm-api/pom.xml
   idm/trunk/picketlink-idm-auth/pom.xml
   idm/trunk/picketlink-idm-cache/pom.xml
   idm/trunk/picketlink-idm-common/pom.xml
   idm/trunk/picketlink-idm-core/pom.xml
   idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/repository/AbstractIdentityStoreRepository.java
   idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/repository/FallbackIdentityStoreRepository.java
   idm/trunk/picketlink-idm-docs/ReferenceGuide/pom.xml
   idm/trunk/picketlink-idm-docs/pom.xml
   idm/trunk/picketlink-idm-hibernate/pom.xml
   idm/trunk/picketlink-idm-ldap/pom.xml
   idm/trunk/picketlink-idm-spi/pom.xml
   idm/trunk/picketlink-idm-spi/src/main/java/org/picketlink/idm/spi/repository/IdentityStoreRepository.java
   idm/trunk/picketlink-idm-testsuite/pom.xml
   idm/trunk/pom.xml
Log:
- switch version to 1.3.0.Alpha01-SNAPSHOT
- push some local work on multi LDAP support for users

Modified: idm/trunk/assembly/pom.xml
===================================================================
--- idm/trunk/assembly/pom.xml	2011-02-04 20:55:39 UTC (rev 733)
+++ idm/trunk/assembly/pom.xml	2011-02-04 21:28:40 UTC (rev 734)
@@ -8,7 +8,7 @@
    <parent>
       <groupId>org.picketlink.idm</groupId>
       <artifactId>picketlink-idm-parent</artifactId>
-      <version>1.2.0.CR02-SNAPSHOT</version>
+      <version>1.3.0.Alpha01-SNAPSHOT</version>
       <relativePath>../parent</relativePath>
    </parent>
 

Modified: idm/trunk/example/auth/pom.xml
===================================================================
--- idm/trunk/example/auth/pom.xml	2011-02-04 20:55:39 UTC (rev 733)
+++ idm/trunk/example/auth/pom.xml	2011-02-04 21:28:40 UTC (rev 734)
@@ -1,7 +1,7 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.picketlink.idm.example</groupId>
-   <version>1.2.0.CR02-SNAPSHOT</version>
+   <version>1.3.0.Alpha01-SNAPSHOT</version>
    <artifactId>example-auth</artifactId>
    <packaging>jar</packaging>
    <name>Example - JEE authentication</name>

Modified: idm/trunk/example/auth-simple/pom.xml
===================================================================
--- idm/trunk/example/auth-simple/pom.xml	2011-02-04 20:55:39 UTC (rev 733)
+++ idm/trunk/example/auth-simple/pom.xml	2011-02-04 21:28:40 UTC (rev 734)
@@ -1,7 +1,7 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.picketlink.idm.example</groupId>
-   <version>1.2.0.CR02-SNAPSHOT</version>
+   <version>1.3.0.Alpha01-SNAPSHOT</version>
    <artifactId>example-auth-simple</artifactId>
    <packaging>jar</packaging>
    <name>Example - JEE authentication (using deployer)</name>

Modified: idm/trunk/example/simple/pom.xml
===================================================================
--- idm/trunk/example/simple/pom.xml	2011-02-04 20:55:39 UTC (rev 733)
+++ idm/trunk/example/simple/pom.xml	2011-02-04 21:28:40 UTC (rev 734)
@@ -1,7 +1,7 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.picketlink.idm.example</groupId>
-   <version>1.2.0.CR02-SNAPSHOT</version>
+   <version>1.3.0.Alpha01-SNAPSHOT</version>
    <artifactId>example-simple</artifactId>
    <packaging>jar</packaging>
    <name>Example - Simple PicketLink IDM Maven2 project</name>

Modified: idm/trunk/integration/deployer/pom.xml
===================================================================
--- idm/trunk/integration/deployer/pom.xml	2011-02-04 20:55:39 UTC (rev 733)
+++ idm/trunk/integration/deployer/pom.xml	2011-02-04 21:28:40 UTC (rev 734)
@@ -10,7 +10,7 @@
    <parent>
       <groupId>org.picketlink.idm</groupId>
       <artifactId>picketlink-idm-integration</artifactId>
-      <version>1.2.0.CR02-SNAPSHOT</version>
+      <version>1.3.0.Alpha01-SNAPSHOT</version>
    </parent>
 
    <properties>

Modified: idm/trunk/integration/jboss5/pom.xml
===================================================================
--- idm/trunk/integration/jboss5/pom.xml	2011-02-04 20:55:39 UTC (rev 733)
+++ idm/trunk/integration/jboss5/pom.xml	2011-02-04 21:28:40 UTC (rev 734)
@@ -10,7 +10,7 @@
    <parent>
       <groupId>org.picketlink.idm</groupId>
       <artifactId>picketlink-idm-integration</artifactId>
-      <version>1.2.0.CR02-SNAPSHOT</version>
+      <version>1.3.0.Alpha01-SNAPSHOT</version>
    </parent>
 
    <dependencies>

Modified: idm/trunk/integration/pom.xml
===================================================================
--- idm/trunk/integration/pom.xml	2011-02-04 20:55:39 UTC (rev 733)
+++ idm/trunk/integration/pom.xml	2011-02-04 21:28:40 UTC (rev 734)
@@ -6,14 +6,14 @@
    <description>PicketLink IDM Integration</description>
    <groupId>org.picketlink.idm</groupId>
    <artifactId>picketlink-idm-integration</artifactId>
-   <version>1.2.0.CR02-SNAPSHOT</version>
+   <version>1.3.0.Alpha01-SNAPSHOT</version>
    <packaging>pom</packaging>
 
    <!-- Parent -->
    <parent>
       <groupId>org.picketlink.idm</groupId>
       <artifactId>picketlink-idm-parent</artifactId>
-      <version>1.2.0.CR02-SNAPSHOT</version>
+      <version>1.3.0.Alpha01-SNAPSHOT</version>
       <relativePath>../parent/pom.xml</relativePath>
    </parent>
 

Modified: idm/trunk/parent/pom.xml
===================================================================
--- idm/trunk/parent/pom.xml	2011-02-04 20:55:39 UTC (rev 733)
+++ idm/trunk/parent/pom.xml	2011-02-04 21:28:40 UTC (rev 734)
@@ -8,7 +8,7 @@
    <groupId>org.picketlink.idm</groupId>
    <artifactId>picketlink-idm-parent</artifactId>
    <packaging>pom</packaging>
-   <version>1.2.0.CR02-SNAPSHOT</version>
+   <version>1.3.0.Alpha01-SNAPSHOT</version>
    <name>PicketLink IDM- Parent</name>
    <url>http://labs.jboss.org/portal/jbosssecurity/</url>
    <description>PicketLink is a cross-cutting project that handles identity  needs for the JEMS projects</description>

Modified: idm/trunk/picketlink-idm-api/pom.xml
===================================================================
--- idm/trunk/picketlink-idm-api/pom.xml	2011-02-04 20:55:39 UTC (rev 733)
+++ idm/trunk/picketlink-idm-api/pom.xml	2011-02-04 21:28:40 UTC (rev 734)
@@ -2,12 +2,12 @@
    <parent>
       <groupId>org.picketlink.idm</groupId>
       <artifactId>picketlink-idm-parent</artifactId>
-      <version>1.2.0.CR02-SNAPSHOT</version>
+      <version>1.3.0.Alpha01-SNAPSHOT</version>
       <relativePath>../parent</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>picketlink-idm-api</artifactId>
-  <version>1.2.0.CR02-SNAPSHOT</version>
+  <version>1.3.0.Alpha01-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>PicketLink IDM API</name>
    <url>http://labs.jboss.org/portal/jbosssecurity/</url>

Modified: idm/trunk/picketlink-idm-auth/pom.xml
===================================================================
--- idm/trunk/picketlink-idm-auth/pom.xml	2011-02-04 20:55:39 UTC (rev 733)
+++ idm/trunk/picketlink-idm-auth/pom.xml	2011-02-04 21:28:40 UTC (rev 734)
@@ -2,12 +2,12 @@
    <parent>
       <groupId>org.picketlink.idm</groupId>
       <artifactId>picketlink-idm-parent</artifactId>
-      <version>1.2.0.CR02-SNAPSHOT</version>
+      <version>1.3.0.Alpha01-SNAPSHOT</version>
       <relativePath>../parent</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>picketlink-idm-auth</artifactId>
-  <version>1.2.0.CR02-SNAPSHOT</version>
+  <version>1.3.0.Alpha01-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>PicketLink IDM Auth</name>
    <url>http://labs.jboss.org/portal/jbosssecurity/</url>

Modified: idm/trunk/picketlink-idm-cache/pom.xml
===================================================================
--- idm/trunk/picketlink-idm-cache/pom.xml	2011-02-04 20:55:39 UTC (rev 733)
+++ idm/trunk/picketlink-idm-cache/pom.xml	2011-02-04 21:28:40 UTC (rev 734)
@@ -2,12 +2,12 @@
    <parent>
       <groupId>org.picketlink.idm</groupId>
       <artifactId>picketlink-idm-parent</artifactId>
-      <version>1.2.0.CR02-SNAPSHOT</version>
+      <version>1.3.0.Alpha01-SNAPSHOT</version>
       <relativePath>../parent</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>picketlink-idm-cache</artifactId>
-  <version>1.2.0.CR02-SNAPSHOT</version>
+  <version>1.3.0.Alpha01-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>PicketLink IDM Cache</name>
    <url>http://labs.jboss.org/portal/jbosssecurity/</url>

Modified: idm/trunk/picketlink-idm-common/pom.xml
===================================================================
--- idm/trunk/picketlink-idm-common/pom.xml	2011-02-04 20:55:39 UTC (rev 733)
+++ idm/trunk/picketlink-idm-common/pom.xml	2011-02-04 21:28:40 UTC (rev 734)
@@ -2,12 +2,12 @@
    <parent>
       <groupId>org.picketlink.idm</groupId>
       <artifactId>picketlink-idm-parent</artifactId>
-      <version>1.2.0.CR02-SNAPSHOT</version>
+      <version>1.3.0.Alpha01-SNAPSHOT</version>
       <relativePath>../parent</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>picketlink-idm-common</artifactId>
-  <version>1.2.0.CR02-SNAPSHOT</version>
+  <version>1.3.0.Alpha01-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>PicketLink IDM Common</name>
    <url>http://labs.jboss.org/portal/jbosssecurity/</url>

Modified: idm/trunk/picketlink-idm-core/pom.xml
===================================================================
--- idm/trunk/picketlink-idm-core/pom.xml	2011-02-04 20:55:39 UTC (rev 733)
+++ idm/trunk/picketlink-idm-core/pom.xml	2011-02-04 21:28:40 UTC (rev 734)
@@ -2,12 +2,12 @@
    <parent>
       <groupId>org.picketlink.idm</groupId>
       <artifactId>picketlink-idm-parent</artifactId>
-      <version>1.2.0.CR02-SNAPSHOT</version>
+      <version>1.3.0.Alpha01-SNAPSHOT</version>
       <relativePath>../parent</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>picketlink-idm-core</artifactId>
-  <version>1.2.0.CR02-SNAPSHOT</version>
+  <version>1.3.0.Alpha01-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>PicketLink IDM Implementation</name>
    <url>http://labs.jboss.org/portal/jbosssecurity/</url>

Modified: idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/repository/AbstractIdentityStoreRepository.java
===================================================================
--- idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/repository/AbstractIdentityStoreRepository.java	2011-02-04 20:55:39 UTC (rev 733)
+++ idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/repository/AbstractIdentityStoreRepository.java	2011-02-04 21:28:40 UTC (rev 734)
@@ -36,6 +36,7 @@
 import org.picketlink.idm.impl.helper.SecurityActions;
 import org.picketlink.idm.impl.cache.JBossCacheIdentityStoreWrapper;
 
+import java.util.LinkedList;
 import java.util.Set;
 import java.util.Map;
 import java.util.HashSet;
@@ -56,10 +57,14 @@
 
    private static Logger log = Logger.getLogger(AbstractIdentityStoreRepository.class.getName());
 
-   protected Map<String, IdentityStore> identityStoreMappings = new HashMap<String, IdentityStore>();
+   protected Map<String, List<IdentityStore>> identityStoreMappings = new HashMap<String, List<IdentityStore>>();
 
-   protected Map<String, AttributeStore> attributeStoreMappings = new HashMap<String, AttributeStore>();
+   protected Map<String, List<AttributeStore>> attributeStoreMappings = new HashMap<String, List<AttributeStore>>();
 
+   protected Set<IdentityStore> configuredIdentityStores = new HashSet<IdentityStore>();
+
+   protected Set<AttributeStore> configuredAttributeStores = new HashSet<AttributeStore>();
+
    protected IdentityStore defaultIdentityStore;
 
    protected AttributeStore defaultAttributeStore;
@@ -95,6 +100,7 @@
       if (asId != null && bootstrappedAttributeStores.keySet().contains(asId))
       {
          defaultAttributeStore = bootstrappedAttributeStores.get(asId);
+         configuredAttributeStores.add(defaultAttributeStore);
 
          //TODO: cache wrap support
       }
@@ -109,6 +115,7 @@
       if (isId != null && bootstrappedIdentityStores.keySet().contains(isId))
       {
          defaultIdentityStore = bootstrappedIdentityStores.get(isId);
+         configuredIdentityStores.add(defaultIdentityStore);
 
          String cacheOption = configurationMD.getOptionSingleValue(CACHE_OPTION);
 
@@ -282,8 +289,24 @@
 
          for (String mapping : identityObjectTypeMappings)
          {
-            identityStoreMappings.put(mapping, store);
-            attributeStoreMappings.put(mapping, store);
+            List<IdentityStore> mappedIS = identityStoreMappings.get(mapping);
+            if (mappedIS == null)
+            {
+               mappedIS = new LinkedList<IdentityStore>();
+               identityStoreMappings.put(mapping, mappedIS);
+            }
+            mappedIS.add(store);
+            configuredIdentityStores.add(store);
+
+            List<AttributeStore> mappedAS = attributeStoreMappings.get(mapping);
+            if (mappedAS == null)
+            {
+               mappedAS = new LinkedList<AttributeStore>();
+               attributeStoreMappings.put(mapping, mappedAS);
+            }
+            mappedAS.add(store);
+            configuredAttributeStores.add(store);
+
          }
 
       }
@@ -292,27 +315,73 @@
 
    public Set<IdentityStore> getConfiguredIdentityStores()
    {
-      return new HashSet<IdentityStore>(identityStoreMappings.values());
+      return new HashSet<IdentityStore>(configuredIdentityStores);
    }
 
    public Set<AttributeStore> getConfiguredAttributeStores()
    {
-      return new HashSet<AttributeStore>(attributeStoreMappings.values());
+      return new HashSet<AttributeStore>(configuredIdentityStores);
    }
 
    public Map<String, IdentityStore> getIdentityStoreMappings()
    {
-      return identityStoreMappings;
+      Map<String, IdentityStore> firstInTheList = new HashMap<String, IdentityStore>();
+
+      for (Map.Entry<String, List<IdentityStore>> entry : identityStoreMappings.entrySet())
+      {
+         if(entry.getValue().size() > 0)
+         {
+            firstInTheList.put(entry.getKey(), entry.getValue().get(0));
+         }
+      }
+
+      return firstInTheList;
    }
 
    public Map<String, AttributeStore> getAttributeStoreMappings()
    {
-      return attributeStoreMappings;
+      Map<String, AttributeStore> firstInTheList = new HashMap<String, AttributeStore>();
+
+      for (Map.Entry<String, List<AttributeStore>> entry : attributeStoreMappings.entrySet())
+      {
+         if(entry.getValue().size() > 0)
+         {
+            firstInTheList.put(entry.getKey(), entry.getValue().get(0));
+         }
+      }
+
+      return firstInTheList;
    }
 
+   public List<IdentityStore> getIdentityStores(IdentityObjectType identityObjectType) throws IdentityException
+   {
+      if (identityStoreMappings.keySet().contains(identityObjectType.getName()))
+      {
+         return identityStoreMappings.get(identityObjectType.getName());
+      }
+      else
+      {
+         return new LinkedList<IdentityStore>();
+      }
+
+   }
+
+   public List<AttributeStore> getAttributeStores(IdentityObjectType identityObjectType) throws IdentityException
+   {
+      if (attributeStoreMappings.keySet().contains(identityObjectType.getName()))
+      {
+         return attributeStoreMappings.get(identityObjectType.getName());
+      }
+      else
+      {
+         return new LinkedList<AttributeStore>();
+      }
+
+   }
+
    public IdentityStore getIdentityStore(IdentityObjectType identityObjectType) throws IdentityException
    {
-      IdentityStore store = identityStoreMappings.get(identityObjectType.getName());
+      IdentityStore store = getIdentityStoreMappings().get(identityObjectType.getName());
 
       if (store == null)
       {
@@ -333,7 +402,7 @@
 
    public AttributeStore getAttributeStore(IdentityObjectType identityObjectType) throws IdentityException
    {
-      AttributeStore store = attributeStoreMappings.get(identityObjectType.getName());
+      AttributeStore store = getAttributeStoreMappings().get(identityObjectType.getName());
 
       if (store == null)
       {

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-02-04 20:55:39 UTC (rev 733)
+++ idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/repository/FallbackIdentityStoreRepository.java	2011-02-04 21:28:40 UTC (rev 734)
@@ -274,12 +274,12 @@
    {
       Map<String, IdentityStoreSession> sessions = new HashMap<String, IdentityStoreSession>();
 
-      for (IdentityStore identityStore : identityStoreMappings.values())
+      for (IdentityStore identityStore : configuredIdentityStores)
       {
          sessions.put(identityStore.getId(), identityStore.createIdentityStoreSession());
       }
 
-      for (AttributeStore attributeStore : attributeStoreMappings.values())
+      for (AttributeStore attributeStore : configuredIdentityStores)
       {
          if (!sessions.containsKey(attributeStore.getId()))
          {
@@ -305,12 +305,12 @@
    {
       Map<String, IdentityStoreSession> sessions = new HashMap<String, IdentityStoreSession>();
 
-      for (IdentityStore identityStore : identityStoreMappings.values())
+      for (IdentityStore identityStore : configuredIdentityStores)
       {
          sessions.put(identityStore.getId(), identityStore.createIdentityStoreSession(sessionOptions));
       }
 
-      for (AttributeStore attributeStore : attributeStoreMappings.values())
+      for (AttributeStore attributeStore : configuredIdentityStores)
       {
          if (!sessions.containsKey(attributeStore.getId()))
          {
@@ -377,6 +377,40 @@
       return ids;
    }
 
+   List<IdentityStore> resolveIdentityStores(IdentityObjectType iot)
+   {
+
+      List<IdentityStore> ids = null;
+      try
+      {
+         ids = getIdentityStores(iot);
+      }
+      catch (IdentityException e)
+      {
+         if (isAllowNotDefinedAttributes())
+         {
+            ids = new LinkedList<IdentityStore>();
+            ids.add(defaultIdentityStore);
+            return ids;
+         }
+
+         if (log.isLoggable(Level.FINER))
+         {
+            log.log(Level.FINER, "Exception occurred: ", e);
+         }
+
+         throw new IllegalStateException("Used IdentityObjectType not mapped. Consider using " + ALLOW_NOT_DEFINED_IDENTITY_OBJECT_TYPES_OPTION +
+            " repository option switch: " + iot );
+      }
+
+      if (ids == null || ids.size() == 0)
+      {
+         ids = new LinkedList<IdentityStore>();
+         ids.add(defaultIdentityStore);
+      }
+      return ids;
+   }
+
    AttributeStore resolveAttributeStore(IdentityObjectType iot)
    {
       AttributeStore ads = null;
@@ -505,31 +539,36 @@
 
    public void removeIdentityObject(IdentityStoreInvocationContext invocationCtx, IdentityObject identity) throws IdentityException
    {
-      IdentityStore targetStore = resolveIdentityStore(identity);
-      IdentityStoreInvocationContext targetCtx = resolveInvocationContext(targetStore, invocationCtx);
+      List<IdentityStore> targetStores = resolveIdentityStores(identity.getIdentityType());
       IdentityStoreInvocationContext defaultCtx = resolveInvocationContext(defaultIdentityStore, invocationCtx);
 
-      if (isIdentityStoreReadOnly(targetStore))
+      for (IdentityStore targetStore : targetStores)
       {
-         targetStore = defaultIdentityStore;
-         targetCtx = resolveInvocationContext(defaultIdentityStore, invocationCtx);
+         IdentityStoreInvocationContext targetCtx = resolveInvocationContext(targetStore, invocationCtx);
 
-      }
+         if (isIdentityStoreReadOnly(targetStore))
+         {
+            targetStore = defaultIdentityStore;
+            targetCtx = resolveInvocationContext(defaultIdentityStore, invocationCtx);
 
-      try
-      {
-         targetStore.removeIdentityObject(targetCtx, identity);
-      }
-      catch (IdentityException e)
-      {
-         if (log.isLoggable(Level.INFO))
+         }
+
+         try
          {
-            log.log(Level.INFO, "Failed to remove IdentityObject from target store: ", e);
+            targetStore.removeIdentityObject(targetCtx, identity);
          }
+         catch (IdentityException e)
+         {
+            if (log.isLoggable(Level.INFO))
+            {
+               log.log(Level.INFO, "Failed to remove IdentityObject from target store: ", e);
+            }
+         }
       }
 
+
       // Sync remove in default store
-      if (targetStore != defaultIdentityStore && hasIdentityObject(defaultCtx, defaultIdentityStore, identity))
+      if (!targetStores.contains(defaultIdentityStore) && hasIdentityObject(defaultCtx, defaultIdentityStore, identity))
       {
 
          try
@@ -548,61 +587,67 @@
 
    public int getIdentityObjectsCount(IdentityStoreInvocationContext invocationCtx, IdentityObjectType identityType) throws IdentityException
    {
-      IdentityStore targetStore = resolveIdentityStore(identityType);
-      IdentityStoreInvocationContext targetCtx = resolveInvocationContext(targetStore, invocationCtx);
+      List<IdentityStore> targetStores = resolveIdentityStores(identityType);
 
       //TODO: Result may be inaccurate - at least try to check if both stores don't match and return bigger count;
 
       int result = 0;
 
-      try
+      for (IdentityStore targetStore : targetStores)
       {
-         result = targetStore.getIdentityObjectsCount(targetCtx, identityType);
-      }
-      catch (IdentityException e)
-      {
-         if (log.isLoggable(Level.FINER))
+         IdentityStoreInvocationContext targetCtx = resolveInvocationContext(targetStore, invocationCtx);
+         try
          {
-            log.log(Level.INFO, "Failed to obtain IdentityObject count: ", e);
+            result += targetStore.getIdentityObjectsCount(targetCtx, identityType);
          }
+         catch (IdentityException e)
+         {
+            if (log.isLoggable(Level.FINER))
+            {
+               log.log(Level.INFO, "Failed to obtain IdentityObject count: ", e);
+            }
+         }
       }
+      
 
       return result;
    }
 
    public IdentityObject findIdentityObject(IdentityStoreInvocationContext invocationContext, String name, IdentityObjectType identityObjectType) throws IdentityException
    {
-      IdentityStore targetStore = resolveIdentityStore(identityObjectType);
-      IdentityStoreInvocationContext targetCtx = resolveInvocationContext(targetStore, invocationContext);
+      List<IdentityStore> targetStores = resolveIdentityStores(identityObjectType);
 
 
       IdentityObject io = null;
 
-      try
+      for (IdentityStore targetStore : targetStores)
       {
-         io = targetStore.findIdentityObject(targetCtx, name, identityObjectType);
-      }
-      catch (IdentityException e)
-      {
-         if (log.isLoggable(Level.INFO))
+         IdentityStoreInvocationContext targetCtx = resolveInvocationContext(targetStore, invocationContext);
+
+         try
          {
-            log.log(Level.INFO, "Failed to create IdentityObject: ", e);
+            io = targetStore.findIdentityObject(targetCtx, name, identityObjectType);
          }
-      }
+         catch (IdentityException e)
+         {
+            if (log.isLoggable(Level.INFO))
+            {
+               log.log(Level.INFO, "Failed to create IdentityObject: ", e);
+            }
+         }
 
-      if (io != null)
-      {
-         return io;
+         if (io != null)
+         {
+            return io;
+         }
+
       }
-      else
-      {
-         targetStore = defaultIdentityStore;
-         targetCtx = resolveInvocationContext(defaultIdentityStore, invocationContext);
-      }
 
+      
       try
       {
-         io = targetStore.findIdentityObject(targetCtx, name, identityObjectType);
+         io = defaultIdentityStore.
+            findIdentityObject(resolveInvocationContext(defaultIdentityStore, invocationContext), name, identityObjectType);
       }
       catch (IdentityException e)
       {
@@ -633,21 +678,25 @@
       return defaultIdentityStore.findIdentityObject(invocationContext, id);
    }
 
-   public Collection<IdentityObject> findIdentityObject(IdentityStoreInvocationContext invocationCtx, IdentityObjectType identityType, IdentityObjectSearchCriteria criteria) throws IdentityException
+   public Collection<IdentityObject> findIdentityObject(IdentityStoreInvocationContext invocationCtx,
+                                                        IdentityObjectType identityType,
+                                                        IdentityObjectSearchCriteria criteria) throws IdentityException
    {
-      IdentityStore targetStore = resolveIdentityStore(identityType);
-      IdentityStoreInvocationContext targetCtx = resolveInvocationContext(targetStore, invocationCtx);
+      List<IdentityStore> targetStores = resolveIdentityStores(identityType);
 
       Collection<IdentityObject> results = new LinkedList<IdentityObject>();
       Collection<IdentityObject> defaultIOs = new LinkedList<IdentityObject>();
 
-      if (targetStore == defaultIdentityStore)
+
+
+      if (targetStores.size() == 1 && targetStores.contains(defaultIdentityStore))
       {
          Collection<IdentityObject> resx = new LinkedList<IdentityObject>();
 
          try
          {
-            resx = targetStore.findIdentityObject(targetCtx, identityType, criteria);
+            IdentityStoreInvocationContext targetCtx = resolveInvocationContext(defaultIdentityStore, invocationCtx);
+            resx = defaultIdentityStore.findIdentityObject(targetCtx, identityType, criteria);
          }
          catch (IdentityException e)
          {
@@ -661,25 +710,28 @@
       }
       else
       {
+
+
          IdentitySearchCriteriaImpl c = null;
          if (criteria != null)
          {
             c = new IdentitySearchCriteriaImpl(criteria);
             c.setPaged(false);
          }
-
          // Get results from default store with not paged criteria
          defaultIOs = defaultIdentityStore.
             findIdentityObject(resolveInvocationContext(defaultIdentityStore, invocationCtx), identityType, c);
 
          // if default store results are not present then apply criteria. Otherwise apply criteria without page
          // as result need to be merged
-         if (defaultIOs.size() == 0)
+         if (defaultIOs.size() == 0 && targetStores.size() == 1)
          {
             Collection<IdentityObject> resx = new LinkedList<IdentityObject>();
 
             try
             {
+               IdentityStore targetStore = targetStores.get(0);
+               IdentityStoreInvocationContext targetCtx = resolveInvocationContext(targetStore, invocationCtx);
                resx =  targetStore.findIdentityObject(targetCtx, identityType, criteria);
             }
             catch (IdentityException e)
@@ -695,17 +747,22 @@
          else
          {
 
-            try
+            for (IdentityStore targetStore : targetStores)
             {
-               results = targetStore.findIdentityObject(targetCtx, identityType, c);
-            }
-            catch (IdentityException e)
-            {
-               if (log.isLoggable(Level.FINER))
+               try
                {
-                  log.log(Level.FINER, "Exception occurred: ", e);
+                  IdentityStoreInvocationContext targetCtx = resolveInvocationContext(targetStore, invocationCtx);
+                  results.addAll(targetStore.findIdentityObject(targetCtx, identityType, c));
                }
+               catch (IdentityException e)
+               {
+                  if (log.isLoggable(Level.FINER))
+                  {
+                     log.log(Level.FINER, "Exception occurred: ", e);
+                  }
+               }
             }
+
          }
 
       }
@@ -757,14 +814,14 @@
 
       try
       {
-         IdentityStore mappedStore = resolveIdentityStore(identity);
+         List<IdentityStore> mappedStores = resolveIdentityStores(identity.getIdentityType());
 
          IdentityStoreInvocationContext mappedCtx = resolveInvocationContext(mappedStore, invocationCxt);
 
          IdentityStoreInvocationContext defaultCtx = resolveInvocationContext(defaultIdentityStore, invocationCxt);
 
 
-         if (mappedStore == defaultIdentityStore)
+         if (mappedStores.size() == 1 && mappedStores.contains(defaultIdentityStore));
          {
             return defaultIdentityStore.findIdentityObject(defaultCtx, identity, relationshipType, parent, criteria);
          }

Modified: idm/trunk/picketlink-idm-docs/ReferenceGuide/pom.xml
===================================================================
--- idm/trunk/picketlink-idm-docs/ReferenceGuide/pom.xml	2011-02-04 20:55:39 UTC (rev 733)
+++ idm/trunk/picketlink-idm-docs/ReferenceGuide/pom.xml	2011-02-04 21:28:40 UTC (rev 734)
@@ -2,14 +2,14 @@
    <parent>
       <groupId>org.picketlink.idm</groupId>
       <artifactId>picketlink-idm-parent</artifactId>
-      <version>1.2.0.CR02-SNAPSHOT</version>
+      <version>1.3.0.Alpha01-SNAPSHOT</version>
       <relativePath>../../parent</relativePath>
    </parent>
 
 
    <modelVersion>4.0.0</modelVersion>
    <artifactId>Reference-Guide-${translation}</artifactId>
-  <version>1.2.0.CR02-SNAPSHOT</version>
+  <version>1.3.0.Alpha01-SNAPSHOT</version>
    <packaging>jdocbook</packaging>
    <name>User Guide (${translation})</name>
   

Modified: idm/trunk/picketlink-idm-docs/pom.xml
===================================================================
--- idm/trunk/picketlink-idm-docs/pom.xml	2011-02-04 20:55:39 UTC (rev 733)
+++ idm/trunk/picketlink-idm-docs/pom.xml	2011-02-04 21:28:40 UTC (rev 734)
@@ -2,13 +2,13 @@
 <parent>
    <groupId>org.picketlink.idm</groupId>
    <artifactId>picketlink-idm-parent</artifactId>
-   <version>1.2.0.CR02-SNAPSHOT</version>
+   <version>1.3.0.Alpha01-SNAPSHOT</version>
    <relativePath>../parent</relativePath>
 </parent>
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.picketlink.docs</groupId>
    <artifactId>picketlink-idm-docs</artifactId>
-  <version>1.2.0.CR02-SNAPSHOT</version>
+  <version>1.3.0.Alpha01-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>PicketLink IDM Docs</name>
    <url>http://www.jboss.com/products/jbossidentity</url>

Modified: idm/trunk/picketlink-idm-hibernate/pom.xml
===================================================================
--- idm/trunk/picketlink-idm-hibernate/pom.xml	2011-02-04 20:55:39 UTC (rev 733)
+++ idm/trunk/picketlink-idm-hibernate/pom.xml	2011-02-04 21:28:40 UTC (rev 734)
@@ -2,12 +2,12 @@
    <parent>
       <groupId>org.picketlink.idm</groupId>
       <artifactId>picketlink-idm-parent</artifactId>
-      <version>1.2.0.CR02-SNAPSHOT</version>
+      <version>1.3.0.Alpha01-SNAPSHOT</version>
       <relativePath>../parent</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>picketlink-idm-hibernate</artifactId>
-  <version>1.2.0.CR02-SNAPSHOT</version>
+  <version>1.3.0.Alpha01-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>PicketLink IDM Hibernate</name>
    <url>http://labs.jboss.org/portal/jbosssecurity/</url>

Modified: idm/trunk/picketlink-idm-ldap/pom.xml
===================================================================
--- idm/trunk/picketlink-idm-ldap/pom.xml	2011-02-04 20:55:39 UTC (rev 733)
+++ idm/trunk/picketlink-idm-ldap/pom.xml	2011-02-04 21:28:40 UTC (rev 734)
@@ -2,12 +2,12 @@
    <parent>
       <groupId>org.picketlink.idm</groupId>
       <artifactId>picketlink-idm-parent</artifactId>
-      <version>1.2.0.CR02-SNAPSHOT</version>
+      <version>1.3.0.Alpha01-SNAPSHOT</version>
       <relativePath>../parent</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>picketlink-idm-ldap</artifactId>
-  <version>1.2.0.CR02-SNAPSHOT</version>
+  <version>1.3.0.Alpha01-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>PicketLink IDM LDAP</name>
    <url>http://labs.jboss.org/portal/jbosssecurity/</url>

Modified: idm/trunk/picketlink-idm-spi/pom.xml
===================================================================
--- idm/trunk/picketlink-idm-spi/pom.xml	2011-02-04 20:55:39 UTC (rev 733)
+++ idm/trunk/picketlink-idm-spi/pom.xml	2011-02-04 21:28:40 UTC (rev 734)
@@ -2,12 +2,12 @@
    <parent>
       <groupId>org.picketlink.idm</groupId>
       <artifactId>picketlink-idm-parent</artifactId>
-      <version>1.2.0.CR02-SNAPSHOT</version>
+      <version>1.3.0.Alpha01-SNAPSHOT</version>
       <relativePath>../parent</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>picketlink-idm-spi</artifactId>
-  <version>1.2.0.CR02-SNAPSHOT</version>
+  <version>1.3.0.Alpha01-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>PicketLink IDM SPI</name>
    <url>http://labs.jboss.org/portal/jbosssecurity/</url>

Modified: idm/trunk/picketlink-idm-spi/src/main/java/org/picketlink/idm/spi/repository/IdentityStoreRepository.java
===================================================================
--- idm/trunk/picketlink-idm-spi/src/main/java/org/picketlink/idm/spi/repository/IdentityStoreRepository.java	2011-02-04 20:55:39 UTC (rev 733)
+++ idm/trunk/picketlink-idm-spi/src/main/java/org/picketlink/idm/spi/repository/IdentityStoreRepository.java	2011-02-04 21:28:40 UTC (rev 734)
@@ -21,6 +21,7 @@
  */
 package org.picketlink.idm.spi.repository;
 
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -74,17 +75,30 @@
     */
    IdentityStore getIdentityStore(IdentityObjectType identityObjectType) throws IdentityException;
 
+    /**
+    * @param identityObjectType
+    * @return proper identity store collection configured to store given identity type
+    */
+   List<IdentityStore> getIdentityStores(IdentityObjectType identityObjectType) throws IdentityException;
+
+
    /**
     * @param identityObjectType
-    * @return proper identity store to store given identity type
+    * @return proper attribute store to store given identity type
     */
    AttributeStore getAttributeStore(IdentityObjectType identityObjectType) throws IdentityException;
 
+   /**
+    * @param identityObjectType
+    * @return proper attribute store to store given identity type
+    */
+   List<AttributeStore> getAttributeStores(IdentityObjectType identityObjectType) throws IdentityException;
 
+
    /**
     * Return a list of relationship policies
     * @return
     */
    //List<RelationshipPolicy<IdentityObjectType, IdentityObjectType>> getRelationshipPolicies(IdentityObjectType identityObjectType);
    
-}
\ No newline at end of file
+}

Modified: idm/trunk/picketlink-idm-testsuite/pom.xml
===================================================================
--- idm/trunk/picketlink-idm-testsuite/pom.xml	2011-02-04 20:55:39 UTC (rev 733)
+++ idm/trunk/picketlink-idm-testsuite/pom.xml	2011-02-04 21:28:40 UTC (rev 734)
@@ -2,12 +2,12 @@
    <parent>
       <groupId>org.picketlink.idm</groupId>
       <artifactId>picketlink-idm-parent</artifactId>
-      <version>1.2.0.CR02-SNAPSHOT</version>
+      <version>1.3.0.Alpha01-SNAPSHOT</version>
       <relativePath>../parent</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>picketlink-idm-testsuite</artifactId>
-  <version>1.2.0.CR02-SNAPSHOT</version>
+  <version>1.3.0.Alpha01-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>PicketLink IDM Testsuite</name>
    <url>http://labs.jboss.org/portal/jbosssecurity/</url>

Added: idm/trunk/picketlink-idm-testsuite/src/test/java/org/picketlink/idm/impl/store/ldap/ManyLDAPStoresTestCase.java
===================================================================
--- idm/trunk/picketlink-idm-testsuite/src/test/java/org/picketlink/idm/impl/store/ldap/ManyLDAPStoresTestCase.java	                        (rev 0)
+++ idm/trunk/picketlink-idm-testsuite/src/test/java/org/picketlink/idm/impl/store/ldap/ManyLDAPStoresTestCase.java	2011-02-04 21:28:40 UTC (rev 734)
@@ -0,0 +1,38 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.picketlink.idm.impl.store.ldap;
+
+import org.picketlink.idm.impl.LDAPTestPOJO;
+
+/**
+ * Simulate config with 3 LDAP Stores. To simplify testing it uses one LDAP server with 3 different organization DNs
+ */
+public class ManyLDAPStoresTestCase extends LDAPTestPOJO
+{
+
+   
+
+   
+
+
+}

Modified: idm/trunk/pom.xml
===================================================================
--- idm/trunk/pom.xml	2011-02-04 20:55:39 UTC (rev 733)
+++ idm/trunk/pom.xml	2011-02-04 21:28:40 UTC (rev 734)
@@ -2,13 +2,13 @@
    <parent>
       <groupId>org.picketlink.idm</groupId>
       <artifactId>picketlink-idm-parent</artifactId>
-      <version>1.2.0.CR02-SNAPSHOT</version>
+      <version>1.3.0.Alpha01-SNAPSHOT</version>
       <relativePath>parent</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.picketlink.idm</groupId>
    <artifactId>jboss-identity-idm-pom</artifactId>
-  <version>1.2.0.CR02-SNAPSHOT</version>
+  <version>1.3.0.Alpha01-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>PicketLink IDM - Aggregator</name>
    <url>http://labs.jboss.org/portal/jbosssecurity/</url>



More information about the picketlink-commits mailing list