Author: bdaw
Date: 2007-03-19 14:35:09 -0400 (Mon, 19 Mar 2007)
New Revision: 6754
Modified:
trunk/identity/build.xml
trunk/identity/src/main/org/jboss/portal/identity/DelegatingUserProfileModuleImpl.java
trunk/identity/src/main/org/jboss/portal/test/identity/IdentityTest.java
trunk/identity/src/main/org/jboss/portal/test/identity/db/DBIdentityTestCase.java
trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPIdentityTestCase.java
Log:
- merge user properties from LDAP and DB + testcase
Modified: trunk/identity/build.xml
===================================================================
--- trunk/identity/build.xml 2007-03-19 18:14:33 UTC (rev 6753)
+++ trunk/identity/build.xml 2007-03-19 18:35:09 UTC (rev 6754)
@@ -453,14 +453,14 @@
<x-test>
<!--<test todir="${test.reports}"
name="org.jboss.portal.test.identity.db.DBIdentityTestCase"/>-->
- <!--<test todir="${test.reports}"
name="org.jboss.portal.test.identity.ldap.LDAPIdentityTestCase"/>-->
- <!--<test todir="${test.reports}"
name="org.jboss.portal.test.identity.ldap.LDAPSimpleUserModuleTestCase"/>
- <test todir="${test.reports}"
name="org.jboss.portal.test.identity.ldap.LDAPSimpleRoleModuleTestCase"/>
+ <test todir="${test.reports}"
name="org.jboss.portal.test.identity.ldap.LDAPIdentityTestCase"/>
+ <!--<test todir="${test.reports}"
name="org.jboss.portal.test.identity.ldap.LDAPSimpleUserModuleTestCase"/>-->
+ <!--<test todir="${test.reports}"
name="org.jboss.portal.test.identity.ldap.LDAPSimpleRoleModuleTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.identity.ldap.LDAPStaticGroupMembershipModuleTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.identity.ldap.LDAPStaticRoleMembershipModuleTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.identity.ldap.LDAPUserProfileModuleTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.identity.ldap.LDAPExtUserModuleTestCase"/>-->
- <test todir="${test.reports}"
name="org.jboss.portal.test.identity.ldap.LDAPExtRoleModuleTestCase"/>
+ <!--<test todir="${test.reports}"
name="org.jboss.portal.test.identity.ldap.LDAPExtRoleModuleTestCase"/>-->
</x-test>
<x-classpath>
<pathelement
location="${build.lib}/portal-identity-lib.jar"/>
Modified:
trunk/identity/src/main/org/jboss/portal/identity/DelegatingUserProfileModuleImpl.java
===================================================================
---
trunk/identity/src/main/org/jboss/portal/identity/DelegatingUserProfileModuleImpl.java 2007-03-19
18:14:33 UTC (rev 6753)
+++
trunk/identity/src/main/org/jboss/portal/identity/DelegatingUserProfileModuleImpl.java 2007-03-19
18:35:09 UTC (rev 6754)
@@ -32,6 +32,8 @@
import javax.naming.InitialContext;
import java.util.Map;
+import java.util.HashMap;
+import java.util.Collections;
/**
* @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw
Dawidowicz</a>
@@ -128,7 +130,6 @@
}
}
- //TODO: wrong coded - should merge properties from LDAP AND DB
public Map getProperties(User user) throws IdentityException,
IllegalArgumentException
{
if (log.isDebugEnabled()) log.debug("getProperties");//: " + name +
"/" + propertyValue)
@@ -136,8 +137,29 @@
{
if (user instanceof LDAPUserImpl && isLDAPSupported())
{
- log.debug("Delegating to LDAP module");
- return getLDAPModule().getProperties(user);
+ log.debug("handling LDAP user implementation");
+
+ Map props = new HashMap();
+
+ UserProfileModule dbModule = null;
+ UserProfileModule ldapModule = null;
+
+ // First get props from databas - its ok if it fails as database support is
not required for LDAP configuration
+ try
+ {
+ dbModule = getDBModule();
+ props.putAll(dbModule.getProperties(user));
+ }
+ catch (Exception e)
+ {
+ //
+ }
+
+ ldapModule = getLDAPModule();
+ props.putAll(ldapModule.getProperties(user));
+
+
+ return Collections.unmodifiableMap(props);
}
else if (user instanceof HibernateUserImpl && isDBSupported())
{
Modified: trunk/identity/src/main/org/jboss/portal/test/identity/IdentityTest.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/IdentityTest.java 2007-03-19
18:14:33 UTC (rev 6753)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/IdentityTest.java 2007-03-19
18:35:09 UTC (rev 6754)
@@ -501,6 +501,36 @@
ctx.commit();
}
+ public void testGetProperties() throws Exception
+ {
+ ctx.begin();
+
+ User user = userModule.createUser("testname", "testpassword");
+
+ // Set few properties for both LDAP and DB mappings
+ //userProfileModule.setProperty(user, "user.name.nickName",
"blah");
+ userProfileModule.setProperty(user, "user.name.family",
"blah");
+ userProfileModule.setProperty(user, "user.name.given",
"blah");
+
+ //LDAP
+ userProfileModule.setProperty(user, "user.business-info.online.email",
"blah");
+ userProfileModule.setProperty(user, "portal.user.occupation",
"blah");
+
+ // Check if they exist - should be merged
+ Map props = userProfileModule.getProperties(user);
+
+
+ //assertTrue(props.containsKey("user.name.nickName"));
+ assertTrue(props.containsKey("user.name.family"));
+ assertTrue(props.containsKey("user.name.given"));
+ assertTrue(props.containsKey("user.business-info.online.email"));
+ assertTrue(props.containsKey("portal.user.occupation"));
+
+
+ ctx.commit();
+ }
+
+
public void testFindUsers2() throws Exception
{
ctx.begin();
Modified:
trunk/identity/src/main/org/jboss/portal/test/identity/db/DBIdentityTestCase.java
===================================================================
---
trunk/identity/src/main/org/jboss/portal/test/identity/db/DBIdentityTestCase.java 2007-03-19
18:14:33 UTC (rev 6753)
+++
trunk/identity/src/main/org/jboss/portal/test/identity/db/DBIdentityTestCase.java 2007-03-19
18:35:09 UTC (rev 6754)
@@ -187,6 +187,11 @@
commit();
}
+ public void testGetProperties() throws Exception
+ {
+ utc.testGetProperties();
+ }
+
public void testStaticProperty() throws Exception
{
utc.testStaticProperty();
Modified:
trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPIdentityTestCase.java
===================================================================
---
trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPIdentityTestCase.java 2007-03-19
18:14:33 UTC (rev 6753)
+++
trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPIdentityTestCase.java 2007-03-19
18:35:09 UTC (rev 6754)
@@ -167,6 +167,11 @@
utc.testDynamicProperty();
}
+ public void testGetProperties() throws Exception
+ {
+ utc.testGetProperties();
+ }
+
public void testStaticProperty() throws Exception
{
utc.testStaticProperty();
Show replies by date