Author: bdaw
Date: 2006-11-22 18:48:17 -0500 (Wed, 22 Nov 2006)
New Revision: 5717
Added:
trunk/identity/src/main/org/jboss/portal/identity2/service/IdentityModuleService.java
Modified:
trunk/identity/src/main/org/jboss/portal/identity2/IdentityContext.java
trunk/identity/src/main/org/jboss/portal/identity2/IdentityServiceControllerImpl.java
trunk/identity/src/main/org/jboss/portal/identity2/config/SimpleConfigurationImpl.java
trunk/identity/src/main/org/jboss/portal/identity2/info/PropertyInfo.java
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPConnectionContext.java
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPMembershipModule.java
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleImpl.java
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleModule.java
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserImpl.java
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserModule.java
trunk/identity/src/main/org/jboss/portal/identity2/service/IdentityConfigurationService.java
trunk/identity/src/main/org/jboss/portal/identity2/service/MembershipModuleService.java
trunk/identity/src/main/org/jboss/portal/identity2/service/RoleModuleService.java
trunk/identity/src/main/org/jboss/portal/identity2/service/UserModuleService.java
trunk/identity/src/main/org/jboss/portal/identity2/service/UserProfileModuleService.java
trunk/identity/src/resources/draft/identity-config.xml
Log:
- added IdentityModuleServices to instantiate modules in more flexible way
Modified: trunk/identity/src/main/org/jboss/portal/identity2/IdentityContext.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/IdentityContext.java 2006-11-22
23:14:30 UTC (rev 5716)
+++ trunk/identity/src/main/org/jboss/portal/identity2/IdentityContext.java 2006-11-22
23:48:17 UTC (rev 5717)
@@ -29,17 +29,17 @@
*/
public interface IdentityContext
{
- public static final String USER_MODULE = "user_module";
+ public static final String TYPE_USER_MODULE = "user_module";
- public static final String ROLE_MODULE = "role_module";
+ public static final String TYPE_ROLE_MODULE = "role_module";
- public static final String MEMBERSHIP_MODULE = "membership_module";
+ public static final String TYPE_MEMBERSHIP_MODULE = "membership_module";
- public static final String USER_PROFILE_MODULE = "user_profile_module";
+ public static final String TYPE_USER_PROFILE_MODULE =
"user_profile_module";
- public static final String CONNECTION_CONTEXT = "connection_context";
+ public static final String TYPE_CONNECTION_CONTEXT = "connection_context";
- public static final String IDENTITY_CONFIGURATION = "configuration";
+ public static final String TYPE_IDENTITY_CONFIGURATION = "configuration";
public void register(Object object, String name) throws IdentityException;
Modified:
trunk/identity/src/main/org/jboss/portal/identity2/IdentityServiceControllerImpl.java
===================================================================
---
trunk/identity/src/main/org/jboss/portal/identity2/IdentityServiceControllerImpl.java 2006-11-22
23:14:30 UTC (rev 5716)
+++
trunk/identity/src/main/org/jboss/portal/identity2/IdentityServiceControllerImpl.java 2006-11-22
23:48:17 UTC (rev 5717)
@@ -27,13 +27,19 @@
import org.jboss.portal.identity2.config.SimpleIdentityConfigurationFactory;
import org.jboss.portal.identity2.config.IdentityConfigurationMetaDataFactory;
import org.jboss.portal.identity2.config.metadata.IdentityConfigurationMetaData;
+import org.jboss.portal.identity2.config.metadata.ModuleMetaData;
+import org.jboss.portal.identity2.config.metadata.ModuleConfigOptionMetaData;
+import org.jboss.portal.identity2.service.IdentityModuleService;
import org.jboss.xb.binding.Unmarshaller;
import org.jboss.xb.binding.UnmarshallerFactory;
import org.jboss.xb.binding.ObjectModelFactory;
+import javax.management.ObjectName;
import java.net.URL;
import java.io.InputStream;
import java.util.Map;
+import java.util.Iterator;
+import java.util.HashMap;
/**
* @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw
Dawidowicz</a>
@@ -49,8 +55,12 @@
private IdentityContext identityContext;
+ private boolean registerMBeans = true;
+
private String configFile;
+ private String defaultConfigFile;
+
protected void startService() throws Exception
{
if (jndiName != null)
@@ -59,30 +69,58 @@
jndiBinding.bind();
}
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+
+ //parse config files
+ IdentityConfigurationMetaData meta = parseConfiguration(configFile);
+ IdentityConfigurationMetaData defaultMeta = parseConfiguration(defaultConfigFile);
+
+ IdentityContextImpl context = new IdentityContextImpl();
+ identityContext = context;
+ context.start();
+
+ //TODO:update meta options using defaultMeta options
+
try
- {
- log.info("Processing portal identity configuration");
- log.debug("config file: " + configFile);
- URL config =
Thread.currentThread().getContextClassLoader().getResource(configFile);
- InputStream in = config.openStream();
- // create unmarshaller
- Unmarshaller unmarshaller =
UnmarshallerFactory.newInstance().newUnmarshaller();
+ {
+ Map modules = meta.getModules().getModules();
- // create an instance of ObjectModelFactory
- ObjectModelFactory factory = new IdentityConfigurationMetaDataFactory();
+ for (Iterator iterator = modules.keySet().iterator(); iterator.hasNext();)
+ {
+ String key = (String)iterator.next();
+ ModuleMetaData module = (ModuleMetaData)modules.get(key);
- // let the object model factory to create an instance of Map and populate
it with data from XML
- IdentityConfigurationMetaData meta =
(IdentityConfigurationMetaData)unmarshaller.unmarshal(in, factory, null);
+ //instantiate the module
+ IdentityModuleService moduleService =
(IdentityModuleService)tcl.loadClass(module.getClassName()).newInstance();
+ moduleService.setIdentityContext(identityContext);
- // close the XML stream
- in.close();
- }
- catch (Exception e)
+ //generate initial options
+ Map configOptions = module.getConfig().getOptions();
+ Map optionMap = new HashMap();
+ for (Iterator iterator1 = configOptions.keySet().iterator();
iterator1.hasNext();)
{
- throw new IdentityException("Cannot parse configuration file",
e);
+ String optionName = (String)iterator1.next();
+ ModuleConfigOptionMetaData option =
(ModuleConfigOptionMetaData)configOptions.get(optionName);
+ optionMap.put(optionName,option.getValue());
}
+ //set options
+ moduleService.setInitOptions(optionMap);
+ //start
+ moduleService.start();
+
+ //register as an mbean
+ if (isRegisterMBeans())
+ {
+ getServer().registerMBean(moduleService, new
ObjectName(module.getServiceName()));
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Cannot initiate identity modules: ", e);
+ }
}
@@ -97,6 +135,36 @@
}
+ private IdentityConfigurationMetaData parseConfiguration(String configFile) throws
IdentityException
+ {
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ IdentityConfigurationMetaData meta = null;
+ try
+ {
+ log.info("Processing portal identity configuration");
+ log.debug("config file: " + configFile);
+ URL config = tcl.getResource(configFile);
+ InputStream in = config.openStream();
+ // create unmarshaller
+ Unmarshaller unmarshaller =
UnmarshallerFactory.newInstance().newUnmarshaller();
+
+ // create an instance of ObjectModelFactory
+ ObjectModelFactory factory = new IdentityConfigurationMetaDataFactory();
+
+ // let the object model factory to create an instance of Map and populate it
with data from XML
+ meta = (IdentityConfigurationMetaData)unmarshaller.unmarshal(in, factory,
null);
+
+ // close the XML stream
+ in.close();
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Cannot parse configuration file", e);
+ }
+ return meta;
+ }
+
+
public IdentityContext getIdentityContext()
{
return identityContext;
@@ -113,7 +181,16 @@
this.configFile = configFile;
}
+ public String getDefaultConfigFile()
+ {
+ return defaultConfigFile;
+ }
+ public void setDefaultConfigFile(String defaultConfigFile)
+ {
+ this.defaultConfigFile = defaultConfigFile;
+ }
+
public String getJndiName()
{
return jndiName;
@@ -133,4 +210,14 @@
{
this.jndiBinding = jndiBinding;
}
+
+ public boolean isRegisterMBeans()
+ {
+ return registerMBeans;
+ }
+
+ public void setRegisterMBeans(boolean registerMBeans)
+ {
+ this.registerMBeans = registerMBeans;
+ }
}
Modified:
trunk/identity/src/main/org/jboss/portal/identity2/config/SimpleConfigurationImpl.java
===================================================================
---
trunk/identity/src/main/org/jboss/portal/identity2/config/SimpleConfigurationImpl.java 2006-11-22
23:14:30 UTC (rev 5716)
+++
trunk/identity/src/main/org/jboss/portal/identity2/config/SimpleConfigurationImpl.java 2006-11-22
23:48:17 UTC (rev 5717)
@@ -94,7 +94,7 @@
}
else
{
- identityContext.register(this, IdentityContext.IDENTITY_CONFIGURATION);
+ identityContext.register(this, IdentityContext.TYPE_IDENTITY_CONFIGURATION);
}
@@ -115,7 +115,7 @@
}
else
{
- identityContext.unregister(IdentityContext.IDENTITY_CONFIGURATION);
+ identityContext.unregister(IdentityContext.TYPE_IDENTITY_CONFIGURATION);
}
}
Modified: trunk/identity/src/main/org/jboss/portal/identity2/info/PropertyInfo.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/info/PropertyInfo.java 2006-11-22
23:14:30 UTC (rev 5716)
+++ trunk/identity/src/main/org/jboss/portal/identity2/info/PropertyInfo.java 2006-11-22
23:48:17 UTC (rev 5717)
@@ -31,6 +31,7 @@
public interface PropertyInfo
{
+ //TODO: make it int or safe type enum
public static final String ACCESS_MODE_READ_ONLY = "read-only";
public static final String ACCESS_MODE_READ_WRITE = "read-write";
public static final String USAGE_MANDATORY = "mandatory";
Modified:
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPConnectionContext.java
===================================================================
---
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPConnectionContext.java 2006-11-22
23:14:30 UTC (rev 5716)
+++
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPConnectionContext.java 2006-11-22
23:48:17 UTC (rev 5717)
@@ -25,7 +25,7 @@
import org.jboss.portal.jems.as.system.AbstractJBossService;
import org.jboss.portal.identity2.IdentityContext;
import org.jboss.portal.identity2.IdentityConfiguration;
-import org.jboss.portal.common.util.JNDI;
+import org.jboss.portal.identity2.service.IdentityModuleService;
import org.jboss.portal.identity.IdentityException;
import javax.naming.Context;
@@ -39,38 +39,13 @@
* @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw
Dawidowicz</a>
* @version $Revision: 1.1 $
*/
-public class LDAPConnectionContext extends AbstractJBossService
+public class LDAPConnectionContext extends IdentityModuleService
{
+ private static final org.jboss.logging.Logger log =
org.jboss.logging.Logger.getLogger(IdentityModuleService.class);
- private IdentityContext identityContext;
- private IdentityConfiguration identityConfiguration;
- protected void startService() throws Exception
- {
- if (identityContext == null)
- {
- log.error("Cannot register module in context - missing reference");
- }
- identityContext.register(this, IdentityContext.CONNECTION_CONTEXT);
-
-
- }
-
-
- protected void stopService() throws Exception
- {
-
- if (identityContext == null)
- {
- log.error("Cannot unregister module in context - missing reference");
- }
-
- identityContext.unregister(IdentityContext.CONNECTION_CONTEXT);
-
- }
-
/*private String name;
private String providerUrl;
@@ -104,7 +79,7 @@
public LDAPConnectionContext()
{
-
+ super(IdentityContext.TYPE_CONNECTION_CONTEXT);
}
@@ -225,31 +200,9 @@
this.authentication = authentication;
}*/
- public IdentityContext getIdentityContext()
- {
- return identityContext;
- }
+
- public void setIdentityContext(IdentityContext identityContext)
- {
- this.identityContext = identityContext;
- }
- public IdentityConfiguration getIdentityConfiguration()
- {
- try
- {
- if (identityConfiguration == null)
- {
- this.identityConfiguration =
(IdentityConfiguration)identityContext.getObject(IdentityContext.IDENTITY_CONFIGURATION);
- }
- return identityConfiguration;
- }
- catch (IdentityException e)
- {
- throw new RuntimeException("Can't obtain IdentityConfiguration",
e);
- }
- }
}
Modified:
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPMembershipModule.java
===================================================================
---
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPMembershipModule.java 2006-11-22
23:14:30 UTC (rev 5716)
+++
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPMembershipModule.java 2006-11-22
23:48:17 UTC (rev 5717)
@@ -53,7 +53,7 @@
{
try
{
- this.connectionContext =
(LDAPConnectionContext)getIdentityContext().getObject(IdentityContext.CONNECTION_CONTEXT);
+ this.connectionContext =
(LDAPConnectionContext)getIdentityContext().getObject(IdentityContext.TYPE_CONNECTION_CONTEXT);
}
catch (ClassCastException e)
{
@@ -72,7 +72,7 @@
{
try
{
- this.userModule =
(LDAPUserModule)getIdentityContext().getObject(IdentityContext.USER_MODULE);
+ this.userModule =
(LDAPUserModule)getIdentityContext().getObject(IdentityContext.TYPE_USER_MODULE);
}
catch (ClassCastException e)
{
@@ -89,7 +89,7 @@
{
try
{
- this.roleModule =
(LDAPRoleModule)getIdentityContext().getObject(IdentityContext.ROLE_MODULE);
+ this.roleModule =
(LDAPRoleModule)getIdentityContext().getObject(IdentityContext.TYPE_ROLE_MODULE);
}
catch (ClassCastException e)
{
Modified: trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleImpl.java 2006-11-22
23:14:30 UTC (rev 5716)
+++ trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleImpl.java 2006-11-22
23:48:17 UTC (rev 5717)
@@ -100,7 +100,7 @@
{
try
{
- MembershipModule mm =
(MembershipModule)identityContext.getObject(IdentityContext.MEMBERSHIP_MODULE);
+ MembershipModule mm =
(MembershipModule)identityContext.getObject(IdentityContext.TYPE_MEMBERSHIP_MODULE);
return mm.getUsers(this);
}
catch (IdentityException e)
Modified: trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleModule.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleModule.java 2006-11-22
23:14:30 UTC (rev 5716)
+++ trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleModule.java 2006-11-22
23:48:17 UTC (rev 5717)
@@ -143,7 +143,7 @@
{
if (connectionContext == null)
{
- this.connectionContext =
(LDAPConnectionContext)getIdentityContext().getObject(IdentityContext.CONNECTION_CONTEXT);
+ this.connectionContext =
(LDAPConnectionContext)getIdentityContext().getObject(IdentityContext.TYPE_CONNECTION_CONTEXT);
}
return connectionContext;
}
Modified: trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleModuleImpl.java
===================================================================
---
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleModuleImpl.java 2006-11-22
23:14:30 UTC (rev 5716)
+++
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleModuleImpl.java 2006-11-22
23:48:17 UTC (rev 5717)
@@ -25,13 +25,10 @@
import org.jboss.portal.common.util.Tools;
import org.jboss.portal.identity.IdentityException;
import org.jboss.portal.identity2.Role;
-import org.jboss.portal.identity2.RoleModule;
import org.jboss.portal.identity2.User;
-import org.jboss.portal.identity.NoSuchUserException;
import org.jboss.portal.identity2.IdentityContext;
import org.jboss.portal.identity2.MembershipModule;
import org.jboss.portal.identity2.IdentityConfiguration;
-import org.jboss.portal.jems.as.system.AbstractJBossService;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
@@ -319,7 +316,7 @@
{
try
{
- MembershipModule mm =
(MembershipModule)getIdentityContext().getObject(IdentityContext.MEMBERSHIP_MODULE);
+ MembershipModule mm =
(MembershipModule)getIdentityContext().getObject(IdentityContext.TYPE_MEMBERSHIP_MODULE);
return mm.findRoleMembers(roleName, offset, limit, userNameFilter);
}
catch (IdentityException e)
@@ -334,7 +331,7 @@
{
try
{
- MembershipModule mm =
(MembershipModule)getIdentityContext().getObject(IdentityContext.MEMBERSHIP_MODULE);
+ MembershipModule mm =
(MembershipModule)getIdentityContext().getObject(IdentityContext.TYPE_MEMBERSHIP_MODULE);
mm.assignRoles(user,roles);
}
catch (IdentityException e)
@@ -349,7 +346,7 @@
{
try
{
- MembershipModule mm =
(MembershipModule)getIdentityContext().getObject(IdentityContext.MEMBERSHIP_MODULE);
+ MembershipModule mm =
(MembershipModule)getIdentityContext().getObject(IdentityContext.TYPE_MEMBERSHIP_MODULE);
return mm.getRoles(user);
}
catch (IdentityException e)
Modified: trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserImpl.java 2006-11-22
23:14:30 UTC (rev 5716)
+++ trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserImpl.java 2006-11-22
23:48:17 UTC (rev 5717)
@@ -30,8 +30,6 @@
import org.jboss.portal.identity2.IdentityConfiguration;
import org.jboss.portal.common.util.Tools;
-import java.util.Date;
-import java.util.Locale;
import java.security.NoSuchAlgorithmException;
/**
@@ -191,7 +189,7 @@
private IdentityConfiguration getIdentityConfiguration() throws IdentityException
{
- return
(IdentityConfiguration)identityContext.getObject(IdentityContext.IDENTITY_CONFIGURATION);
+ return
(IdentityConfiguration)identityContext.getObject(IdentityContext.TYPE_IDENTITY_CONFIGURATION);
}
private String getHashAlgorightm()
Modified: trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserModule.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserModule.java 2006-11-22
23:14:30 UTC (rev 5716)
+++ trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserModule.java 2006-11-22
23:48:17 UTC (rev 5717)
@@ -143,7 +143,7 @@
{
if (userProfileModule == null)
{
- this.userProfileModule =
(UserProfileModule)getIdentityContext().getObject(IdentityContext.USER_PROFILE_MODULE);
+ this.userProfileModule =
(UserProfileModule)getIdentityContext().getObject(IdentityContext.TYPE_USER_PROFILE_MODULE);
}
return userProfileModule;
}
@@ -184,7 +184,7 @@
{
if (connectionContext == null)
{
- this.connectionContext =
(LDAPConnectionContext)getIdentityContext().getObject(IdentityContext.CONNECTION_CONTEXT);
+ this.connectionContext =
(LDAPConnectionContext)getIdentityContext().getObject(IdentityContext.TYPE_CONNECTION_CONTEXT);
}
return connectionContext;
}
Modified:
trunk/identity/src/main/org/jboss/portal/identity2/service/IdentityConfigurationService.java
===================================================================
---
trunk/identity/src/main/org/jboss/portal/identity2/service/IdentityConfigurationService.java 2006-11-22
23:14:30 UTC (rev 5716)
+++
trunk/identity/src/main/org/jboss/portal/identity2/service/IdentityConfigurationService.java 2006-11-22
23:48:17 UTC (rev 5717)
@@ -24,110 +24,73 @@
import org.jboss.portal.jems.as.system.AbstractJBossService;
import org.jboss.portal.identity2.IdentityConfiguration;
import org.jboss.portal.identity2.IdentityContext;
-import org.jboss.portal.identity2.config.SimpleIdentityConfigurationFactory;
+import org.jboss.portal.identity2.config.metadata.OptionsMetaData;
+import org.jboss.portal.identity2.config.metadata.OptionsGroupMetaData;
+import org.jboss.portal.identity2.config.metadata.OptionsGroupOptionMetaData;
import org.jboss.portal.common.util.JNDI;
import org.jboss.portal.identity.IdentityException;
-import org.jboss.xb.binding.Unmarshaller;
-import org.jboss.xb.binding.UnmarshallerFactory;
-import org.jboss.xb.binding.ObjectModelFactory;
import java.util.Map;
import java.util.Set;
-import java.net.URL;
-import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Iterator;
/**
* @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw
Dawidowicz</a>
* @version $Revision: 1.1 $
*/
-public class IdentityConfigurationService extends AbstractJBossService implements
IdentityConfiguration
+public class IdentityConfigurationService extends IdentityModuleService implements
IdentityConfiguration
{
+ //TODO: improve access to data to not blow up by NullPointerEx
+
private static final org.jboss.logging.Logger log =
org.jboss.logging.Logger.getLogger(IdentityConfigurationService.class);
private Map data;
- private String jndiName;
+ public IdentityConfigurationService()
+ {
+ super(IdentityContext.TYPE_IDENTITY_CONFIGURATION);
+ }
- //private String configFile;
-
- protected JNDI.Binding jndiBinding;
-
- private IdentityContext identityContext;
-
public IdentityConfigurationService(Map optionGroups)
{
+ this();
this.data = optionGroups;
}
- protected void startService() throws Exception
+ public IdentityConfigurationService(OptionsMetaData meta) throws IdentityException
{
-
-
- /*try
+ this();
+ try
{
- log.info("Processing portal identity configuration");
- log.debug("config file: " + configFile);
- URL config =
Thread.currentThread().getContextClassLoader().getResource(configFile);
- InputStream in = config.openStream();
- // create unmarshaller
- Unmarshaller unmarshaller =
UnmarshallerFactory.newInstance().newUnmarshaller();
+ Map newGroups = new HashMap();
+ Map groups = meta.getGroups();
+ for (Iterator iterator = groups.keySet().iterator(); iterator.hasNext();)
+ {
+ String groupKey = (String)iterator.next();
+ OptionsGroupMetaData group = (OptionsGroupMetaData)groups.get(groupKey);
- // create an instance of ObjectModelFactory
- ObjectModelFactory factory = new SimpleIdentityConfigurationFactory();
+ Map newOptions = new HashMap();
+ Map options = group.getOptions();
+ for (Iterator iterator1 = options.keySet().iterator(); iterator1.hasNext();)
+ {
+ String optionKey = (String)iterator1.next();
+ OptionsGroupOptionMetaData option =
(OptionsGroupOptionMetaData)options.get(optionKey);
- // let the object model factory to create an instance of Map and populate it
with data from XML
- data = (Map)unmarshaller.unmarshal(in, factory, null);
+ newOptions.put(option.getName(),option.getValues());
+ }
- // close the XML stream
- in.close();
+ newGroups.put(group.getName(), newOptions);
+ }
+ setData(newGroups);
}
catch (Exception e)
{
- throw new IdentityException("Cannot parse configuration file", e);
- }*/
-
- //
- if (jndiName != null)
- {
- jndiBinding = new JNDI.Binding(jndiName, this);
- jndiBinding.bind();
+ throw new IdentityException("Cannot create identity configuration options
data:", e);
}
-
- if (identityContext == null)
- {
- throw new IdentityException("Cannot register module in context - missing
reference");
- }
- else
- {
- identityContext.register(this, IdentityContext.IDENTITY_CONFIGURATION);
- }
-
-
}
-
- protected void stopService() throws Exception
- {
- if (jndiBinding != null)
- {
- jndiBinding.unbind();
- jndiBinding = null;
- }
-
- if (identityContext == null)
- {
- log.error("Cannot unregister module in context - missing reference");
- }
- else
- {
- identityContext.unregister(IdentityContext.IDENTITY_CONFIGURATION);
- }
-
- }
-
-
-
public Set getValues(String optionGroup, String option)
{
if (optionGroup == null)
@@ -292,16 +255,6 @@
return data;
}
- public String getJndiName()
- {
- return jndiName;
- }
-
- public void setJndiName(String jndiName)
- {
- this.jndiName = jndiName;
- }
-
// public String getConfigFile()
// {
// return configFile;
@@ -312,14 +265,5 @@
// this.configFile = configFile;
// }
- public IdentityContext getIdentityContext()
- {
- return identityContext;
- }
- public void setIdentityContext(IdentityContext identityContext)
- {
- this.identityContext = identityContext;
- }
-
}
Added:
trunk/identity/src/main/org/jboss/portal/identity2/service/IdentityModuleService.java
===================================================================
---
trunk/identity/src/main/org/jboss/portal/identity2/service/IdentityModuleService.java 2006-11-22
23:14:30 UTC (rev 5716)
+++
trunk/identity/src/main/org/jboss/portal/identity2/service/IdentityModuleService.java 2006-11-22
23:48:17 UTC (rev 5717)
@@ -0,0 +1,162 @@
+/*
+* 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.jboss.portal.identity2.service;
+
+import org.jboss.portal.identity2.IdentityContext;
+import org.jboss.portal.identity2.IdentityConfiguration;
+import org.jboss.portal.common.util.JNDI;
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw
Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class IdentityModuleService extends AbstractJBossService
+{
+ private static final org.jboss.logging.Logger log =
org.jboss.logging.Logger.getLogger(IdentityModuleService.class);
+
+ private String jndiName;
+
+ private IdentityContext identityContext;
+
+ private IdentityConfiguration identityConfiguration;
+
+ private JNDI.Binding jndiBinding;
+
+ private Map initOptions;
+
+ private String moduleType;
+
+ //restrict instance creation
+ private IdentityModuleService()
+ {
+
+ }
+
+ protected IdentityModuleService(String type)
+ {
+ moduleType = type;
+ }
+
+ protected void startService() throws Exception
+ {
+
+ //
+ if (jndiName != null)
+ {
+ jndiBinding = new JNDI.Binding(jndiName, this);
+ jndiBinding.bind();
+ }
+
+ if (identityContext == null)
+ {
+ throw new IdentityException("Cannot register module in context - missing
reference");
+ }
+ else
+ {
+ //identityContext.register(this, IdentityContext.TYPE_ROLE_MODULE);
+ identityContext.register(this, this.moduleType);
+ }
+ }
+
+
+ protected void stopService() throws Exception
+ {
+ if (jndiBinding != null)
+ {
+ jndiBinding.unbind();
+ jndiBinding = null;
+ }
+
+ if (identityContext == null)
+ {
+ log.error("Cannot unregister module in context - missing reference");
+ }
+ else
+ {
+ //identityContext.unregister(IdentityContext.TYPE_ROLE_MODULE);
+ identityContext.unregister(this.moduleType);
+ }
+
+ }
+
+ protected IdentityConfiguration getIdentityConfiguration() //throws IdentityException
+ {
+ /*if (identityConfiguration == null)
+ {
+ this.identityConfiguration =
(IdentityConfiguration)identityContext.getObject(IdentityContext.TYPE_IDENTITY_CONFIGURATION);
+ }
+ return identityConfiguration;*/
+ try
+ {
+ if (identityConfiguration == null)
+ {
+ this.identityConfiguration =
(IdentityConfiguration)identityContext.getObject(IdentityContext.TYPE_IDENTITY_CONFIGURATION);
+ }
+ return identityConfiguration;
+ }
+ catch (IdentityException e)
+ {
+ throw new RuntimeException("Can't obtain IdentityConfiguration",
e);
+ }
+ }
+
+ public IdentityContext getIdentityContext()
+ {
+ return identityContext;
+ }
+
+ public void setIdentityContext(IdentityContext identityContext)
+ {
+ this.identityContext = identityContext;
+ }
+
+ protected String getJndiName()
+ {
+ return jndiName;
+ }
+
+ protected void setJndiName(String jndiName)
+ {
+ this.jndiName = jndiName;
+ }
+
+ public Map getInitOptions()
+ {
+ return initOptions;
+ }
+
+
+ public void setInitOptions(Map initOptions)
+ {
+ this.initOptions = initOptions;
+ }
+
+
+ public String getModuleType()
+ {
+ return moduleType;
+ }
+}
Modified:
trunk/identity/src/main/org/jboss/portal/identity2/service/MembershipModuleService.java
===================================================================
---
trunk/identity/src/main/org/jboss/portal/identity2/service/MembershipModuleService.java 2006-11-22
23:14:30 UTC (rev 5716)
+++
trunk/identity/src/main/org/jboss/portal/identity2/service/MembershipModuleService.java 2006-11-22
23:48:17 UTC (rev 5717)
@@ -27,98 +27,32 @@
import org.jboss.portal.identity2.MembershipModule;
import org.jboss.portal.identity2.IdentityContext;
import org.jboss.portal.identity2.IdentityConfiguration;
+import org.jboss.portal.identity2.info.ProfileInfo;
+import java.util.Map;
+
/**
* @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw
Dawidowicz</a>
* @version $Revision: 1.1 $
*/
-public abstract class MembershipModuleService extends AbstractJBossService implements
MembershipModule
+public abstract class MembershipModuleService extends IdentityModuleService implements
MembershipModule
{
private static final org.jboss.logging.Logger log =
org.jboss.logging.Logger.getLogger(MembershipModuleService.class);
- private IdentityContext identityContext;
+ private ProfileInfo profileInfo;
- private IdentityConfiguration identityConfiguration;
-
- private String jndiName;
-
- protected JNDI.Binding jndiBinding;
-
-
- protected void startService() throws Exception
+ protected MembershipModuleService()
{
-
- //
- if (jndiName != null)
- {
- jndiBinding = new JNDI.Binding(jndiName, this);
- jndiBinding.bind();
- }
-
- if (identityContext == null)
- {
- throw new IdentityException("Cannot register module in context - missing
reference");
- }
- else
- {
- identityContext.register(this, IdentityContext.MEMBERSHIP_MODULE);
- }
-
-
-
-
+ super(IdentityContext.TYPE_MEMBERSHIP_MODULE);
}
-
- protected void stopService() throws Exception
+ public ProfileInfo getProfileInfo()
{
- if (jndiBinding != null)
- {
- jndiBinding.unbind();
- jndiBinding = null;
- }
-
- if (identityContext == null)
- {
- log.error("Cannot unregister module in context - missing reference");
- }
- else
- {
- identityContext.unregister(IdentityContext.MEMBERSHIP_MODULE);
- }
-
+ return profileInfo;
}
- //************************************
- //******* Getters and Setters ********
- //************************************
-
- protected IdentityConfiguration getIdentityConfiguration() throws IdentityException
+ public void setProfileInfo(ProfileInfo profileInfo)
{
- if (identityConfiguration == null)
- {
- this.identityConfiguration =
(IdentityConfiguration)identityContext.getObject(IdentityContext.IDENTITY_CONFIGURATION);
- }
- return identityConfiguration;
+ this.profileInfo = profileInfo;
}
-
- public IdentityContext getIdentityContext()
- {
- return identityContext;
- }
-
- public void setIdentityContext(IdentityContext identityContext)
- {
- this.identityContext = identityContext;
- }
-
- public String getJndiName()
- {
- return jndiName;
- }
-
- public void setJndiName(String jndiName)
- {
- this.jndiName = jndiName;
- }
}
Modified:
trunk/identity/src/main/org/jboss/portal/identity2/service/RoleModuleService.java
===================================================================
---
trunk/identity/src/main/org/jboss/portal/identity2/service/RoleModuleService.java 2006-11-22
23:14:30 UTC (rev 5716)
+++
trunk/identity/src/main/org/jboss/portal/identity2/service/RoleModuleService.java 2006-11-22
23:48:17 UTC (rev 5717)
@@ -28,91 +28,18 @@
import org.jboss.portal.identity2.IdentityContext;
import org.jboss.portal.identity2.IdentityConfiguration;
+import java.util.Map;
+
/**
* @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw
Dawidowicz</a>
* @version $Revision: 1.1 $
*/
-public abstract class RoleModuleService extends AbstractJBossService implements
RoleModule
+public abstract class RoleModuleService extends IdentityModuleService implements
RoleModule
{
private static final org.jboss.logging.Logger log =
org.jboss.logging.Logger.getLogger(RoleModuleService.class);
- private String jndiName;
-
- private IdentityContext identityContext;
-
- private IdentityConfiguration identityConfiguration;
-
- private JNDI.Binding jndiBinding;
-
-
- protected void startService() throws Exception
+ protected RoleModuleService()
{
-
- //
- if (jndiName != null)
- {
- jndiBinding = new JNDI.Binding(jndiName, this);
- jndiBinding.bind();
- }
-
- if (identityContext == null)
- {
- throw new IdentityException("Cannot register module in context - missing
reference");
- }
- else
- {
- identityContext.register(this, IdentityContext.ROLE_MODULE);
- }
-
-
+ super(IdentityContext.TYPE_ROLE_MODULE);
}
-
-
- protected void stopService() throws Exception
- {
- if (jndiBinding != null)
- {
- jndiBinding.unbind();
- jndiBinding = null;
- }
-
- if (identityContext == null)
- {
- log.error("Cannot unregister module in context - missing reference");
- }
- else
- {
- identityContext.unregister(IdentityContext.ROLE_MODULE);
- }
-
- }
-
- protected IdentityConfiguration getIdentityConfiguration() throws IdentityException
- {
- if (identityConfiguration == null)
- {
- this.identityConfiguration =
(IdentityConfiguration)identityContext.getObject(IdentityContext.IDENTITY_CONFIGURATION);
- }
- return identityConfiguration;
- }
-
- public IdentityContext getIdentityContext()
- {
- return identityContext;
- }
-
- public void setIdentityContext(IdentityContext identityContext)
- {
- this.identityContext = identityContext;
- }
-
- protected String getJndiName()
- {
- return jndiName;
- }
-
- protected void setJndiName(String jndiName)
- {
- this.jndiName = jndiName;
- }
}
Modified:
trunk/identity/src/main/org/jboss/portal/identity2/service/UserModuleService.java
===================================================================
---
trunk/identity/src/main/org/jboss/portal/identity2/service/UserModuleService.java 2006-11-22
23:14:30 UTC (rev 5716)
+++
trunk/identity/src/main/org/jboss/portal/identity2/service/UserModuleService.java 2006-11-22
23:48:17 UTC (rev 5717)
@@ -28,89 +28,18 @@
import org.jboss.portal.identity2.IdentityConfiguration;
import org.jboss.portal.identity2.IdentityContext;
+import java.util.Map;
+
/**
* @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw
Dawidowicz</a>
* @version $Revision: 1.1 $
*/
-public abstract class UserModuleService extends AbstractJBossService implements
UserModule
+public abstract class UserModuleService extends IdentityModuleService implements
UserModule
{
private static final org.jboss.logging.Logger log =
org.jboss.logging.Logger.getLogger(UserModuleService.class);
- private IdentityConfiguration identityConfiguration;
-
- private String jndiName;
-
- private IdentityContext identityContext;
-
- private JNDI.Binding jndiBinding;
-
- protected void startService() throws Exception
+ protected UserModuleService()
{
-
- //
- if (jndiName != null)
- {
- jndiBinding = new JNDI.Binding(jndiName, this);
- jndiBinding.bind();
- }
-
- if (identityContext == null)
- {
- throw new IdentityException("Cannot register module in context - missing
reference");
- }
- else
- {
- identityContext.register(this, IdentityContext.USER_MODULE);
- }
-
-
+ super(IdentityContext.TYPE_USER_MODULE);
}
-
-
- protected void stopService() throws Exception
- {
- if (jndiBinding != null)
- {
- jndiBinding.unbind();
- jndiBinding = null;
- }
-
- if (identityContext == null)
- {
- log.error("Cannot unregister module in context - missing reference");
- }
- else
- {
- identityContext.unregister(IdentityContext.USER_MODULE);
- }
- }
-
- protected IdentityConfiguration getIdentityConfiguration() throws IdentityException
- {
- if (identityConfiguration == null)
- {
- this.identityConfiguration =
(IdentityConfiguration)identityContext.getObject(IdentityContext.IDENTITY_CONFIGURATION);
- }
- return identityConfiguration;
- }
-
- public IdentityContext getIdentityContext()
- {
- return identityContext;
- }
-
- public void setIdentityContext(IdentityContext identityContext)
- {
- this.identityContext = identityContext;
- }
-
- public String getJndiName()
- {
- return jndiName;
- }
-
- public void setJndiName(String jndiName)
- {
- this.jndiName = jndiName;
- }
}
Modified:
trunk/identity/src/main/org/jboss/portal/identity2/service/UserProfileModuleService.java
===================================================================
---
trunk/identity/src/main/org/jboss/portal/identity2/service/UserProfileModuleService.java 2006-11-22
23:14:30 UTC (rev 5716)
+++
trunk/identity/src/main/org/jboss/portal/identity2/service/UserProfileModuleService.java 2006-11-22
23:48:17 UTC (rev 5717)
@@ -28,89 +28,20 @@
import org.jboss.portal.identity2.IdentityConfiguration;
import org.jboss.portal.identity2.IdentityContext;
+import java.util.Map;
+
/**
* @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw
Dawidowicz</a>
* @version $Revision: 1.1 $
*/
-public abstract class UserProfileModuleService extends AbstractJBossService implements
UserProfileModule
+public abstract class UserProfileModuleService extends IdentityModuleService implements
UserProfileModule
{
private static final org.jboss.logging.Logger log =
org.jboss.logging.Logger.getLogger(UserProfileModuleService.class);
- private IdentityConfiguration identityConfiguration;
-
- private String jndiName;
-
- private IdentityContext identityContext;
-
- private JNDI.Binding jndiBinding;
-
- protected void startService() throws Exception
+ protected UserProfileModuleService()
{
-
- //
- if (jndiName != null)
- {
- jndiBinding = new JNDI.Binding(jndiName, this);
- jndiBinding.bind();
- }
-
- if (identityContext == null)
- {
- throw new IdentityException("Cannot register module in context - missing
reference");
- }
- else
- {
- identityContext.register(this, IdentityContext.USER_PROFILE_MODULE);
- }
-
-
+ super(IdentityContext.TYPE_USER_PROFILE_MODULE);
}
- protected void stopService() throws Exception
- {
- if (jndiBinding != null)
- {
- jndiBinding.unbind();
- jndiBinding = null;
- }
-
- if (identityContext == null)
- {
- log.error("Cannot unregister module in context - missing reference");
- }
- else
- {
- identityContext.unregister(IdentityContext.USER_PROFILE_MODULE);
- }
- }
-
- protected IdentityConfiguration getIdentityConfiguration() throws IdentityException
- {
- if (identityConfiguration == null)
- {
- this.identityConfiguration =
(IdentityConfiguration)identityContext.getObject(IdentityContext.IDENTITY_CONFIGURATION);
- }
- return identityConfiguration;
- }
-
- public IdentityContext getIdentityContext()
- {
- return identityContext;
- }
-
- public void setIdentityContext(IdentityContext identityContext)
- {
- this.identityContext = identityContext;
- }
-
- public String getJndiName()
- {
- return jndiName;
- }
-
- public void setJndiName(String jndiName)
- {
- this.jndiName = jndiName;
- }
}
Modified: trunk/identity/src/resources/draft/identity-config.xml
===================================================================
--- trunk/identity/src/resources/draft/identity-config.xml 2006-11-22 23:14:30 UTC (rev
5716)
+++ trunk/identity/src/resources/draft/identity-config.xml 2006-11-22 23:48:17 UTC (rev
5717)
@@ -118,7 +118,7 @@
<!--For ldap configuration this is needed additionally to use ldap
connection...-->
<module>
<!--type used to correctly map in IdentityContext registry-->
- <type>LDAPConnectionContext</type>
+ <type>ConnectionContext</type>
<implementation>CUSTOM</implementation>
<!--name of service and class for creating mbean-->