Author: shane.bryzak(a)jboss.com
Date: 2010-06-23 19:40:36 -0400 (Wed, 23 Jun 2010)
New Revision: 317
Modified:
idm/trunk/picketlink-idm-api/src/main/java/org/picketlink/idm/api/IdentitySessionFactory.java
idm/trunk/picketlink-idm-core/pom.xml
idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/api/IdentitySessionFactoryImpl.java
idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/api/session/IdentitySessionImpl.java
idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/cache/JBossCacheAttributeStoreWrapper.java
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/WrapperIdentityStoreRepository.java
idm/trunk/picketlink-idm-hibernate/src/main/java/org/picketlink/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java
idm/trunk/picketlink-idm-ldap/src/main/java/org/picketlink/idm/impl/store/ldap/LDAPIdentityStoreImpl.java
idm/trunk/picketlink-idm-spi/src/main/java/org/picketlink/idm/spi/store/IdentityStoreSessionFactory.java
Log:
modify IdentityStore api to accept session options
Modified:
idm/trunk/picketlink-idm-api/src/main/java/org/picketlink/idm/api/IdentitySessionFactory.java
===================================================================
---
idm/trunk/picketlink-idm-api/src/main/java/org/picketlink/idm/api/IdentitySessionFactory.java 2010-06-22
07:46:51 UTC (rev 316)
+++
idm/trunk/picketlink-idm-api/src/main/java/org/picketlink/idm/api/IdentitySessionFactory.java 2010-06-23
23:40:36 UTC (rev 317)
@@ -22,12 +22,18 @@
package org.picketlink.idm.api;
+import java.util.Map;
+
import org.picketlink.idm.common.exception.IdentityException;
/**
- * Creates IdentitySession objects for a given Realm.
- *
+ * Creates IdentitySession objects for a given Realm. An IdentitySessionFactory
+ * is typically created from an IdentityConfiguration.
+ *
+ * @see org.picketlink.idm.api.cfg.IdentityConfiguration#buildIdentitySessionFactory()
+ *
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @author Shane Bryzak
* @version : 0.1 $
*/
public interface IdentitySessionFactory
@@ -43,10 +49,25 @@
boolean isClosed();
/**
- * Create IdentitySession
- * @return
+ * Creates a new IdentitySession.
+ *
+ * @param realmName The name of the realm
+ * @return The new IdentitySession
*/
IdentitySession createIdentitySession(String realmName) throws IdentityException;
+
+ /**
+ * Creates a new IdentitySession for the given realm. This method accepts
+ * a sessionOptions parameter which may be used to customize the IdentitySession
+ * instance returned.
+ *
+ * @param realmName The name of the realm
+ * @param sessionOptions A Map containing session options
+ * @return The new IdentitySession
+ * @throws IdentityException
+ */
+ IdentitySession createIdentitySession(String realmName,
+ Map<String,Object> sessionOptions) throws IdentityException;
/**
Modified: idm/trunk/picketlink-idm-core/pom.xml
===================================================================
--- idm/trunk/picketlink-idm-core/pom.xml 2010-06-22 07:46:51 UTC (rev 316)
+++ idm/trunk/picketlink-idm-core/pom.xml 2010-06-23 23:40:36 UTC (rev 317)
@@ -8,7 +8,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>picketlink-idm-core</artifactId>
<packaging>jar</packaging>
- <name>PicketLink IDM Implemnentation</name>
+ <name>PicketLink IDM Implementation</name>
<
url>http://labs.jboss.org/portal/jbosssecurity/</url>
<description>PicketLink IDM IMPL contains the implementation of the API and the
Identity Model.</description>
<licenses>
Modified:
idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/api/IdentitySessionFactoryImpl.java
===================================================================
---
idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/api/IdentitySessionFactoryImpl.java 2010-06-22
07:46:51 UTC (rev 316)
+++
idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/api/IdentitySessionFactoryImpl.java 2010-06-23
23:40:36 UTC (rev 317)
@@ -66,10 +66,15 @@
{
return false;
}
-
+
public IdentitySession createIdentitySession(String realmName) throws
IdentityException
{
+ return createIdentitySession(realmName, null);
+ }
+ public IdentitySession createIdentitySession(String realmName,
+ Map<String,Object> sessionOptions) throws IdentityException
+ {
IdentitySessionConfigurationContext sessionConfigCtx =
sessionContextMap.get(realmName);
// If no realm mapped then look for a template which name is a prefix of realmName
@@ -112,7 +117,8 @@
sessionConfigCtx.getTypeMapper(),
sessionConfigCtx.getApiCacheProvider(),
sessionConfigCtx.getIdentityConfigurationContext(),
- sessionConfigCtx.getRealmOptions());
+ sessionConfigCtx.getRealmOptions(),
+ sessionOptions);
realmMap.put(realmName, newSession);
Modified:
idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/api/session/IdentitySessionImpl.java
===================================================================
---
idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/api/session/IdentitySessionImpl.java 2010-06-22
07:46:51 UTC (rev 316)
+++
idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/api/session/IdentitySessionImpl.java 2010-06-23
23:40:36 UTC (rev 317)
@@ -113,17 +113,29 @@
{
return sessionContext;
}
+
+ public IdentitySessionImpl(String realmName,
+ IdentityStoreRepository repository,
+ IdentityObjectTypeMapper typeMapper,
+ APICacheProvider apiCacheProvider,
+ IdentityConfigurationContext configurationContext,
+ Map<String, List<String>> realmOptions) throws IdentityException
+ {
+ this(realmName, repository, typeMapper, apiCacheProvider,
+ configurationContext, realmOptions, null);
+ }
public IdentitySessionImpl(String realmName,
IdentityStoreRepository repository,
IdentityObjectTypeMapper typeMapper,
APICacheProvider apiCacheProvider,
IdentityConfigurationContext configurationContext,
- Map<String, List<String>> realmOptions) throws
IdentityException
+ Map<String, List<String>> realmOptions,
+ Map<String,Object> sessionOptions) throws
IdentityException
{
this.realmName = realmName;
- IdentityStoreSession storeSession = repository.createIdentityStoreSession();
+ IdentityStoreSession storeSession =
repository.createIdentityStoreSession(sessionOptions);
final IdentityStoreInvocationContext invocationCtx = new
SimpleIdentityStoreInvocationContext(storeSession, realmName,
String.valueOf(this.hashCode()));
IdentityStoreInvocationContextResolver resolver = new
IdentityStoreInvocationContextResolver()
@@ -164,13 +176,6 @@
this.userQueryExecutor = new UserQueryExecutorImpl(this);
this.groupQueryExecutor = new GroupQueryExecutorImpl(this);
this.roleQueryExecutor = new RoleQueryExecutorImpl(this);
-
-
-
-
-
-
-
}
public String getId()
Modified:
idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/cache/JBossCacheAttributeStoreWrapper.java
===================================================================
---
idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/cache/JBossCacheAttributeStoreWrapper.java 2010-06-22
07:46:51 UTC (rev 316)
+++
idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/cache/JBossCacheAttributeStoreWrapper.java 2010-06-23
23:40:36 UTC (rev 317)
@@ -83,7 +83,14 @@
{
return attributeStore.createIdentityStoreSession();
}
+
+ public IdentityStoreSession createIdentityStoreSession(
+ Map<String, Object> sessionOptions) throws IdentityException
+ {
+ return attributeStore.createIdentityStoreSession(sessionOptions);
+ }
+
public Set<String> getSupportedAttributeNames(IdentityStoreInvocationContext
invocationContext,
IdentityObjectType identityType) throws
IdentityException
{
@@ -186,5 +193,4 @@
{
return "JBossCacheAttributeStoreWrapper (AttributeStore=" +
attributeStore.getId() + ")";
}
-
}
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 2010-06-22
07:46:51 UTC (rev 316)
+++
idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/repository/FallbackIdentityStoreRepository.java 2010-06-23
23:40:36 UTC (rev 317)
@@ -299,7 +299,38 @@
return new RepositoryIdentityStoreSessionImpl(sessions);
}
+
+ public IdentityStoreSession createIdentityStoreSession(
+ Map<String, Object> sessionOptions) throws IdentityException
+ {
+ Map<String, IdentityStoreSession> sessions = new HashMap<String,
IdentityStoreSession>();
+ for (IdentityStore identityStore : identityStoreMappings.values())
+ {
+ sessions.put(identityStore.getId(),
identityStore.createIdentityStoreSession(sessionOptions));
+ }
+
+ for (AttributeStore attributeStore : attributeStoreMappings.values())
+ {
+ if (!sessions.containsKey(attributeStore.getId()))
+ {
+ sessions.put(attributeStore.getId(),
attributeStore.createIdentityStoreSession(sessionOptions));
+ }
+ }
+
+ if (!sessions.containsKey(defaultAttributeStore.getId()))
+ {
+ sessions.put(defaultAttributeStore.getId(),
defaultAttributeStore.createIdentityStoreSession(sessionOptions));
+ }
+
+ if (!sessions.containsKey(defaultIdentityStore.getId()))
+ {
+ sessions.put(defaultIdentityStore.getId(),
defaultIdentityStore.createIdentityStoreSession(sessionOptions));
+ }
+
+ return new RepositoryIdentityStoreSessionImpl(sessions);
+ }
+
public String getId()
{
return id;
@@ -1887,4 +1918,6 @@
}
+
+
}
Modified:
idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/repository/WrapperIdentityStoreRepository.java
===================================================================
---
idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/repository/WrapperIdentityStoreRepository.java 2010-06-22
07:46:51 UTC (rev 316)
+++
idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/repository/WrapperIdentityStoreRepository.java 2010-06-23
23:40:36 UTC (rev 317)
@@ -89,7 +89,23 @@
return new RepositoryIdentityStoreSessionImpl(sessions);
}
+
+ public IdentityStoreSession createIdentityStoreSession(
+ Map<String, Object> sessionOptions) throws IdentityException
+ {
+ Map<String, IdentityStoreSession> sessions = new HashMap<String,
IdentityStoreSession>();
+
+ sessions.put(defaultAttributeStore.getId(),
defaultAttributeStore.createIdentityStoreSession(sessionOptions));
+
+ if (!sessions.containsKey(defaultIdentityStore.getId()))
+ {
+ sessions.put(defaultIdentityStore.getId(),
defaultIdentityStore.createIdentityStoreSession(sessionOptions));
+ }
+
+ return new RepositoryIdentityStoreSessionImpl(sessions);
+ }
+
IdentityStoreInvocationContext
resolveIdentityStoreInvocationContext(IdentityStoreInvocationContext invocationCtx)
{
return resolveInvocationContext(defaultIdentityStore.getId(), invocationCtx);
Modified:
idm/trunk/picketlink-idm-hibernate/src/main/java/org/picketlink/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java
===================================================================
---
idm/trunk/picketlink-idm-hibernate/src/main/java/org/picketlink/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java 2010-06-22
07:46:51 UTC (rev 316)
+++
idm/trunk/picketlink-idm-hibernate/src/main/java/org/picketlink/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java 2010-06-23
23:40:36 UTC (rev 317)
@@ -472,8 +472,14 @@
throw new IdentityException("Failed to obtain Hibernate
SessionFactory",e);
}
- }
+ }
+ public IdentityStoreSession createIdentityStoreSession(
+ Map<String, Object> sessionOptions) throws IdentityException
+ {
+ return createIdentityStoreSession();
+ }
+
public String getId()
{
return id;
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 2010-06-22
07:46:51 UTC (rev 316)
+++
idm/trunk/picketlink-idm-ldap/src/main/java/org/picketlink/idm/impl/store/ldap/LDAPIdentityStoreImpl.java 2010-06-23
23:40:36 UTC (rev 317)
@@ -302,7 +302,14 @@
{
return new LDAPIdentityStoreSessionImpl(configuration);
}
+
+ public IdentityStoreSession createIdentityStoreSession(
+ Map<String, Object> sessionOptions) throws IdentityException
+ {
+ return createIdentityStoreSession();
+ }
+
public String getId()
{
return id;
Modified:
idm/trunk/picketlink-idm-spi/src/main/java/org/picketlink/idm/spi/store/IdentityStoreSessionFactory.java
===================================================================
---
idm/trunk/picketlink-idm-spi/src/main/java/org/picketlink/idm/spi/store/IdentityStoreSessionFactory.java 2010-06-22
07:46:51 UTC (rev 316)
+++
idm/trunk/picketlink-idm-spi/src/main/java/org/picketlink/idm/spi/store/IdentityStoreSessionFactory.java 2010-06-23
23:40:36 UTC (rev 317)
@@ -25,17 +25,34 @@
import org.picketlink.idm.common.exception.IdentityException;
import java.io.Serializable;
+import java.util.Map;
/**
+ * Factory interface for creating IdentityStoreSession instances.
+ *
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @author Shane Bryzak
* @version : 0.1 $
*/
public interface IdentityStoreSessionFactory extends Serializable
{
-
/**
- * @return
+ * Creates a new IdentityStoreSession.
+ *
+ * @return The new IdentityStoreSession
+ * @throws IdentityException
*/
IdentityStoreSession createIdentityStoreSession() throws IdentityException;
+ /**
+ * Creates an IdentityStoreSession. This factory method allows additional
+ * session options to be passed in which may be used by the factory method
+ * implementation to customise the IdentityStoreSession returned.
+ *
+ * @param sessionOptions A Map containing the session option values
+ * @return The new IdentityStoreSession
+ * @throws IdentityException
+ */
+ IdentityStoreSession createIdentityStoreSession(Map<String,Object>
sessionOptions) throws IdentityException;
+
}