Author: bdaw
Date: 2006-12-13 10:20:01 -0500 (Wed, 13 Dec 2006)
New Revision: 5832
Modified:
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/LDAPUserImpl.java
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserModule.java
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserProfileModule.java
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserProfileModuleImpl.java
Log:
identity ldap modules improvements
Modified:
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPMembershipModule.java
===================================================================
---
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPMembershipModule.java 2006-12-13
15:16:44 UTC (rev 5831)
+++
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPMembershipModule.java 2006-12-13
15:20:01 UTC (rev 5832)
@@ -44,6 +44,11 @@
protected void startService() throws Exception
{
+ if (getConnectionJNDIName() == null)
+ {
+ throw new IdentityException("Cannot obtain ldap connection context JNDI
name");
+ }
+
connectionContext = (LDAPConnectionContext)new
InitialContext().lookup(getConnectionJNDIName());
super.startService(); //To change body of overridden methods use File | Settings
| File Templates.
Modified: trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleImpl.java 2006-12-13
15:16:44 UTC (rev 5831)
+++ trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleImpl.java 2006-12-13
15:20:01 UTC (rev 5832)
@@ -37,6 +37,8 @@
{
private static final org.jboss.logging.Logger log =
org.jboss.logging.Logger.getLogger(LDAPRoleImpl.class);
+ //TODO: make setters to update the state of the entry
+
//TODO:only to make a fasade for implementing old Role interface
private IdentityContext identityContext;
@@ -96,19 +98,19 @@
}
//TODO: fasade to MembershipModule.getUsers() method call - change this
- public Set getUsers()
- {
- try
- {
- MembershipModule mm =
(MembershipModule)identityContext.getObject(IdentityContext.TYPE_MEMBERSHIP_MODULE);
- return mm.getUsers(this);
- }
- catch (IdentityException e)
- {
- log.error("Unable to delegate method to MembershipModule: ", e);
- }
- return null;
- }
+// public Set getUsers()
+// {
+// try
+// {
+// MembershipModule mm =
(MembershipModule)identityContext.getObject(IdentityContext.TYPE_MEMBERSHIP_MODULE);
+// return mm.getUsers(this);
+// }
+// catch (IdentityException e)
+// {
+// log.error("Unable to delegate method to MembershipModule: ", e);
+// }
+// return null;
+// }
//**************************
Modified: trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleModule.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleModule.java 2006-12-13
15:16:44 UTC (rev 5831)
+++ trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleModule.java 2006-12-13
15:20:01 UTC (rev 5832)
@@ -47,6 +47,11 @@
protected void startService() throws Exception
{
+ if (getConnectionJNDIName() == null)
+ {
+ throw new IdentityException("Cannot obtain ldap connection context JNDI
name");
+ }
+
connectionContext = (LDAPConnectionContext)new
InitialContext().lookup(getConnectionJNDIName());
super.startService(); //To change body of overridden methods use File | Settings
| File Templates.
Modified: trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserImpl.java 2006-12-13
15:16:44 UTC (rev 5831)
+++ trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserImpl.java 2006-12-13
15:20:01 UTC (rev 5832)
@@ -39,6 +39,8 @@
public class LDAPUserImpl implements User
{
private static final org.jboss.logging.Logger log =
org.jboss.logging.Logger.getLogger(LDAPUserImpl.class);
+
+ //TODO: make setters to update the state of the entry
//TODO:this is to enable user act like a fasade to identity modules calls
IdentityContext identityContext;
@@ -140,11 +142,15 @@
}
}
- public ProfileMap getProfile()
+ public String getPassword()
{
- throw new UnsupportedOperationException("Not yet implemented");
+ return this.password;
}
+ public void setPassword(String password)
+ {
+ this.password = password;
+ }
//**************************
//*** Getter and Setters
Modified: trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserModule.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserModule.java 2006-12-13
15:16:44 UTC (rev 5831)
+++ trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserModule.java 2006-12-13
15:20:01 UTC (rev 5832)
@@ -54,6 +54,11 @@
protected void startService() throws Exception
{
+ if (getConnectionJNDIName() == null)
+ {
+ throw new IdentityException("Cannot obtain ldap connection context JNDI
name");
+ }
+
connectionContext = (LDAPConnectionContext)new
InitialContext().lookup(getConnectionJNDIName());
super.startService(); //To change body of overridden methods use File | Settings
| File Templates.
Modified: trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserModuleImpl.java
===================================================================
---
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserModuleImpl.java 2006-12-13
15:16:44 UTC (rev 5831)
+++
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserModuleImpl.java 2006-12-13
15:20:01 UTC (rev 5832)
@@ -121,17 +121,17 @@
- public User createUser(String userName, String password, String realEmail) throws
IdentityException, IllegalArgumentException
+ public User createUser(String userName, String password) throws IdentityException,
IllegalArgumentException
{
if (userName == null)
{
throw new IdentityException("User name cannot be null");
}
- if (realEmail == null)
+ /*if (realEmail == null)
{
throw new IdentityException("User email cannot be null");
- }
+ }*/
if (password == null)
{
throw new IdentityException("User password cannot be null");
Modified:
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserProfileModule.java
===================================================================
---
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserProfileModule.java 2006-12-13
15:16:44 UTC (rev 5831)
+++
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserProfileModule.java 2006-12-13
15:20:01 UTC (rev 5832)
@@ -37,6 +37,10 @@
protected void startService() throws Exception
{
+ if (getConnectionJNDIName() == null)
+ {
+ throw new IdentityException("Cannot obtain ldap connection context JNDI
name");
+ }
connectionContext = (LDAPConnectionContext)new
InitialContext().lookup(getConnectionJNDIName());
super.startService(); //To change body of overridden methods use File | Settings
| File Templates.
Modified:
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserProfileModuleImpl.java
===================================================================
---
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserProfileModuleImpl.java 2006-12-13
15:16:44 UTC (rev 5831)
+++
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserProfileModuleImpl.java 2006-12-13
15:20:01 UTC (rev 5832)
@@ -23,6 +23,10 @@
import org.jboss.portal.identity2.User;
import org.jboss.portal.identity2.IdentityConfiguration;
+import org.jboss.portal.identity2.UserProfileModule;
+import org.jboss.portal.identity2.IdentityContext;
+import org.jboss.portal.identity2.info.ProfileInfo;
+import org.jboss.portal.identity2.info.PropertyInfo;
import org.jboss.portal.identity.IdentityException;
import javax.naming.directory.Attributes;
@@ -202,7 +206,21 @@
private String resolveAttributeName(String propertyName) throws IdentityException
{
- return
getIdentityConfiguration().getValue(IdentityConfiguration.GROUP_USER_PROFILE_MAPPINGS,
propertyName);
+ //return
getIdentityConfiguration().getValue(IdentityConfiguration.GROUP_USER_PROFILE_MAPPINGS,
propertyName);
+
+ PropertyInfo pi = getProfileInfo().getPropertyInfo(propertyName);
+
+ if (pi == null)
+ {
+ throw new IdentityException("Cannot find profile information about
property: " + propertyName);
+ }
+
+ String mapping = pi.getMappingLDAPValue();
+ if (mapping == null)
+ {
+ throw new IdentityException("This property is not mapped as LDAP attribute:
" + propertyName);
+ }
+ return mapping;
}
/**
@@ -212,26 +230,52 @@
*/
private Map resolveAttributesMappingMap() throws IdentityException
{
- Map group =
getIdentityConfiguration().getOptions(IdentityConfiguration.GROUP_USER_PROFILE_MAPPINGS);
+ //Map group =
getIdentityConfiguration().getOptions(IdentityConfiguration.GROUP_USER_PROFILE_MAPPINGS);
- if (group == null)
- {
- throw new IdentityException("User profile attributes mappings not found in
the configuration");
- }
+ Map infos = getProfileInfo().getPropertiesInfo();
+ Set keys = infos.keySet();
+
Map mappings = new HashMap();
- Set options = group.keySet();
- for (Iterator iterator = options.iterator(); iterator.hasNext();)
+ for (Iterator iterator = keys.iterator(); iterator.hasNext();)
{
- String optname = (String)iterator.next();
- Set values = (Set)group.get(optname);
- if (values.size() > 0)
+ String key = (String)iterator.next();
+ PropertyInfo prop = (PropertyInfo)infos.get(key);
+ if (prop.isMappedLDAP())
{
- mappings.put(optname, values.toArray()[0]);
+ mappings.put(prop.getName(), prop.getMappingLDAPValue());
}
}
return mappings;
}
+ /**
+ * obtains UserProfile object - if module is used as a Delegate it tries to obtain it
from the main one.
+ * @return
+ * @throws IdentityException
+ */
+ public ProfileInfo getProfileInfo() throws IdentityException
+ {
+ ProfileInfo profileInfo = super.getProfileInfo();
+ if (profileInfo == null)
+ {
+ return profileInfo;
+ }
+ else
+ {
+ //obtain main UserProfileModule
+ UserProfileModule module =
(UserProfileModule)getIdentityContext().getObject(IdentityContext.TYPE_USER_PROFILE_MODULE);
+ if (module == this)
+ {
+ throw new IdentityException("ProfileInfo not accessible - check
configuration");
+ }
+ else
+ {
+ setProfileInfo(module.getProfileInfo());
+ return profileInfo;
+ }
+ }
+ }
+
}
Show replies by date