JBoss Identity SVN: r390 - idm/tags.
by jboss-identity-commits@lists.jboss.org
Author: bdaw
Date: 2009-03-19 18:02:17 -0400 (Thu, 19 Mar 2009)
New Revision: 390
Added:
idm/tags/1.0.0.Alpha3/
Log:
one more time
Copied: idm/tags/1.0.0.Alpha3 (from rev 389, idm/trunk)
15 years, 9 months
JBoss Identity SVN: r389 - in idm/trunk: assembly and 6 other directories.
by jboss-identity-commits@lists.jboss.org
Author: bdaw
Date: 2009-03-19 18:01:16 -0400 (Thu, 19 Mar 2009)
New Revision: 389
Modified:
idm/trunk/assembly/pom.xml
idm/trunk/example/maven2/pom.xml
idm/trunk/idm-api/pom.xml
idm/trunk/idm-common/pom.xml
idm/trunk/idm-spi/pom.xml
idm/trunk/idm/pom.xml
idm/trunk/parent/pom.xml
idm/trunk/pom.xml
Log:
3 not 2...
Modified: idm/trunk/assembly/pom.xml
===================================================================
--- idm/trunk/assembly/pom.xml 2009-03-19 22:00:23 UTC (rev 388)
+++ idm/trunk/assembly/pom.xml 2009-03-19 22:01:16 UTC (rev 389)
@@ -2,7 +2,7 @@
<parent>
<groupId>org.jboss.identity</groupId>
<artifactId>idm-parent</artifactId>
- <version>1.0.0.Alpha2</version>
+ <version>1.0.0.Alpha3</version>
<relativePath>../parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: idm/trunk/example/maven2/pom.xml
===================================================================
--- idm/trunk/example/maven2/pom.xml 2009-03-19 22:00:23 UTC (rev 388)
+++ idm/trunk/example/maven2/pom.xml 2009-03-19 22:01:16 UTC (rev 389)
@@ -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.jboss.identity</groupId>
- <version>1.0.0.Alpha2</version>
+ <version>1.0.0.Alpha3</version>
<artifactId>idm-maven2-example</artifactId>
<packaging>jar</packaging>
<name>JBoss Identity IDM Maven2 example project</name>
Modified: idm/trunk/idm/pom.xml
===================================================================
--- idm/trunk/idm/pom.xml 2009-03-19 22:00:23 UTC (rev 388)
+++ idm/trunk/idm/pom.xml 2009-03-19 22:01:16 UTC (rev 389)
@@ -2,7 +2,7 @@
<parent>
<groupId>org.jboss.identity</groupId>
<artifactId>idm-parent</artifactId>
- <version>1.0.0.Alpha2</version>
+ <version>1.0.0.Alpha3</version>
<relativePath>../parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: idm/trunk/idm-api/pom.xml
===================================================================
--- idm/trunk/idm-api/pom.xml 2009-03-19 22:00:23 UTC (rev 388)
+++ idm/trunk/idm-api/pom.xml 2009-03-19 22:01:16 UTC (rev 389)
@@ -2,7 +2,7 @@
<parent>
<groupId>org.jboss.identity</groupId>
<artifactId>idm-parent</artifactId>
- <version>1.0.0.Alpha2</version>
+ <version>1.0.0.Alpha3</version>
<relativePath>../parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: idm/trunk/idm-common/pom.xml
===================================================================
--- idm/trunk/idm-common/pom.xml 2009-03-19 22:00:23 UTC (rev 388)
+++ idm/trunk/idm-common/pom.xml 2009-03-19 22:01:16 UTC (rev 389)
@@ -2,7 +2,7 @@
<parent>
<groupId>org.jboss.identity</groupId>
<artifactId>idm-parent</artifactId>
- <version>1.0.0.Alpha2</version>
+ <version>1.0.0.Alpha3</version>
<relativePath>../parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: idm/trunk/idm-spi/pom.xml
===================================================================
--- idm/trunk/idm-spi/pom.xml 2009-03-19 22:00:23 UTC (rev 388)
+++ idm/trunk/idm-spi/pom.xml 2009-03-19 22:01:16 UTC (rev 389)
@@ -2,7 +2,7 @@
<parent>
<groupId>org.jboss.identity</groupId>
<artifactId>idm-parent</artifactId>
- <version>1.0.0.Alpha2</version>
+ <version>1.0.0.Alpha3</version>
<relativePath>../parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: idm/trunk/parent/pom.xml
===================================================================
--- idm/trunk/parent/pom.xml 2009-03-19 22:00:23 UTC (rev 388)
+++ idm/trunk/parent/pom.xml 2009-03-19 22:01:16 UTC (rev 389)
@@ -8,7 +8,7 @@
<groupId>org.jboss.identity</groupId>
<artifactId>idm-parent</artifactId>
<packaging>pom</packaging>
- <version>1.0.0.Alpha2</version>
+ <version>1.0.0.Alpha3</version>
<name>JBoss Identity IDM- Parent</name>
<url>http://labs.jboss.org/portal/jbosssecurity/</url>
<description>JBoss Identity is a cross-cutting project that handles identity needs for the JEMS projects</description>
Modified: idm/trunk/pom.xml
===================================================================
--- idm/trunk/pom.xml 2009-03-19 22:00:23 UTC (rev 388)
+++ idm/trunk/pom.xml 2009-03-19 22:01:16 UTC (rev 389)
@@ -2,7 +2,7 @@
<parent>
<groupId>org.jboss.identity</groupId>
<artifactId>idm-parent</artifactId>
- <version>1.0.0.Alpha2</version>
+ <version>1.0.0.Alpha3</version>
<relativePath>parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
15 years, 9 months
JBoss Identity SVN: r388 - idm/tags.
by jboss-identity-commits@lists.jboss.org
Author: bdaw
Date: 2009-03-19 18:00:23 -0400 (Thu, 19 Mar 2009)
New Revision: 388
Removed:
idm/tags/1.0.0.Alpha3/
Log:
oups..
15 years, 9 months
JBoss Identity SVN: r387 - idm/tags.
by jboss-identity-commits@lists.jboss.org
Author: bdaw
Date: 2009-03-19 17:58:03 -0400 (Thu, 19 Mar 2009)
New Revision: 387
Added:
idm/tags/1.0.0.Alpha3/
Log:
tag 1.0.0.Alpha3
Copied: idm/tags/1.0.0.Alpha3 (from rev 386, idm/trunk)
15 years, 9 months
JBoss Identity SVN: r386 - in idm/trunk: assembly and 6 other directories.
by jboss-identity-commits@lists.jboss.org
Author: bdaw
Date: 2009-03-19 17:55:54 -0400 (Thu, 19 Mar 2009)
New Revision: 386
Modified:
idm/trunk/assembly/pom.xml
idm/trunk/example/maven2/pom.xml
idm/trunk/idm-api/pom.xml
idm/trunk/idm-common/pom.xml
idm/trunk/idm-spi/pom.xml
idm/trunk/idm/pom.xml
idm/trunk/parent/pom.xml
idm/trunk/pom.xml
Log:
change version o 1.0.0.Alpha2
Modified: idm/trunk/assembly/pom.xml
===================================================================
--- idm/trunk/assembly/pom.xml 2009-03-19 21:44:54 UTC (rev 385)
+++ idm/trunk/assembly/pom.xml 2009-03-19 21:55:54 UTC (rev 386)
@@ -2,7 +2,7 @@
<parent>
<groupId>org.jboss.identity</groupId>
<artifactId>idm-parent</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.0.0.Alpha2</version>
<relativePath>../parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: idm/trunk/example/maven2/pom.xml
===================================================================
--- idm/trunk/example/maven2/pom.xml 2009-03-19 21:44:54 UTC (rev 385)
+++ idm/trunk/example/maven2/pom.xml 2009-03-19 21:55:54 UTC (rev 386)
@@ -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.jboss.identity</groupId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.0.0.Alpha2</version>
<artifactId>idm-maven2-example</artifactId>
<packaging>jar</packaging>
<name>JBoss Identity IDM Maven2 example project</name>
Modified: idm/trunk/idm/pom.xml
===================================================================
--- idm/trunk/idm/pom.xml 2009-03-19 21:44:54 UTC (rev 385)
+++ idm/trunk/idm/pom.xml 2009-03-19 21:55:54 UTC (rev 386)
@@ -2,7 +2,7 @@
<parent>
<groupId>org.jboss.identity</groupId>
<artifactId>idm-parent</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.0.0.Alpha2</version>
<relativePath>../parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: idm/trunk/idm-api/pom.xml
===================================================================
--- idm/trunk/idm-api/pom.xml 2009-03-19 21:44:54 UTC (rev 385)
+++ idm/trunk/idm-api/pom.xml 2009-03-19 21:55:54 UTC (rev 386)
@@ -2,7 +2,7 @@
<parent>
<groupId>org.jboss.identity</groupId>
<artifactId>idm-parent</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.0.0.Alpha2</version>
<relativePath>../parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: idm/trunk/idm-common/pom.xml
===================================================================
--- idm/trunk/idm-common/pom.xml 2009-03-19 21:44:54 UTC (rev 385)
+++ idm/trunk/idm-common/pom.xml 2009-03-19 21:55:54 UTC (rev 386)
@@ -2,7 +2,7 @@
<parent>
<groupId>org.jboss.identity</groupId>
<artifactId>idm-parent</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.0.0.Alpha2</version>
<relativePath>../parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: idm/trunk/idm-spi/pom.xml
===================================================================
--- idm/trunk/idm-spi/pom.xml 2009-03-19 21:44:54 UTC (rev 385)
+++ idm/trunk/idm-spi/pom.xml 2009-03-19 21:55:54 UTC (rev 386)
@@ -2,7 +2,7 @@
<parent>
<groupId>org.jboss.identity</groupId>
<artifactId>idm-parent</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.0.0.Alpha2</version>
<relativePath>../parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: idm/trunk/parent/pom.xml
===================================================================
--- idm/trunk/parent/pom.xml 2009-03-19 21:44:54 UTC (rev 385)
+++ idm/trunk/parent/pom.xml 2009-03-19 21:55:54 UTC (rev 386)
@@ -8,7 +8,7 @@
<groupId>org.jboss.identity</groupId>
<artifactId>idm-parent</artifactId>
<packaging>pom</packaging>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.0.0.Alpha2</version>
<name>JBoss Identity IDM- Parent</name>
<url>http://labs.jboss.org/portal/jbosssecurity/</url>
<description>JBoss Identity is a cross-cutting project that handles identity needs for the JEMS projects</description>
Modified: idm/trunk/pom.xml
===================================================================
--- idm/trunk/pom.xml 2009-03-19 21:44:54 UTC (rev 385)
+++ idm/trunk/pom.xml 2009-03-19 21:55:54 UTC (rev 386)
@@ -2,7 +2,7 @@
<parent>
<groupId>org.jboss.identity</groupId>
<artifactId>idm-parent</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.0.0.Alpha2</version>
<relativePath>parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
15 years, 9 months
JBoss Identity SVN: r385 - in idm/trunk: idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers and 2 other directories.
by jboss-identity-commits@lists.jboss.org
Author: bdaw
Date: 2009-03-19 17:44:54 -0400 (Thu, 19 Mar 2009)
New Revision: 385
Modified:
idm/trunk/example/maven2/src/test/java/org/jboss/identity/idm/example/DBTestCase.java
idm/trunk/example/maven2/src/test/java/org/jboss/identity/idm/example/InjectSFTestCase.java
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/Group.java
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RelationshipManager.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTest.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RelationshipManagerTest.java
Log:
bobo
Modified: idm/trunk/example/maven2/src/test/java/org/jboss/identity/idm/example/DBTestCase.java
===================================================================
--- idm/trunk/example/maven2/src/test/java/org/jboss/identity/idm/example/DBTestCase.java 2009-03-19 19:34:38 UTC (rev 384)
+++ idm/trunk/example/maven2/src/test/java/org/jboss/identity/idm/example/DBTestCase.java 2009-03-19 21:44:54 UTC (rev 385)
@@ -95,10 +95,10 @@
identitySession.getRelationshipManager().associateGroups(acmeOrg, itGroup);
identitySession.getRelationshipManager().associateGroups(acmeOrg, hrGroup);
- identitySession.getRelationshipManager().associateUsers(itGroup, johnDoe);
- identitySession.getRelationshipManager().associateUsers(itGroup, alice);
+ identitySession.getRelationshipManager().associateUser(itGroup, johnDoe);
+ identitySession.getRelationshipManager().associateUser(itGroup, alice);
- identitySession.getRelationshipManager().associateUsers(hrGroup, eva);
+ identitySession.getRelationshipManager().associateUser(hrGroup, eva);
RoleType managerRT = identitySession.getRoleManager().createRoleType("manager");
@@ -145,7 +145,7 @@
Group otherGroup = identitySession.getPersistenceManager().createGroup("otherGroup", GROUP);
- identitySession.getRelationshipManager().associateUsers(otherGroup, xUser);
+ identitySession.getRelationshipManager().associateUser(otherGroup, xUser);
assertEquals(1, identitySession.getRelationshipManager().findAssociatedGroups(xUser, GROUP).size());
assertEquals(1, identitySession.getRoleManager().findGroupsWithRelatedRole(xUser, GROUP, null).size());
Modified: idm/trunk/example/maven2/src/test/java/org/jboss/identity/idm/example/InjectSFTestCase.java
===================================================================
--- idm/trunk/example/maven2/src/test/java/org/jboss/identity/idm/example/InjectSFTestCase.java 2009-03-19 19:34:38 UTC (rev 384)
+++ idm/trunk/example/maven2/src/test/java/org/jboss/identity/idm/example/InjectSFTestCase.java 2009-03-19 21:44:54 UTC (rev 385)
@@ -28,6 +28,7 @@
import org.jboss.identity.idm.api.IdentitySearchControl;
import org.jboss.identity.idm.api.Attribute;
import org.jboss.identity.idm.api.AttributeDescription;
+import org.jboss.identity.idm.api.Group;
import org.jboss.identity.idm.api.cfg.IdentityConfiguration;
import org.jboss.identity.idm.impl.configuration.IdentityConfigurationImpl;
import org.jboss.identity.idm.impl.api.SimpleAttribute;
@@ -102,10 +103,10 @@
identitySession.getRelationshipManager().associateGroupsByIds(acmeOrgId, itGroupId);
identitySession.getRelationshipManager().associateGroupsByIds(acmeOrgId, hrGroupId);
- identitySession.getRelationshipManager().associateUsersByIds(itGroupId, johnDoeUser);
- identitySession.getRelationshipManager().associateUsersByIds(itGroupId, aliceUser);
+ identitySession.getRelationshipManager().associateUserByIds(itGroupId, johnDoeUser);
+ identitySession.getRelationshipManager().associateUserByIds(itGroupId, aliceUser);
- identitySession.getRelationshipManager().associateUsersByIds(hrGroupId, evaUser);
+ identitySession.getRelationshipManager().associateUserByIds(hrGroupId, evaUser);
identitySession.getRoleManager().createRoleType("manager");
@@ -152,13 +153,16 @@
String otherGroupId = identitySession.getPersistenceManager().createGroup("otherGroup", GROUP).getId();
- identitySession.getRelationshipManager().associateUsersByIds(otherGroupId, xUser);
+ identitySession.getRelationshipManager().associateUserByIds(otherGroupId, xUser);
assertEquals(1, identitySession.getRelationshipManager().findAssociatedGroups(xUser, GROUP, null).size());
assertEquals(1, identitySession.getRoleManager().findGroupsWithRelatedRole(xUser, GROUP, null).size());
assertEquals(1, identitySession.getRoleManager().findGroupsWithRelatedRole(xUser, null).size());
+
+
+
identitySession.getTransaction().commit();
identitySession.close();
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java 2009-03-19 19:34:38 UTC (rev 384)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java 2009-03-19 21:44:54 UTC (rev 385)
@@ -37,7 +37,6 @@
import org.jboss.identity.idm.spi.searchcontrol.IdentityObjectSearchControl;
import org.jboss.identity.idm.impl.NotYetImplementedException;
import org.jboss.identity.idm.impl.api.session.managers.AbstractManager;
-import org.jboss.identity.idm.impl.api.model.GroupId;
import java.util.Collection;
import java.util.Iterator;
@@ -235,12 +234,12 @@
{
User member = membersIterator.next();
- associateUsers(parent, member);
+ associateUser(parent, member);
}
}
}
- public void associateUsers(Group parent, Collection<User> members) throws IdentityException
+ public void associateUser(Group parent, Collection<User> members) throws IdentityException
{
checkNotNullArgument(parent, "Parent group");
@@ -262,7 +261,7 @@
{
String member = membersIterator.next();
- associateUsersByIds(parent, member);
+ associateUserByIds(parent, member);
}
}
@@ -276,7 +275,7 @@
}
- public void associateUsers(Group parent, User member) throws IdentityException
+ public void associateUser(Group parent, User member) throws IdentityException
{
checkNotNullArgument(parent, "Parent group");
checkNotNullArgument(member, "Member user");
@@ -285,7 +284,7 @@
}
- public void associateUsersByIds(String parentId, String memberId) throws IdentityException
+ public void associateUserByIds(String parentId, String memberId) throws IdentityException
{
checkNotNullArgument(parentId, "Parent group Id");
checkNotNullArgument(memberId, "Member user Id");
Modified: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTest.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTest.java 2009-03-19 19:34:38 UTC (rev 384)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTest.java 2009-03-19 21:44:54 UTC (rev 385)
@@ -152,23 +152,23 @@
// Store as employees
- session.getRelationshipManager().associateUsers(employeesGroup, theuteUser);
- session.getRelationshipManager().associateUsers(employeesGroup, mlittleUser);
- session.getRelationshipManager().associateUsers(employeesGroup, asaldhanaUser);
- session.getRelationshipManager().associateUsers(employeesGroup, bdawidowUser);
- session.getRelationshipManager().associateUsers(employeesGroup, claprunUser);
- session.getRelationshipManager().associateUsers(employeesGroup, whalesUser);
- session.getRelationshipManager().associateUsers(employeesGroup, sshahUser);
- session.getRelationshipManager().associateUsers(employeesGroup, mwringeUser);
+ session.getRelationshipManager().associateUser(employeesGroup, theuteUser);
+ session.getRelationshipManager().associateUser(employeesGroup, mlittleUser);
+ session.getRelationshipManager().associateUser(employeesGroup, asaldhanaUser);
+ session.getRelationshipManager().associateUser(employeesGroup, bdawidowUser);
+ session.getRelationshipManager().associateUser(employeesGroup, claprunUser);
+ session.getRelationshipManager().associateUser(employeesGroup, whalesUser);
+ session.getRelationshipManager().associateUser(employeesGroup, sshahUser);
+ session.getRelationshipManager().associateUser(employeesGroup, mwringeUser);
// Portal team for management purposes
Group portalTeamGroup = session.getPersistenceManager().createGroup("Portal Team", PEOPLE);
- session.getRelationshipManager().associateUsers(portalTeamGroup, bdawidowUser);
- session.getRelationshipManager().associateUsers(portalTeamGroup, claprunUser);
- session.getRelationshipManager().associateUsers(portalTeamGroup, whalesUser);
- session.getRelationshipManager().associateUsers(portalTeamGroup, sshahUser);
- session.getRelationshipManager().associateUsers(portalTeamGroup, mwringeUser);
+ session.getRelationshipManager().associateUser(portalTeamGroup, bdawidowUser);
+ session.getRelationshipManager().associateUser(portalTeamGroup, claprunUser);
+ session.getRelationshipManager().associateUser(portalTeamGroup, whalesUser);
+ session.getRelationshipManager().associateUser(portalTeamGroup, sshahUser);
+ session.getRelationshipManager().associateUser(portalTeamGroup, mwringeUser);
// Portal team is under common frameworks
@@ -420,17 +420,17 @@
// All users are under people root
- session.getRelationshipManager().associateUsers(usersROOTGroup, anneUser);
- session.getRelationshipManager().associateUsers(usersROOTGroup, marieUser);
- session.getRelationshipManager().associateUsers(usersROOTGroup, eveUser);
- session.getRelationshipManager().associateUsers(usersROOTGroup, angelinaUser);
- session.getRelationshipManager().associateUsers(usersROOTGroup, joannaUser);
- session.getRelationshipManager().associateUsers(usersROOTGroup, merilUser);
- session.getRelationshipManager().associateUsers(usersROOTGroup, johnUser);
- session.getRelationshipManager().associateUsers(usersROOTGroup, stanUser);
- session.getRelationshipManager().associateUsers(usersROOTGroup, chrisUser);
- session.getRelationshipManager().associateUsers(usersROOTGroup, billUser);
- session.getRelationshipManager().associateUsers(usersROOTGroup, jackUser);
+ session.getRelationshipManager().associateUser(usersROOTGroup, anneUser);
+ session.getRelationshipManager().associateUser(usersROOTGroup, marieUser);
+ session.getRelationshipManager().associateUser(usersROOTGroup, eveUser);
+ session.getRelationshipManager().associateUser(usersROOTGroup, angelinaUser);
+ session.getRelationshipManager().associateUser(usersROOTGroup, joannaUser);
+ session.getRelationshipManager().associateUser(usersROOTGroup, merilUser);
+ session.getRelationshipManager().associateUser(usersROOTGroup, johnUser);
+ session.getRelationshipManager().associateUser(usersROOTGroup, stanUser);
+ session.getRelationshipManager().associateUser(usersROOTGroup, chrisUser);
+ session.getRelationshipManager().associateUser(usersROOTGroup, billUser);
+ session.getRelationshipManager().associateUser(usersROOTGroup, jackUser);
session.getTransaction().commit();
@@ -452,7 +452,7 @@
// Anna works in Paris office and participates in BASE jumping community as a forum moderator and CMS admin
- session.getRelationshipManager().associateUsers(parisOffice, anneUser);
+ session.getRelationshipManager().associateUser(parisOffice, anneUser);
// Anne could be just associated with BASE jumping community group using RelationshipManager but insted Role mechanism
// is used to have more fine grained control of access rights inside of a community
@@ -470,7 +470,7 @@
// Anne belongs to CMS portal admins security group
- session.getRelationshipManager().associateUsers(cmsAdminGroup, anneUser);
+ session.getRelationshipManager().associateUser(cmsAdminGroup, anneUser);
// Ann is also an owner of geeks community
@@ -491,7 +491,7 @@
// She works in London and is office manager there - se both RelationshipManager and RoleManager used against
// the same pair of identity objects
- session.getRelationshipManager().associateUsers(londonOffice, angelinaUser);
+ session.getRelationshipManager().associateUser(londonOffice, angelinaUser);
session.getRoleManager().createRole(officeManagerRT, angelinaUser, londonOffice);
@@ -502,7 +502,7 @@
// As office manager she also edits portal cms content
- session.getRelationshipManager().associateUsers(cmsEditorGroup, angelinaUser);
+ session.getRelationshipManager().associateUser(cmsEditorGroup, angelinaUser);
//
Modified: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RelationshipManagerTest.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RelationshipManagerTest.java 2009-03-19 19:34:38 UTC (rev 384)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RelationshipManagerTest.java 2009-03-19 21:44:54 UTC (rev 385)
@@ -154,8 +154,8 @@
// Associate Group and Users
- session.getRelationshipManager().associateUsers(group1, user1);
- session.getRelationshipManager().associateUsers(group1, user2);
+ session.getRelationshipManager().associateUser(group1, user1);
+ session.getRelationshipManager().associateUser(group1, user2);
// isAssociated
@@ -204,8 +204,8 @@
session.getRelationshipManager().disassociateUsersByIds(Arrays.asList(group1.getId()), Arrays.asList(user1.getId(), user2.getId()));
// reassociate #3
- session.getRelationshipManager().associateUsersByIds(group1.getId(), user1.getId());
- session.getRelationshipManager().associateUsersByIds(group1.getId(), user2.getId());
+ session.getRelationshipManager().associateUserByIds(group1.getId(), user1.getId());
+ session.getRelationshipManager().associateUserByIds(group1.getId(), user2.getId());
assertTrue(session.getRelationshipManager().isAssociated(Arrays.asList(group1), Arrays.asList(user1, user2)));
@@ -336,8 +336,8 @@
session.getRelationshipManager().associateGroups(group1, group2);
session.getRelationshipManager().associateGroups(group1, group3);
- session.getRelationshipManager().associateUsers(group1, user1);
- session.getRelationshipManager().associateUsers(group1, user2);
+ session.getRelationshipManager().associateUser(group1, user1);
+ session.getRelationshipManager().associateUser(group1, user2);
session.getRoleManager().createRoleType("rt1");
session.getRoleManager().createRoleType("rt2");
Modified: idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/Group.java
===================================================================
--- idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/Group.java 2009-03-19 19:34:38 UTC (rev 384)
+++ idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/Group.java 2009-03-19 21:44:54 UTC (rev 385)
@@ -27,7 +27,7 @@
/**
* Represents a Group. Group has a name that is unique in scope of a given group type. This means that groupType/name pairs
* uniquely identifies group. Group Id contains encoded group type and name imformation. In default implementation
- * it can look as follows: "group://GROUP_TYPE/GROUP_NAME". Still prefix and format of Id can change in the future so
+ * it can look as follows: "group:/GROUP_TYPE/GROUP_NAME". Still prefix and format of Id can change in the future so
* PersistenceManager.createGroupId(String groupName, String groupType) method should be used to create it.
*
* @author Anil.Saldhana(a)redhat.com
Modified: idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java
===================================================================
--- idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java 2009-03-19 19:34:38 UTC (rev 384)
+++ idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java 2009-03-19 21:44:54 UTC (rev 385)
@@ -69,7 +69,7 @@
/**
* <p>Create a group Id. Result string can be used in other methods. Group Id contains encoded group type and
* name imformation.
- * In default implementation it can look as follows: "group://GROUP_TYPE/GROUP_NAME".
+ * In default implementation it can look as follows: "group:/GROUP_TYPE/GROUP_NAME".
* Still prefix and format of Id can change in the future so this method should be used to create it.</p>
* @param groupName
* @param groupType
Modified: idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RelationshipManager.java
===================================================================
--- idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RelationshipManager.java 2009-03-19 19:34:38 UTC (rev 384)
+++ idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RelationshipManager.java 2009-03-19 21:44:54 UTC (rev 385)
@@ -116,7 +116,7 @@
* @param members
* @throws org.jboss.identity.idm.exception.IdentityException
*/
- void associateUsers(Group parent, Collection<User> members)
+ void associateUser(Group parent, Collection<User> members)
throws IdentityException;
/**
@@ -143,7 +143,7 @@
* @param members
* @throws org.jboss.identity.idm.exception.IdentityException
*/
- void associateUsers(Group parents, User members)
+ void associateUser(Group parents, User members)
throws IdentityException;
/**
@@ -152,7 +152,7 @@
* @param memberid
* @throws org.jboss.identity.idm.exception.IdentityException
*/
- void associateUsersByIds(String parentGroupId, String memberid)
+ void associateUserByIds(String parentGroupId, String memberid)
throws IdentityException;
/**
@@ -428,7 +428,7 @@
/**
- * Find all groups that given identity is associated with.
+ * Find all groups that given identity is associated with. Will return groups connected with a given user with a role
*
* @param user child identity
* @param groupType can be null
@@ -440,7 +440,7 @@
IdentitySearchControl[] controls) throws IdentityException;
/**
- * Find all groups that given identity is associated with.
+ * Find all groups that given identity is associated with. Will return groups connected with a given user with a role
*
* @param userId
* @param groupType can be null
@@ -452,7 +452,7 @@
IdentitySearchControl[] controls) throws IdentityException;
/**
- * Find identities that have relationship with given parent group.
+ * Find identities that have relationship with given parent group. Will return users connected with a given group with a role
*
* @param group parent group
* @return
@@ -461,7 +461,7 @@
Collection<User> findRelatedUsers(Group group, IdentitySearchControl[] controls) throws IdentityException;
/**
- * Find identities that have relationship with given parent group.
+ * Find identities that have relationship with given parent group. Will return users connected with a given group with a role
*
* @param groupId parent group id
* @return
15 years, 9 months
JBoss Identity SVN: r384 - in idm/trunk: example/maven2/src/test/resources and 5 other directories.
by jboss-identity-commits@lists.jboss.org
Author: bdaw
Date: 2009-03-19 15:34:38 -0400 (Thu, 19 Mar 2009)
New Revision: 384
Added:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/IdentitySessionConfigurationContext.java
Removed:
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/GroupType.java
Modified:
idm/trunk/example/maven2/src/test/java/org/jboss/identity/idm/example/InjectSFTestCase.java
idm/trunk/example/maven2/src/test/resources/example-db-config.xml
idm/trunk/example/maven2/src/test/resources/example-db-inject-sf-config.xml
idm/trunk/example/maven2/src/test/resources/example-mixed-config.xml
idm/trunk/example/maven2/src/test/resources/hibernate-jboss-identity-classes.cfg.xml
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/AttributesManager.java
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/IdentitySessionFactory.java
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RelationshipManager.java
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RoleManager.java
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/User.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/IdentitySessionFactoryImpl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/IdentityConfigurationImpl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java
Log:
- Some cleanups
Modified: idm/trunk/example/maven2/src/test/java/org/jboss/identity/idm/example/InjectSFTestCase.java
===================================================================
--- idm/trunk/example/maven2/src/test/java/org/jboss/identity/idm/example/InjectSFTestCase.java 2009-03-19 13:23:38 UTC (rev 383)
+++ idm/trunk/example/maven2/src/test/java/org/jboss/identity/idm/example/InjectSFTestCase.java 2009-03-19 19:34:38 UTC (rev 384)
@@ -90,9 +90,9 @@
// Use username nad group ids instead of objects
- String johnDoeUser = identitySession.getPersistenceManager().createUser("John Doe").getName();
- String aliceUser = identitySession.getPersistenceManager().createUser("Alice").getName();
- String evaUser = identitySession.getPersistenceManager().createUser("Eva").getName();
+ String johnDoeUser = identitySession.getPersistenceManager().createUser("John Doe").getId();
+ String aliceUser = identitySession.getPersistenceManager().createUser("Alice").getId();
+ String evaUser = identitySession.getPersistenceManager().createUser("Eva").getId();
String acmeOrgId = identitySession.getPersistenceManager().createGroup("ACME", ORGANIZATION).getId();
@@ -141,7 +141,7 @@
assertTrue(Arrays.equals((byte[])attributes.get("picture").getValue(), picture));
- String xUser = identitySession.getPersistenceManager().createUser("x").getName();
+ String xUser = identitySession.getPersistenceManager().createUser("x").getId();
String someGroupId = identitySession.getPersistenceManager().createGroup("someGroup", GROUP).getId();
identitySession.getRoleManager().createRole("manager", xUser, someGroupId);
Modified: idm/trunk/example/maven2/src/test/resources/example-db-config.xml
===================================================================
--- idm/trunk/example/maven2/src/test/resources/example-db-config.xml 2009-03-19 13:23:38 UTC (rev 383)
+++ idm/trunk/example/maven2/src/test/resources/example-db-config.xml 2009-03-19 19:34:38 UTC (rev 384)
@@ -37,10 +37,6 @@
<relationships>
<relationship>
<relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
- <identity-object-type-ref>ORGANIZATION</identity-object-type-ref>
- </relationship>
- <relationship>
- <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
<identity-object-type-ref>GROUP</identity-object-type-ref>
</relationship>
</relationships>
@@ -63,6 +59,10 @@
<name>ORGANIZATION</name>
<relationships>
<relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
<identity-object-type-ref>USER</identity-object-type-ref>
</relationship>
@@ -79,6 +79,10 @@
<name>GROUP</name>
<relationships>
<relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
<identity-object-type-ref>USER</identity-object-type-ref>
</relationship>
Modified: idm/trunk/example/maven2/src/test/resources/example-db-inject-sf-config.xml
===================================================================
--- idm/trunk/example/maven2/src/test/resources/example-db-inject-sf-config.xml 2009-03-19 13:23:38 UTC (rev 383)
+++ idm/trunk/example/maven2/src/test/resources/example-db-inject-sf-config.xml 2009-03-19 19:34:38 UTC (rev 384)
@@ -35,14 +35,6 @@
<identity-object-type>
<name>USER</name>
<relationships>
- <relationship>
- <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
- <identity-object-type-ref>ORGANIZATION</identity-object-type-ref>
- </relationship>
- <relationship>
- <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
- <identity-object-type-ref>GROUP</identity-object-type-ref>
- </relationship>
</relationships>
<credentials>
<credential-type>PASSWORD</credential-type>
@@ -63,6 +55,10 @@
<name>ORGANIZATION</name>
<relationships>
<relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
<identity-object-type-ref>USER</identity-object-type-ref>
</relationship>
@@ -79,6 +75,10 @@
<name>GROUP</name>
<relationships>
<relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
<identity-object-type-ref>USER</identity-object-type-ref>
</relationship>
Modified: idm/trunk/example/maven2/src/test/resources/example-mixed-config.xml
===================================================================
--- idm/trunk/example/maven2/src/test/resources/example-mixed-config.xml 2009-03-19 13:23:38 UTC (rev 383)
+++ idm/trunk/example/maven2/src/test/resources/example-mixed-config.xml 2009-03-19 19:34:38 UTC (rev 384)
@@ -58,14 +58,6 @@
<identity-object-type>
<name>USER</name>
<relationships>
- <relationship>
- <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
- <identity-object-type-ref>ORGANIZATION</identity-object-type-ref>
- </relationship>
- <relationship>
- <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
- <identity-object-type-ref>GROUP</identity-object-type-ref>
- </relationship>
</relationships>
<credentials>
<credential-type>PASSWORD</credential-type>
@@ -86,6 +78,10 @@
<name>ORGANIZATION</name>
<relationships>
<relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
<identity-object-type-ref>USER</identity-object-type-ref>
</relationship>
@@ -102,6 +98,10 @@
<name>GROUP</name>
<relationships>
<relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
<identity-object-type-ref>USER</identity-object-type-ref>
</relationship>
Modified: idm/trunk/example/maven2/src/test/resources/hibernate-jboss-identity-classes.cfg.xml
===================================================================
--- idm/trunk/example/maven2/src/test/resources/hibernate-jboss-identity-classes.cfg.xml 2009-03-19 13:23:38 UTC (rev 383)
+++ idm/trunk/example/maven2/src/test/resources/hibernate-jboss-identity-classes.cfg.xml 2009-03-19 19:34:38 UTC (rev 384)
@@ -44,7 +44,8 @@
<property name="hibernate.connection.password"></property>
<!-- Mapping classes -->
- <!-- all nessesary mappings are added programatically to the configuration -->
+ <!-- all nessesary mappings are added programatically to the configuration in the store-->
+ <!-- this is for manual SF creation-->
<mapping class="org.jboss.identity.idm.impl.model.hibernate.HibernateRealm"/>
<mapping class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObject"/>
<mapping class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredential"/>
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/IdentitySessionFactoryImpl.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/IdentitySessionFactoryImpl.java 2009-03-19 13:23:38 UTC (rev 383)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/IdentitySessionFactoryImpl.java 2009-03-19 19:34:38 UTC (rev 384)
@@ -32,6 +32,7 @@
import org.jboss.identity.idm.spi.store.AttributeStore;
import org.jboss.identity.idm.spi.repository.IdentityStoreRepository;
import org.jboss.identity.idm.impl.configuration.jaxb2.JAXB2IdentityConfiguration;
+import org.jboss.identity.idm.impl.configuration.IdentitySessionConfigurationContext;
import org.jboss.identity.idm.impl.api.session.IdentitySessionImpl;
import org.jboss.identity.idm.impl.api.session.mapper.DirectIdentityObjectTypeMapperImpl;
import org.jboss.identity.idm.impl.api.session.mapper.IdentityObjectTypeMapper;
@@ -51,18 +52,21 @@
public class IdentitySessionFactoryImpl implements IdentitySessionFactory
{
- private final Map<String, IdentitySession> realmMap;
+ private final Map<String, IdentitySession> realmMap = new HashMap<String, IdentitySession>();
- public IdentitySessionFactoryImpl(Map<String, IdentitySession> realmMap)
+ private final Map<String, IdentitySessionConfigurationContext> sessionContextMap;
+
+ public IdentitySessionFactoryImpl(Map<String, IdentitySessionConfigurationContext> sessionContextMap)
{
- this.realmMap = realmMap;
+ this.sessionContextMap = sessionContextMap;
}
public void close()
{
-
+ //TODO: close all sessions and put closed state?
+ //TODO: should keep map of all bootstrapped stores/repos and cleanup
}
public boolean isClosed()
@@ -70,13 +74,35 @@
return false;
}
- public IdentitySession createIdentitySession(String realmName)
+ public IdentitySession createIdentitySession(String realmName) throws IdentityException
{
- return realmMap.get(realmName);
+
+ if (!sessionContextMap.containsKey(realmName))
+ {
+ throw new IdentityException("Cannot find configured realm with a given name: " + realmName);
+ }
+
+ //IdentitySession session = new IdentitySessionImpl(realmName, repo, mapper);
+ IdentitySessionConfigurationContext sessionConfigCtx = sessionContextMap.get(realmName);
+
+ IdentitySession newSession =
+ new IdentitySessionImpl(sessionConfigCtx.getRealmName(),
+ sessionConfigCtx.getRepository(), sessionConfigCtx.getTypeMapper());
+
+ realmMap.put(realmName, newSession);
+
+ return newSession;
}
- public IdentitySession getCurrentIdentitySession(String realmName)
+ public IdentitySession getCurrentIdentitySession(String realmName) throws IdentityException
{
- return realmMap.get(realmName);
+ if (realmMap.containsKey(realmName))
+ {
+ return realmMap.get(realmName);
+ }
+ else
+ {
+ return createIdentitySession(realmName);
+ }
}
}
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java 2009-03-19 13:23:38 UTC (rev 383)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java 2009-03-19 19:34:38 UTC (rev 384)
@@ -37,6 +37,7 @@
import org.jboss.identity.idm.spi.searchcontrol.IdentityObjectSearchControl;
import org.jboss.identity.idm.impl.NotYetImplementedException;
import org.jboss.identity.idm.impl.api.session.managers.AbstractManager;
+import org.jboss.identity.idm.impl.api.model.GroupId;
import java.util.Collection;
import java.util.Iterator;
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/IdentityConfigurationImpl.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/IdentityConfigurationImpl.java 2009-03-19 13:23:38 UTC (rev 383)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/IdentityConfigurationImpl.java 2009-03-19 19:34:38 UTC (rev 384)
@@ -24,14 +24,12 @@
import org.jboss.identity.idm.api.cfg.IdentityConfiguration;
import org.jboss.identity.idm.api.cfg.IdentityConfigurationRegistry;
-import org.jboss.identity.idm.api.IdentitySession;
import org.jboss.identity.idm.api.IdentitySessionFactory;
import org.jboss.identity.idm.impl.helper.CopyOnWriteRegistry;
import org.jboss.identity.idm.impl.configuration.jaxb2.JAXB2IdentityConfiguration;
import org.jboss.identity.idm.impl.api.session.mapper.IdentityObjectTypeMapper;
import org.jboss.identity.idm.impl.api.session.mapper.DirectIdentityObjectTypeMapperImpl;
import org.jboss.identity.idm.impl.api.session.mapper.IdentityObjectTypeMapperImpl;
-import org.jboss.identity.idm.impl.api.session.IdentitySessionImpl;
import org.jboss.identity.idm.impl.api.IdentitySessionFactoryImpl;
import org.jboss.identity.idm.exception.IdentityException;
import org.jboss.identity.idm.exception.IdentityConfigurationException;
@@ -135,7 +133,7 @@
public IdentitySessionFactory buildIdentitySessionFactory() throws IdentityConfigurationException
{
- Map<String, IdentitySession> realmMap = null;
+ Map<String, IdentitySessionConfigurationContext> realmMap = null;
if (configMD == null)
{
@@ -144,7 +142,7 @@
try
{
- realmMap = createSessionMap(configMD);
+ realmMap = createRealmMap(configMD);
}
catch (Exception e)
{
@@ -154,7 +152,7 @@
return new IdentitySessionFactoryImpl(realmMap);
}
- private Map<String, IdentitySession> createSessionMap(IdentityConfigurationMetaData configMD) throws Exception
+ private Map<String, IdentitySessionConfigurationContext> createRealmMap(IdentityConfigurationMetaData configMD) throws Exception
{
//TODO: some validation, sanity checks and error reporting
@@ -229,7 +227,7 @@
// Realms
- Map<String, IdentitySession> sessionMap = new HashMap<String, IdentitySession>();
+ Map<String, IdentitySessionConfigurationContext> sessionCtxMap = new HashMap<String, IdentitySessionConfigurationContext>();
for (RealmConfigurationMetaData metaData : configMD.getRealms())
{
@@ -249,12 +247,14 @@
mapper = new IdentityObjectTypeMapperImpl(metaData.getGroupTypeMappings(), metaData.getIdentityMapping());
}
- IdentitySession session = new IdentitySessionImpl(realmName, repo, mapper);
+ //IdentitySession session = new IdentitySessionImpl(realmName, repo, mapper);
+ IdentitySessionConfigurationContext sessionConfigCtx =
+ new IdentitySessionConfigurationContext(realmName, configMD, repo, mapper);
- sessionMap.put(realmName, session);
+ sessionCtxMap.put(realmName, sessionConfigCtx);
}
- return sessionMap;
+ return sessionCtxMap;
}
}
Added: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/IdentitySessionConfigurationContext.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/IdentitySessionConfigurationContext.java (rev 0)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/IdentitySessionConfigurationContext.java 2009-03-19 19:34:38 UTC (rev 384)
@@ -0,0 +1,70 @@
+/*
+* 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.identity.idm.impl.configuration;
+
+import org.jboss.identity.idm.spi.repository.IdentityStoreRepository;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityConfigurationMetaData;
+import org.jboss.identity.idm.impl.api.session.mapper.IdentityObjectTypeMapper;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class IdentitySessionConfigurationContext
+{
+ private final String realmName;
+ private final IdentityConfigurationMetaData identityConfigurationMetaData;
+ private final IdentityStoreRepository repository;
+ private final IdentityObjectTypeMapper typeMapper;
+
+ public IdentitySessionConfigurationContext(String realmName,
+ IdentityConfigurationMetaData identityConfigurationMetaData,
+ IdentityStoreRepository repository,
+ IdentityObjectTypeMapper typeMapper)
+ {
+ this.realmName = realmName;
+ this.identityConfigurationMetaData = identityConfigurationMetaData;
+ this.repository = repository;
+ this.typeMapper = typeMapper;
+ }
+
+ public String getRealmName()
+ {
+ return realmName;
+ }
+
+ public IdentityConfigurationMetaData getIdentityConfigurationMetaData()
+ {
+ return identityConfigurationMetaData;
+ }
+
+ public IdentityStoreRepository getRepository()
+ {
+ return repository;
+ }
+
+ public IdentityObjectTypeMapper getTypeMapper()
+ {
+ return typeMapper;
+ }
+}
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java 2009-03-19 13:23:38 UTC (rev 383)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java 2009-03-19 19:34:38 UTC (rev 384)
@@ -406,7 +406,7 @@
}
catch (Exception e)
{
- throw new IdentityException("Failed to obtain HibernateEntityManager",e);
+ throw new IdentityException("Failed to obtain Hibernate SessionFactory",e);
}
}
Modified: idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/AttributesManager.java
===================================================================
--- idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/AttributesManager.java 2009-03-19 13:23:38 UTC (rev 383)
+++ idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/AttributesManager.java 2009-03-19 19:34:38 UTC (rev 384)
@@ -51,7 +51,7 @@
AttributeDescription getAttributeDescription(IdentityType identityType, String name);
/**
- * Get AttributeDesciption object for single attribute supported with a given group id or userName
+ * Get AttributeDesciption object for single attribute supported with a given IdentityType id
*
* @param id
* @return
@@ -67,8 +67,7 @@
Map<String, AttributeDescription> getSupportedAttributesDescriptions(IdentityType identityType);
/**
- * Get AttributeDesciption objects for all attributes supported with an IdentityType object with a given id (for a Group)
- * or username (for User)
+ * Get AttributeDesciption objects for all attributes supported with an IdentityType object with a given IdentityType id
*
* @param id
* @return
@@ -84,7 +83,7 @@
throws IdentityException;
/**
- * @param id - name of User object or id of a Group
+ * @param id - IdentityType id
* @return names of supported attributes
* @throws org.jboss.identity.idm.exception.IdentityException
*/
@@ -101,7 +100,7 @@
Map<String, Attribute> getAttributes(IdentityType identity) throws IdentityException;
/**
- * Get attributes for the given IdentityType
+ * Get attributes for the given IdentityType id
*
* @param id
* @return
@@ -120,7 +119,7 @@
Attribute getAttribute(IdentityType identity, String attributeName) throws IdentityException;
/**
- * Get attribute values for the given IdentityType
+ * Get attribute values for the given IdentityType id
*
* @param id
* @param attributeName
@@ -142,7 +141,7 @@
/**
* Update attributes with new values - previous values will be overwritten. All the other attributes are not changed -
- * method doesn't overwrite whole attribute set connected with a given IdentityType object.
+ * method doesn't overwrite whole attribute set connected with a given IdentityType id.
*
* @param id
* @param attributes
Deleted: idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/GroupType.java
===================================================================
--- idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/GroupType.java 2009-03-19 13:23:38 UTC (rev 383)
+++ idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/GroupType.java 2009-03-19 19:34:38 UTC (rev 384)
@@ -1,39 +0,0 @@
-///*
-// * JBoss, Home of Professional Open Source.
-// * Copyright 2008, Red Hat Middleware LLC, and individual contributors
-// * as indicated by the @author tags. See the copyright.txt file 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.identity.idm.api;
-//
-///**
-// * Type of Group
-// *
-// * @author Anil.Saldhana(a)redhat.com
-// * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
-// * @since Jul 11, 2008
-// */
-//public interface GroupType
-//{
-//
-// /**
-// * @return group type name
-// */
-// String getName();
-//
-//}
\ No newline at end of file
Modified: idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/IdentitySessionFactory.java
===================================================================
--- idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/IdentitySessionFactory.java 2009-03-19 13:23:38 UTC (rev 383)
+++ idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/IdentitySessionFactory.java 2009-03-19 19:34:38 UTC (rev 384)
@@ -22,6 +22,8 @@
package org.jboss.identity.idm.api;
+import org.jboss.identity.idm.exception.IdentityException;
+
/**
* Creates IdentitySession objects for a given Realm.
*
@@ -44,13 +46,13 @@
* Create IdentitySession
* @return
*/
- IdentitySession createIdentitySession(String realmName);
+ IdentitySession createIdentitySession(String realmName) throws IdentityException;
/**
- * Get current open session associated with a realm
+ * Get current open session associated with a realm. If not present, creates one
* @return
*/
- IdentitySession getCurrentIdentitySession(String realmName);
+ IdentitySession getCurrentIdentitySession(String realmName) throws IdentityException;
}
Modified: idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java
===================================================================
--- idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java 2009-03-19 13:23:38 UTC (rev 383)
+++ idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java 2009-03-19 19:34:38 UTC (rev 384)
@@ -51,11 +51,11 @@
/**
* <p>Create User object</p>
- * @param userName
+ * @param id
* @throws IdentityException
* @return
*/
- User createUser(String userName) throws IdentityException;
+ User createUser(String id) throws IdentityException;
/**
* <p>Create a group of a particular type</p>
@@ -67,7 +67,10 @@
throws IdentityException;
/**
- * <p>Create a group Id. Result string can be used in other methods</p>
+ * <p>Create a group Id. Result string can be used in other methods. Group Id contains encoded group type and
+ * name imformation.
+ * In default implementation it can look as follows: "group://GROUP_TYPE/GROUP_NAME".
+ * Still prefix and format of Id can change in the future so this method should be used to create it.</p>
* @param groupName
* @param groupType
* @return
@@ -89,12 +92,12 @@
/**
* Remove given identity
*
- * @param userName
+ * @param id
* @param force - if true all present relationships will be removed, if false any present relationship will cause
* removal to fail
* @throws org.jboss.identity.idm.exception.IdentityException
*/
- void removeUser(String userName, boolean force) throws IdentityException;
+ void removeUser(String id, boolean force) throws IdentityException;
/**
* Remove given group
@@ -190,6 +193,7 @@
Collection<Group> findGroup(String groupType) throws IdentityException;
+ //TODO: commented out for now as it is not implemented
/**
* Whether Identity is a virtual
* (such as a pseudonym)
Modified: idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RelationshipManager.java
===================================================================
--- idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RelationshipManager.java 2009-03-19 13:23:38 UTC (rev 383)
+++ idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RelationshipManager.java 2009-03-19 19:34:38 UTC (rev 384)
@@ -149,10 +149,10 @@
/**
* <p>Associate identities to groups</p>
* @param parentGroupId
- * @param memberUserName
+ * @param memberid
* @throws org.jboss.identity.idm.exception.IdentityException
*/
- void associateUsersByIds(String parentGroupId, String memberUserName)
+ void associateUsersByIds(String parentGroupId, String memberid)
throws IdentityException;
/**
@@ -271,9 +271,7 @@
/**
* Find groups that are associated with given group.
- * If the paginatedSearch or orderedSearch operations
- * are not supported, dedicated parameters will
- * take no effect. If 'parent' parameter is set to false, all parent group will be returned. If parent parameter is
+ * If 'parent' parameter is set to false, all parent group will be returned. If parent parameter is
* set to true and 'inherited' is set to true all nested subgroubs will be returned.
*
* @param group parent group
@@ -292,9 +290,7 @@
/**
* Find groups that are associated with given group.
- * If the paginatedSearch or orderedSearch operations
- * are not supported, dedicated parameters will
- * take no effect. If 'parent' parameter is set to false, all parent group will be returned. If parent parameter is
+ * If 'parent' parameter is set to false, all parent group will be returned. If parent parameter is
* set to true and 'inherited' is set to true all nested subgroubs will be returned.
*
* @param group parent group
@@ -314,9 +310,7 @@
/**
* Find groups that are associated with given group.
- * If the paginatedSearch or orderedSearch operations
- * are not supported, dedicated parameters will
- * take no effect. If 'parent' parameter is set to false, all parent group will be returned. If parent parameter is
+ * If 'parent' parameter is set to false, all parent group will be returned. If parent parameter is
* set to true and 'inherited' is set to true all nested subgroubs will be returned.
*
* @param groupId Id of parent group
@@ -346,9 +340,6 @@
/**
* Find all groups that given identity is associated with.
- * If the paginatedSearch or orderedSearch operations
- * are not supported, dedicated parameters will
- * take no effect
*
* @param user child identity
* @param groupType can be null
@@ -361,24 +352,18 @@
/**
* Find all groups that given identity is associated with.
- * If the paginatedSearch or orderedSearch operations
- * are not supported, dedicated parameters will
- * take no effect
*
- * @param userName child identity name
+ * @param userId - id of associated user
* @param groupType can be null
* @return
* @throws org.jboss.identity.idm.exception.IdentityException
*/
- Collection<Group> findAssociatedGroups(String userName,
+ Collection<Group> findAssociatedGroups(String userId,
String groupType,
IdentitySearchControl[] controls) throws IdentityException;
/**
* Find all groups that given identity is associated with.
- * If the paginatedSearch or orderedSearch operations
- * are not supported, dedicated parameters will
- * take no effect
*
* @param user child identity
* @return
@@ -389,15 +374,12 @@
/**
* Find all groups that given identity is associated with.
- * If the paginatedSearch or orderedSearch operations
- * are not supported, dedicated parameters will
- * take no effect
*
- * @param userName child identity name
+ * @param userId
* @return
* @throws org.jboss.identity.idm.exception.IdentityException
*/
- Collection<Group> findAssociatedGroups(String userName,
+ Collection<Group> findAssociatedGroups(String userId,
IdentitySearchControl[] controls) throws IdentityException;
/**
@@ -411,9 +393,6 @@
/**
* Find identities that have relationship with given parent group.
- * If the paginatedSearch or orderedSearch operations
- * are not supported in this store implementation, dedicated parameters will
- * take no effect
*
* @param group parent group
* @param inherited if true also identities from subgroubs will be retrieved. Default is false
@@ -425,9 +404,6 @@
/**
* Find identities that have relationship with given parent group.
- * If the paginatedSearch or orderedSearch operations
- * are not supported in this store implementation, dedicated parameters will
- * take no effect
*
* @param group parent group
* @param inherited if true also identities from subgroubs will be retrieved. Default is false
@@ -440,9 +416,6 @@
/**
* Find identities that have relationship with given parent group.
- * If the paginatedSearch or orderedSearch operations
- * are not supported in this store implementation, dedicated parameters will
- * take no effect
*
* @param groupId parent group id
* @param inherited if true also identities from subgroubs will be retrieved. Default is false
@@ -456,9 +429,6 @@
/**
* Find all groups that given identity is associated with.
- * If the paginatedSearch or orderedSearch operations
- * are not supported, dedicated parameters will
- * take no effect
*
* @param user child identity
* @param groupType can be null
@@ -471,24 +441,18 @@
/**
* Find all groups that given identity is associated with.
- * If the paginatedSearch or orderedSearch operations
- * are not supported, dedicated parameters will
- * take no effect
*
- * @param userName child identity name
+ * @param userId
* @param groupType can be null
* @return
* @throws org.jboss.identity.idm.exception.IdentityException
*/
- Collection<Group> findRelatedGroups(String userName,
+ Collection<Group> findRelatedGroups(String userId,
String groupType,
IdentitySearchControl[] controls) throws IdentityException;
/**
* Find identities that have relationship with given parent group.
- * If the paginatedSearch or orderedSearch operations
- * are not supported in this store implementation, dedicated parameters will
- * take no effect
*
* @param group parent group
* @return
@@ -498,10 +462,7 @@
/**
* Find identities that have relationship with given parent group.
- * If the paginatedSearch or orderedSearch operations
- * are not supported in this store implementation, dedicated parameters will
- * take no effect
- *
+ *
* @param groupId parent group id
* @return
* @throws org.jboss.identity.idm.exception.IdentityException
Modified: idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RoleManager.java
===================================================================
--- idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RoleManager.java 2009-03-19 13:23:38 UTC (rev 383)
+++ idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RoleManager.java 2009-03-19 19:34:38 UTC (rev 384)
@@ -100,12 +100,12 @@
/**
* Create role
* @param roleTypeName
- * @param userName
+ * @param userId
* @param groupId
* @return
* @throws IdentityException
*/
- Role createRole(String roleTypeName, String userName, String groupId) throws IdentityException;
+ Role createRole(String roleTypeName, String userId, String groupId) throws IdentityException;
/**
* Remove Role
@@ -119,11 +119,11 @@
/**
* Remove Role
* @param roleTypeName
- * @param userName
+ * @param userId
* @param groupId
* @throws IdentityException
*/
- void removeRole(String roleTypeName, String userName, String groupId) throws IdentityException;
+ void removeRole(String roleTypeName, String userId, String groupId) throws IdentityException;
/**
* Remove Role
@@ -144,16 +144,16 @@
/**
* Check if Role is present
- * @param userName
+ * @param userId
* @param groupId
* @param roleTypeName
* @return
* @throws IdentityException
*/
- boolean hasRole(String userName, String groupId, String roleTypeName) throws IdentityException;
+ boolean hasRole(String userId, String groupId, String roleTypeName) throws IdentityException;
/**
- * Find RoleType objects for roles associated with a given Identity and Group
+ * Find RoleType objects for roles associated with a given User and Group
* @param user
* @param group
* @return
@@ -163,17 +163,17 @@
IdentitySearchControl[] controls) throws IdentityException;
/**
- * Find RoleType objects for roles associated with a given Identity and Group
- * @param userName
+ * Find RoleType objects for roles associated with a given User and Group
+ * @param userId
* @param groupId
* @return
* @throws IdentityException
*/
- Collection<RoleType> findRoleTypes(String userName, String groupId,
+ Collection<RoleType> findRoleTypes(String userId, String groupId,
IdentitySearchControl[] controls) throws IdentityException;
/**
- * Find RoleType objects for roles associated with a given Identity and Group
+ * Find RoleType objects for roles associated with a given User and Group
* @param user
* @param group
* @return
@@ -199,11 +199,11 @@
/**
* Find RoleType objects for roles associated with a given Identity
- * @param userName
+ * @param userId
* @return
* @throws IdentityException
*/
- Collection<RoleType> findUserRoleTypes(String userName, IdentitySearchControl[] controls) throws IdentityException;
+ Collection<RoleType> findUserRoleTypes(String userId, IdentitySearchControl[] controls) throws IdentityException;
/**
* Find RoleType objects for roles associated with a given Group
@@ -232,7 +232,7 @@
IdentitySearchControl[] controls) throws IdentityException;
/**
- * Find all Groups with which Identity has a Role association
+ * Find all Groups with which User has a Role association
*
* @param user
* @param controls
@@ -243,19 +243,19 @@
IdentitySearchControl[] controls) throws IdentityException;
/**
- * Find all Groups with which Identity has a Role association
+ * Find all Groups with which User has a Role association
*
- * @param userName
+ * @param userId
* @param controls
* @return
* @throws IdentityException
*/
- Collection<Group> findGroupsWithRelatedRole(String userName,
+ Collection<Group> findGroupsWithRelatedRole(String userId,
IdentitySearchControl[] controls) throws IdentityException;
/**
- * Find all Groups with which Identity has a Role association
+ * Find all Groups with which User has a Role association
*
* @param user
* @param controls
@@ -267,14 +267,14 @@
IdentitySearchControl[] controls) throws IdentityException;
/**
- * Find all Groups with which Identity has a Role association
+ * Find all Groups with which User has a Role association
*
- * @param userName
+ * @param userId
* @param controls
* @return
* @throws IdentityException
*/
- Collection<Group> findGroupsWithRelatedRole(String userName,
+ Collection<Group> findGroupsWithRelatedRole(String userId,
String groupType,
IdentitySearchControl[] controls) throws IdentityException;
@@ -289,7 +289,7 @@
RoleType roleType) throws IdentityException;
/**
- * Find Role objects with a given RoleType name associated with IdentityType for a given id (Group) or name (User)
+ * Find Role objects with a given RoleType name associated with IdentityType for a given id
* @param id
* @param roleTypeName
* @return
Modified: idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/User.java
===================================================================
--- idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/User.java 2009-03-19 13:23:38 UTC (rev 383)
+++ idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/User.java 2009-03-19 19:34:38 UTC (rev 384)
@@ -29,7 +29,6 @@
* @since Jun 30, 2008
*/
public interface User extends IdentityType
-{
-
+{
}
\ No newline at end of file
15 years, 9 months
JBoss Identity SVN: r383 - in idm/trunk: idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers and 2 other directories.
by jboss-identity-commits@lists.jboss.org
Author: bdaw
Date: 2009-03-19 09:23:38 -0400 (Thu, 19 Mar 2009)
New Revision: 383
Modified:
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/Group.java
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/IdentityType.java
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/User.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleUser.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AbstractManager.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/PersistenceManagerTest.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RelationshipManagerTest.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RoleManagerTest.java
Log:
- Use id instead of name in User
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleUser.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleUser.java 2009-03-19 12:54:42 UTC (rev 382)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleUser.java 2009-03-19 13:23:38 UTC (rev 383)
@@ -30,17 +30,17 @@
*/
public class SimpleUser implements User
{
- private final String name;
+ private final String id;
- public SimpleUser(String name)
+ public SimpleUser(String id)
{
- this.name = name;
+ this.id = id;
}
- public String getName()
+ public String getId()
{
- return name;
+ return id;
}
@Override
@@ -57,7 +57,7 @@
SimpleUser that = (SimpleUser)o;
- if (name != null ? !name.equals(that.name) : that.name != null)
+ if (id != null ? !id.equals(that.id) : that.id != null)
{
return false;
}
@@ -68,6 +68,6 @@
@Override
public int hashCode()
{
- return name != null ? name.hashCode() : 0;
+ return id != null ? id.hashCode() : 0;
}
}
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AbstractManager.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AbstractManager.java 2009-03-19 12:54:42 UTC (rev 382)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AbstractManager.java 2009-03-19 13:23:38 UTC (rev 383)
@@ -116,7 +116,7 @@
{
IdentityObjectType iot = getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType();
- return new SimpleIdentityObject(identity.getName(), iot);
+ return new SimpleIdentityObject(identity.getId(), iot);
}
protected IdentityObject createIdentityObjectForUserName(String userName)
Modified: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/PersistenceManagerTest.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/PersistenceManagerTest.java 2009-03-19 12:54:42 UTC (rev 382)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/PersistenceManagerTest.java 2009-03-19 13:23:38 UTC (rev 383)
@@ -25,19 +25,9 @@
import org.jboss.identity.idm.api.IdentitySession;
import org.jboss.identity.idm.api.Group;
import org.jboss.identity.idm.api.User;
-import org.jboss.identity.idm.api.RoleType;
import org.jboss.identity.idm.api.IdentitySessionFactory;
-import org.jboss.identity.idm.api.Attribute;
-import org.jboss.identity.idm.api.AttributeDescription;
import org.jboss.identity.idm.api.IdentitySearchControl;
-import org.jboss.identity.idm.p3p.P3PConstants;
-import org.jboss.identity.idm.exception.IdentityException;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Random;
-import java.util.Arrays;
-
import junit.framework.Assert;
/**
@@ -155,7 +145,7 @@
User u1 = session.getPersistenceManager().createUser("olo");
assertNotNull(u1);
- assertEquals(u1.getName(), "olo");
+ assertEquals(u1.getId(), "olo");
session.getPersistenceManager().createUser("anna");
Modified: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RelationshipManagerTest.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RelationshipManagerTest.java 2009-03-19 12:54:42 UTC (rev 382)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RelationshipManagerTest.java 2009-03-19 13:23:38 UTC (rev 383)
@@ -25,18 +25,10 @@
import org.jboss.identity.idm.api.IdentitySession;
import org.jboss.identity.idm.api.Group;
import org.jboss.identity.idm.api.User;
-import org.jboss.identity.idm.api.RoleType;
import org.jboss.identity.idm.api.IdentitySessionFactory;
-import org.jboss.identity.idm.api.Attribute;
-import org.jboss.identity.idm.api.AttributeDescription;
import org.jboss.identity.idm.api.IdentitySearchControl;
-import org.jboss.identity.idm.p3p.P3PConstants;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Random;
import java.util.Arrays;
-import java.util.LinkedList;
import junit.framework.Assert;
@@ -177,18 +169,18 @@
assertFalse(session.getRelationshipManager().isAssociated(Arrays.asList(group1, group2), Arrays.asList(user1, user2)));
assertFalse(session.getRelationshipManager().isAssociated(Arrays.asList(group2), Arrays.asList(user3)));
- assertTrue(session.getRelationshipManager().isAssociatedByIds(group1.getId(), user1.getName()));
- assertTrue(session.getRelationshipManager().isAssociatedByIds(group1.getId(), user2.getName()));
- assertFalse(session.getRelationshipManager().isAssociatedByIds(group1.getId(), user3.getName()));
- assertFalse(session.getRelationshipManager().isAssociatedByIds(group2.getId(), user1.getName()));
- assertFalse(session.getRelationshipManager().isAssociatedByIds(group2.getId(), user3.getName()));
+ assertTrue(session.getRelationshipManager().isAssociatedByIds(group1.getId(), user1.getId()));
+ assertTrue(session.getRelationshipManager().isAssociatedByIds(group1.getId(), user2.getId()));
+ assertFalse(session.getRelationshipManager().isAssociatedByIds(group1.getId(), user3.getId()));
+ assertFalse(session.getRelationshipManager().isAssociatedByIds(group2.getId(), user1.getId()));
+ assertFalse(session.getRelationshipManager().isAssociatedByIds(group2.getId(), user3.getId()));
assertTrue(session.getRelationshipManager().
- isAssociatedByIds(Arrays.asList(group1.getId()), Arrays.asList(user1.getName(), user2.getName())));
+ isAssociatedByIds(Arrays.asList(group1.getId()), Arrays.asList(user1.getId(), user2.getId())));
assertFalse(session.getRelationshipManager().
- isAssociatedByIds(Arrays.asList(group1.getId(), group2.getId()), Arrays.asList(user1.getName(), user2.getName())));
+ isAssociatedByIds(Arrays.asList(group1.getId(), group2.getId()), Arrays.asList(user1.getId(), user2.getId())));
assertFalse(session.getRelationshipManager().
- isAssociatedByIds(Arrays.asList(group2.getId(), group3.getId()), Arrays.asList(user1.getName())));
+ isAssociatedByIds(Arrays.asList(group2.getId(), group3.getId()), Arrays.asList(user1.getId())));
// Associate groups / users - other methods
@@ -206,14 +198,14 @@
session.getRelationshipManager().disassociateUsers(Arrays.asList(group1), Arrays.asList(user1, user2));
// reassociate #2
- session.getRelationshipManager().associateUsersByIds(Arrays.asList(group1.getId()), Arrays.asList(user1.getName(), user2.getName()));
+ session.getRelationshipManager().associateUsersByIds(Arrays.asList(group1.getId()), Arrays.asList(user1.getId(), user2.getId()));
assertTrue(session.getRelationshipManager().isAssociated(Arrays.asList(group1), Arrays.asList(user1, user2)));
- session.getRelationshipManager().disassociateUsersByIds(Arrays.asList(group1.getId()), Arrays.asList(user1.getName(), user2.getName()));
+ session.getRelationshipManager().disassociateUsersByIds(Arrays.asList(group1.getId()), Arrays.asList(user1.getId(), user2.getId()));
// reassociate #3
- session.getRelationshipManager().associateUsersByIds(group1.getId(), user1.getName());
- session.getRelationshipManager().associateUsersByIds(group1.getId(), user2.getName());
+ session.getRelationshipManager().associateUsersByIds(group1.getId(), user1.getId());
+ session.getRelationshipManager().associateUsersByIds(group1.getId(), user2.getId());
assertTrue(session.getRelationshipManager().isAssociated(Arrays.asList(group1), Arrays.asList(user1, user2)));
@@ -281,10 +273,10 @@
assertEquals(0, session.getRelationshipManager().findAssociatedGroups(user4).size());
// #6
- assertEquals(1, session.getRelationshipManager().findAssociatedGroups(user1.getName(), null).size());
- assertEquals(2, session.getRelationshipManager().findAssociatedGroups(user2.getName(), null).size());
- assertEquals(2, session.getRelationshipManager().findAssociatedGroups(user3.getName(), null).size());
- assertEquals(0, session.getRelationshipManager().findAssociatedGroups(user4.getName(), null).size());
+ assertEquals(1, session.getRelationshipManager().findAssociatedGroups(user1.getId(), null).size());
+ assertEquals(2, session.getRelationshipManager().findAssociatedGroups(user2.getId(), null).size());
+ assertEquals(2, session.getRelationshipManager().findAssociatedGroups(user3.getId(), null).size());
+ assertEquals(0, session.getRelationshipManager().findAssociatedGroups(user4.getId(), null).size());
// #7
assertEquals(1, session.getRelationshipManager().findAssociatedGroups(user1, ORGANIZATION).size());
@@ -298,14 +290,14 @@
assertEquals(0, session.getRelationshipManager().findAssociatedGroups(user4, ORGANIZATION_UNIT).size());
// #7
- assertEquals(1, session.getRelationshipManager().findAssociatedGroups(user1.getName(), ORGANIZATION, null).size());
- assertEquals(0, session.getRelationshipManager().findAssociatedGroups(user1.getName(), ORGANIZATION_UNIT, null).size());
- assertEquals(1, session.getRelationshipManager().findAssociatedGroups(user2.getName(), ORGANIZATION, null).size());
- assertEquals(1, session.getRelationshipManager().findAssociatedGroups(user2.getName(), ORGANIZATION_UNIT, null).size());
- assertEquals(1, session.getRelationshipManager().findAssociatedGroups(user3.getName(), ORGANIZATION, null).size());
- assertEquals(1, session.getRelationshipManager().findAssociatedGroups(user3.getName(), ORGANIZATION_UNIT, null).size());
- assertEquals(0, session.getRelationshipManager().findAssociatedGroups(user4.getName(), ORGANIZATION, null).size());
- assertEquals(0, session.getRelationshipManager().findAssociatedGroups(user4.getName(), ORGANIZATION_UNIT, null).size());
+ assertEquals(1, session.getRelationshipManager().findAssociatedGroups(user1.getId(), ORGANIZATION, null).size());
+ assertEquals(0, session.getRelationshipManager().findAssociatedGroups(user1.getId(), ORGANIZATION_UNIT, null).size());
+ assertEquals(1, session.getRelationshipManager().findAssociatedGroups(user2.getId(), ORGANIZATION, null).size());
+ assertEquals(1, session.getRelationshipManager().findAssociatedGroups(user2.getId(), ORGANIZATION_UNIT, null).size());
+ assertEquals(1, session.getRelationshipManager().findAssociatedGroups(user3.getId(), ORGANIZATION, null).size());
+ assertEquals(1, session.getRelationshipManager().findAssociatedGroups(user3.getId(), ORGANIZATION_UNIT, null).size());
+ assertEquals(0, session.getRelationshipManager().findAssociatedGroups(user4.getId(), ORGANIZATION, null).size());
+ assertEquals(0, session.getRelationshipManager().findAssociatedGroups(user4.getId(), ORGANIZATION_UNIT, null).size());
// Cleanup and check
session.getRelationshipManager().disassociateUsers(Arrays.asList(group1), Arrays.asList(user1, user2, user3));
@@ -350,13 +342,13 @@
session.getRoleManager().createRoleType("rt1");
session.getRoleManager().createRoleType("rt2");
- session.getRoleManager().createRole("rt1", user1.getName(), group1.getId());
- session.getRoleManager().createRole("rt1", user3.getName(), group1.getId());
- session.getRoleManager().createRole("rt1", user4.getName(), group1.getId());
- session.getRoleManager().createRole("rt2", user3.getName(), group1.getId());
+ session.getRoleManager().createRole("rt1", user1.getId(), group1.getId());
+ session.getRoleManager().createRole("rt1", user3.getId(), group1.getId());
+ session.getRoleManager().createRole("rt1", user4.getId(), group1.getId());
+ session.getRoleManager().createRole("rt2", user3.getId(), group1.getId());
- session.getRoleManager().createRole("rt1", user3.getName(), group2.getId());
- session.getRoleManager().createRole("rt2", user2.getName(), group3.getId());
+ session.getRoleManager().createRole("rt1", user3.getId(), group2.getId());
+ session.getRoleManager().createRole("rt2", user2.getId(), group3.getId());
// Assert
Modified: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RoleManagerTest.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RoleManagerTest.java 2009-03-19 12:54:42 UTC (rev 382)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RoleManagerTest.java 2009-03-19 13:23:38 UTC (rev 383)
@@ -27,19 +27,8 @@
import org.jboss.identity.idm.api.User;
import org.jboss.identity.idm.api.RoleType;
import org.jboss.identity.idm.api.IdentitySessionFactory;
-import org.jboss.identity.idm.api.Attribute;
-import org.jboss.identity.idm.api.AttributeDescription;
-import org.jboss.identity.idm.api.IdentitySearchControl;
-import org.jboss.identity.idm.api.RoleManager;
import org.jboss.identity.idm.api.Role;
-import org.jboss.identity.idm.p3p.P3PConstants;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Random;
-import java.util.Arrays;
-import java.util.LinkedList;
-
import junit.framework.Assert;
/**
@@ -133,7 +122,7 @@
Role role1 = session.getRoleManager().createRole(rt1, user1, group1);
Role role2 = session.getRoleManager().createRole(rt1, user1, group2);
- Role role3 = session.getRoleManager().createRole("rt2", user1.getName(), group1.getId());
+ Role role3 = session.getRoleManager().createRole("rt2", user1.getId(), group1.getId());
//
@@ -150,24 +139,24 @@
//
assertEquals(2, session.getRoleManager().findRoles(user1, rt1).size());
- assertEquals(1, session.getRoleManager().findRoles(user1.getName(), "rt2").size());
+ assertEquals(1, session.getRoleManager().findRoles(user1.getId(), "rt2").size());
assertEquals(1, session.getRoleManager().findRoles(group1.getId(), "rt1").size());
assertEquals(1, session.getRoleManager().findRoles(group1, rt1).size());
//
assertEquals(2, session.getRoleManager().findGroupsWithRelatedRole(user1, null).size());
- assertEquals(1, session.getRoleManager().findGroupsWithRelatedRole(user1.getName(), ORGANIZATION, null).size());
+ assertEquals(1, session.getRoleManager().findGroupsWithRelatedRole(user1.getId(), ORGANIZATION, null).size());
//
assertEquals(2, session.getRoleManager().findRoleTypes(user1, group1).size());
- assertEquals(1, session.getRoleManager().findRoleTypes(user1.getName(), group2.getId(), null).size());
+ assertEquals(1, session.getRoleManager().findRoleTypes(user1.getId(), group2.getId(), null).size());
//
assertEquals(2, session.getRoleManager().findUserRoleTypes(user1).size());
- assertEquals(0, session.getRoleManager().findUserRoleTypes(user2.getName(), null).size());
+ assertEquals(0, session.getRoleManager().findUserRoleTypes(user2.getId(), null).size());
//
assertTrue(session.getRoleManager().hasRole(user1, group1, rt1));
@@ -182,7 +171,7 @@
session.getRoleManager().removeRole(rt1, user1, group1);
session.getRoleManager().removeRole(role2);
- session.getRoleManager().removeRole("rt2", user1.getName(), group1.getId());
+ session.getRoleManager().removeRole("rt2", user1.getId(), group1.getId());
assertFalse(session.getRoleManager().hasRole(user1, group1, rt1));
assertFalse(session.getRoleManager().hasRole(user1, group1, rt2));
@@ -203,24 +192,24 @@
//
assertEquals(0, session.getRoleManager().findRoles(user1, rt1).size());
- assertEquals(0, session.getRoleManager().findRoles(user1.getName(), "rt2").size());
+ assertEquals(0, session.getRoleManager().findRoles(user1.getId(), "rt2").size());
assertEquals(0, session.getRoleManager().findRoles(group1.getId(), "rt1").size());
assertEquals(0, session.getRoleManager().findRoles(group1, rt1).size());
//
assertEquals(0, session.getRoleManager().findGroupsWithRelatedRole(user1, null).size());
- assertEquals(0, session.getRoleManager().findGroupsWithRelatedRole(user1.getName(), ORGANIZATION, null).size());
+ assertEquals(0, session.getRoleManager().findGroupsWithRelatedRole(user1.getId(), ORGANIZATION, null).size());
//
assertEquals(0, session.getRoleManager().findRoleTypes(user1, group1).size());
- assertEquals(0, session.getRoleManager().findRoleTypes(user1.getName(), group2.getId(), null).size());
+ assertEquals(0, session.getRoleManager().findRoleTypes(user1.getId(), group2.getId(), null).size());
//
assertEquals(0, session.getRoleManager().findUserRoleTypes(user1).size());
- assertEquals(0, session.getRoleManager().findUserRoleTypes(user2.getName(), null).size());
+ assertEquals(0, session.getRoleManager().findUserRoleTypes(user2.getId(), null).size());
Modified: idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/Group.java
===================================================================
--- idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/Group.java 2009-03-19 12:54:42 UTC (rev 382)
+++ idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/Group.java 2009-03-19 13:23:38 UTC (rev 383)
@@ -25,7 +25,10 @@
package org.jboss.identity.idm.api;
/**
- * Represents a Group
+ * Represents a Group. Group has a name that is unique in scope of a given group type. This means that groupType/name pairs
+ * uniquely identifies group. Group Id contains encoded group type and name imformation. In default implementation
+ * it can look as follows: "group://GROUP_TYPE/GROUP_NAME". Still prefix and format of Id can change in the future so
+ * PersistenceManager.createGroupId(String groupName, String groupType) method should be used to create it.
*
* @author Anil.Saldhana(a)redhat.com
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
@@ -35,9 +38,9 @@
{
/**
- * @return id of this Group. Should be in format "groupType/groupName"
+ * @return the name of the Group
*/
- String getId();
+ String getName();
/**
* @return group type name
Modified: idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/IdentityType.java
===================================================================
--- idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/IdentityType.java 2009-03-19 12:54:42 UTC (rev 382)
+++ idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/IdentityType.java 2009-03-19 13:23:38 UTC (rev 383)
@@ -35,8 +35,8 @@
{
/**
- * @return the name of the IdentityType
+ * @return the id of the IdentityType
*/
- String getName();
+ String getId();
}
\ No newline at end of file
Modified: idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/User.java
===================================================================
--- idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/User.java 2009-03-19 12:54:42 UTC (rev 382)
+++ idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/User.java 2009-03-19 13:23:38 UTC (rev 383)
@@ -22,7 +22,7 @@
package org.jboss.identity.idm.api;
/**
- * Represents an Identity
+ * Represents an User. User has unique id.
*
* @author Anil.Saldhana(a)redhat.com
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
@@ -30,5 +30,6 @@
*/
public interface User extends IdentityType
{
+
}
\ No newline at end of file
15 years, 9 months
JBoss Identity SVN: r382 - in idm/trunk: idm/src/main/java/org/jboss/identity/idm/impl/repository and 3 other directories.
by jboss-identity-commits@lists.jboss.org
Author: bdaw
Date: 2009-03-19 08:54:42 -0400 (Thu, 19 Mar 2009)
New Revision: 382
Modified:
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RelationshipManager.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AttributesManagerImpl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RoleManagerImpl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/FallbackIdentityStoreRepository.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestCase.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RelationshipManagerTest.java
idm/trunk/idm/src/test/resources/organization-test-config.xml
Log:
- few more new API methods, test cases and bug fixes...
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AttributesManagerImpl.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AttributesManagerImpl.java 2009-03-18 21:22:32 UTC (rev 381)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AttributesManagerImpl.java 2009-03-19 12:54:42 UTC (rev 382)
@@ -59,6 +59,9 @@
public AttributeDescription getAttributeDescription(IdentityType identityType, String name)
{
+ checkNotNullArgument(identityType, "IdentityType");
+ checkNotNullArgument(name, "Attribute name");
+
Map<String, IdentityObjectAttributeMetaData> mdMap =
getRepository().getAttributesMetaData(getInvocationContext(), createIdentityObject(identityType).getIdentityType());
@@ -81,6 +84,9 @@
public AttributeDescription getAttributeDescription(String id, String attributeName)
{
+ checkNotNullArgument(id, "IdentityType Id");
+ checkNotNullArgument(attributeName, "Attribute name");
+
IdentityType identityType = createIdentityTypeFromId(id);
return getAttributeDescription(identityType, attributeName);
@@ -90,6 +96,8 @@
public Map<String, AttributeDescription> getSupportedAttributesDescriptions(IdentityType identityType)
{
+ checkNotNullArgument(identityType, "IdentityType");
+
Map<String, IdentityObjectAttributeMetaData> mdMap =
getRepository().getAttributesMetaData(getInvocationContext(), createIdentityObject(identityType).getIdentityType());
@@ -115,6 +123,8 @@
public Map<String, AttributeDescription> getSupportedAttributesDescriptions(String id)
{
+ checkNotNullArgument(id, "Id (Group) or name (User)");
+
IdentityType identityType = createIdentityTypeFromId(id);
return getSupportedAttributesDescriptions(identityType);
@@ -122,11 +132,15 @@
public Set<String> getSupportedAttributeNames(IdentityType identityType) throws IdentityException
{
+ checkNotNullArgument(identityType, "IdentityType");
+
return getRepository().getSupportedAttributeNames(getInvocationContext(), createIdentityObject(identityType).getIdentityType());
}
public Set<String> getSupportedAttributeNames(String id) throws IdentityException
{
+ checkNotNullArgument(id, "Id (Group) or name (User)");
+
IdentityType identityType = createIdentityTypeFromId(id);
return getSupportedAttributeNames(identityType);
@@ -134,6 +148,8 @@
public Map<String, Attribute> getAttributes(IdentityType identity) throws IdentityException
{
+ checkNotNullArgument(identity, "IdentityType");
+
Map<String, IdentityObjectAttribute> map = getRepository().getAttributes(getInvocationContext(), createIdentityObject(identity));
Map<String, Attribute> newMap = new HashMap<String, Attribute>();
@@ -147,6 +163,10 @@
public Map<String, Attribute> getAttributes(String id) throws IdentityException
{
+
+ checkNotNullArgument(id, "Id (Group) or name (User)");
+
+
IdentityType identityType = createIdentityTypeFromId(id);
return getAttributes(identityType);
@@ -154,12 +174,18 @@
public void updateAttributes(IdentityType identity, Attribute[] attributes) throws IdentityException
{
+ checkNotNullArgument(identity, "IdentityType");
+ checkNotNullArgument(attributes, "Attributes");
+
getRepository().updateAttributes(getInvocationContext(), createIdentityObject(identity), convertAttributes(attributes));
}
public void updateAttributes(String id, Attribute[] attributes) throws IdentityException
{
+ checkNotNullArgument(id, "Id (Group) or name (User)");
+ checkNotNullArgument(attributes, "Attributes");
+
IdentityType identityType = createIdentityTypeFromId(id);
updateAttributes(identityType, attributes);
@@ -168,11 +194,17 @@
public Attribute getAttribute(IdentityType identity, String attributeName) throws IdentityException
{
+ checkNotNullArgument(identity, "IdentityType");
+ checkNotNullArgument(attributeName, "Attribute name");
+
return getAttributes(identity).get(attributeName);
}
public Attribute getAttribute(String id, String attributeName) throws IdentityException
{
+ checkNotNullArgument(id, "Id (Group) or name (User)");
+ checkNotNullArgument(attributeName, "Attribute name");
+
IdentityType identityType = createIdentityTypeFromId(id);
return getAttribute(identityType, attributeName);
@@ -180,6 +212,10 @@
public void addAttribute(IdentityType identity, String attributeName, Object[] values) throws IdentityException
{
+ checkNotNullArgument(identity, "IdentityType");
+ checkNotNullArgument(attributeName, "Attribute name");
+ checkNotNullArgument(values, "Attribute values");
+
Attribute[] attrs = new Attribute[]{new SimpleAttribute(attributeName, values)};
addAttributes(identity, attrs);
@@ -187,6 +223,9 @@
public void addAttributes(String id, Attribute[] attributes) throws IdentityException
{
+ checkNotNullArgument(id, "Id (Group) or name (User)");
+ checkNotNullArgument(attributes, "Attributes");
+
IdentityType identityType = createIdentityTypeFromId(id);
addAttributes(identityType, attributes);
@@ -195,6 +234,10 @@
public void addAttribute(IdentityType identity, String attributeName, Object value) throws IdentityException
{
+ checkNotNullArgument(identity, "IdentityType");
+ checkNotNullArgument(attributeName, "Attribute name");
+ checkNotNullArgument(value, "Attribute value");
+
Attribute[] attrs = new Attribute[]{new SimpleAttribute(attributeName, value)};
@@ -204,6 +247,10 @@
public void addAttribute(String id, String attributeName, Object[] values) throws IdentityException
{
+ checkNotNullArgument(id, "Id (Group) or name (User)");
+ checkNotNullArgument(attributeName, "Attribute name");
+ checkNotNullArgument(values, "Attribute values");
+
IdentityType identityType = createIdentityTypeFromId(id);
addAttribute(identityType, attributeName, values);
@@ -212,6 +259,10 @@
public void addAttribute(String id, String attributeName, Object value) throws IdentityException
{
+ checkNotNullArgument(id, "Id (Group) or name (User)");
+ checkNotNullArgument(attributeName, "Attribute name");
+ checkNotNullArgument(value, "Attribute value");
+
IdentityType identityType = createIdentityTypeFromId(id);
addAttribute(identityType, attributeName, value);
@@ -220,6 +271,8 @@
public void addAttributes(IdentityType identity, Attribute[] attributes) throws IdentityException
{
+ checkNotNullArgument(identity, "IdentityType");
+ checkNotNullArgument(attributes, "Attributes");
getRepository().addAttributes(getInvocationContext(), createIdentityObject(identity), convertAttributes(attributes));
}
@@ -227,11 +280,16 @@
public void removeAttributes(IdentityType identity, String[] attributeNames) throws IdentityException
{
+ checkNotNullArgument(identity, "IdentityType");
+ checkNotNullArgument(attributeNames, "Attribute names");
getRepository().removeAttributes(getInvocationContext(), createIdentityObject(identity), attributeNames);
}
public void removeAttributes(String id, String[] attributeNames) throws IdentityException
{
+ checkNotNullArgument(id, "Id (Group) or name (User)");
+ checkNotNullArgument(attributeNames, "Attribute names");
+
IdentityType identityType = createIdentityTypeFromId(id);
removeAttributes(identityType, attributeNames);
@@ -240,26 +298,36 @@
public boolean hasPassword(User identity) throws IdentityException
{
+ checkNotNullArgument(identity, "User");
return getRepository().getSupportedFeatures().isCredentialSupported(createIdentityObject(identity).getIdentityType(), PasswordCredential.TYPE);
}
public boolean validatePassword(User identity, String password) throws IdentityException
{
+ checkNotNullArgument(identity, "User");
+ checkNotNullArgument(password, "Password");
return getRepository().validateCredential(getInvocationContext(), createIdentityObject(identity), new PasswordCredential(password));
}
public void updatePassword(User identity, String password) throws IdentityException
{
+ checkNotNullArgument(identity, "User");
+ checkNotNullArgument(password, "Password");
getRepository().updateCredential(getInvocationContext(), createIdentityObject(identity), new PasswordCredential(password));
}
public boolean hasCredential(User identity, CredentialType credentialType) throws IdentityException
{
+ checkNotNullArgument(identity, "User");
+ checkNotNullArgument(credentialType, "CredentialType");
+
return getRepository().getSupportedFeatures().isCredentialSupported(createIdentityObject(identity).getIdentityType(), new SimpleCredentialType(credentialType.getName()));
}
public boolean validateCredentials(User identity, Credential[] credentials) throws IdentityException
{
+ checkNotNullArgument(identity, "User");
+ checkNotNullArgument(credentials, "Credentials");
for (Credential credential : credentials)
{
@@ -285,6 +353,9 @@
public void updateCredential(User identity, Credential credential) throws IdentityException
{
+ checkNotNullArgument(identity, "User");
+ checkNotNullArgument(credential, "Credential");
+
if (credential instanceof IdentityObjectCredential)
{
getRepository().updateCredential(getInvocationContext(), createIdentityObject(identity), (IdentityObjectCredential)credential);
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java 2009-03-18 21:22:32 UTC (rev 381)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java 2009-03-19 12:54:42 UTC (rev 382)
@@ -44,6 +44,7 @@
import java.util.LinkedList;
import java.util.Set;
import java.util.HashSet;
+import java.util.Arrays;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
@@ -170,6 +171,14 @@
}
}
+ public void associateGroups(Group parent, Collection<Group> members) throws IdentityException
+ {
+ checkNotNullArgument(parent, "parent");
+ checkNotNullArgument(members, "members");
+
+ associateGroups(Arrays.asList(parent), members);
+ }
+
public void associateGroupsByIds(Collection<String> parentIds, Collection<String> memberIds) throws IdentityException
{
checkNotNullArgument(parentIds, "Parents Ids");
@@ -188,6 +197,13 @@
}
}
+ public void associateGroupsByIds(String parentId, Collection<String> memberIds) throws IdentityException
+ {
+ checkNotNullArgument(parentId, "Parent Id");
+
+ associateGroupsByIds(Arrays.asList(parentId), memberIds);
+ }
+
public void associateGroups(Group parent, Group member) throws IdentityException
{
checkNotNullArgument(parent, "Parent group");
@@ -223,6 +239,14 @@
}
}
+ public void associateUsers(Group parent, Collection<User> members) throws IdentityException
+ {
+ checkNotNullArgument(parent, "Parent group");
+
+ associateUsers(Arrays.asList(parent), members);
+
+ }
+
public void associateUsersByIds(Collection<String> parents, Collection<String> members) throws IdentityException
{
@@ -243,6 +267,14 @@
}
+ public void associateUsersByIds(String parentId, Collection<String> members) throws IdentityException
+ {
+ checkNotNullArgument(parentId, "Parent Id");
+
+ associateUsersByIds(Arrays.asList(parentId), members);
+
+ }
+
public void associateUsers(Group parent, User member) throws IdentityException
{
checkNotNullArgument(parent, "Parent group");
@@ -279,6 +311,13 @@
}
}
+ public void disassociateGroups(Group parent, Collection<Group> members) throws IdentityException
+ {
+ checkNotNullArgument(parent, "Parent");
+
+ disassociateGroups(Arrays.asList(parent), members);
+ }
+
public void disassociateGroupsByIds(Collection<String> parents, Collection<String> members) throws IdentityException
{
checkNotNullArgument(parents, "parents");
@@ -297,6 +336,13 @@
}
}
+ public void disassociateGroupsByIds(String parent, Collection<String> members) throws IdentityException
+ {
+ checkNotNullArgument(parent, "Parent Id");
+
+ disassociateGroupsByIds(Arrays.asList(parent), members);
+ }
+
public void disassociateUsers(Collection<Group> parents, Collection<User> members) throws IdentityException
{
checkNotNullArgument(parents, "parents");
@@ -316,6 +362,13 @@
}
+ public void disassociateUsers(Group parent, Collection<User> members) throws IdentityException
+ {
+ checkNotNullArgument(parent, "Parent group");
+
+ disassociateUsers(Arrays.asList(parent), members);
+ }
+
public void disassociateUsersByIds(Collection<String> parents, Collection<String> members) throws IdentityException
{
checkNotNullArgument(parents, "parents");
@@ -335,6 +388,14 @@
}
}
+ public void disassociateUsersByIds(String parent, Collection<String> members) throws IdentityException
+ {
+ checkNotNullArgument(parent, "Parent Id");
+
+ disassociateUsersByIds(Arrays.asList(parent), members);
+
+ }
+
public <G extends IdentityType, I extends IdentityType> boolean isAssociated(Collection<G> parents, Collection<I> members) throws IdentityException
{
//TODO: maybe IdentityStore should have isRelationshipPresent method to improve this?
@@ -420,12 +481,13 @@
public Collection<Group> findAssociatedGroups(Group group, String groupType, boolean parent, boolean inherited, IdentitySearchControl[] controls) throws IdentityException
{
+
checkNotNullArgument(group, "Group");
- checkNotNullArgument(groupType, "Group type");
+// checkNotNullArgument(groupType, "Group type");
List<Group> identities = new LinkedList<Group>();
- IdentityObjectType iot = getIdentityObjectType(groupType);
+ IdentityObjectType iot = groupType != null ? getIdentityObjectType(groupType) : null;
//TODO Handle inherited
if (inherited)
@@ -437,7 +499,7 @@
for (IdentityObject io : ios)
{
- if (io.getIdentityType().getName().equals(iot.getName()))
+ if (iot == null || io.getIdentityType().getName().equals(iot.getName()))
{
identities.add(createGroup(io));
}
@@ -450,7 +512,7 @@
public Collection<Group> findAssociatedGroups(String groupId, String groupType, boolean parent, boolean inherited, IdentitySearchControl[] controls) throws IdentityException
{
checkNotNullArgument(groupId, "Group Id");
- checkNotNullArgument(groupType, "Group type");
+// checkNotNullArgument(groupType, "Group type");
Group group = createGroupFromId(groupId);
@@ -460,7 +522,7 @@
public Collection<Group> findAssociatedGroups(Group group, String groupType, boolean parent, boolean inherited) throws IdentityException
{
checkNotNullArgument(group, "Group");
- checkNotNullArgument(groupType, "Group type");
+// checkNotNullArgument(groupType, "Group type");
return findAssociatedGroups(group, groupType, parent, inherited, null);
}
@@ -468,17 +530,17 @@
public Collection<Group> findAssociatedGroups(User identity, String groupType, IdentitySearchControl[] controls) throws IdentityException
{
checkNotNullArgument(identity, "User");
- checkNotNullArgument(groupType, "Group type");
+ //checkNotNullArgument(groupType, "Group type");
List<Group> identities = new LinkedList<Group>();
- IdentityObjectType iot = getIdentityObjectType(groupType);
+ IdentityObjectType iot = groupType != null ? getIdentityObjectType(groupType) : null;
Collection<IdentityObject> ios = getRepository().findIdentityObject(getInvocationContext(), createIdentityObject(identity), MEMBER, false, convertSearchControls(controls));
for (IdentityObject io : ios)
{
- if (io.getIdentityType().getName().equals(iot.getName()))
+ if (iot == null || io.getIdentityType().getName().equals(iot.getName()))
{
identities.add(createGroup(io));
}
@@ -490,7 +552,7 @@
public Collection<Group> findAssociatedGroups(String userName, String groupType, IdentitySearchControl[] controls) throws IdentityException
{
checkNotNullArgument(userName, "User name");
- checkNotNullArgument(groupType, "Group type");
+ //checkNotNullArgument(groupType, "Group type");
User user = createUserFromId(userName);
@@ -500,7 +562,7 @@
public Collection<Group> findAssociatedGroups(User identity, String groupType) throws IdentityException
{
checkNotNullArgument(identity, "User");
- checkNotNullArgument(groupType, "Group type");
+ //checkNotNullArgument(groupType, "Group type");
return findAssociatedGroups(identity, groupType, null);
}
@@ -513,8 +575,14 @@
Collection<IdentityObject> ios = getRepository().findIdentityObject(getInvocationContext(), createIdentityObject(identity), MEMBER, false, convertSearchControls(controls));
+
+ String userTypeName = getUserObjectType().getName();
+
for (IdentityObject io : ios)
{
+
+ // Filter out users
+ if (!io.getIdentityType().getName().equals(userTypeName))
identities.add(createGroup(io));
}
@@ -555,6 +623,7 @@
for (IdentityObject io : ios)
{
+ //Filter out groups
if (io.getIdentityType().getName().equals(userTypeName))
{
identities.add(createUser(io));
@@ -580,5 +649,68 @@
return findAssociatedUsers(group, inherited, null);
}
-
+ public Collection<Group> findRelatedGroups(User user, String groupType, IdentitySearchControl[] controls) throws IdentityException
+ {
+ checkNotNullArgument(user, "User");
+
+ List<Group> identities = new LinkedList<Group>();
+
+ Collection<IdentityObject> ios = getRepository().findIdentityObject(getInvocationContext(), createIdentityObject(user), null, false, convertSearchControls(controls));
+
+
+ String userTypeName = getUserObjectType().getName();
+
+ for (IdentityObject io : ios)
+ {
+ // Filter out users
+ if (!io.getIdentityType().getName().equals(userTypeName))
+ identities.add(createGroup(io));
+ }
+
+ return identities;
+ }
+
+ public Collection<Group> findRelatedGroups(String userName, String groupType, IdentitySearchControl[] controls) throws IdentityException
+ {
+ checkNotNullArgument(userName, "User name");
+
+ User user = createUserFromId(userName);
+
+ return findRelatedGroups(user, groupType, controls);
+ }
+
+ public Collection<User> findRelatedUsers(Group group, IdentitySearchControl[] controls) throws IdentityException
+ {
+ checkNotNullArgument(group, "Group");
+
+ List<User> identities = new LinkedList<User>();
+
+ Collection<IdentityObject> ios = getRepository().findIdentityObject(getInvocationContext(), createIdentityObject(group), null, true, convertSearchControls(controls));
+
+ String userTypeName = getUserObjectType().getName();
+
+ for (IdentityObject io : ios)
+ {
+ if (io.getIdentityType().getName().equals(userTypeName))
+ {
+ User user = createUser(io);
+
+ if (!identities.contains(user))
+ {
+ identities.add(createUser(io));
+ }
+ }
+ }
+
+ return identities;
+ }
+
+ public Collection<User> findRelatedUsers(String groupId, IdentitySearchControl[] controls) throws IdentityException
+ {
+ checkNotNullArgument(groupId, "Group Id");
+
+ Group group = createGroupFromId(groupId);
+
+ return findRelatedUsers(group, controls);
+ }
}
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RoleManagerImpl.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RoleManagerImpl.java 2009-03-18 21:22:32 UTC (rev 381)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RoleManagerImpl.java 2009-03-19 12:54:42 UTC (rev 382)
@@ -191,10 +191,10 @@
//TODO: add createRoleType switch to the API
- IdentityObjectRelationship rel = getRepository().createRelationship(getInvocationContext(), createIdentityObject(identity), createIdentityObject(group), ROLE, roleType.getName(), false);
+ IdentityObjectRelationship rel = getRepository().createRelationship(getInvocationContext(), createIdentityObject(group), createIdentityObject(identity), ROLE, roleType.getName(), false);
//TODO: null id - IdentityObjectRelationship doesn't have id
- return new SimpleRole(new SimpleRoleType(rel.getName()), createUser(rel.getFromIdentityObject()), createGroup(rel.getToIdentityObject()));
+ return new SimpleRole(new SimpleRoleType(rel.getName()), createUser(rel.getToIdentityObject()), createGroup(rel.getFromIdentityObject()));
}
@@ -216,7 +216,7 @@
checkNotNullArgument(identity, "User");
checkNotNullArgument(group, "Group");
- getRepository().removeRelationship(getInvocationContext(), createIdentityObject(identity), createIdentityObject(group), ROLE, roleType.getName());
+ getRepository().removeRelationship(getInvocationContext(), createIdentityObject(group), createIdentityObject(identity), ROLE, roleType.getName());
}
public void removeRole(String roleTypeName, String userName, String groupId) throws IdentityException
@@ -235,7 +235,7 @@
{
checkNotNullArgument(role, "Role");
- getRepository().removeRelationship(getInvocationContext(), createIdentityObject(role.getIdentity()), createIdentityObject(role.getGroup()), ROLE, role.getRoleType().getName());
+ getRepository().removeRelationship(getInvocationContext(), createIdentityObject(role.getGroup()), createIdentityObject(role.getIdentity()), ROLE, role.getRoleType().getName());
}
public boolean hasRole(User identity, Group group, RoleType roleType) throws IdentityException
@@ -246,7 +246,7 @@
//TODO: does separate hasRelationship method in IdentityStore makes sense?
- Set<IdentityObjectRelationship> rels = getRepository().resolveRelationships(getInvocationContext(), createIdentityObject(identity), createIdentityObject(group), ROLE);
+ Set<IdentityObjectRelationship> rels = getRepository().resolveRelationships(getInvocationContext(), createIdentityObject(group), createIdentityObject(identity), ROLE);
for (IdentityObjectRelationship rel : rels)
{
@@ -285,7 +285,7 @@
checkNotNullArgument(identity, "User");
checkNotNullArgument(group, "Group");
- Set<IdentityObjectRelationship> rels = getRepository().resolveRelationships(getInvocationContext(), createIdentityObject(identity), createIdentityObject(group), ROLE);
+ Set<IdentityObjectRelationship> rels = getRepository().resolveRelationships(getInvocationContext(), createIdentityObject(group), createIdentityObject(identity), ROLE);
Set<RoleType> types = new HashSet<RoleType>();
for (IdentityObjectRelationship rel : rels)
@@ -400,7 +400,7 @@
Collection<IdentityObject> ios = null;
- ios = getRepository().findIdentityObject(getInvocationContext(), createIdentityObject(identity), ROLE, true, convertSearchControls(controls));
+ ios = getRepository().findIdentityObject(getInvocationContext(), createIdentityObject(identity), ROLE, false, convertSearchControls(controls));
for (IdentityObject io : ios)
{
@@ -431,7 +431,7 @@
Collection<IdentityObject> ios = null;
- ios = getRepository().findIdentityObject(getInvocationContext(), createIdentityObject(identity), ROLE, true, convertSearchControls(controls));
+ ios = getRepository().findIdentityObject(getInvocationContext(), createIdentityObject(identity), ROLE, false, convertSearchControls(controls));
for (IdentityObject io : ios)
{
@@ -467,19 +467,19 @@
// If Identity then search for parent relationships
if (identityType instanceof User)
{
- relationships = getRepository().resolveRelationships(getInvocationContext(), createIdentityObject(identityType), ROLE, true, true, null);
+ relationships = getRepository().resolveRelationships(getInvocationContext(), createIdentityObject(identityType), ROLE, false, true, null);
}
// If Group then search for child relationships
else
{
- relationships = getRepository().resolveRelationships(getInvocationContext(), createIdentityObject(identityType), ROLE, false, true, null);
+ relationships = getRepository().resolveRelationships(getInvocationContext(), createIdentityObject(identityType), ROLE, true, true, null);
}
for (IdentityObjectRelationship relationship : relationships)
{
if (roleType.getName().equals(relationship.getName()))
{
- roles.add(new SimpleRole(new SimpleRoleType(relationship.getName()), createUser(relationship.getFromIdentityObject()), createGroup(relationship.getToIdentityObject())));
+ roles.add(new SimpleRole(new SimpleRoleType(relationship.getName()), createUser(relationship.getToIdentityObject()), createGroup(relationship.getFromIdentityObject())));
}
}
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/FallbackIdentityStoreRepository.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/FallbackIdentityStoreRepository.java 2009-03-18 21:22:32 UTC (rev 381)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/FallbackIdentityStoreRepository.java 2009-03-19 12:54:42 UTC (rev 382)
@@ -58,6 +58,7 @@
import java.util.Comparator;
import java.util.Arrays;
import java.util.ArrayList;
+import java.util.LinkedHashSet;
/**
* <p>In FallbackIdentityStoreRepository one IdentityStore plays the role of default store. Any operation that cannot be
@@ -441,7 +442,7 @@
Collection<IdentityObject> results = new LinkedList<IdentityObject>();
- if (!RoleManagerImpl.ROLE.getName().equals(relationshipType.getName()) ||
+ if (relationshipType == null || !RoleManagerImpl.ROLE.getName().equals(relationshipType.getName()) ||
mappedStore.getSupportedFeatures().isNamedRelationshipsSupported())
{
results = mappedStore.findIdentityObject(mappedCtx, identity, relationshipType, parent, controls);
@@ -484,15 +485,16 @@
// If default store contain related relationships merge and sort/page once more
if (objects != null && objects.size() != 0)
{
+
results.addAll(objects);
- //TODO: hardcoded List
+ //TODO: hardcoded - expects List
if (pageSearchControl != null && results instanceof List)
{
results = cutPageFromResults((List<IdentityObject>)results, pageSearchControl);
}
- //TODO: hardcoded List
+ //TODO: hardcoded - expects List
if (sortSearchControl != null && results instanceof List)
{
sortByName((List<IdentityObject>)results, sortSearchControl.isAscending());
Modified: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestCase.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestCase.java 2009-03-18 21:22:32 UTC (rev 381)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestCase.java 2009-03-19 12:54:42 UTC (rev 382)
@@ -102,6 +102,25 @@
relationshipManagerTest.testMethods("realm://RedHat/DB_LDAP");
}
+ public void testDBRelationshipManagerMergedRoleAssociations() throws Exception
+ {
+ identitySessionFactory = new IdentityConfigurationImpl().
+ configure(new File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
+
+ relationshipManagerTest.testMergedRoleAssociations("realm://RedHat/DB");
+ }
+
+ public void testLDAPMixedRelationshipManagerMergedRoleAssociations() throws Exception
+ {
+ populateClean();
+
+ identitySessionFactory = new IdentityConfigurationImpl().
+ configure(new File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
+
+
+ relationshipManagerTest.testMergedRoleAssociations("realm://RedHat/DB_LDAP");
+ }
+
public void testDBRoleManager() throws Exception
{
identitySessionFactory = new IdentityConfigurationImpl().
Modified: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RelationshipManagerTest.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RelationshipManagerTest.java 2009-03-18 21:22:32 UTC (rev 381)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RelationshipManagerTest.java 2009-03-19 12:54:42 UTC (rev 382)
@@ -253,6 +253,7 @@
// Find groups
// #1
+ assertEquals(3, session.getRelationshipManager().findAssociatedGroups(group2, null, true, false).size());
assertEquals(2, session.getRelationshipManager().findAssociatedGroups(group2, DEPARTMENT, true, false).size());
assertEquals(1, session.getRelationshipManager().findAssociatedGroups(group2, ORGANIZATION_UNIT, true, false).size());
assertEquals(0, session.getRelationshipManager().findAssociatedGroups(group2, ORGANIZATION, true, false).size());
@@ -266,6 +267,7 @@
assertEquals(1, session.getRelationshipManager().findAssociatedGroups(group3, ORGANIZATION_UNIT, false, false).size());
assertEquals(1, session.getRelationshipManager().findAssociatedGroups(group4, ORGANIZATION_UNIT, false, false).size());
assertEquals(0, session.getRelationshipManager().findAssociatedGroups(group2, ORGANIZATION, false, false).size());
+ assertEquals(3, session.getRelationshipManager().findAssociatedGroups(group2, null, true, false).size());
// #4
assertEquals(1, session.getRelationshipManager().findAssociatedGroups(group3.getId(), ORGANIZATION_UNIT, false, false, null).size());
@@ -287,6 +289,7 @@
// #7
assertEquals(1, session.getRelationshipManager().findAssociatedGroups(user1, ORGANIZATION).size());
assertEquals(0, session.getRelationshipManager().findAssociatedGroups(user1, ORGANIZATION_UNIT).size());
+ assertEquals(2, session.getRelationshipManager().findAssociatedGroups(user2, (String)null).size());
assertEquals(1, session.getRelationshipManager().findAssociatedGroups(user2, ORGANIZATION).size());
assertEquals(1, session.getRelationshipManager().findAssociatedGroups(user2, ORGANIZATION_UNIT).size());
assertEquals(1, session.getRelationshipManager().findAssociatedGroups(user3, ORGANIZATION).size());
@@ -317,6 +320,59 @@
}
+ public void testMergedRoleAssociations(String realmName) throws Exception
+ {
+ IdentitySessionFactory factory = ctx.getIdentitySessionFactory();
+ IdentitySession session = factory.createIdentitySession(realmName);
+ session.getTransaction().start();
+
+ // Create stuff
+ User user1 = session.getPersistenceManager().createUser("user1");
+ User user2 = session.getPersistenceManager().createUser("user2");
+ User user3 = session.getPersistenceManager().createUser("user3");
+ User user4 = session.getPersistenceManager().createUser("user4");
+
+ Group group1 = session.getPersistenceManager().createGroup("group1", ORGANIZATION);
+ Group group2 = session.getPersistenceManager().createGroup("group2", ORGANIZATION_UNIT);
+ Group group3 = session.getPersistenceManager().createGroup("group3", ORGANIZATION_UNIT);
+ Group group4 = session.getPersistenceManager().createGroup("group4", DEPARTMENT);
+ Group group5 = session.getPersistenceManager().createGroup("group5", DEPARTMENT);
+
+ // Associate
+
+ session.getRelationshipManager().associateGroups(group1, group2);
+ session.getRelationshipManager().associateGroups(group1, group3);
+ session.getRelationshipManager().associateUsers(group1, user1);
+ session.getRelationshipManager().associateUsers(group1, user2);
+
+ session.getRoleManager().createRoleType("rt1");
+ session.getRoleManager().createRoleType("rt2");
+
+ session.getRoleManager().createRole("rt1", user1.getName(), group1.getId());
+ session.getRoleManager().createRole("rt1", user3.getName(), group1.getId());
+ session.getRoleManager().createRole("rt1", user4.getName(), group1.getId());
+ session.getRoleManager().createRole("rt2", user3.getName(), group1.getId());
+
+ session.getRoleManager().createRole("rt1", user3.getName(), group2.getId());
+ session.getRoleManager().createRole("rt2", user2.getName(), group3.getId());
+
+ // Assert
+
+ assertEquals(2, session.getRelationshipManager().findAssociatedUsers(group1, false, null).size());
+ assertEquals(4, session.getRelationshipManager().findRelatedUsers(group1, null).size());
+
+ assertEquals(0, session.getRelationshipManager().findAssociatedUsers(group2, false, null).size());
+ assertEquals(1, session.getRelationshipManager().findRelatedUsers(group2, null).size());
+
+ assertEquals(0, session.getRelationshipManager().findAssociatedGroups(user3, (IdentitySearchControl[])null).size());
+ assertEquals(2, session.getRelationshipManager().findRelatedGroups(user3, null, null).size());
+
+ assertEquals(1, session.getRelationshipManager().findAssociatedGroups(user2, (IdentitySearchControl[])null).size());
+ assertEquals(2, session.getRelationshipManager().findRelatedGroups(user2, null, null).size());
+
+ session.getTransaction().commit();
+
+ }
}
\ No newline at end of file
Modified: idm/trunk/idm/src/test/resources/organization-test-config.xml
===================================================================
--- idm/trunk/idm/src/test/resources/organization-test-config.xml 2009-03-18 21:22:32 UTC (rev 381)
+++ idm/trunk/idm/src/test/resources/organization-test-config.xml 2009-03-19 12:54:42 UTC (rev 382)
@@ -165,34 +165,34 @@
<identity-object-type>
<name>USER</name>
<relationships>
- <relationship>
- <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
- <identity-object-type-ref>ORGANIZATION</identity-object-type-ref>
- </relationship>
- <relationship>
- <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
- <identity-object-type-ref>COMMUNITY</identity-object-type-ref>
- </relationship>
- <relationship>
- <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
- <identity-object-type-ref>OFFICE</identity-object-type-ref>
- </relationship>
- <relationship>
- <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
- <identity-object-type-ref>SECURITY</identity-object-type-ref>
- </relationship>
- <relationship>
- <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
- <identity-object-type-ref>ORGANIZATION_UNIT</identity-object-type-ref>
- </relationship>
- <relationship>
- <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
- <identity-object-type-ref>PROJECT</identity-object-type-ref>
- </relationship>
- <relationship>
- <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
- <identity-object-type-ref>PEOPLE</identity-object-type-ref>
- </relationship>
+ <!--<relationship>-->
+ <!--<relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>-->
+ <!--<identity-object-type-ref>ORGANIZATION</identity-object-type-ref>-->
+ <!--</relationship>-->
+ <!--<relationship>-->
+ <!--<relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>-->
+ <!--<identity-object-type-ref>COMMUNITY</identity-object-type-ref>-->
+ <!--</relationship>-->
+ <!--<relationship>-->
+ <!--<relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>-->
+ <!--<identity-object-type-ref>OFFICE</identity-object-type-ref>-->
+ <!--</relationship>-->
+ <!--<relationship>-->
+ <!--<relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>-->
+ <!--<identity-object-type-ref>SECURITY</identity-object-type-ref>-->
+ <!--</relationship>-->
+ <!--<relationship>-->
+ <!--<relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>-->
+ <!--<identity-object-type-ref>ORGANIZATION_UNIT</identity-object-type-ref>-->
+ <!--</relationship>-->
+ <!--<relationship>-->
+ <!--<relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>-->
+ <!--<identity-object-type-ref>PROJECT</identity-object-type-ref>-->
+ <!--</relationship>-->
+ <!--<relationship>-->
+ <!--<relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>-->
+ <!--<identity-object-type-ref>PEOPLE</identity-object-type-ref>-->
+ <!--</relationship>-->
</relationships>
<credentials>
<credential-type>PASSWORD</credential-type>
@@ -213,6 +213,10 @@
<name>ORGANIZATION</name>
<relationships>
<relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
<identity-object-type-ref>USER</identity-object-type-ref>
</relationship>
@@ -237,6 +241,10 @@
<name>ORGANIZATION_UNIT</name>
<relationships>
<relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
<identity-object-type-ref>USER</identity-object-type-ref>
</relationship>
@@ -273,6 +281,10 @@
<name>DIVISION</name>
<relationships>
<relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
<identity-object-type-ref>USER</identity-object-type-ref>
</relationship>
@@ -293,6 +305,10 @@
<name>DEPARTMENT</name>
<relationships>
<relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
<identity-object-type-ref>USER</identity-object-type-ref>
</relationship>
@@ -313,6 +329,10 @@
<name>PROJECT</name>
<relationships>
<relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
<identity-object-type-ref>USER</identity-object-type-ref>
</relationship>
@@ -325,6 +345,10 @@
<name>PEOPLE</name>
<relationships>
<relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
<identity-object-type-ref>USER</identity-object-type-ref>
</relationship>
@@ -337,6 +361,10 @@
<name>ADMINISTRATION</name>
<relationships>
<relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
<identity-object-type-ref>USER</identity-object-type-ref>
</relationship>
@@ -349,6 +377,10 @@
<name>COMMUNITY</name>
<relationships>
<relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
<identity-object-type-ref>USER</identity-object-type-ref>
</relationship>
@@ -361,6 +393,10 @@
<name>OFFICE</name>
<relationships>
<relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
<identity-object-type-ref>USER</identity-object-type-ref>
</relationship>
@@ -373,6 +409,10 @@
<name>SECURITY</name>
<relationships>
<relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
<identity-object-type-ref>USER</identity-object-type-ref>
</relationship>
@@ -385,6 +425,10 @@
<name>SYSTEM</name>
<relationships>
<relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
<identity-object-type-ref>USER</identity-object-type-ref>
</relationship>
Modified: idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java
===================================================================
--- idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java 2009-03-18 21:22:32 UTC (rev 381)
+++ idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java 2009-03-19 12:54:42 UTC (rev 382)
@@ -27,7 +27,7 @@
import java.util.Collection;
/**
- * Exposes all management operations on Group and Identity objects.
+ * Exposes all management operations on Group and User objects.
*
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
* @version : 0.1 $
@@ -50,7 +50,7 @@
// Create
/**
- * <p>Create an identity in the realm</p>
+ * <p>Create User object</p>
* @param userName
* @throws IdentityException
* @return
@@ -67,7 +67,7 @@
throws IdentityException;
/**
- * <p>Create a group Id</p>
+ * <p>Create a group Id. Result string can be used in other methods</p>
* @param groupName
* @param groupType
* @return
Modified: idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RelationshipManager.java
===================================================================
--- idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RelationshipManager.java 2009-03-18 21:22:32 UTC (rev 381)
+++ idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RelationshipManager.java 2009-03-19 12:54:42 UTC (rev 382)
@@ -58,6 +58,15 @@
/**
* <p>Associate groups</p>
+ * @param parent
+ * @param members
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ void associateGroups(Group parent, Collection<Group> members)
+ throws IdentityException;
+
+ /**
+ * <p>Associate groups</p>
* @param parentIds
* @param memberIds
* @throws org.jboss.identity.idm.exception.IdentityException
@@ -67,6 +76,15 @@
/**
* <p>Associate groups</p>
+ * @param parentId
+ * @param memberIds
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ void associateGroupsByIds(String parentId, Collection<String> memberIds)
+ throws IdentityException;
+
+ /**
+ * <p>Associate groups</p>
* @param parent
* @param member
* @throws org.jboss.identity.idm.exception.IdentityException
@@ -93,6 +111,15 @@
throws IdentityException;
/**
+ * <p>Associate identities to group</p>
+ * @param parent
+ * @param members
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ void associateUsers(Group parent, Collection<User> members)
+ throws IdentityException;
+
+ /**
* <p>Associate identities to groups</p>
* @param parents
* @param members
@@ -103,6 +130,15 @@
/**
* <p>Associate identities to groups</p>
+ * @param parentId
+ * @param members
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ void associateUsersByIds(String parentId, Collection<String> members)
+ throws IdentityException;
+
+ /**
+ * <p>Associate identities to groups</p>
* @param parents
* @param members
* @throws org.jboss.identity.idm.exception.IdentityException
@@ -130,6 +166,15 @@
/**
* <p>Disassociate groups</p>
+ * @param parent
+ * @param members
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ void disassociateGroups(Group parent, Collection<Group> members)
+ throws IdentityException;
+
+ /**
+ * <p>Disassociate groups</p>
* @param parents
* @param members
* @throws org.jboss.identity.idm.exception.IdentityException
@@ -138,6 +183,15 @@
throws IdentityException;
/**
+ * <p>Disassociate groups</p>
+ * @param parent
+ * @param members
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ void disassociateGroupsByIds(String parent, Collection<String> members)
+ throws IdentityException;
+
+ /**
* <p>Disassociate identities from groups</p>
* @param parents
* @param members
@@ -148,6 +202,15 @@
/**
* <p>Disassociate identities from groups</p>
+ * @param parent
+ * @param members
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ void disassociateUsers(Group parent, Collection<User> members)
+ throws IdentityException;
+
+ /**
+ * <p>Disassociate identities from groups</p>
* @param parents
* @param members
* @throws org.jboss.identity.idm.exception.IdentityException
@@ -156,6 +219,15 @@
throws IdentityException;
/**
+ * <p>Disassociate identities from groups</p>
+ * @param parent
+ * @param members
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ void disassociateUsersByIds(String parent, Collection<String> members)
+ throws IdentityException;
+
+ /**
* <p>Check if association is present </p>
* @param parents
* @param members
@@ -381,5 +453,60 @@
boolean inherited,
IdentitySearchControl[] controls) throws IdentityException;
+
+ /**
+ * Find all groups that given identity is associated with.
+ * If the paginatedSearch or orderedSearch operations
+ * are not supported, dedicated parameters will
+ * take no effect
+ *
+ * @param user child identity
+ * @param groupType can be null
+ * @return
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ Collection<Group> findRelatedGroups(User user,
+ String groupType,
+ IdentitySearchControl[] controls) throws IdentityException;
+
+ /**
+ * Find all groups that given identity is associated with.
+ * If the paginatedSearch or orderedSearch operations
+ * are not supported, dedicated parameters will
+ * take no effect
+ *
+ * @param userName child identity name
+ * @param groupType can be null
+ * @return
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ Collection<Group> findRelatedGroups(String userName,
+ String groupType,
+ IdentitySearchControl[] controls) throws IdentityException;
+
+ /**
+ * Find identities that have relationship with given parent group.
+ * If the paginatedSearch or orderedSearch operations
+ * are not supported in this store implementation, dedicated parameters will
+ * take no effect
+ *
+ * @param group parent group
+ * @return
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ Collection<User> findRelatedUsers(Group group, IdentitySearchControl[] controls) throws IdentityException;
+
+ /**
+ * Find identities that have relationship with given parent group.
+ * If the paginatedSearch or orderedSearch operations
+ * are not supported in this store implementation, dedicated parameters will
+ * take no effect
+ *
+ * @param groupId parent group id
+ * @return
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ Collection<User> findRelatedUsers(String groupId, IdentitySearchControl[] controls) throws IdentityException;
+
}
15 years, 9 months
JBoss Identity SVN: r381 - in idm/trunk: idm/src/test/java/org/jboss/identity/idm/impl/api and 1 other directories.
by jboss-identity-commits@lists.jboss.org
Author: bdaw
Date: 2009-03-18 17:22:32 -0400 (Wed, 18 Mar 2009)
New Revision: 381
Modified:
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AbstractManager.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/PersistenceManagerImpl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RoleManagerImpl.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/PersistenceManagerTest.java
Log:
dummy sanity checks
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AbstractManager.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AbstractManager.java 2009-03-18 20:27:31 UTC (rev 380)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AbstractManager.java 2009-03-18 21:22:32 UTC (rev 381)
@@ -267,5 +267,14 @@
}
}
+ protected void checkObjectName(String name)
+ {
+ //TODO: extract this, let to define broader set of constraints and apply also in the
+ //TODO: SPI to filter what comes fromdata stores
+ if (name.contains("/"))
+ {
+ throw new IllegalArgumentException("name cannot contain '/' character");
+ }
+ }
}
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/PersistenceManagerImpl.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/PersistenceManagerImpl.java 2009-03-18 20:27:31 UTC (rev 380)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/PersistenceManagerImpl.java 2009-03-18 21:22:32 UTC (rev 381)
@@ -126,6 +126,9 @@
public User createUser(String identityName) throws IdentityException
{
+ checkNotNullArgument(identityName, "Identity name");
+ checkObjectName(identityName);
+
IdentityObjectType iot = getUserObjectType();
IdentityObject identityObject = getRepository().createIdentityObject(getInvocationContext(), identityName, iot);
@@ -135,6 +138,11 @@
public Group createGroup(String groupName, String groupType) throws IdentityException
{
+ checkNotNullArgument(groupName, "Group name");
+ checkNotNullArgument(groupType, "Group type");
+ checkObjectName(groupName);
+ checkObjectName(groupType);
+
IdentityObjectType iot = getIdentityObjectType(groupType);
IdentityObject identityObject = getRepository().createIdentityObject(getInvocationContext(), groupName, iot);
@@ -144,21 +152,30 @@
public String createGroupId(String groupName, String groupType)
{
+ checkNotNullArgument(groupName, "Group name");
+ checkNotNullArgument(groupType, "Group type");
+ checkObjectName(groupName);
+ checkObjectName(groupType);
+
return new GroupId(groupName, groupType).getId();
}
- public void removeUser(User identity, boolean force) throws IdentityException
+ public void removeUser(User user, boolean force) throws IdentityException
{
- getRepository().removeIdentityObject(getInvocationContext(), createIdentityObject(identity));
+ checkNotNullArgument(user, "User");
+ getRepository().removeIdentityObject(getInvocationContext(), createIdentityObject(user));
}
public void removeUser(String userName, boolean force) throws IdentityException
{
+ checkNotNullArgument(userName, "User name");
getRepository().removeIdentityObject(getInvocationContext(), createIdentityObjectForUserName(userName));
}
public void removeGroup(Group group, boolean force) throws IdentityException
{
+ checkNotNullArgument(group, "Group");
+
//TODO: force
getRepository().removeIdentityObject(getInvocationContext(), createIdentityObject(group));
@@ -166,6 +183,8 @@
public void removeGroup(String groupId, boolean force) throws IdentityException
{
+ checkNotNullArgument(groupId, "Group Id");
+
//TODO: force
getRepository().removeIdentityObject(getInvocationContext(), createIdentityObjectForGroupId(groupId));
@@ -180,6 +199,8 @@
public int getGroupTypeCount(String groupType) throws IdentityException
{
+ checkNotNullArgument(groupType, "Group type");
+
IdentityObjectType iot = getIdentityObjectType(groupType);
return getRepository().getIdentityObjectsCount(getInvocationContext(), iot);
@@ -187,6 +208,8 @@
public User findUser(String name) throws IdentityException
{
+ checkNotNullArgument(name, "User name");
+
return createUser(getRepository().findIdentityObject(getInvocationContext(), name, getUserObjectType()));
}
@@ -208,16 +231,22 @@
public Group findGroup(String name, String groupType) throws IdentityException
{
+ checkNotNullArgument(name, "Group name");
+ checkNotNullArgument(groupType, "Group type");
+
return createGroup(getRepository().findIdentityObject(getInvocationContext(), name, getIdentityObjectType(groupType)));
}
public Group findGroupById(String id) throws IdentityException
{
+ checkNotNullArgument(id, "Group id");
return createGroup(getRepository().findIdentityObject(getInvocationContext(), id));
}
public Collection<Group> findGroup(String groupType, IdentitySearchControl[] controls) throws IdentityException
{
+ checkNotNullArgument(groupType, "Group type");
+
Collection<IdentityObject> ios = getRepository().findIdentityObject(getInvocationContext(), getIdentityObjectType(groupType), convertSearchControls(controls));
List<Group> groups = new LinkedList<Group>();
@@ -232,12 +261,14 @@
public Collection<Group> findGroup(String groupType) throws IdentityException
{
+ checkNotNullArgument(groupType, "Group type");
+
return findGroup(groupType, (IdentitySearchControl[]) null);
}
- public boolean isVirtual(User identity)
- {
- //TODO:NYI
- throw new NotYetImplementedException("Postponed");
- }
+// public boolean isVirtual(User identity)
+// {
+// //TODO:NYI
+// throw new NotYetImplementedException("Postponed");
+// }
}
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java 2009-03-18 20:27:31 UTC (rev 380)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java 2009-03-18 21:22:32 UTC (rev 381)
@@ -154,6 +154,9 @@
public void associateGroups(Collection<Group> parents, Collection<Group> members) throws IdentityException
{
+ checkNotNullArgument(parents, "parents");
+ checkNotNullArgument(members, "members");
+
for (Iterator<Group> parentsIterator = parents.iterator(); parentsIterator.hasNext();)
{
Group parent = parentsIterator.next();
@@ -169,6 +172,9 @@
public void associateGroupsByIds(Collection<String> parentIds, Collection<String> memberIds) throws IdentityException
{
+ checkNotNullArgument(parentIds, "Parents Ids");
+ checkNotNullArgument(memberIds, "Members Ids");
+
for (Iterator<String> parentsIterator = parentIds.iterator(); parentsIterator.hasNext();)
{
String parentId = parentsIterator.next();
@@ -184,17 +190,26 @@
public void associateGroups(Group parent, Group member) throws IdentityException
{
+ checkNotNullArgument(parent, "Parent group");
+ checkNotNullArgument(member, "Member group");
+
getRepository().createRelationship(getInvocationContext(), createIdentityObject(parent), createIdentityObject(member), MEMBER, null, true);
}
public void associateGroupsByIds(String parentId, String memberId) throws IdentityException
{
+ checkNotNullArgument(parentId, "Parent Id");
+ checkNotNullArgument(memberId, "Member Id");
+
getRepository().createRelationship(getInvocationContext(), createIdentityObjectForGroupId(parentId), createIdentityObjectForGroupId(memberId), MEMBER, null, true);
}
public void associateUsers(Collection<Group> parents, Collection<User> members) throws IdentityException
{
+ checkNotNullArgument(parents, "parents");
+ checkNotNullArgument(members, "members");
+
for (Iterator<Group> parentsIterator = parents.iterator(); parentsIterator.hasNext();)
{
Group parent = parentsIterator.next();
@@ -210,6 +225,10 @@
public void associateUsersByIds(Collection<String> parents, Collection<String> members) throws IdentityException
{
+
+ checkNotNullArgument(parents, "parents");
+ checkNotNullArgument(members, "members");
+
for (Iterator<String> parentsIterator = parents.iterator(); parentsIterator.hasNext();)
{
String parent = parentsIterator.next();
@@ -226,18 +245,27 @@
public void associateUsers(Group parent, User member) throws IdentityException
{
+ checkNotNullArgument(parent, "Parent group");
+ checkNotNullArgument(member, "Member user");
+
getRepository().createRelationship(getInvocationContext(), createIdentityObject(parent), createIdentityObject(member), MEMBER, null, true);
}
public void associateUsersByIds(String parentId, String memberId) throws IdentityException
{
+ checkNotNullArgument(parentId, "Parent group Id");
+ checkNotNullArgument(memberId, "Member user Id");
+
getRepository().createRelationship(getInvocationContext(), createIdentityObjectForGroupId(parentId), createIdentityObjectForUserName(memberId), MEMBER, null, true);
}
public void disassociateGroups(Collection<Group> parents, Collection<Group> members) throws IdentityException
{
+ checkNotNullArgument(parents, "parents");
+ checkNotNullArgument(members, "members");
+
for (Iterator<Group> parentsIterator = parents.iterator(); parentsIterator.hasNext();)
{
Group parent = parentsIterator.next();
@@ -253,6 +281,9 @@
public void disassociateGroupsByIds(Collection<String> parents, Collection<String> members) throws IdentityException
{
+ checkNotNullArgument(parents, "parents");
+ checkNotNullArgument(members, "members");
+
for (Iterator<String> parentsIterator = parents.iterator(); parentsIterator.hasNext();)
{
String parent = parentsIterator.next();
@@ -268,6 +299,9 @@
public void disassociateUsers(Collection<Group> parents, Collection<User> members) throws IdentityException
{
+ checkNotNullArgument(parents, "parents");
+ checkNotNullArgument(members, "members");
+
for (Iterator<Group> parentsIterator = parents.iterator(); parentsIterator.hasNext();)
{
Group parent = parentsIterator.next();
@@ -284,6 +318,10 @@
public void disassociateUsersByIds(Collection<String> parents, Collection<String> members) throws IdentityException
{
+ checkNotNullArgument(parents, "parents");
+ checkNotNullArgument(members, "members");
+
+
for (Iterator<String> parentsIterator = parents.iterator(); parentsIterator.hasNext();)
{
String parent = parentsIterator.next();
@@ -301,6 +339,10 @@
{
//TODO: maybe IdentityStore should have isRelationshipPresent method to improve this?
+ checkNotNullArgument(parents, "parents");
+ checkNotNullArgument(members, "members");
+
+
for (Iterator<G> parentsIterator = parents.iterator(); parentsIterator.hasNext();)
{
IdentityType parent = parentsIterator.next();
@@ -323,6 +365,10 @@
public boolean isAssociatedByIds(Collection<String> parents, Collection<String> members) throws IdentityException
{
+ checkNotNullArgument(parents, "parents");
+ checkNotNullArgument(members, "members");
+
+
for (Iterator<String> parentsIterator = parents.iterator(); parentsIterator.hasNext();)
{
String parent = parentsIterator.next();
@@ -344,6 +390,10 @@
public <G extends IdentityType, I extends IdentityType> boolean isAssociated(G parent, I member) throws IdentityException
{
+ checkNotNullArgument(parent, "Parent IdentityType");
+ checkNotNullArgument(member, "Member IdentityType");
+
+
Set<G> parents = new HashSet<G>();
parents.add(parent);
Set<I> members = new HashSet<I>();
@@ -354,6 +404,10 @@
public boolean isAssociatedByIds(String parent, String member) throws IdentityException
{
+ checkNotNullArgument(parent, "Parent Id");
+ checkNotNullArgument(member, "Member Id");
+
+
Collection<IdentityObjectRelationship> relationships = getRepository().resolveRelationships(getInvocationContext(), createIdentityObject(parent), createIdentityObject(member), MEMBER);
if (relationships.size() == 0)
@@ -366,6 +420,8 @@
public Collection<Group> findAssociatedGroups(Group group, String groupType, boolean parent, boolean inherited, IdentitySearchControl[] controls) throws IdentityException
{
+ checkNotNullArgument(group, "Group");
+ checkNotNullArgument(groupType, "Group type");
List<Group> identities = new LinkedList<Group>();
@@ -393,6 +449,9 @@
public Collection<Group> findAssociatedGroups(String groupId, String groupType, boolean parent, boolean inherited, IdentitySearchControl[] controls) throws IdentityException
{
+ checkNotNullArgument(groupId, "Group Id");
+ checkNotNullArgument(groupType, "Group type");
+
Group group = createGroupFromId(groupId);
return findAssociatedGroups(group, groupType, parent, inherited, controls);
@@ -400,11 +459,17 @@
public Collection<Group> findAssociatedGroups(Group group, String groupType, boolean parent, boolean inherited) throws IdentityException
{
+ checkNotNullArgument(group, "Group");
+ checkNotNullArgument(groupType, "Group type");
+
return findAssociatedGroups(group, groupType, parent, inherited, null);
}
public Collection<Group> findAssociatedGroups(User identity, String groupType, IdentitySearchControl[] controls) throws IdentityException
{
+ checkNotNullArgument(identity, "User");
+ checkNotNullArgument(groupType, "Group type");
+
List<Group> identities = new LinkedList<Group>();
IdentityObjectType iot = getIdentityObjectType(groupType);
@@ -424,6 +489,9 @@
public Collection<Group> findAssociatedGroups(String userName, String groupType, IdentitySearchControl[] controls) throws IdentityException
{
+ checkNotNullArgument(userName, "User name");
+ checkNotNullArgument(groupType, "Group type");
+
User user = createUserFromId(userName);
return findAssociatedGroups(user, groupType, controls);
@@ -431,11 +499,16 @@
public Collection<Group> findAssociatedGroups(User identity, String groupType) throws IdentityException
{
+ checkNotNullArgument(identity, "User");
+ checkNotNullArgument(groupType, "Group type");
+
return findAssociatedGroups(identity, groupType, null);
}
public Collection<Group> findAssociatedGroups(User identity, IdentitySearchControl[] controls) throws IdentityException
{
+ checkNotNullArgument(identity, "User");
+
List<Group> identities = new LinkedList<Group>();
Collection<IdentityObject> ios = getRepository().findIdentityObject(getInvocationContext(), createIdentityObject(identity), MEMBER, false, convertSearchControls(controls));
@@ -450,6 +523,8 @@
public Collection<Group> findAssociatedGroups(String userName, IdentitySearchControl[] controls) throws IdentityException
{
+ checkNotNullArgument(userName, "User name");
+
User user = createUserFromId(userName);
return findAssociatedGroups(user, controls);
@@ -457,11 +532,15 @@
public Collection<Group> findAssociatedGroups(User identity) throws IdentityException
{
+ checkNotNullArgument(identity, "User");
+
return findAssociatedGroups(identity, new IdentitySearchControl[] {});
}
public Collection<User> findAssociatedUsers(Group group, boolean inherited, IdentitySearchControl[] controls) throws IdentityException
{
+ checkNotNullArgument(group, "Group");
+
List<User> identities = new LinkedList<User>();
//TODO Handle inherited
@@ -487,6 +566,8 @@
public Collection<User> findAssociatedUsers(String groupId, boolean inherited, IdentitySearchControl[] controls) throws IdentityException
{
+ checkNotNullArgument(groupId, "Group Id");
+
Group group = createGroupFromId(groupId);
return findAssociatedUsers(group, inherited, controls);
@@ -494,6 +575,8 @@
public Collection<User> findAssociatedUsers(Group group, boolean inherited) throws IdentityException
{
+ checkNotNullArgument(group, "Group");
+
return findAssociatedUsers(group, inherited, null);
}
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RoleManagerImpl.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RoleManagerImpl.java 2009-03-18 20:27:31 UTC (rev 380)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RoleManagerImpl.java 2009-03-18 21:22:32 UTC (rev 381)
@@ -102,6 +102,9 @@
public RoleType createRoleType(String name) throws IdentityException
{
+ checkNotNullArgument(name, "RoleType name");
+ checkObjectName(name);
+
String roleType = null;
try
@@ -118,6 +121,8 @@
public void removeRoleType(String name) throws IdentityException
{
+ checkNotNullArgument(name, "RoleType name");
+
try
{
getRepository().removeRelationshipName(getInvocationContext(), name);
@@ -130,11 +135,15 @@
public void removeRoleType(RoleType roleType) throws IdentityException
{
+ checkNotNullArgument(roleType, "RoleType");
+
removeRoleType(roleType.getName());
}
public RoleType getRoleType(String name) throws IdentityException
{
+
+ checkNotNullArgument(name, "RoleType name");
try
{
Set<String> names = getRepository().getRelationshipNames(getInvocationContext(), null);
@@ -153,6 +162,7 @@
public Collection<RoleType> findRoleTypes(IdentitySearchControl[] controls) throws IdentityException
{
+
try
{
@@ -175,6 +185,10 @@
public Role createRole(RoleType roleType, User identity, Group group) throws IdentityException
{
+ checkNotNullArgument(roleType, "RoleType");
+ checkNotNullArgument(identity, "User");
+ checkNotNullArgument(group, "Group");
+
//TODO: add createRoleType switch to the API
IdentityObjectRelationship rel = getRepository().createRelationship(getInvocationContext(), createIdentityObject(identity), createIdentityObject(group), ROLE, roleType.getName(), false);
@@ -186,6 +200,10 @@
public Role createRole(String roleTypeName, String userName, String groupId) throws IdentityException
{
+ checkNotNullArgument(roleTypeName, "RoleType name");
+ checkNotNullArgument(userName, "User name");
+ checkNotNullArgument(groupId, "Group Id");
+
User user = createUserFromId(userName);
Group group = createGroupFromId(groupId);
@@ -194,11 +212,19 @@
public void removeRole(RoleType roleType, User identity, Group group) throws IdentityException
{
+ checkNotNullArgument(roleType, "RoleType");
+ checkNotNullArgument(identity, "User");
+ checkNotNullArgument(group, "Group");
+
getRepository().removeRelationship(getInvocationContext(), createIdentityObject(identity), createIdentityObject(group), ROLE, roleType.getName());
}
public void removeRole(String roleTypeName, String userName, String groupId) throws IdentityException
{
+ checkNotNullArgument(roleTypeName, "RoleType name");
+ checkNotNullArgument(userName, "User name");
+ checkNotNullArgument(groupId, "Group Id");
+
User user = createUserFromId(userName);
Group group = createGroupFromId(groupId);
@@ -207,11 +233,17 @@
public void removeRole(Role role) throws IdentityException
{
+ checkNotNullArgument(role, "Role");
+
getRepository().removeRelationship(getInvocationContext(), createIdentityObject(role.getIdentity()), createIdentityObject(role.getGroup()), ROLE, role.getRoleType().getName());
}
public boolean hasRole(User identity, Group group, RoleType roleType) throws IdentityException
{
+ checkNotNullArgument(roleType, "RoleType");
+ checkNotNullArgument(identity, "User");
+ checkNotNullArgument(group, "Group");
+
//TODO: does separate hasRelationship method in IdentityStore makes sense?
Set<IdentityObjectRelationship> rels = getRepository().resolveRelationships(getInvocationContext(), createIdentityObject(identity), createIdentityObject(group), ROLE);
@@ -229,6 +261,10 @@
public boolean hasRole(String userName, String groupId, String roleTypeName) throws IdentityException
{
+ checkNotNullArgument(roleTypeName, "RoleType name");
+ checkNotNullArgument(userName, "User name");
+ checkNotNullArgument(groupId, "Group Id");
+
User user = createUserFromId(userName);
Group group = createGroupFromId(groupId);
@@ -237,11 +273,17 @@
public Collection<RoleType> findRoleTypes(User identity, Group group) throws IdentityException
{
+
+ checkNotNullArgument(identity, "User");
+ checkNotNullArgument(group, "Group");
+
return findRoleTypes(identity, group, null);
}
public Collection<RoleType> findRoleTypes(User identity, Group group, IdentitySearchControl[] controls) throws IdentityException
{
+ checkNotNullArgument(identity, "User");
+ checkNotNullArgument(group, "Group");
Set<IdentityObjectRelationship> rels = getRepository().resolveRelationships(getInvocationContext(), createIdentityObject(identity), createIdentityObject(group), ROLE);
Set<RoleType> types = new HashSet<RoleType>();
@@ -258,6 +300,9 @@
public Collection<RoleType> findRoleTypes(String userName, String groupId, IdentitySearchControl[] controls) throws IdentityException
{
+ checkNotNullArgument(userName, "User name");
+ checkNotNullArgument(groupId, "Group Id");
+
User user = createUserFromId(userName);
Group group = createGroupFromId(groupId);
@@ -266,11 +311,15 @@
public Collection<RoleType> findUserRoleTypes(User identity) throws IdentityException
{
+ checkNotNullArgument(identity, "User");
+
return findUserRoleTypes(identity, null);
}
public Collection<RoleType> findUserRoleTypes(User identity, IdentitySearchControl[] controls) throws IdentityException
{
+ checkNotNullArgument(identity, "User");
+
Set<RoleType> types = new HashSet<RoleType>();
try
@@ -294,6 +343,8 @@
public Collection<RoleType> findUserRoleTypes(String userName, IdentitySearchControl[] controls) throws IdentityException
{
+ checkNotNullArgument(userName, "User name");
+
User user = createUserFromId(userName);
return findUserRoleTypes(user, controls);
@@ -301,11 +352,15 @@
public Collection<RoleType> findGroupRoleTypes(Group group) throws IdentityException
{
+ checkNotNullArgument(group, "Group");
+
return findGroupRoleTypes(group, null);
}
public Collection<RoleType> findGroupRoleTypes(String groupId, IdentitySearchControl[] controls) throws IdentityException
{
+ checkNotNullArgument(groupId, "Group Id");
+
Group group = createGroupFromId(groupId);
return findGroupRoleTypes(group, controls);
@@ -313,6 +368,8 @@
public Collection<RoleType> findGroupRoleTypes(Group group, IdentitySearchControl[] controls) throws IdentityException
{
+ checkNotNullArgument(group, "Group");
+
Set<RoleType> types = new HashSet<RoleType>();
try
@@ -336,6 +393,8 @@
public Collection<Group> findGroupsWithRelatedRole(User identity, IdentitySearchControl[] controls) throws IdentityException
{
+ checkNotNullArgument(identity, "User");
+
List<Group> identities = new LinkedList<Group>();
@@ -354,6 +413,8 @@
public Collection<Group> findGroupsWithRelatedRole(String userName, IdentitySearchControl[] controls) throws IdentityException
{
+ checkNotNullArgument(userName, "User name");
+
User user = createUserFromId(userName);
return findGroupsWithRelatedRole(user, controls);
@@ -361,6 +422,9 @@
public Collection<Group> findGroupsWithRelatedRole(User identity, String groupType, IdentitySearchControl[] controls) throws IdentityException
{
+ checkNotNullArgument(identity, "User");
+ checkNotNullArgument(groupType, "Group type");
+
List<Group> identities = new LinkedList<Group>();
IdentityObjectType iot = getIdentityObjectType(groupType);
@@ -382,6 +446,10 @@
public Collection<Group> findGroupsWithRelatedRole(String userName, String groupType, IdentitySearchControl[] controls) throws IdentityException
{
+ checkNotNullArgument(userName, "User name");
+ checkNotNullArgument(groupType, "Group type");
+
+
User user = createUserFromId(userName);
return findGroupsWithRelatedRole(user, groupType, controls);
@@ -389,6 +457,9 @@
public Collection<Role> findRoles(IdentityType identityType, RoleType roleType) throws IdentityException
{
+ checkNotNullArgument(identityType, "IdentityType");
+ checkNotNullArgument(roleType, "RoleType");
+
Set<Role> roles = new HashSet<Role>();
Set<IdentityObjectRelationship> relationships = null;
@@ -418,6 +489,9 @@
public <T extends IdentityType> Collection<Role> findRoles(String id, String roleTypeName) throws IdentityException
{
+ checkNotNullArgument(id, "Group id or User name");
+ checkNotNullArgument(roleTypeName, "RoleType name");
+
return findRoles(createIdentityTypeFromId(id), new SimpleRoleType(roleTypeName));
}
}
Modified: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/PersistenceManagerTest.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/PersistenceManagerTest.java 2009-03-18 20:27:31 UTC (rev 380)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/PersistenceManagerTest.java 2009-03-18 21:22:32 UTC (rev 381)
@@ -31,6 +31,7 @@
import org.jboss.identity.idm.api.AttributeDescription;
import org.jboss.identity.idm.api.IdentitySearchControl;
import org.jboss.identity.idm.p3p.P3PConstants;
+import org.jboss.identity.idm.exception.IdentityException;
import java.util.Collection;
import java.util.Map;
@@ -86,6 +87,29 @@
session.getTransaction().start();
+ // Bad names
+
+ try
+ {
+ session.getPersistenceManager().createUser("lol/olo");
+ fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ // expected
+ }
+
+ try
+ {
+ session.getPersistenceManager().createGroup("/toto", ORGANIZATION);
+ fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ // expected
+ }
+
+
// Create / Remove
// Group
Modified: idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java
===================================================================
--- idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java 2009-03-18 20:27:31 UTC (rev 380)
+++ idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java 2009-03-18 21:22:32 UTC (rev 381)
@@ -195,7 +195,7 @@
* (such as a pseudonym)
* @return true (virtual identity)
*/
- boolean isVirtual(User user);
+// boolean isVirtual(User user);
}
15 years, 9 months