Author: bdaw
Date: 2009-03-16 08:54:47 -0400 (Mon, 16 Mar 2009)
New Revision: 368
Added:
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/GroupId.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleUser.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/ModelTestCase.java
idm/trunk/idm/src/test/resources/hibernate-jboss-identity-classes.cfg.xml
idm/trunk/idm/src/test/resources/hibernate-jboss-identity.cfg.xml
Removed:
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/Identity.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleIdentity.java
idm/trunk/idm/src/test/resources/META-INF/
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/Group.java
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/IdentityType.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/PersistenceManagerFeaturesDescription.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/RelationshipManagerFeaturesDescription.java
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/Role.java
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RoleManager.java
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObject.java
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectAttribute.java
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectRelationship.java
idm/trunk/idm/pom.xml
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleGroup.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleGroupType.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleRole.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/AttributesManagerImpl.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/main/java/org/jboss/identity/idm/impl/api/session/mapper/DirectIdentityObjectTypeMapperImpl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/mapper/IdentityObjectTypeMapper.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/mapper/IdentityObjectTypeMapperImpl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/IdentityTypeMappingsType.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObject.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectAttribute.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectBinaryAttribute.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectRelationship.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectRelationshipName.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectTextAttribute.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateRealm.java
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/HibernateIdentityStoreSessionImpl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/types/SimpleIdentityObject.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/HibernateTestSupport.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/GroupTypeEnum.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/store/CommonIdentityStoreTest.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/IdentityTypeEnum.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreTestCase.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelTestCase.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateTestBase.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreTestCase.java
idm/trunk/idm/src/test/resources/identity-config.xml
idm/trunk/idm/src/test/resources/identity-config.xsd
idm/trunk/idm/src/test/resources/organization-test-config.xml
idm/trunk/idm/src/test/resources/store-test-config.xml
idm/trunk/idm/src/test/resources/test-config.xml
Log:
- Few API changes (Identity renamed to User)
- Removed JPA and switched to pure hibernate
- Upgraded to hibernate 3.3.1.GA
Modified: idm/trunk/idm/pom.xml
===================================================================
--- idm/trunk/idm/pom.xml 2009-03-11 12:43:49 UTC (rev 367)
+++ idm/trunk/idm/pom.xml 2009-03-16 12:54:47 UTC (rev 368)
@@ -40,24 +40,51 @@
</dependency>
<dependency>
<groupId>org.jboss.identity</groupId>
- <artifactId>idm-spi</artifactId>
- <version>${project.version}</version>
+ <artifactId>idm-spi</artifactId>
+ <version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>javax.persistence</groupId>
- <artifactId>persistence-api</artifactId>
- </dependency>
- <dependency>
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ <version>2.1.8</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+
+ <!-- hibernate -->
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
+ <version>3.3.1.GA</version>
+ </dependency>
+ <dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
- <version>3.3.1.GA</version>
+ <version>3.4.0.GA</version>
</dependency>
+ <!-- Javassist as Hibernate's bytecode provider -->
+ <dependency>
+ <groupId>javassist</groupId>
+ <artifactId>javassist</artifactId>
+ <version>3.4.GA</version>
+ </dependency>
+ <!-- Hibernate logging set up -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.5.2</version>
+ </dependency>
+ <!--<dependency>-->
+ <!--<groupId>log4j</groupId>-->
+ <!--<artifactId>log4j</artifactId>-->
+ <!--<version>1.2.14</version>-->
+ <!--</dependency>-->
+
+
<dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-entitymanager</artifactId>
- <version>3.3.2.GA</version>
- </dependency>
- <dependency>
<groupId>org.jboss.cache</groupId>
<artifactId>jbosscache-core</artifactId>
<version>3.0.2.GA</version>
@@ -86,20 +113,6 @@
<version>3.2.76</version>
<scope>test</scope>
</dependency>
- <!--<dependency>-->
- <!--<groupId>sun-jaxb</groupId>-->
- <!--<artifactId>jaxb-impl</artifactId>-->
- <!--<version>2.1.4</version>-->
- <!--</dependency>-->
- <!--<dependency>-->
- <!--<groupId>sun-jaxb</groupId>-->
- <!--<artifactId>jaxb-api</artifactId>-->
- <!--<version>2.1.4</version>-->
- <!--</dependency>-->
- <dependency>
- <groupId>com.sun.xml.bind</groupId>
- <artifactId>jaxb-impl</artifactId>
- <version>2.1.8</version>
- </dependency>
+
</dependencies>
</project>
Added: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/model/GroupId.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/model/GroupId.java
(rev 0)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/model/GroupId.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -0,0 +1,83 @@
+/*
+* 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.api.model;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class GroupId
+{
+
+ private String name;
+
+ private String type;
+
+ public GroupId(String name, String type)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("name is null");
+ }
+ if (type == null)
+ {
+ throw new IllegalArgumentException("type is null");
+ }
+
+ this.name = name;
+ this.type = type;
+ }
+
+ public GroupId(String id)
+ {
+ if (id == null)
+ {
+ throw new IllegalArgumentException("id is null");
+ }
+
+ String[] parts = id.split("/");
+
+ if (parts == null || parts.length != 2)
+ {
+ throw new IllegalArgumentException("group id not following required format:
type/name: " + id);
+ }
+
+ name = parts[1];
+ type = parts[0];
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getType()
+ {
+ return type;
+ }
+
+ public String getId()
+ {
+ return type + "/" + name;
+ }
+}
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleGroup.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleGroup.java 2009-03-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleGroup.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -23,8 +23,8 @@
package org.jboss.identity.idm.impl.api.model;
import org.jboss.identity.idm.api.Group;
-import org.jboss.identity.idm.api.GroupType;
+
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
* @version : 0.1 $
@@ -35,21 +35,28 @@
private final String id;
- private final GroupType groupType;
+ private final String groupType;
- public SimpleGroup(String name, String id, GroupType groupType)
+ public SimpleGroup(String name, String id, String groupType)
{
this.name = name;
this.id = id;
this.groupType = groupType;
}
+ public SimpleGroup(GroupId groupId)
+ {
+ this.name = groupId.getName();
+ this.groupType = groupId.getType();
+ this.id = groupId.getId();
+ }
+
public String getName()
{
return name;
}
- public GroupType getGroupType()
+ public String getGroupType()
{
return groupType;
}
@@ -59,11 +66,7 @@
return id;
}
- public String getDescription()
- {
- return null;
- }
-
+ @Override
public boolean equals(Object o)
{
if (this == o)
@@ -81,6 +84,10 @@
{
return false;
}
+ if (id != null ? !id.equals(that.id) : that.id != null)
+ {
+ return false;
+ }
if (name != null ? !name.equals(that.name) : that.name != null)
{
return false;
@@ -89,10 +96,10 @@
return true;
}
+ @Override
public int hashCode()
{
- int result;
- result = (name != null ? name.hashCode() : 0);
+ int result = name != null ? name.hashCode() : 0;
result = 31 * result + (id != null ? id.hashCode() : 0);
result = 31 * result + (groupType != null ? groupType.hashCode() : 0);
return result;
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleGroupType.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleGroupType.java 2009-03-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleGroupType.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -1,71 +1,71 @@
-/*
-* 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.api.model;
-
-import org.jboss.identity.idm.api.GroupType;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
- * @version : 0.1 $
- */
-public class SimpleGroupType implements GroupType
-{
-
- private final String name;
-
- public SimpleGroupType(String name)
- {
- this.name = name;
- }
-
- public String getName()
- {
- return name;
- }
-
- public boolean equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
- if (o == null || getClass() != o.getClass())
- {
- return false;
- }
-
- SimpleGroupType that = (SimpleGroupType)o;
-
- if (name != null ? !name.equals(that.name) : that.name != null)
- {
- return false;
- }
-
- return true;
- }
-
- public int hashCode()
- {
- return (name != null ? name.hashCode() : 0);
- }
-}
+///*
+//* 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.api.model;
+//
+//import org.jboss.identity.idm.api.GroupType;
+//
+///**
+// * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+// * @version : 0.1 $
+// */
+//public class SimpleGroupType implements GroupType
+//{
+//
+// private final String name;
+//
+// public SimpleGroupType(String name)
+// {
+// this.name = name;
+// }
+//
+// public String getName()
+// {
+// return name;
+// }
+//
+// public boolean equals(Object o)
+// {
+// if (this == o)
+// {
+// return true;
+// }
+// if (o == null || getClass() != o.getClass())
+// {
+// return false;
+// }
+//
+// SimpleGroupType that = (SimpleGroupType)o;
+//
+// if (name != null ? !name.equals(that.name) : that.name != null)
+// {
+// return false;
+// }
+//
+// return true;
+// }
+//
+// public int hashCode()
+// {
+// return (name != null ? name.hashCode() : 0);
+// }
+//}
Deleted:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleIdentity.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleIdentity.java 2009-03-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleIdentity.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -1,92 +0,0 @@
-/*
-* 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.api.model;
-
-import org.jboss.identity.idm.api.Identity;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
- * @version : 0.1 $
- */
-public class SimpleIdentity implements Identity
-{
- private final String name;
-
- private final String id;
-
-
- public SimpleIdentity(String name, String id)
- {
- this.name = name;
- this.id = id;
- }
-
- public String getName()
- {
- return name;
- }
-
- public boolean isVirtual()
- {
- return false;
- }
-
- public String getId()
- {
- return id;
- }
-
- public String getDescription()
- {
- return null;
- }
-
- public boolean equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
- if (o == null || getClass() != o.getClass())
- {
- return false;
- }
-
- SimpleIdentity that = (SimpleIdentity)o;
-
- if (name != null ? !name.equals(that.name) : that.name != null)
- {
- return false;
- }
-
- return true;
- }
-
- public int hashCode()
- {
- int result;
- result = (name != null ? name.hashCode() : 0);
- result = 31 * result + (id != null ? id.hashCode() : 0);
- return result;
- }
-}
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleRole.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleRole.java 2009-03-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleRole.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -24,7 +24,7 @@
import org.jboss.identity.idm.api.Role;
import org.jboss.identity.idm.api.RoleType;
-import org.jboss.identity.idm.api.Identity;
+import org.jboss.identity.idm.api.User;
import org.jboss.identity.idm.api.Group;
/**
@@ -35,18 +35,18 @@
{
private final RoleType type;
- private final Identity identity;
+ private final User identity;
private final Group group;
- public SimpleRole(RoleType type, Identity identity, Group group)
+ public SimpleRole(RoleType type, User identity, Group group)
{
this.type = type;
this.identity = identity;
this.group = group;
}
- public Identity getIdentity()
+ public User getIdentity()
{
return identity;
}
Copied: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleUser.java
(from rev 247,
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleIdentity.java)
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleUser.java
(rev 0)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleUser.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -0,0 +1,73 @@
+/*
+* 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.api.model;
+
+import org.jboss.identity.idm.api.User;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class SimpleUser implements User
+{
+ private final String name;
+
+
+ public SimpleUser(String name)
+ {
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ SimpleUser that = (SimpleUser)o;
+
+ if (name != null ? !name.equals(that.name) : that.name != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return name != null ? name.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-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AbstractManager.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -23,9 +23,8 @@
package org.jboss.identity.idm.impl.api.session.managers;
import org.jboss.identity.idm.api.IdentitySession;
-import org.jboss.identity.idm.api.Identity;
+import org.jboss.identity.idm.api.User;
import org.jboss.identity.idm.api.Group;
-import org.jboss.identity.idm.api.GroupType;
import org.jboss.identity.idm.api.IdentityType;
import org.jboss.identity.idm.api.IdentitySearchControl;
import org.jboss.identity.idm.api.Attribute;
@@ -38,8 +37,9 @@
import org.jboss.identity.idm.impl.types.SimpleIdentityObject;
import org.jboss.identity.idm.impl.api.session.context.IdentitySessionContext;
import org.jboss.identity.idm.impl.api.session.IdentitySessionImpl;
-import org.jboss.identity.idm.impl.api.model.SimpleIdentity;
+import org.jboss.identity.idm.impl.api.model.SimpleUser;
import org.jboss.identity.idm.impl.api.model.SimpleGroup;
+import org.jboss.identity.idm.impl.api.model.GroupId;
import org.jboss.identity.idm.impl.api.SimpleAttribute;
import java.util.List;
@@ -82,24 +82,36 @@
return getSessionContext().resolveStoreInvocationContext();
}
- protected Identity createIdentity(IdentityObject identityObject)
+ protected User createUser(IdentityObject identityObject)
{
- return new SimpleIdentity(identityObject.getName(), identityObject.getId());
+ return new SimpleUser(identityObject.getName());
}
+ protected User createUserFromId(String name)
+ {
+ return new SimpleUser(name);
+ }
+
protected Group createGroup(IdentityObject identityObject)
{
- GroupType groupType =
getSessionContext().getIdentityObjectTypeMapper().getGroupType(identityObject.getIdentityType());
+ String groupType =
getSessionContext().getIdentityObjectTypeMapper().getGroupType(identityObject.getIdentityType());
return new SimpleGroup(identityObject.getName(), identityObject.getId(),
groupType);
}
- protected IdentityObject createIdentityObject(Identity identity)
+ protected IdentityObject createIdentityObject(User identity)
{
IdentityObjectType iot =
getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType();
- return new SimpleIdentityObject(identity.getName(), identity.getId(), iot);
+ return new SimpleIdentityObject(identity.getName(), iot);
}
+ protected IdentityObject createIdentityObjectForUserName(String userName)
+ {
+ IdentityObjectType iot =
getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType();
+
+ return new SimpleIdentityObject(userName, iot);
+ }
+
protected IdentityObject createIdentityObject(Group group)
{
IdentityObjectType iot =
getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType(group.getGroupType());
@@ -107,11 +119,20 @@
return new SimpleIdentityObject(group.getName(), group.getId(), iot);
}
+ protected IdentityObject createIdentityObjectForGroupId(String groupId)
+ {
+ GroupId id = new GroupId(groupId);
+
+ IdentityObjectType iot =
getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType(id.getType());
+
+ return new SimpleIdentityObject(id.getName(), null, iot);
+ }
+
protected IdentityObject createIdentityObject(IdentityType identityType)
{
- if (identityType instanceof Identity)
+ if (identityType instanceof User)
{
- return createIdentityObject((Identity)identityType);
+ return createIdentityObject((User)identityType);
}
else if (identityType instanceof Group)
{
@@ -122,6 +143,11 @@
}
+ protected Group createGroupFromId(String id)
+ {
+ return new SimpleGroup(new GroupId(id));
+ }
+
protected IdentityObjectSearchControl[] convertSearchControls(IdentitySearchControl[]
controls)
{
if (controls == null)
@@ -154,7 +180,7 @@
return getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType();
}
- protected IdentityObjectType getIdentityObjectType(GroupType groupType)
+ protected IdentityObjectType getIdentityObjectType(String groupType)
{
return
getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType(groupType);
}
@@ -206,5 +232,4 @@
}
-
}
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-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AttributesManagerImpl.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -25,7 +25,7 @@
import org.jboss.identity.idm.api.IdentitySession;
import org.jboss.identity.idm.api.AttributesManager;
import org.jboss.identity.idm.api.IdentityType;
-import org.jboss.identity.idm.api.Identity;
+import org.jboss.identity.idm.api.User;
import org.jboss.identity.idm.api.AttributeDescription;
import org.jboss.identity.idm.api.CredentialType;
import org.jboss.identity.idm.api.Credential;
@@ -161,27 +161,27 @@
getRepository().removeAttributes(getInvocationContext(),
createIdentityObject(identity), attributeNames);
}
- public boolean hasPassword(Identity identity) throws IdentityException
+ public boolean hasPassword(User identity) throws IdentityException
{
return
getRepository().getSupportedFeatures().isCredentialSupported(createIdentityObject(identity).getIdentityType(),
PasswordCredential.TYPE);
}
- public boolean validatePassword(Identity identity, String password) throws
IdentityException
+ public boolean validatePassword(User identity, String password) throws
IdentityException
{
return getRepository().validateCredential(getInvocationContext(),
createIdentityObject(identity), new PasswordCredential(password));
}
- public void updatePassword(Identity identity, String password) throws
IdentityException
+ public void updatePassword(User identity, String password) throws IdentityException
{
getRepository().updateCredential(getInvocationContext(),
createIdentityObject(identity), new PasswordCredential(password));
}
- public boolean hasCredential(Identity identity, CredentialType credentialType) throws
IdentityException
+ public boolean hasCredential(User identity, CredentialType credentialType) throws
IdentityException
{
return
getRepository().getSupportedFeatures().isCredentialSupported(createIdentityObject(identity).getIdentityType(),
new SimpleCredentialType(credentialType.getName()));
}
- public boolean validateCredentials(Identity identity, Credential[] credentials) throws
IdentityException
+ public boolean validateCredentials(User identity, Credential[] credentials) throws
IdentityException
{
for (Credential credential : credentials)
@@ -206,7 +206,7 @@
return true;
}
- public void updateCredential(Identity identity, Credential credential) throws
IdentityException
+ public void updateCredential(User identity, Credential credential) throws
IdentityException
{
if (credential instanceof IdentityObjectCredential)
{
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-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/PersistenceManagerImpl.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -23,9 +23,8 @@
package org.jboss.identity.idm.impl.api.session.managers;
import org.jboss.identity.idm.api.PersistenceManager;
-import org.jboss.identity.idm.api.Identity;
+import org.jboss.identity.idm.api.User;
import org.jboss.identity.idm.api.Group;
-import org.jboss.identity.idm.api.GroupType;
import org.jboss.identity.idm.api.IdentitySession;
import org.jboss.identity.idm.api.PersistenceManagerFeaturesDescription;
import org.jboss.identity.idm.api.IdentitySearchControl;
@@ -57,7 +56,7 @@
featuresDescription = new PersistenceManagerFeaturesDescription()
{
- public boolean isIdentitiesAddRemoveSupported()
+ public boolean isUsersAddRemoveSupported()
{
IdentityObjectType objectType =
getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType();
@@ -65,7 +64,7 @@
isIdentityObjectAddRemoveSupported(objectType);
}
- public boolean isGroupsAddRemoveSupported(GroupType groupType)
+ public boolean isGroupsAddRemoveSupported(String groupType)
{
IdentityObjectType objectType =
getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType(groupType);
@@ -73,7 +72,7 @@
isIdentityObjectAddRemoveSupported(objectType);
}
- public boolean isIdentitiesSearchControlSupported(IdentitySearchControl
control)
+ public boolean isUsersSearchControlSupported(IdentitySearchControl control)
{
IdentityObjectType objectType =
getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType();
@@ -87,7 +86,7 @@
}
- public boolean isIdentitiesSearchControlSupported(Class controlClazz)
+ public boolean isUsersSearchControlSupported(Class controlClazz)
{
IdentityObjectType objectType =
getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType();
@@ -96,7 +95,7 @@
}
- public boolean isGroupsSearchControlSupported(GroupType groupType,
IdentitySearchControl control)
+ public boolean isGroupsSearchControlSupported(String groupType,
IdentitySearchControl control)
{
IdentityObjectType objectType =
getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType(groupType);
@@ -109,7 +108,7 @@
return false;
}
- public boolean isGroupsSearchControlSupported(GroupType groupType, Class
controlClazz)
+ public boolean isGroupsSearchControlSupported(String groupType, Class
controlClazz)
{
IdentityObjectType objectType =
getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType(groupType);
@@ -124,16 +123,16 @@
return featuresDescription;
}
- public Identity createIdentity(String identityName) throws IdentityException
+ public User createUser(String identityName) throws IdentityException
{
IdentityObjectType iot = getIdentityObjectType();
IdentityObject identityObject =
getRepository().createIdentityObject(getInvocationContext(), identityName, iot);
- return createIdentity(identityObject);
+ return createUser(identityObject);
}
- public Group createGroup(String groupName, GroupType groupType) throws
IdentityException
+ public Group createGroup(String groupName, String groupType) throws IdentityException
{
IdentityObjectType iot = getIdentityObjectType(groupType);
@@ -142,11 +141,16 @@
return createGroup(identityObject);
}
- public void removeIdentity(Identity identity, boolean force) throws IdentityException
+ public void removeUser(User identity, boolean force) throws IdentityException
{
getRepository().removeIdentityObject(getInvocationContext(),
createIdentityObject(identity));
}
+ public void removeUser(String userName, boolean force) throws IdentityException
+ {
+ getRepository().removeIdentityObject(getInvocationContext(),
createIdentityObjectForUserName(userName));
+ }
+
public void removeGroup(Group group, boolean force) throws IdentityException
{
//TODO: force
@@ -154,47 +158,54 @@
getRepository().removeIdentityObject(getInvocationContext(),
createIdentityObject(group));
}
- public int getIdentityCount() throws IdentityException
+ public void removeGroup(String groupId, boolean force) throws IdentityException
{
+ //TODO: force
+
+ getRepository().removeIdentityObject(getInvocationContext(),
createIdentityObjectForGroupId(groupId));
+ }
+
+ public int getUserCount() throws IdentityException
+ {
IdentityObjectType iot = getIdentityObjectType();
return getRepository().getIdentityObjectsCount(getInvocationContext(), iot);
}
- public int getGroupTypeCount(GroupType groupType) throws IdentityException
+ public int getGroupTypeCount(String groupType) throws IdentityException
{
IdentityObjectType iot = getIdentityObjectType(groupType);
return getRepository().getIdentityObjectsCount(getInvocationContext(), iot);
}
- public Identity findIdentity(String name) throws IdentityException
+ public User findUser(String name) throws IdentityException
{
- return createIdentity(getRepository().findIdentityObject(getInvocationContext(),
name, getIdentityObjectType()));
+ return createUser(getRepository().findIdentityObject(getInvocationContext(), name,
getIdentityObjectType()));
}
- public Identity findIdentityById(String id) throws IdentityException
+ public User findUserById(String id) throws IdentityException
{
- return createIdentity(getRepository().findIdentityObject(getInvocationContext(),
id));
+ return createUser(getRepository().findIdentityObject(getInvocationContext(), id));
}
- public Collection<Identity> findIdentity(IdentitySearchControl[] controls)
throws IdentityException
+ public Collection<User> findUser(IdentitySearchControl[] controls) throws
IdentityException
{
Collection<IdentityObject> ios =
getRepository().findIdentityObject(getInvocationContext(), getIdentityObjectType(),
convertSearchControls(controls));
- List<Identity> identities = new LinkedList<Identity>();
+ List<User> identities = new LinkedList<User>();
for (Iterator<IdentityObject> iterator = ios.iterator();
iterator.hasNext();)
{
IdentityObject identityObject = iterator.next();
- identities.add(createIdentity(identityObject));
+ identities.add(createUser(identityObject));
}
return identities;
}
- public Group findGroup(String name, GroupType groupType) throws IdentityException
+ public Group findGroup(String name, String groupType) throws IdentityException
{
return createGroup(getRepository().findIdentityObject(getInvocationContext(), name,
getIdentityObjectType(groupType)));
}
@@ -204,7 +215,7 @@
return createGroup(getRepository().findIdentityObject(getInvocationContext(),
id));
}
- public Collection<Group> findGroup(GroupType groupType, IdentitySearchControl[]
controls) throws IdentityException
+ public Collection<Group> findGroup(String groupType, IdentitySearchControl[]
controls) throws IdentityException
{
Collection<IdentityObject> ios =
getRepository().findIdentityObject(getInvocationContext(),
getIdentityObjectType(groupType), convertSearchControls(controls));
List<Group> groups = new LinkedList<Group>();
@@ -218,12 +229,12 @@
return groups;
}
- public Collection<Group> findGroup(GroupType groupType) throws
IdentityException
+ public Collection<Group> findGroup(String groupType) throws IdentityException
{
- return findGroup(groupType, null);
+ return findGroup(groupType, (IdentitySearchControl[]) null);
}
- public boolean isVirtual(Identity identity)
+ 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-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -25,9 +25,8 @@
import org.jboss.identity.idm.api.RelationshipManager;
import org.jboss.identity.idm.api.IdentitySession;
import org.jboss.identity.idm.api.Group;
-import org.jboss.identity.idm.api.Identity;
+import org.jboss.identity.idm.api.User;
import org.jboss.identity.idm.api.IdentityType;
-import org.jboss.identity.idm.api.GroupType;
import org.jboss.identity.idm.api.RelationshipManagerFeaturesDescription;
import org.jboss.identity.idm.api.IdentitySearchControl;
import org.jboss.identity.idm.exception.IdentityException;
@@ -38,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.session.mapper.IdentityObjectTypeMapper;
import java.util.Collection;
import java.util.Iterator;
@@ -69,7 +67,7 @@
featuresDescription = new RelationshipManagerFeaturesDescription()
{
- public boolean isIdentityAssociationSupported(GroupType fromGroupType)
+ public boolean isIdentityAssociationSupported(String fromGroupType)
{
IdentityObjectType identityOT =
getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType();
@@ -87,7 +85,7 @@
}
- public boolean isGroupAssociationSupported(GroupType fromGroupType, GroupType
toGroupType)
+ public boolean isGroupAssociationSupported(String fromGroupType, String
toGroupType)
{
IdentityObjectType toGroupOT =
getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType(toGroupType);
IdentityObjectType fromGroupOT =
getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType(fromGroupType);
@@ -126,7 +124,7 @@
}
- public boolean isGroupsSearchControlSupported(GroupType groupType,
IdentitySearchControl control)
+ public boolean isGroupsSearchControlSupported(String groupType,
IdentitySearchControl control)
{
IdentityObjectType objectType =
getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType(groupType);
@@ -139,7 +137,7 @@
return false;
}
- public boolean isGroupsSearchControlSupported(GroupType groupType, Class
controlClazz)
+ public boolean isGroupsSearchControlSupported(String groupType, Class
controlClazz)
{
IdentityObjectType objectType =
getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType(groupType);
@@ -169,31 +167,75 @@
}
}
+ public void associateGroupsByIds(Collection<String> parentIds,
Collection<String> memberIds) throws IdentityException
+ {
+ for (Iterator<String> parentsIterator = parentIds.iterator();
parentsIterator.hasNext();)
+ {
+ String parentId = parentsIterator.next();
+
+ for (Iterator<String> membersIterator = memberIds.iterator();
membersIterator.hasNext();)
+ {
+ String memberId = membersIterator.next();
+
+ associateGroupsByIds(parentId, memberId);
+ }
+ }
+ }
+
public void associateGroups(Group parent, Group member) throws IdentityException
{
getRepository().createRelationship(getInvocationContext(),
createIdentityObject(parent), createIdentityObject(member), MEMBER, null, true);
}
+
- public void associateIdentities(Collection<Group> parents,
Collection<Identity> members) throws IdentityException
+ public void associateGroupsByIds(String parentId, String memberId) throws
IdentityException
{
+ getRepository().createRelationship(getInvocationContext(),
createIdentityObjectForGroupId(parentId), createIdentityObjectForGroupId(memberId),
MEMBER, null, true);
+ }
+
+ public void associateUsers(Collection<Group> parents, Collection<User>
members) throws IdentityException
+ {
for (Iterator<Group> parentsIterator = parents.iterator();
parentsIterator.hasNext();)
{
Group parent = parentsIterator.next();
- for (Iterator<Identity> membersIterator = members.iterator();
membersIterator.hasNext();)
+ for (Iterator<User> membersIterator = members.iterator();
membersIterator.hasNext();)
{
- Identity member = membersIterator.next();
+ User member = membersIterator.next();
- associateIdentities(parent, member);
+ associateUsers(parent, member);
}
}
}
- public void associateIdentities(Group parent, Identity member) throws
IdentityException
+ public void associateUsersByIds(Collection<String> parents,
Collection<String> members) throws IdentityException
{
+ for (Iterator<String> parentsIterator = parents.iterator();
parentsIterator.hasNext();)
+ {
+ String parent = parentsIterator.next();
+
+ for (Iterator<String> membersIterator = members.iterator();
membersIterator.hasNext();)
+ {
+ String member = membersIterator.next();
+
+ associateUsersByIds(parent, member);
+ }
+ }
+
+ }
+
+ public void associateUsers(Group parent, User member) throws IdentityException
+ {
getRepository().createRelationship(getInvocationContext(),
createIdentityObject(parent), createIdentityObject(member), MEMBER, null, true);
}
+
+ public void associateUsersByIds(String parentId, String memberId) throws
IdentityException
+ {
+ getRepository().createRelationship(getInvocationContext(),
createIdentityObjectForUserName(parentId), createIdentityObjectForUserName(memberId),
MEMBER, null, true);
+
+ }
+
public void disassociateGroups(Collection<Group> parents,
Collection<Group> members) throws IdentityException
{
for (Iterator<Group> parentsIterator = parents.iterator();
parentsIterator.hasNext();)
@@ -209,15 +251,30 @@
}
}
- public void disassociateIdentities(Collection<Group> parents,
Collection<Identity> members) throws IdentityException
+ public void disassociateGroupsByIds(Collection<String> parents,
Collection<String> members) throws IdentityException
{
+ for (Iterator<String> parentsIterator = parents.iterator();
parentsIterator.hasNext();)
+ {
+ String parent = parentsIterator.next();
+
+ for (Iterator<String> membersIterator = members.iterator();
membersIterator.hasNext();)
+ {
+ String member = membersIterator.next();
+
+ getRepository().removeRelationship(getInvocationContext(),
createIdentityObjectForGroupId(parent), createIdentityObjectForGroupId(member), MEMBER,
null);
+ }
+ }
+ }
+
+ public void disassociateUsers(Collection<Group> parents, Collection<User>
members) throws IdentityException
+ {
for (Iterator<Group> parentsIterator = parents.iterator();
parentsIterator.hasNext();)
{
Group parent = parentsIterator.next();
- for (Iterator<Identity> membersIterator = members.iterator();
membersIterator.hasNext();)
+ for (Iterator<User> membersIterator = members.iterator();
membersIterator.hasNext();)
{
- Identity member = membersIterator.next();
+ User member = membersIterator.next();
getRepository().removeRelationship(getInvocationContext(),
createIdentityObject(parent), createIdentityObject(member), MEMBER, null);
}
@@ -225,6 +282,21 @@
}
+ public void disassociateUsersByIds(Collection<String> parents,
Collection<String> members) throws IdentityException
+ {
+ for (Iterator<String> parentsIterator = parents.iterator();
parentsIterator.hasNext();)
+ {
+ String parent = parentsIterator.next();
+
+ for (Iterator<String> membersIterator = members.iterator();
membersIterator.hasNext();)
+ {
+ String member = membersIterator.next();
+
+ getRepository().removeRelationship(getInvocationContext(),
createIdentityObjectForGroupId(parent), createIdentityObjectForUserName(member), MEMBER,
null);
+ }
+ }
+ }
+
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?
@@ -259,7 +331,7 @@
return isAssociated(parents, members);
}
- public Collection<Group> findAssociatedGroups(Group group, GroupType groupType,
boolean parent, boolean inherited, IdentitySearchControl[] controls) throws
IdentityException
+ public Collection<Group> findAssociatedGroups(Group group, String groupType,
boolean parent, boolean inherited, IdentitySearchControl[] controls) throws
IdentityException
{
List<Group> identities = new LinkedList<Group>();
@@ -286,12 +358,19 @@
}
- public Collection<Group> findAssociatedGroups(Group group, GroupType groupType,
boolean parent, boolean inherited) throws IdentityException
+ public Collection<Group> findAssociatedGroups(String groupId, String groupType,
boolean parent, boolean inherited, IdentitySearchControl[] controls) throws
IdentityException
{
+ Group group = createGroupFromId(groupId);
+
+ return findAssociatedGroups(group, groupType, parent, inherited, controls);
+ }
+
+ public Collection<Group> findAssociatedGroups(Group group, String groupType,
boolean parent, boolean inherited) throws IdentityException
+ {
return findAssociatedGroups(group, groupType, parent, inherited, null);
}
- public Collection<Group> findAssociatedGroups(Identity identity, GroupType
groupType, IdentitySearchControl[] controls) throws IdentityException
+ public Collection<Group> findAssociatedGroups(User identity, String groupType,
IdentitySearchControl[] controls) throws IdentityException
{
List<Group> identities = new LinkedList<Group>();
@@ -310,12 +389,19 @@
return identities;
}
- public Collection<Group> findAssociatedGroups(Identity identity, GroupType
groupType) throws IdentityException
+ public Collection<Group> findAssociatedGroups(String userName, String groupType,
IdentitySearchControl[] controls) throws IdentityException
{
+ User user = createUserFromId(userName);
+
+ return findAssociatedGroups(user, groupType, controls);
+ }
+
+ public Collection<Group> findAssociatedGroups(User identity, String groupType)
throws IdentityException
+ {
return findAssociatedGroups(identity, groupType, null);
}
- public Collection<Group> findAssociatedGroups(Identity identity,
IdentitySearchControl[] controls) throws IdentityException
+ public Collection<Group> findAssociatedGroups(User identity,
IdentitySearchControl[] controls) throws IdentityException
{
List<Group> identities = new LinkedList<Group>();
@@ -329,14 +415,21 @@
return identities;
}
- public Collection<Group> findAssociatedGroups(Identity identity) throws
IdentityException
+ public Collection<Group> findAssociatedGroups(String userName,
IdentitySearchControl[] controls) throws IdentityException
{
+ User user = createUserFromId(userName);
+
+ return findAssociatedGroups(user, controls);
+ }
+
+ public Collection<Group> findAssociatedGroups(User identity) throws
IdentityException
+ {
return findAssociatedGroups(identity, new IdentitySearchControl[] {});
}
- public Collection<Identity> findAssociatedIdentities(Group group, boolean
inherited, IdentitySearchControl[] controls) throws IdentityException
+ public Collection<User> findAssociatedUsers(Group group, boolean inherited,
IdentitySearchControl[] controls) throws IdentityException
{
- List<Identity> identities = new LinkedList<Identity>();
+ List<User> identities = new LinkedList<User>();
//TODO Handle inherited
if (inherited)
@@ -350,14 +443,23 @@
for (IdentityObject io : ios)
{
- identities.add(createIdentity(io));
+ identities.add(createUser(io));
}
return identities;
}
- public Collection<Identity> findAssociatedIdentities(Group group, boolean
inherited) throws IdentityException
+ public Collection<User> findAssociatedUsers(String groupId, boolean inherited,
IdentitySearchControl[] controls) throws IdentityException
{
- return findAssociatedIdentities(group, inherited, null);
+ Group group = createGroupFromId(groupId);
+
+ return findAssociatedUsers(group, inherited, controls);
}
+
+ public Collection<User> findAssociatedUsers(Group group, boolean inherited)
throws IdentityException
+ {
+ 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-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RoleManagerImpl.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -26,12 +26,11 @@
import org.jboss.identity.idm.api.IdentitySession;
import org.jboss.identity.idm.api.RoleType;
import org.jboss.identity.idm.api.Role;
-import org.jboss.identity.idm.api.Identity;
+import org.jboss.identity.idm.api.User;
import org.jboss.identity.idm.api.Group;
import org.jboss.identity.idm.api.IdentityType;
import org.jboss.identity.idm.api.RoleManagerFeaturesDescription;
import org.jboss.identity.idm.api.IdentitySearchControl;
-import org.jboss.identity.idm.api.GroupType;
import org.jboss.identity.idm.exception.IdentityException;
import org.jboss.identity.idm.spi.model.IdentityObjectRelationshipType;
import org.jboss.identity.idm.spi.model.IdentityObjectRelationship;
@@ -39,7 +38,6 @@
import org.jboss.identity.idm.spi.model.IdentityObject;
import org.jboss.identity.idm.spi.exception.OperationNotSupportedException;
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.SimpleRoleType;
import org.jboss.identity.idm.impl.api.model.SimpleRole;
@@ -175,28 +173,44 @@
}
- public Role createRole(RoleType roleType, Identity identity, Group group) throws
IdentityException
+ public Role createRole(RoleType roleType, User identity, Group group) throws
IdentityException
{
//TODO: add createRoleType switch to the API
IdentityObjectRelationship rel =
getRepository().createRelationship(getInvocationContext(), createIdentityObject(identity),
createIdentityObject(group), ROLE, roleType.getName(), false);
//TODO: null id - IdentityObjectRelationship doesn't have id
- return new SimpleRole(new SimpleRoleType(rel.getName()),
createIdentity(rel.getFromIdentityObject()), createGroup(rel.getToIdentityObject()));
+ return new SimpleRole(new SimpleRoleType(rel.getName()),
createUser(rel.getFromIdentityObject()), createGroup(rel.getToIdentityObject()));
}
- public void removeRole(RoleType roleType, Identity identity, Group group) throws
IdentityException
+ public Role createRole(RoleType roleType, String userName, String groupId) throws
IdentityException
{
+ User user = createUserFromId(userName);
+ Group group = createGroupFromId(groupId);
+
+ return createRole(roleType, user, group);
+ }
+
+ public void removeRole(RoleType roleType, User identity, Group group) throws
IdentityException
+ {
getRepository().removeRelationship(getInvocationContext(),
createIdentityObject(identity), createIdentityObject(group), ROLE, roleType.getName());
}
+ public void removeRole(RoleType roleType, String userName, String groupId) throws
IdentityException
+ {
+ User user = createUserFromId(userName);
+ Group group = createGroupFromId(groupId);
+
+ removeRole(roleType, user, group);
+ }
+
public void removeRole(Role role) throws IdentityException
{
getRepository().removeRelationship(getInvocationContext(),
createIdentityObject(role.getIdentity()), createIdentityObject(role.getGroup()), ROLE,
role.getRoleType().getName());
}
- public boolean hasRole(Identity identity, Group group, RoleType roleType) throws
IdentityException
+ public boolean hasRole(User identity, Group group, RoleType roleType) throws
IdentityException
{
//TODO: does separate hasRelationship method in IdentityStore makes sense?
@@ -213,12 +227,20 @@
return false;
}
- public Collection<RoleType> findRoleTypes(Identity identity, Group group) throws
IdentityException
+ public boolean hasRole(String userName, String groupId, RoleType roleType) throws
IdentityException
{
+ User user = createUserFromId(userName);
+ Group group = createGroupFromId(groupId);
+
+ return hasRole(user, group, roleType);
+ }
+
+ public Collection<RoleType> findRoleTypes(User identity, Group group) throws
IdentityException
+ {
return findRoleTypes(identity, group, null);
}
- public Collection<RoleType> findRoleTypes(Identity identity, Group group,
IdentitySearchControl[] controls) throws IdentityException
+ public Collection<RoleType> findRoleTypes(User identity, Group group,
IdentitySearchControl[] controls) throws IdentityException
{
Set<IdentityObjectRelationship> rels =
getRepository().resolveRelationships(getInvocationContext(),
createIdentityObject(identity), createIdentityObject(group), ROLE);
@@ -234,13 +256,21 @@
}
- public Collection<RoleType> findIdentityRoleTypes(Identity identity) throws
IdentityException
+ public Collection<RoleType> findRoleTypes(String userName, String groupId,
IdentitySearchControl[] controls) throws IdentityException
{
- return findIdentityRoleTypes(identity, null);
+ User user = createUserFromId(userName);
+ Group group = createGroupFromId(groupId);
+
+ return findRoleTypes(user, group, controls);
}
- public Collection<RoleType> findIdentityRoleTypes(Identity identity,
IdentitySearchControl[] controls) throws IdentityException
+ public Collection<RoleType> findUserRoleTypes(User identity) throws
IdentityException
{
+ return findUserRoleTypes(identity, null);
+ }
+
+ public Collection<RoleType> findUserRoleTypes(User identity,
IdentitySearchControl[] controls) throws IdentityException
+ {
Set<RoleType> types = new HashSet<RoleType>();
try
@@ -262,11 +292,25 @@
}
+ public Collection<RoleType> findUserRoleTypes(String userName,
IdentitySearchControl[] controls) throws IdentityException
+ {
+ User user = createUserFromId(userName);
+
+ return findUserRoleTypes(user, controls);
+ }
+
public Collection<RoleType> findGroupRoleTypes(Group group) throws
IdentityException
{
return findGroupRoleTypes(group, null);
}
+ public Collection<RoleType> findGroupRoleTypes(String groupId,
IdentitySearchControl[] controls) throws IdentityException
+ {
+ Group group = createGroupFromId(groupId);
+
+ return findGroupRoleTypes(group, controls);
+ }
+
public Collection<RoleType> findGroupRoleTypes(Group group,
IdentitySearchControl[] controls) throws IdentityException
{
Set<RoleType> types = new HashSet<RoleType>();
@@ -290,7 +334,7 @@
}
- public Collection<Group> findGroupsWithRelatedRole(Identity identity,
IdentitySearchControl[] controls) throws IdentityException
+ public Collection<Group> findGroupsWithRelatedRole(User identity,
IdentitySearchControl[] controls) throws IdentityException
{
List<Group> identities = new LinkedList<Group>();
@@ -308,8 +352,15 @@
return identities;
}
- public Collection<Group> findGroupsWithRelatedRole(Identity identity, GroupType
groupType, IdentitySearchControl[] controls) throws IdentityException
+ public Collection<Group> findGroupsWithRelatedRole(String userName,
IdentitySearchControl[] controls) throws IdentityException
{
+ User user = createUserFromId(userName);
+
+ return findGroupsWithRelatedRole(user, controls);
+ }
+
+ public Collection<Group> findGroupsWithRelatedRole(User identity, String
groupType, IdentitySearchControl[] controls) throws IdentityException
+ {
List<Group> identities = new LinkedList<Group>();
IdentityObjectType iot = getIdentityObjectType(groupType);
@@ -329,6 +380,13 @@
return identities;
}
+ public Collection<Group> findGroupsWithRelatedRole(String userName, String
groupType, IdentitySearchControl[] controls) throws IdentityException
+ {
+ User user = createUserFromId(userName);
+
+ return findGroupsWithRelatedRole(user, groupType, controls);
+ }
+
public Collection<Role> findRoles(IdentityType identityType, RoleType roleType)
throws IdentityException
{
Set<Role> roles = new HashSet<Role>();
@@ -336,7 +394,7 @@
Set<IdentityObjectRelationship> relationships = null;
// If Identity then search for parent relationships
- if (identityType instanceof Identity)
+ if (identityType instanceof User)
{
relationships = getRepository().resolveRelationships(getInvocationContext(),
createIdentityObject(identityType), ROLE, true, true, null);
}
@@ -350,11 +408,13 @@
{
if (roleType.getName().equals(relationship.getName()))
{
- roles.add(new SimpleRole(new SimpleRoleType(relationship.getName()),
createIdentity(relationship.getFromIdentityObject()),
createGroup(relationship.getToIdentityObject())));
+ roles.add(new SimpleRole(new SimpleRoleType(relationship.getName()),
createUser(relationship.getFromIdentityObject()),
createGroup(relationship.getToIdentityObject())));
}
}
return roles;
}
+
+
}
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/mapper/DirectIdentityObjectTypeMapperImpl.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/mapper/DirectIdentityObjectTypeMapperImpl.java 2009-03-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/mapper/DirectIdentityObjectTypeMapperImpl.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -25,8 +25,6 @@
import org.jboss.identity.idm.spi.model.IdentityObjectType;
import org.jboss.identity.idm.impl.types.SimpleIdentityObjectType;
import org.jboss.identity.idm.impl.api.session.mapper.IdentityObjectTypeMapper;
-import org.jboss.identity.idm.impl.api.model.SimpleGroupType;
-import org.jboss.identity.idm.api.GroupType;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
@@ -47,24 +45,24 @@
return new SimpleIdentityObjectType(identityTypeName);
}
- public IdentityObjectType getIdentityObjectType(GroupType groupType)
+ public IdentityObjectType getIdentityObjectType(String groupType)
{
if (groupType == null)
{
throw new IllegalArgumentException("groupType is null");
}
- return new SimpleIdentityObjectType(groupType.getName());
+ return new SimpleIdentityObjectType(groupType);
}
- public GroupType getGroupType(IdentityObjectType identityObjectType)
+ public String getGroupType(IdentityObjectType identityObjectType)
{
if (identityObjectType == null)
{
throw new IllegalArgumentException("identityObjectType is null");
}
- return new SimpleGroupType(identityObjectType.getName());
+ return identityObjectType.getName();
}
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/mapper/IdentityObjectTypeMapper.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/mapper/IdentityObjectTypeMapper.java 2009-03-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/mapper/IdentityObjectTypeMapper.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -23,8 +23,8 @@
package org.jboss.identity.idm.impl.api.session.mapper;
import org.jboss.identity.idm.spi.model.IdentityObjectType;
-import org.jboss.identity.idm.api.GroupType;
+
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
* @version : 0.1 $
@@ -35,10 +35,10 @@
IdentityObjectType getIdentityObjectType();
- IdentityObjectType getIdentityObjectType(GroupType groupType);
+ IdentityObjectType getIdentityObjectType(String groupType);
- GroupType getGroupType(IdentityObjectType identityObjectType);
+ String getGroupType(IdentityObjectType identityObjectType);
boolean isGroupType(IdentityObjectType identityObjectType);
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/mapper/IdentityObjectTypeMapperImpl.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/mapper/IdentityObjectTypeMapperImpl.java 2009-03-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/mapper/IdentityObjectTypeMapperImpl.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -23,10 +23,8 @@
package org.jboss.identity.idm.impl.api.session.mapper;
import org.jboss.identity.idm.spi.model.IdentityObjectType;
-import org.jboss.identity.idm.api.GroupType;
import org.jboss.identity.idm.impl.types.SimpleIdentityObjectType;
import org.jboss.identity.idm.impl.api.session.mapper.IdentityObjectTypeMapper;
-import org.jboss.identity.idm.impl.api.model.SimpleGroupType;
import java.util.Map;
import java.util.Collections;
@@ -56,7 +54,7 @@
return new SimpleIdentityObjectType(identityTypeName);
}
- public IdentityObjectType getIdentityObjectType(GroupType groupType)
+ public IdentityObjectType getIdentityObjectType(String groupType)
{
if (groupType == null)
{
@@ -65,7 +63,7 @@
for (Map.Entry<String, String> entry : groupTypeMap.entrySet())
{
- if (entry.getValue().equals(groupType.getName()))
+ if (entry.getValue().equals(groupType))
{
return new SimpleIdentityObjectType(entry.getKey());
}
@@ -74,22 +72,15 @@
return null;
}
- public GroupType getGroupType(IdentityObjectType identityObjectType)
+ public String getGroupType(IdentityObjectType identityObjectType)
{
if (identityObjectType == null)
{
throw new IllegalArgumentException("identityObjectType is null");
}
- String name = groupTypeMap.get(identityObjectType.getName());
+ return groupTypeMap.get(identityObjectType.getName());
- if (name != null)
- {
- return new SimpleGroupType(name);
- }
-
- return null;
-
}
public boolean isGroupType(IdentityObjectType identityObjectType)
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/IdentityTypeMappingsType.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/IdentityTypeMappingsType.java 2009-03-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/IdentityTypeMappingsType.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -43,7 +43,7 @@
})
public class IdentityTypeMappingsType {
- @XmlElement(name = "identity-mapping", required = true)
+ @XmlElement(name = "user-mapping", required = true)
protected String identityMapping;
@XmlElement(name = "group-type-mapping")
protected List<GroupTypeMappingType> groupTypeMapping;
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObject.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObject.java 2009-03-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObject.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -54,30 +54,6 @@
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
* @version : 0.1 $
*/
-//@NamedQueries({
-// @NamedQuery(
-// name = "findIdentityObjectByNameAndType",
-// query = "select o from HibernateIdentityObject o where o.realm like :realm
and o.name like :name and o.identityType.name like :typeName"
-// ),
-// @NamedQuery(
-// name = "findIdentityObjectsByType",
-// query = "select o from HibernateIdentityObject o where o.name like
:nameFilter and o.realm like :realm and o.identityType.name like :typeName"
-// ),
-// @NamedQuery(
-// name = "findIdentityObjectsByTypeOrderedByNameAsc",
-// query = "select o from HibernateIdentityObject o where o.name like
:nameFilter and o.realm like :realm and o.identityType.name like :typeName " +
-// "order by o.name asc"
-// ),
-// @NamedQuery(
-// name = "findIdentityObjectsByTypeOrderedByNameDesc",
-// query = "select o from HibernateIdentityObject o where o.name like
:nameFilter and o.realm like :realm and o.identityType.name like :typeName " +
-// "order by o.name desc"
-// ),
-// @NamedQuery(
-// name = "countIdentityObjectsByType",
-// query = "select count(o.id) from HibernateIdentityObject o where o.realm
like :realm and o.identityType.name like :typeName"
-// )
-// })
@Entity
@Table(name = "identity_obj", uniqueConstraints =
{@UniqueConstraint(columnNames = {"NAME", "IDENTITY_TYPE",
"REALM"})})
public class HibernateIdentityObject implements IdentityObject
@@ -117,10 +93,10 @@
@OneToMany(mappedBy = "toIdentityObject")
private Set<HibernateIdentityObjectRelationship> toRelationships = new
HashSet<HibernateIdentityObjectRelationship>();
- @OneToMany(fetch = FetchType.EAGER, cascade = {CascadeType.PERSIST, CascadeType.MERGE,
CascadeType.REMOVE},
+ @OneToMany(fetch = FetchType.EAGER, cascade = {CascadeType.ALL},
mappedBy = "identityObject")
@org.hibernate.annotations.Cascade(
- value = org.hibernate.annotations.CascadeType.DELETE_ORPHAN
+ value = {org.hibernate.annotations.CascadeType.DELETE_ORPHAN}
)
private Set<HibernateIdentityObjectAttribute> attributes = new
HashSet<HibernateIdentityObjectAttribute>();
@@ -193,6 +169,12 @@
this.attributes = attributes;
}
+ public void addAttribute(HibernateIdentityObjectAttribute attribute)
+ {
+ attribute.setIdentityObject(this);
+ this.attributes.add(attribute);
+ }
+
public Map<String, Collection> getAttributesAsMap()
{
Map<String, Collection> map = new HashMap<String, Collection>();
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectAttribute.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectAttribute.java 2009-03-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectAttribute.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -47,6 +47,7 @@
{
@Id
@GeneratedValue
+ @Column(name="ATTRIBUTE_ID")
private Long id;
@ManyToOne
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectBinaryAttribute.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectBinaryAttribute.java 2009-03-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectBinaryAttribute.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -26,6 +26,8 @@
import javax.persistence.Entity;
import javax.persistence.Table;
+import javax.persistence.PrimaryKeyJoinColumn;
+import javax.persistence.OneToMany;
import java.util.Set;
import java.util.HashSet;
import java.util.Collections;
@@ -37,9 +39,11 @@
@Entity
@Table(name = "identity_obj_attrs_binary")
+@PrimaryKeyJoinColumn(name = "ATTRIBUTE_ID")
public class HibernateIdentityObjectBinaryAttribute extends
HibernateIdentityObjectAttribute
{
- @CollectionOfElements
+
+ @CollectionOfElements(targetElement = byte[].class)
private Set<byte[]> values = new HashSet<byte[]>();
public HibernateIdentityObjectBinaryAttribute()
@@ -86,5 +90,5 @@
values.add((byte[])value);
}
}
-
+
}
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectRelationship.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectRelationship.java 2009-03-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectRelationship.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -42,16 +42,6 @@
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
* @version : 0.1 $
*/
-//@NamedQueries({
-// @NamedQuery(
-// name = "findIdentityObjectRelationshipsByType",
-// query = "select r from HibernateIdentityObjectRelationship r where
r.type.name like :typeName"
-// ),
-// @NamedQuery(
-// name = "findIdentityObjectRelationshipNamesByType",
-// query = "select r.name from HibernateIdentityObjectRelationship r where
r.type.name like :typeName"
-// )
-// })
@Entity
@Table(name="identity_relationship", uniqueConstraints =
{@UniqueConstraint(columnNames = {"NAME", "TYPE",
"FROM_IDENTITY", "TO_IDENTITY"})})
public class HibernateIdentityObjectRelationship implements IdentityObjectRelationship
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectRelationshipName.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectRelationshipName.java 2009-03-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectRelationshipName.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -39,42 +39,6 @@
*/
@Entity
@Table(name="identity_relationship_name", uniqueConstraints =
{@UniqueConstraint(columnNames = {"NAME", "REALM"})})
-//@NamedQueries({
-// @NamedQuery(
-// name = "findIdentityObjectRelationshipNameByName",
-// query = "select rn from HibernateIdentityObjectRelationshipName rn where
rn.name like :name and rn.realm like :realm"
-// ),
-// @NamedQuery(
-// name = "findIdentityObjectRelationshipNames",
-// query = "select rn.name from HibernateIdentityObjectRelationshipName rn
where rn.name like :nameFilter and rn.realm like :realm"
-// ),
-// @NamedQuery(
-// name = "findIdentityObjectRelationshipNamesOrderedByNameAsc",
-// query = "select rn.name from HibernateIdentityObjectRelationshipName rn
where rn.name like :nameFilter and rn.realm like :realm " +
-// "order by rn.name asc"
-// ),
-// @NamedQuery(
-// name = "findIdentityObjectRelationshipNamesOrderedByNameDesc",
-// query = "select rn.name from HibernateIdentityObjectRelationshipName rn
where rn.name like :nameFilter and rn.realm like :realm " +
-// "order by rn.name desc"
-// ),
-// @NamedQuery(
-// name = "findIdentityObjectRelationshipNamesForIdentityObject",
-// query = "select r.name.name from HibernateIdentityObjectRelationship r where
" +
-// "r.fromIdentityObject like :identityObject or r.toIdentityObject like
:identityObject"
-// ),
-// @NamedQuery(
-// name =
"findIdentityObjectRelationshipNamesForIdentityObjectOrderedByNameAsc",
-// query = "select r.name.name from HibernateIdentityObjectRelationship r where
" +
-// "r.fromIdentityObject like :identityObject or r.toIdentityObject like
:identityObject " +
-// "order by r.name.name asc"
-// ),
-// @NamedQuery(
-// name =
"findIdentityObjectRelationshipNamesForIdentityObjectOrdereByNameDesc",
-// query = "select r.name.name from HibernateIdentityObjectRelationship r where
" +
-// "r.fromIdentityObject like :identityObject or r.toIdentityObject like
:identityObject " +
-// "order by r.name.name desc")
-//})
public class HibernateIdentityObjectRelationshipName
{
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectTextAttribute.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectTextAttribute.java 2009-03-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectTextAttribute.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -28,6 +28,8 @@
import javax.persistence.Entity;
import javax.persistence.Table;
+import javax.persistence.PrimaryKeyJoinColumn;
+import javax.persistence.OneToMany;
import org.hibernate.annotations.CollectionOfElements;
@@ -37,6 +39,7 @@
*/
@Entity
@Table(name = "identity_obj_attrs_text")
+@PrimaryKeyJoinColumn(name = "ATTRIBUTE_ID")
public class HibernateIdentityObjectTextAttribute extends
HibernateIdentityObjectAttribute
{
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateRealm.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateRealm.java 2009-03-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateRealm.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -41,12 +41,6 @@
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
* @version : 0.1 $
*/
-//@NamedQueries({
-// @NamedQuery(
-// name = "findIRealmByName",
-// query = "select o from HibernateRealm o where o.name like :name"
-// )
-//})
@Entity
@Table(name = "identity_realm", uniqueConstraints =
{@UniqueConstraint(columnNames = {"NAME"})})
public class HibernateRealm
@@ -91,6 +85,14 @@
return name;
}
+ @Override
+ public String toString()
+ {
+ return "HibernateRealm{" +
+ "name='" + name + '\'' +
+ '}';
+ }
+
public void setName(String name)
{
this.name = name;
@@ -105,4 +107,6 @@
{
this.properties = properties;
}
+
+
}
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-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -38,8 +38,10 @@
import org.hibernate.Session;
import org.hibernate.Query;
import org.hibernate.SessionFactory;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.criterion.Restrictions;
-import org.hibernate.ejb.HibernateEntityManagerFactory;
+//import org.hibernate.ejb.HibernateEntityManagerFactory;
import org.jboss.identity.idm.exception.IdentityException;
import org.jboss.identity.idm.impl.api.AttributeFilterSearchControl;
import org.jboss.identity.idm.impl.api.NameFilterSearchControl;
@@ -74,9 +76,10 @@
import org.jboss.identity.idm.spi.store.IdentityStoreInvocationContext;
import org.jboss.identity.idm.spi.store.IdentityStoreSession;
-import javax.persistence.Persistence;
+//import javax.persistence.Persistence;
import javax.naming.InitialContext;
import javax.naming.NamingException;
+//import javax.persistence.Persistence;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
@@ -106,6 +109,8 @@
public static final String PERSISTENCE_UNIT = "persistenceUnit";
+ public static final String HIBERNATE_CONFIGURATION =
"hibernateConfiguration";
+
public static final String HIBERNATE_SESSION_FACTORY_JNDI_NAME =
"hibernateSessionFactoryJNDIName";
public static final String POPULATE_MEMBERSHIP_TYPES =
"populateRelationshipTypes";
@@ -304,6 +309,8 @@
hibernateSession.flush();
+ hibernateSession.close();
+
}
protected SessionFactory
bootstrapHibernateSessionFactory(IdentityStoreConfigurationMetaData configurationMD)
throws IdentityException
@@ -311,6 +318,7 @@
String sfJNDIName =
configurationMD.getOptionSingleValue(HIBERNATE_SESSION_FACTORY_JNDI_NAME);
String persistenceUnit = configurationMD.getOptionSingleValue(PERSISTENCE_UNIT);
+ String hibernateConfiguration =
configurationMD.getOptionSingleValue(HIBERNATE_CONFIGURATION);
if (sfJNDIName != null)
{
@@ -323,19 +331,46 @@
throw new IdentityException("Cannot obtain hibernate SessionFactory from
provided JNDI name: " + sfJNDIName, e);
}
}
- else if (persistenceUnit != null)
+ else if (hibernateConfiguration != null)
{
try
{
- return
((HibernateEntityManagerFactory)Persistence.createEntityManagerFactory(persistenceUnit)).getSessionFactory();
+ AnnotationConfiguration config = new
AnnotationConfiguration().configure(hibernateConfiguration);
+
+ return config.addAnnotatedClass(HibernateIdentityObject.class)
+ .addAnnotatedClass(HibernateIdentityObjectAttribute.class)
+ .addAnnotatedClass(HibernateIdentityObjectBinaryAttribute.class)
+ .addAnnotatedClass(HibernateIdentityObjectTextAttribute.class)
+ .addAnnotatedClass(HibernateIdentityObjectCredential.class)
+ .addAnnotatedClass(HibernateIdentityObjectCredentialType.class)
+ .addAnnotatedClass(HibernateIdentityObjectRelationship.class)
+ .addAnnotatedClass(HibernateIdentityObjectRelationshipName.class)
+ .addAnnotatedClass(HibernateIdentityObjectRelationshipType.class)
+ .addAnnotatedClass(HibernateIdentityObjectType.class)
+ .addAnnotatedClass(HibernateRealm.class).buildSessionFactory();
+
+
}
catch (Exception e)
{
- throw new IdentityException("Cannot obtain hibernate SessionFactory
using provided persistence unit name: "+ persistenceUnit, e);
+ throw new IdentityException("Cannot obtain hibernate SessionFactory
using provided hibernate configuration: "+ hibernateConfiguration, e);
}
}
+// else if (persistenceUnit != null)
+// {
+//
+// try
+// {
+// return
((HibernateEntityManagerFactory)Persistence.createEntityManagerFactory(persistenceUnit)).getSessionFactory();
+// }
+// catch (Exception e)
+// {
+// throw new IdentityException("Cannot obtain hibernate SessionFactory
using provided persistence unit name: "+ persistenceUnit, e);
+// }
+//
+// }
throw new IdentityException("Cannot obtain hibernate SessionFactory. None of
supported options specified: "
+ HIBERNATE_SESSION_FACTORY_JNDI_NAME + ", " + PERSISTENCE_UNIT);
@@ -348,7 +383,7 @@
{
try
{
- return new HibernateIdentityStoreSessionImpl(sessionFactory.openSession());
+ return new HibernateIdentityStoreSessionImpl(sessionFactory);
}
catch (Exception e)
{
@@ -402,11 +437,10 @@
if (results.size() != 0)
{
- throw new IdentityException("IdentityObject already present in this
IdentityStore");
+ throw new IdentityException("IdentityObject already present in this
IdentityStore:" +
+ "name=" + name + "; type=" + identityObjectType.getName()
+ "; realm=" + realm);
}
-
-
HibernateIdentityObjectType hibernateType = getHibernateIdentityObjectType(ctx,
identityObjectType);
HibernateIdentityObject io = new HibernateIdentityObject(name, hibernateType,
realm);
@@ -1494,6 +1528,8 @@
Map<String, IdentityObjectAttributeMetaData> mdMap =
attributesMetaData.get(identity.getIdentityType().getName());
+ Session hibernateSession = getHibernateSession(ctx);
+
for (IdentityObjectAttribute attribute : attributes)
{
String name = resolveAttributeStoreMapping(identity.getIdentityType(),
attribute.getName());
@@ -1631,7 +1667,7 @@
}
- hibernateObject.getAttributes().add(hibernateAttribute);
+ hibernateObject.addAttribute(hibernateAttribute);
}
}
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreSessionImpl.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreSessionImpl.java 2009-03-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreSessionImpl.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -24,11 +24,8 @@
import org.jboss.identity.idm.spi.store.IdentityStoreSession;
import org.jboss.identity.idm.exception.IdentityException;
-import org.hibernate.Session;
-import org.hibernate.ejb.HibernateEntityManagerFactory;
+import org.hibernate.SessionFactory;
-import javax.persistence.Persistence;
-
/**
* Wrapper around HibernateEntityManager
*
@@ -38,42 +35,36 @@
public class HibernateIdentityStoreSessionImpl implements IdentityStoreSession
{
- private final Session hibernateSession;
+ private final SessionFactory sessionFactory;
- public HibernateIdentityStoreSessionImpl(Session hibernateSession)
+ public HibernateIdentityStoreSessionImpl(SessionFactory sessionFactory)
{
- this.hibernateSession = hibernateSession;
+ this.sessionFactory = sessionFactory;
}
- public HibernateIdentityStoreSessionImpl(String persistenceUnit)
- {
- HibernateEntityManagerFactory emFactory =
(HibernateEntityManagerFactory)Persistence.createEntityManagerFactory(persistenceUnit);
- hibernateSession = emFactory.getSessionFactory().openSession();
- }
-
public Object getSessionContext()
{
- return hibernateSession;
+ return sessionFactory.getCurrentSession();
}
public void close() throws IdentityException
{
- hibernateSession.close();
+ sessionFactory.getCurrentSession().close();
}
public void save() throws IdentityException
{
- hibernateSession.flush();
+ sessionFactory.getCurrentSession().flush();
}
public void clear() throws IdentityException
{
- hibernateSession.clear();
+ sessionFactory.getCurrentSession().clear();
}
public boolean isOpen()
{
- return hibernateSession.isOpen();
+ return sessionFactory.getCurrentSession().isOpen();
}
public boolean isTransactionSupported()
@@ -83,21 +74,21 @@
public void startTransaction()
{
- hibernateSession.getTransaction().begin();
+ sessionFactory.getCurrentSession().getTransaction().begin();
}
public void commitTransaction()
{
- hibernateSession.getTransaction().commit();
+ sessionFactory.getCurrentSession().getTransaction().commit();
}
public void rollbackTransaction()
{
- hibernateSession.getTransaction().rollback();
+ sessionFactory.getCurrentSession().getTransaction().rollback();
}
public boolean isTransactionActive()
{
- return hibernateSession.getTransaction().isActive();
+ return sessionFactory.getCurrentSession().getTransaction().isActive();
}
}
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/types/SimpleIdentityObject.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/types/SimpleIdentityObject.java 2009-03-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/types/SimpleIdentityObject.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -64,6 +64,22 @@
this.type = type;
}
+ public SimpleIdentityObject(String name, IdentityObjectType type)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("name is null");
+ }
+ if (type == null)
+ {
+ throw new IllegalArgumentException("type is null");
+ }
+
+ this.name = name;
+ this.type = type;
+ this.id = null;
+ }
+
public String getName()
{
return name;
Modified:
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/HibernateTestSupport.java
===================================================================
---
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/HibernateTestSupport.java 2009-03-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/HibernateTestSupport.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -24,10 +24,9 @@
import
org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipType;
import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectType;
-import org.hibernate.ejb.HibernateEntityManagerFactory;
-import org.hibernate.ejb.HibernateEntityManager;
+import org.hibernate.SessionFactory;
+import org.hibernate.cfg.AnnotationConfiguration;
-import javax.persistence.Persistence;
import java.util.logging.Logger;
import java.sql.Connection;
import java.sql.DriverManager;
@@ -40,33 +39,26 @@
{
private static Logger logger =
Logger.getLogger(HibernateTestSupport.class.getName());
- private HibernateEntityManagerFactory emFactory;
+ protected SessionFactory sessionFactory;
- protected HibernateEntityManager em;
-
private Connection connection;
private final String databaseName;
- private final String persistenceUnit;
+ private final String hibernateConfiguration;
- public HibernateTestSupport(String databaseName, String persistenceUnit)
+ public HibernateTestSupport(String databaseName, String hibernateConfiguration)
{
this.databaseName = databaseName;
- this.persistenceUnit = persistenceUnit;
+ this.hibernateConfiguration = hibernateConfiguration;
}
- public HibernateEntityManager getHibernateEntityManager()
+ public SessionFactory getSessionFactory()
{
- return em;
+ return sessionFactory;
}
- public HibernateEntityManagerFactory getHibernateEntityManagerFactory()
- {
- return emFactory;
- }
-
public void start() throws Exception {
try {
logger.info("Starting in-memory HSQL database for unit tests");
@@ -82,8 +74,8 @@
try
{
logger.info("Building JPA EntityManager for unit tests");
- emFactory =
(HibernateEntityManagerFactory)Persistence.createEntityManagerFactory(persistenceUnit);
- em = (HibernateEntityManager)emFactory.createEntityManager();
+ //emFactory =
(HibernateEntityManagerFactory)Persistence.createEntityManagerFactory(persistenceUnit);
+ sessionFactory = new
AnnotationConfiguration().configure(hibernateConfiguration).buildSessionFactory();
}
catch (Exception ex)
{
@@ -95,14 +87,11 @@
public void stop() throws Exception {
logger.info("Shuting down Hibernate JPA layer.");
- if (em != null)
+ if (sessionFactory != null)
{
- em.close();
+ sessionFactory.close();
}
- if (emFactory != null)
- {
- emFactory.close();
- }
+
logger.info("Stopping in-memory HSQL database.");
try
{
@@ -116,30 +105,30 @@
public void populateObjectTypes(String[] typeNames) throws Exception
{
- em.getTransaction().begin();
+ sessionFactory.getCurrentSession().getTransaction().begin();
for (String typeName : typeNames)
{
HibernateIdentityObjectType hibernateType = new
HibernateIdentityObjectType(typeName);
- em.persist(hibernateType);
+ sessionFactory.getCurrentSession().persist(hibernateType);
}
- em.getTransaction().commit();
+ sessionFactory.getCurrentSession().getTransaction().commit();
}
public void populateRelationshipTypes(String[] typeNames) throws Exception
{
- em.getTransaction().begin();
+ sessionFactory.getCurrentSession().getTransaction().begin();
for (String typeName : typeNames)
{
HibernateIdentityObjectRelationshipType hibernateType = new
HibernateIdentityObjectRelationshipType(typeName);
- em.persist(hibernateType);
+ sessionFactory.getCurrentSession().persist(hibernateType);
}
- em.getTransaction().commit();
+ sessionFactory.getCurrentSession().getTransaction().commit();
}
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-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestCase.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -42,7 +42,8 @@
*/
public class APITestCase extends TestCase implements APITestContext
{
- HibernateTestSupport hibernateSupport = new
HibernateTestSupport("unit-testing-jpa1", "jboss-identity-model1");
+ HibernateTestSupport hibernateSupport =
+ new HibernateTestSupport("unit-testing-jpa1",
"hibernate-jboss-identity-classes.cfg.xml");
OrganizationTest orgTest;
Modified: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/GroupTypeEnum.java
===================================================================
---
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/GroupTypeEnum.java 2009-03-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/GroupTypeEnum.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -23,13 +23,13 @@
package org.jboss.identity.idm.impl.api;
-import org.jboss.identity.idm.api.GroupType;
+
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
* @version : 0.1 $
*/
-public enum GroupTypeEnum implements GroupType
+public enum GroupTypeEnum
{
ADMINISTRATION,
ORGANIZATION,
Added: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/ModelTestCase.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/ModelTestCase.java
(rev 0)
+++
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/ModelTestCase.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -0,0 +1,44 @@
+/*
+* 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.api;
+
+import junit.framework.TestCase;
+import org.jboss.identity.idm.impl.api.model.GroupId;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class ModelTestCase extends TestCase
+{
+
+ public void testGroupId() throws Exception
+ {
+ GroupId id = new GroupId("groupTypeName/groupName");
+ assertEquals("groupName", id.getName());
+ assertEquals("groupTypeName", id.getType());
+
+ }
+
+
+}
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-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTest.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -24,14 +24,12 @@
import org.jboss.identity.idm.api.IdentitySession;
import org.jboss.identity.idm.api.Group;
-import org.jboss.identity.idm.api.GroupType;
-import org.jboss.identity.idm.api.Identity;
+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.p3p.P3PConstants;
-import org.jboss.identity.idm.impl.api.model.SimpleGroupType;
import java.util.Collection;
import java.util.Map;
@@ -69,12 +67,12 @@
{
// GroupType
- GroupType ORGANIZATION = new SimpleGroupType("ORGANIZATION");
- GroupType ORGANIZATION_UNIT = new SimpleGroupType("ORGANIZATION_UNIT");
- GroupType DIVISION = new SimpleGroupType("DIVISION");
- GroupType DEPARTMENT = new SimpleGroupType("DEPARTMENT");
- GroupType PROJECT = new SimpleGroupType("PROJECT");
- GroupType PEOPLE = new SimpleGroupType("PEOPLE");
+ String ORGANIZATION = "ORGANIZATION";
+ String ORGANIZATION_UNIT = "ORGANIZATION_UNIT";
+ String DIVISION = "DIVISION";
+ String DEPARTMENT = "DEPARTMENT";
+ String PROJECT = "PROJECT";
+ String PEOPLE = "PEOPLE";
IdentitySessionFactory factory = ctx.getIdentitySessionFactory();
@@ -138,39 +136,39 @@
// Management
- Identity theuteUser =
session.getPersistenceManager().createIdentity("theute");
- Identity mlittleUser =
session.getPersistenceManager().createIdentity("mlittle");
- Identity bgeorgesUser =
session.getPersistenceManager().createIdentity("bgeorges");
- Identity asaldhanaUser =
session.getPersistenceManager().createIdentity("asaldhana");
- Identity janderseUser =
session.getPersistenceManager().createIdentity("janderse");
+ User theuteUser = session.getPersistenceManager().createUser("theute");
+ User mlittleUser =
session.getPersistenceManager().createUser("mlittle");
+ User bgeorgesUser =
session.getPersistenceManager().createUser("bgeorges");
+ User asaldhanaUser =
session.getPersistenceManager().createUser("asaldhana");
+ User janderseUser =
session.getPersistenceManager().createUser("janderse");
// Portal Team
- Identity bdawidowUser =
session.getPersistenceManager().createIdentity("bdawidow");
- Identity claprunUser =
session.getPersistenceManager().createIdentity("claprun");
- Identity whalesUser =
session.getPersistenceManager().createIdentity("whales");
- Identity sshahUser =
session.getPersistenceManager().createIdentity("sshah");
- Identity mwringeUser =
session.getPersistenceManager().createIdentity("mwringe");
+ User bdawidowUser =
session.getPersistenceManager().createUser("bdawidow");
+ User claprunUser =
session.getPersistenceManager().createUser("claprun");
+ User whalesUser = session.getPersistenceManager().createUser("whales");
+ User sshahUser = session.getPersistenceManager().createUser("sshah");
+ User mwringeUser =
session.getPersistenceManager().createUser("mwringe");
// Store as employees
- session.getRelationshipManager().associateIdentities(employeesGroup, theuteUser);
- session.getRelationshipManager().associateIdentities(employeesGroup, mlittleUser);
- session.getRelationshipManager().associateIdentities(employeesGroup,
asaldhanaUser);
- session.getRelationshipManager().associateIdentities(employeesGroup,
bdawidowUser);
- session.getRelationshipManager().associateIdentities(employeesGroup, claprunUser);
- session.getRelationshipManager().associateIdentities(employeesGroup, whalesUser);
- session.getRelationshipManager().associateIdentities(employeesGroup, sshahUser);
- session.getRelationshipManager().associateIdentities(employeesGroup, mwringeUser);
+ 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);
// Portal team for management purposes
Group portalTeamGroup = session.getPersistenceManager().createGroup("Portal
Team", PEOPLE);
- session.getRelationshipManager().associateIdentities(portalTeamGroup,
bdawidowUser);
- session.getRelationshipManager().associateIdentities(portalTeamGroup,
claprunUser);
- session.getRelationshipManager().associateIdentities(portalTeamGroup, whalesUser);
- session.getRelationshipManager().associateIdentities(portalTeamGroup, sshahUser);
- session.getRelationshipManager().associateIdentities(portalTeamGroup,
mwringeUser);
+ 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);
// Portal team is under common frameworks
@@ -216,7 +214,7 @@
// Check what RoleTypes has user theute
- Collection<RoleType> roleTypes =
session.getRoleManager().findIdentityRoleTypes(theuteUser);
+ Collection<RoleType> roleTypes =
session.getRoleManager().findUserRoleTypes(theuteUser);
assertEquals(3, roleTypes.size());
assertTrue(roleTypes.contains(developerRT));
assertTrue(roleTypes.contains(leadDeveloperRT));
@@ -229,7 +227,7 @@
// Check where anil is Lead Developer and where Developer
- roleTypes = session.getRoleManager().findIdentityRoleTypes(asaldhanaUser);
+ roleTypes = session.getRoleManager().findUserRoleTypes(asaldhanaUser);
assertEquals(2, roleTypes.size());
assertTrue(roleTypes.contains(developerRT));
assertTrue(roleTypes.contains(leadDeveloperRT));
@@ -247,7 +245,7 @@
// Assert relationships
- Collection<Identity> identities =
session.getRelationshipManager().findAssociatedIdentities(portalTeamGroup, false);
+ Collection<User> identities =
session.getRelationshipManager().findAssociatedUsers(portalTeamGroup, false);
assertEquals(5, identities.size());
assertTrue(identities.contains(claprunUser));
assertTrue(identities.contains(mwringeUser));
@@ -304,16 +302,16 @@
public void testSamplePortal(String realmName) throws Exception
{
- GroupType SYSTEM = new SimpleGroupType("SYSTEM");
- GroupType ADMINISTRATION = new SimpleGroupType("ADMINISTRATION");
- GroupType COMMUNITY = new SimpleGroupType("COMMUNITY");
- GroupType ORGANIZATION = new SimpleGroupType("ORGANIZATION");
- GroupType ORGANIZATION_UNIT = new SimpleGroupType("ORGANIZATION_UNIT");
- GroupType OFFICE = new SimpleGroupType("OFFICE");
- GroupType DIVISION = new SimpleGroupType("DIVISION");
- GroupType DEPARTMENT = new SimpleGroupType("DEPARTMENT");
- GroupType SECURITY = new SimpleGroupType("SECURITY");
- GroupType PEOPLE = new SimpleGroupType("PEOPLE");
+ String SYSTEM = "SYSTEM";
+ String ADMINISTRATION = "ADMINISTRATION";
+ String COMMUNITY = "COMMUNITY";
+ String ORGANIZATION = "ORGANIZATION";
+ String ORGANIZATION_UNIT = "ORGANIZATION_UNIT";
+ String OFFICE = "OFFICE";
+ String DIVISION = "DIVISION";
+ String DEPARTMENT = "DEPARTMENT";
+ String SECURITY = "SECURITY";
+ String PEOPLE = "PEOPLE";
IdentitySessionFactory factory = ctx.getIdentitySessionFactory();
@@ -321,6 +319,8 @@
session.getTransaction().start();
+
+
// Create all role types
RoleType adminRT = session.getRoleManager().createRoleType("Admin");
RoleType accountAdminRT = session.getRoleManager().createRoleType("Account
Admin");
@@ -340,6 +340,10 @@
Group organizationRootGroup =
session.getPersistenceManager().createGroup("ORGANIZATION_ROOT",SYSTEM);
Group usersROOTGroup =
session.getPersistenceManager().createGroup("USERS_ROOT",SYSTEM);
+ session.getTransaction().commit();
+
+ session.getTransaction().start();
+
// Communities
Group portalLoversCommunity =
session.getPersistenceManager().createGroup("Portal Lovers", COMMUNITY);
@@ -398,33 +402,40 @@
// People
- Identity anneUser =
session.getPersistenceManager().createIdentity("anne");
- Identity marieUser =
session.getPersistenceManager().createIdentity("marie");
- Identity eveUser =
session.getPersistenceManager().createIdentity("eve");
- Identity angelinaUser =
session.getPersistenceManager().createIdentity("angelina");
- Identity joannaUser =
session.getPersistenceManager().createIdentity("joanna");
- Identity merilUser =
session.getPersistenceManager().createIdentity("meril");
- Identity johnUser =
session.getPersistenceManager().createIdentity("john");
- Identity stanUser =
session.getPersistenceManager().createIdentity("stan");
- Identity chrisUser =
session.getPersistenceManager().createIdentity("chris");
- Identity billUser =
session.getPersistenceManager().createIdentity("bill");
- Identity jackUser =
session.getPersistenceManager().createIdentity("jack");
+ User anneUser = session.getPersistenceManager().createUser("anne");
+ User marieUser = session.getPersistenceManager().createUser("marie");
+ User eveUser = session.getPersistenceManager().createUser("eve");
+ User angelinaUser =
session.getPersistenceManager().createUser("angelina");
+ User joannaUser = session.getPersistenceManager().createUser("joanna");
+ User merilUser = session.getPersistenceManager().createUser("meril");
+ User johnUser = session.getPersistenceManager().createUser("john");
+ User stanUser = session.getPersistenceManager().createUser("stan");
+ User chrisUser = session.getPersistenceManager().createUser("chris");
+ User billUser = session.getPersistenceManager().createUser("bill");
+ User jackUser = session.getPersistenceManager().createUser("jack");
+ session.getTransaction().commit();
+
+ session.getTransaction().start();
+
// All users are under people root
- session.getRelationshipManager().associateIdentities(usersROOTGroup, anneUser);
- session.getRelationshipManager().associateIdentities(usersROOTGroup, marieUser);
- session.getRelationshipManager().associateIdentities(usersROOTGroup, eveUser);
- session.getRelationshipManager().associateIdentities(usersROOTGroup,
angelinaUser);
- session.getRelationshipManager().associateIdentities(usersROOTGroup, joannaUser);
- session.getRelationshipManager().associateIdentities(usersROOTGroup, merilUser);
- session.getRelationshipManager().associateIdentities(usersROOTGroup, johnUser);
- session.getRelationshipManager().associateIdentities(usersROOTGroup, stanUser);
- session.getRelationshipManager().associateIdentities(usersROOTGroup, chrisUser);
- session.getRelationshipManager().associateIdentities(usersROOTGroup, billUser);
- session.getRelationshipManager().associateIdentities(usersROOTGroup, jackUser);
+ 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.getTransaction().commit();
+ session.getTransaction().start();
+
//
@@ -441,18 +452,25 @@
// Anna works in Paris office and participates in BASE jumping community as a forum
moderator and CMS admin
- session.getRelationshipManager().associateIdentities(parisOffice, anneUser);
+ session.getRelationshipManager().associateUsers(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
+
+ session.save();
+
+ session.getTransaction().commit();
+
+ session.getTransaction().start();
+
session.getRoleManager().createRole(communityMemberRT, anneUser,
baseJumpingCommunity);
session.getRoleManager().createRole(communityForumModeratorRT, anneUser,
baseJumpingCommunity);
session.getRoleManager().createRole(communityCMSAdminRT, anneUser,
baseJumpingCommunity);
// Anne belongs to CMS portal admins security group
- session.getRelationshipManager().associateIdentities(cmsAdminGroup, anneUser);
+ session.getRelationshipManager().associateUsers(cmsAdminGroup, anneUser);
// Ann is also an owner of geeks community
@@ -473,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().associateIdentities(londonOffice, angelinaUser);
+ session.getRelationshipManager().associateUsers(londonOffice, angelinaUser);
session.getRoleManager().createRole(officeManagerRT, angelinaUser, londonOffice);
@@ -484,7 +502,7 @@
// As office manager she also edits portal cms content
- session.getRelationshipManager().associateIdentities(cmsEditorGroup,
angelinaUser);
+ session.getRelationshipManager().associateUsers(cmsEditorGroup, angelinaUser);
//
@@ -493,9 +511,9 @@
// Some assertions
// How many users do we have in whole acme org and how many people in paris and
london offices
- assertEquals(11,
session.getRelationshipManager().findAssociatedIdentities(usersROOTGroup, false).size());
- assertEquals(1,
session.getRelationshipManager().findAssociatedIdentities(parisOffice, false).size());
- assertEquals(1,
session.getRelationshipManager().findAssociatedIdentities(londonOffice, false).size());
+ assertEquals(11,
session.getRelationshipManager().findAssociatedUsers(usersROOTGroup, false).size());
+ assertEquals(1, session.getRelationshipManager().findAssociatedUsers(parisOffice,
false).size());
+ assertEquals(1, session.getRelationshipManager().findAssociatedUsers(londonOffice,
false).size());
// Is anne geeks community owner?
Modified:
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/CommonIdentityStoreTest.java
===================================================================
---
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/CommonIdentityStoreTest.java 2009-03-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/CommonIdentityStoreTest.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -71,8 +71,8 @@
testContext.begin();
- IdentityObject user1 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Adam",
IdentityTypeEnum.IDENTITY);
- IdentityObject user2 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Eva",
IdentityTypeEnum.IDENTITY);
+ IdentityObject user1 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Adam",
IdentityTypeEnum.USER);
+ IdentityObject user2 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Eva",
IdentityTypeEnum.USER);
IdentityObject group1 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Devision1",
IdentityTypeEnum.ORGANIZATION);
IdentityObject group2 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Devision2",
IdentityTypeEnum.ORGANIZATION);
@@ -82,7 +82,7 @@
testContext.flush();
assertEquals(0,
testContext.getStore().getIdentityObjectsCount(testContext.getCtx(),
IdentityTypeEnum.ROLE));
- assertEquals(2,
testContext.getStore().getIdentityObjectsCount(testContext.getCtx(),
IdentityTypeEnum.IDENTITY));
+ assertEquals(2,
testContext.getStore().getIdentityObjectsCount(testContext.getCtx(),
IdentityTypeEnum.USER));
assertEquals(4,
testContext.getStore().getIdentityObjectsCount(testContext.getCtx(),
IdentityTypeEnum.ORGANIZATION));
testContext.flush();
@@ -91,14 +91,14 @@
testContext.getStore().removeIdentityObject(testContext.getCtx(), group1);
testContext.getStore().removeIdentityObject(testContext.getCtx(), group2);
- assertEquals(1,
testContext.getStore().getIdentityObjectsCount(testContext.getCtx(),
IdentityTypeEnum.IDENTITY));
+ assertEquals(1,
testContext.getStore().getIdentityObjectsCount(testContext.getCtx(),
IdentityTypeEnum.USER));
assertEquals(2,
testContext.getStore().getIdentityObjectsCount(testContext.getCtx(),
IdentityTypeEnum.ORGANIZATION));
testContext.getStore().removeIdentityObject(testContext.getCtx(), user2);
testContext.getStore().removeIdentityObject(testContext.getCtx(), group3);
testContext.getStore().removeIdentityObject(testContext.getCtx(), group4);
- assertEquals(0,
testContext.getStore().getIdentityObjectsCount(testContext.getCtx(),
IdentityTypeEnum.IDENTITY));
+ assertEquals(0,
testContext.getStore().getIdentityObjectsCount(testContext.getCtx(),
IdentityTypeEnum.USER));
assertEquals(0,
testContext.getStore().getIdentityObjectsCount(testContext.getCtx(),
IdentityTypeEnum.ORGANIZATION));
testContext.commit();
@@ -110,8 +110,8 @@
testContext.begin();
- IdentityObject user1 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Adam",
IdentityTypeEnum.IDENTITY);
- IdentityObject user2 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Eva",
IdentityTypeEnum.IDENTITY);
+ IdentityObject user1 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Adam",
IdentityTypeEnum.USER);
+ IdentityObject user2 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Eva",
IdentityTypeEnum.USER);
IdentityObject group1 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Devision1",
IdentityTypeEnum.ORGANIZATION);
IdentityObject group2 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Devision2",
IdentityTypeEnum.ORGANIZATION);
@@ -120,13 +120,13 @@
testContext.flush();
- IdentityObject xx = testContext.getStore().findIdentityObject(testContext.getCtx(),
"Adam", IdentityTypeEnum.IDENTITY);
+ IdentityObject xx = testContext.getStore().findIdentityObject(testContext.getCtx(),
"Adam", IdentityTypeEnum.USER);
assertEquals(xx.getId(), user1.getId());
xx = testContext.getStore().findIdentityObject(testContext.getCtx(),
user2.getId());
assertEquals(xx.getId(), user2.getId());
- Collection results =
testContext.getStore().findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY,
null);
+ Collection results =
testContext.getStore().findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER,
null);
assertEquals(2, results.size());
results = testContext.getStore().findIdentityObject(testContext.getCtx(),
IdentityTypeEnum.ORGANIZATION, null);
@@ -145,8 +145,8 @@
testContext.begin();
- IdentityObject user1 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Adam",
IdentityTypeEnum.IDENTITY);
- IdentityObject user2 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Eva",
IdentityTypeEnum.IDENTITY);
+ IdentityObject user1 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Adam",
IdentityTypeEnum.USER);
+ IdentityObject user2 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Eva",
IdentityTypeEnum.USER);
testContext.flush();
@@ -243,8 +243,8 @@
testContext.begin();
- IdentityObject user1 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Adam",
IdentityTypeEnum.IDENTITY);
- IdentityObject user2 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Eva",
IdentityTypeEnum.IDENTITY);
+ IdentityObject user1 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Adam",
IdentityTypeEnum.USER);
+ IdentityObject user2 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Eva",
IdentityTypeEnum.USER);
IdentityObject group1 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Devision1",
IdentityTypeEnum.ORGANIZATION);
IdentityObject group2 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Devision2",
IdentityTypeEnum.ORGANIZATION);
@@ -303,14 +303,14 @@
{
testContext.begin();
- IdentityObject user1 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Adam",
IdentityTypeEnum.IDENTITY);
- IdentityObject user2 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Eva",
IdentityTypeEnum.IDENTITY);
+ IdentityObject user1 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Adam",
IdentityTypeEnum.USER);
+ IdentityObject user2 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Eva",
IdentityTypeEnum.USER);
IdentityObjectCredential passwordCredential1 = new
PasswordCredential("SamplePasswordOne");
IdentityObjectCredential passwordCredential2 = new
PasswordCredential("SamplePasswordTwo");
// If PASSWORD is supported
-
assertTrue(testContext.getStore().getSupportedFeatures().isCredentialSupported(IdentityTypeEnum.IDENTITY,
passwordCredential1.getType()));
+
assertTrue(testContext.getStore().getSupportedFeatures().isCredentialSupported(IdentityTypeEnum.USER,
passwordCredential1.getType()));
testContext.getStore().updateCredential(testContext.getCtx(), user1,
passwordCredential1);
testContext.getStore().updateCredential(testContext.getCtx(), user2,
passwordCredential2);
@@ -327,8 +327,8 @@
{
testContext.begin();
- IdentityObject user1 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Adam2",
IdentityTypeEnum.IDENTITY);
- IdentityObject user2 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Eva2",
IdentityTypeEnum.IDENTITY);
+ IdentityObject user1 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Adam2",
IdentityTypeEnum.USER);
+ IdentityObject user2 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Eva2",
IdentityTypeEnum.USER);
Random random = new Random();
@@ -342,7 +342,7 @@
// If BINARY is supported
-
assertTrue(testContext.getStore().getSupportedFeatures().isCredentialSupported(IdentityTypeEnum.IDENTITY,
binaryCredential1.getType()));
+
assertTrue(testContext.getStore().getSupportedFeatures().isCredentialSupported(IdentityTypeEnum.USER,
binaryCredential1.getType()));
testContext.getStore().updateCredential(testContext.getCtx(), user1,
binaryCredential1);
testContext.getStore().updateCredential(testContext.getCtx(), user2,
binaryCredential2);
@@ -362,92 +362,92 @@
{
testContext.begin();
- IdentityObject group1 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Division1",
IdentityTypeEnum.IDENTITY);
- IdentityObject group2 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Division2",
IdentityTypeEnum.IDENTITY);
- IdentityObject group3 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Division3",
IdentityTypeEnum.IDENTITY);
- IdentityObject group4 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Company1",
IdentityTypeEnum.IDENTITY);
- IdentityObject group5 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Company2",
IdentityTypeEnum.IDENTITY);
- IdentityObject group6 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Entity1",
IdentityTypeEnum.IDENTITY);
- IdentityObject group7 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Entity2",
IdentityTypeEnum.IDENTITY);
- IdentityObject group8 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Entity3",
IdentityTypeEnum.IDENTITY);
+ IdentityObject group1 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Division1",
IdentityTypeEnum.USER);
+ IdentityObject group2 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Division2",
IdentityTypeEnum.USER);
+ IdentityObject group3 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Division3",
IdentityTypeEnum.USER);
+ IdentityObject group4 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Company1",
IdentityTypeEnum.USER);
+ IdentityObject group5 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Company2",
IdentityTypeEnum.USER);
+ IdentityObject group6 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Entity1",
IdentityTypeEnum.USER);
+ IdentityObject group7 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Entity2",
IdentityTypeEnum.USER);
+ IdentityObject group8 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Entity3",
IdentityTypeEnum.USER);
Collection<IdentityObject> results = null;
IdentityObjectSearchControl control = null;
// TODO: by RelationshipType
- if
(testContext.getStore().getSupportedFeatures().isControlSupported(IdentityTypeEnum.IDENTITY,
NameFilterSearchControl.class))
+ if
(testContext.getStore().getSupportedFeatures().isControlSupported(IdentityTypeEnum.USER,
NameFilterSearchControl.class))
{
control = new NameFilterSearchControl("*");
results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new
IdentityObjectSearchControl[]{control});
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER, new
IdentityObjectSearchControl[]{control});
assertEquals(8, results.size());
control = new NameFilterSearchControl("D*");
results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new
IdentityObjectSearchControl[]{control});
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER, new
IdentityObjectSearchControl[]{control});
assertEquals(3, results.size());
control = new NameFilterSearchControl("*2");
results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new
IdentityObjectSearchControl[]{control});
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER, new
IdentityObjectSearchControl[]{control});
assertEquals(3, results.size());
control = new NameFilterSearchControl("*3");
results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new
IdentityObjectSearchControl[]{control});
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER, new
IdentityObjectSearchControl[]{control});
assertEquals(2, results.size());
control = new NameFilterSearchControl("Company1");
results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new
IdentityObjectSearchControl[]{control});
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER, new
IdentityObjectSearchControl[]{control});
assertEquals(1, results.size());
control = new NameFilterSearchControl("Totoro");
results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new
IdentityObjectSearchControl[]{control});
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER, new
IdentityObjectSearchControl[]{control});
assertEquals(0, results.size());
}
- if
(testContext.getStore().getSupportedFeatures().isControlSupported(IdentityTypeEnum.IDENTITY,
PageSearchControl.class))
+ if
(testContext.getStore().getSupportedFeatures().isControlSupported(IdentityTypeEnum.USER,
PageSearchControl.class))
{
control = new PageSearchControl(0, 3);
results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new
IdentityObjectSearchControl[]{control});
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER, new
IdentityObjectSearchControl[]{control});
assertEquals(3, results.size());
control = new PageSearchControl(2, 2);
results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new
IdentityObjectSearchControl[]{control});
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER, new
IdentityObjectSearchControl[]{control});
assertEquals(2, results.size());
}
- if
(testContext.getStore().getSupportedFeatures().isControlSupported(IdentityTypeEnum.IDENTITY,
SortByNameSearchControl.class))
+ if
(testContext.getStore().getSupportedFeatures().isControlSupported(IdentityTypeEnum.USER,
SortByNameSearchControl.class))
{
control = new SortByNameSearchControl(true);
results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new
IdentityObjectSearchControl[]{control});
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER, new
IdentityObjectSearchControl[]{control});
assertEquals(8, results.size());
@@ -460,7 +460,7 @@
control = new SortByNameSearchControl(false);
results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new
IdentityObjectSearchControl[]{control});
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER, new
IdentityObjectSearchControl[]{control});
assertEquals(8, results.size());
@@ -473,13 +473,13 @@
// Combine controls to check that the results are diffrent for pagination
- if
(testContext.getStore().getSupportedFeatures().isControlSupported(IdentityTypeEnum.IDENTITY,
PageSearchControl.class))
+ if
(testContext.getStore().getSupportedFeatures().isControlSupported(IdentityTypeEnum.USER,
PageSearchControl.class))
{
control = new SortByNameSearchControl(true);
IdentityObjectSearchControl control2 = new PageSearchControl(0, 3);
results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new
IdentityObjectSearchControl[]{control, control2});
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER, new
IdentityObjectSearchControl[]{control, control2});
assertEquals(3, results.size());
assertEquals("Company1",
((List<IdentityObject>)results).get(0).getName());
@@ -488,7 +488,7 @@
control2 = new PageSearchControl(3, 1);
results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new
IdentityObjectSearchControl[]{control, control2});
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER, new
IdentityObjectSearchControl[]{control, control2});
assertEquals(1, results.size());
@@ -499,7 +499,7 @@
}
- if
(testContext.getStore().getSupportedFeatures().isControlSupported(IdentityTypeEnum.IDENTITY,
AttributeFilterSearchControl.class))
+ if
(testContext.getStore().getSupportedFeatures().isControlSupported(IdentityTypeEnum.USER,
AttributeFilterSearchControl.class))
{
Map<String, String[]> attrs = new HashMap<String, String[]>();
attrs.put("phone", new String[] {"777 777 777"});
@@ -513,7 +513,7 @@
control = new AttributeFilterSearchControl(attrs);
results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new
IdentityObjectSearchControl[]{control});
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER, new
IdentityObjectSearchControl[]{control});
assertEquals(1, results.size());
Modified:
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/IdentityTypeEnum.java
===================================================================
---
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/IdentityTypeEnum.java 2009-03-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/IdentityTypeEnum.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -30,7 +30,6 @@
*/
public enum IdentityTypeEnum implements IdentityObjectType
{
- IDENTITY,
USER,
ROLE,
GROUP,
Modified:
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreTestCase.java
===================================================================
---
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreTestCase.java 2009-03-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreTestCase.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -37,8 +37,6 @@
import org.jboss.identity.idm.impl.configuration.jaxb2.JAXB2IdentityConfiguration;
import org.jboss.identity.idm.impl.api.SimpleAttribute;
import org.jboss.identity.idm.exception.IdentityException;
-import org.hibernate.ejb.HibernateEntityManager;
-import org.hibernate.ejb.HibernateEntityManagerFactory;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
@@ -88,15 +86,16 @@
store = new HibernateIdentityStoreImpl("HibernateTestStore")
{
+ @Override
protected Session getHibernateSession(IdentityStoreInvocationContext ctx)
{
- return em.getSession();
+ return sessionFactory.getCurrentSession();
}
@Override
protected SessionFactory
bootstrapHibernateSessionFactory(IdentityStoreConfigurationMetaData configurationMD)
throws IdentityException
{
- return emFactory.getSessionFactory();
+ return sessionFactory;
}
};
@@ -122,18 +121,18 @@
public void begin() throws Exception
{
- em.getTransaction().begin();
+ sessionFactory.getCurrentSession().getTransaction().begin();
}
public void commit() throws Exception
{
- em.getTransaction().commit();
+ sessionFactory.getCurrentSession().getTransaction().commit();
}
public void flush() throws Exception
{
- em.flush();
+ sessionFactory.getCurrentSession().flush();
}
public IdentityStore getStore()
@@ -165,12 +164,12 @@
public void testAttributes() throws Exception
{
- em.getTransaction().begin();
+ begin();
- IdentityObject user1 = store.createIdentityObject(ctx, "Adam",
IdentityTypeEnum.IDENTITY);
- IdentityObject user2 = store.createIdentityObject(ctx, "Eva",
IdentityTypeEnum.IDENTITY);
+ IdentityObject user1 = store.createIdentityObject(ctx, "Adam",
IdentityTypeEnum.USER);
+ IdentityObject user2 = store.createIdentityObject(ctx, "Eva",
IdentityTypeEnum.USER);
- em.flush();
+ sessionFactory.getCurrentSession().flush();
IdentityObjectAttribute[] attrs = new IdentityObjectAttribute[]{
new SimpleAttribute("key1", new String[]{"val1",
"val2", "val3"}),
@@ -179,7 +178,7 @@
store.addAttributes(ctx, user1, attrs);
- em.flush();
+ sessionFactory.getCurrentSession().flush();
Map<String, IdentityObjectAttribute> persistedAttrs =
store.getAttributes(ctx, user1);
@@ -191,7 +190,7 @@
assertTrue(persistedAttrs.containsKey("key2"));
assertEquals(4, persistedAttrs.get("key2").getSize());
- em.flush();
+ sessionFactory.getCurrentSession().flush();
attrs = new IdentityObjectAttribute[]{
new SimpleAttribute("key3", new String[]{"val1"})
@@ -200,7 +199,7 @@
store.addAttributes(ctx, user1, attrs);
- em.flush();
+ sessionFactory.getCurrentSession().flush();
persistedAttrs = store.getAttributes(ctx, user1);
@@ -215,7 +214,7 @@
assertTrue(persistedAttrs.containsKey("key3"));
assertEquals(1, persistedAttrs.get("key3").getSize());
- em.flush();
+ sessionFactory.getCurrentSession().flush();
attrs = new IdentityObjectAttribute[]{
new SimpleAttribute("key3", new String[]{"val2"})
@@ -223,7 +222,7 @@
store.addAttributes(ctx, user1, attrs);
- em.flush();
+ sessionFactory.getCurrentSession().flush();
persistedAttrs = store.getAttributes(ctx, user1);
@@ -232,11 +231,11 @@
assertTrue(persistedAttrs.containsKey("key3"));
assertEquals(2, persistedAttrs.get("key3").getSize());
- em.flush();
+ sessionFactory.getCurrentSession().flush();
store.updateAttributes(ctx, user1, attrs);
- em.flush();
+ sessionFactory.getCurrentSession().flush();
persistedAttrs = store.getAttributes(ctx, user1);
@@ -245,18 +244,18 @@
assertTrue(persistedAttrs.containsKey("key3"));
assertEquals(1, persistedAttrs.get("key3").getSize());
- em.flush();
+ sessionFactory.getCurrentSession().flush();
store.removeAttributes(ctx, user1, new String[] {"key3"});
- em.flush();
+ sessionFactory.getCurrentSession().flush();
persistedAttrs = store.getAttributes(ctx, user1);
assertEquals(2, persistedAttrs.keySet().size());
- em.getTransaction().commit();
+ sessionFactory.getCurrentSession().getTransaction().commit();
}
Modified:
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelTestCase.java
===================================================================
---
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelTestCase.java 2009-03-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelTestCase.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -22,8 +22,6 @@
package org.jboss.identity.idm.impl.store.hibernate;
-import javax.persistence.Query;
-
import org.jboss.identity.idm.impl.store.hibernate.HibernateTestBase;
import
org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipType;
import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObject;
@@ -31,6 +29,8 @@
import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationship;
import org.jboss.identity.idm.impl.model.hibernate.HibernateRealm;
import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectTextAttribute;
+import org.hibernate.Session;
+import org.hibernate.Query;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
@@ -45,18 +45,19 @@
public void testPersistence() {
- em.getTransaction().begin();
+ Session session = sessionFactory.getCurrentSession();
+ session.getTransaction().begin();
HibernateRealm realm = new HibernateRealm("default");
- em.persist(realm);
+ session.persist(realm);
//
HibernateIdentityObjectType iot = new HibernateIdentityObjectType();
iot.setName("User");
- em.persist(iot);
- assertTrue(em.contains(iot));
+ session.persist(iot);
+ assertTrue(session.contains(iot));
HibernateIdentityObject io = new HibernateIdentityObject();
@@ -64,11 +65,11 @@
io.setRealm(realm);
io.setIdentityType(iot);
- em.persist(io);
- assertTrue(em.contains(io));
+ session.persist(io);
+ assertTrue(session.contains(io));
- em.remove(io);
- assertFalse(em.contains(io));
+ session.delete(io);
+ assertFalse(session.contains(io));
//
@@ -79,8 +80,8 @@
HibernateIdentityObjectRelationshipType iort = new
HibernateIdentityObjectRelationshipType();
iort.setName("Member");
- em.persist(iort);
- assertTrue(em.contains(iort));
+ session.persist(iort);
+ assertTrue(session.contains(iort));
//
@@ -95,104 +96,111 @@
//
- assertTrue(em.contains(iort));
+ assertTrue(session.contains(iort));
- em.remove(iort);
- assertFalse(em.contains(iort));
+ session.delete(iort);
+ assertFalse(session.contains(iort));
- em.getTransaction().commit();
+ session.getTransaction().commit();
}
public void testRelationships()
{
+ Session session = sessionFactory.getCurrentSession();
- em.getTransaction().begin();
+ session.getTransaction().begin();
HibernateRealm realm = new HibernateRealm("default");
- em.persist(realm);
+ session.persist(realm);
HibernateIdentityObjectType groupType = new
HibernateIdentityObjectType("Group");
- em.persist(groupType);
+ session.persist(groupType);
HibernateIdentityObjectType userType = new
HibernateIdentityObjectType("User");
- em.persist(userType);
+ session.persist(userType);
HibernateIdentityObject user1 = new HibernateIdentityObject("user1",
userType, realm);
- em.persist(user1);
+ session.persist(user1);
HibernateIdentityObject user2 = new HibernateIdentityObject("user2",
userType, realm);
- em.persist(user2);
+ session.persist(user2);
HibernateIdentityObject user3 = new HibernateIdentityObject("user3",
userType, realm);
- em.persist(user3);
+ session.persist(user3);
HibernateIdentityObject group1 = new HibernateIdentityObject("group1",
groupType, realm);
- em.persist(group1);
+ session.persist(group1);
HibernateIdentityObject group2 = new HibernateIdentityObject("group2",
groupType, realm);
- em.persist(group2);
+ session.persist(group2);
HibernateIdentityObject group3 = new HibernateIdentityObject("group3",
groupType, realm);
- em.persist(group3);
+ session.persist(group3);
HibernateIdentityObjectRelationshipType memberType = new
HibernateIdentityObjectRelationshipType("member");
- em.persist(memberType);
+ session.persist(memberType);
HibernateIdentityObjectRelationship relationship = new
HibernateIdentityObjectRelationship(memberType, group1, user1);
- em.persist(relationship);
+ session.persist(relationship);
relationship = new HibernateIdentityObjectRelationship(memberType, group1, user2);
- em.persist(relationship);
+ session.persist(relationship);
relationship = new HibernateIdentityObjectRelationship(memberType, group2, user3);
- em.persist(relationship);
+ session.persist(relationship);
relationship = new HibernateIdentityObjectRelationship(memberType, group2,
group1);
- em.persist(relationship);
+ session.persist(relationship);
- em.getTransaction().commit();
+ session.getTransaction().commit();
//
+ session = sessionFactory.getCurrentSession();
- em.getTransaction().begin();
+ session.getTransaction().begin();
- Query ioQuery = em.createQuery("select o from HibernateIdentityObject o where
o.name like :name");
+ Query ioQuery = session.createQuery("select o from HibernateIdentityObject o
where o.name like :name");
- group1 = (HibernateIdentityObject)ioQuery.setParameter("name",
"group1").getSingleResult();
+ group1 = (HibernateIdentityObject)ioQuery.setParameter("name",
"group1").uniqueResult();
assertEquals(2, group1.getFromRelationships().size());
assertEquals(1, group1.getToRelationships().size());
- group2 = (HibernateIdentityObject)ioQuery.setParameter("name",
"group2").getSingleResult();
+ group2 = (HibernateIdentityObject)ioQuery.setParameter("name",
"group2").uniqueResult();
assertEquals(2, group2.getFromRelationships().size());
assertEquals(0, group2.getToRelationships().size());
- user3 = (HibernateIdentityObject)ioQuery.setParameter("name",
"user3").getSingleResult();
+ user3 = (HibernateIdentityObject)ioQuery.setParameter("name",
"user3").uniqueResult();
assertEquals(1, user3.getToRelationships().size());
assertEquals(0, user3.getFromRelationships().size());
assertEquals("group2",
user3.getToRelationships().iterator().next().getFromIdentityObject().getName());
- em.getTransaction().commit();
+ session.getTransaction().commit();
}
public void testNameTypeConstraint() throws Exception
{
- em.getTransaction().begin();
+ Session session = sessionFactory.getCurrentSession();
+ session.getTransaction().begin();
+
HibernateRealm realm = new HibernateRealm("default");
- em.persist(realm);
+ session.persist(realm);
HibernateIdentityObjectType groupType = new
HibernateIdentityObjectType("Group");
- em.persist(groupType);
+ session.persist(groupType);
HibernateIdentityObjectType userType = new
HibernateIdentityObjectType("User");
- em.persist(userType);
+ session.persist(userType);
HibernateIdentityObject user1 = new HibernateIdentityObject("user1",
userType, realm);
- em.persist(user1);
+ session.persist(user1);
HibernateIdentityObject user2 = new HibernateIdentityObject("user2",
userType, realm);
- em.persist(user2);
+ session.persist(user2);
- em.getTransaction().commit();
- em.getTransaction().begin();
+ session.getTransaction().commit();
+ session = sessionFactory.getCurrentSession();
+
+ session.getTransaction().begin();
+
try
{
HibernateIdentityObject user3 = new HibernateIdentityObject("user2",
userType, realm);
- em.persist(user3);
+ session.persist(user3);
// Should fail
fail();
@@ -200,29 +208,30 @@
catch (Exception e)
{
//expected
- em.getTransaction().rollback();
+ session.getTransaction().rollback();
}
+ session = sessionFactory.getCurrentSession();
- em.getTransaction().begin();
+ session.getTransaction().begin();
HibernateIdentityObject user4 = new HibernateIdentityObject("group1",
userType, realm);
- em.persist(user4);
+ session.persist(user4);
HibernateIdentityObject group1 = new HibernateIdentityObject("group1",
groupType, realm);
- em.persist(group1);
+ session.persist(group1);
HibernateIdentityObject group2 = new HibernateIdentityObject("group2",
groupType, realm);
- em.persist(group2);
+ session.persist(group2);
- em.flush();
+ //session.flush();
try
{
HibernateIdentityObject group3 = new HibernateIdentityObject("group2",
groupType, realm);
- em.persist(group3);
+ session.persist(group3);
// Should fail
fail();
@@ -230,35 +239,41 @@
catch (Exception e)
{
//expected
- em.getTransaction().rollback();
+ session.getTransaction().rollback();
}
- em.getTransaction().begin();
+ session = sessionFactory.getCurrentSession();
+ session.getTransaction().begin();
+
HibernateIdentityObject group4 = new HibernateIdentityObject("user1",
groupType, realm);
- em.persist(group4);
+ session.persist(group4);
- em.getTransaction().commit();
+ session.flush();
+ session.getTransaction().commit();
+
}
public void testAttributes() throws Exception
{
+ Session session = sessionFactory.getCurrentSession();
- em.getTransaction().begin();
+ session.getTransaction().begin();
+
HibernateRealm realm = new HibernateRealm("default");
- em.persist(realm);
+ session.persist(realm);
HibernateIdentityObjectType userType = new
HibernateIdentityObjectType("User");
- em.persist(userType);
+ session.persist(userType);
HibernateIdentityObject user1 = new HibernateIdentityObject("user1",
userType, realm);
- em.persist(user1);
+ session.persist(user1);
// Set<String> values1 = new HashSet<String>();
// values1.add("Val1");
@@ -270,20 +285,19 @@
user1.getAttributes().add(new HibernateIdentityObjectTextAttribute(user1,
"simple2", new String[]{"Val1", "Val2",
"Val3"}));
- em.getTransaction().commit();
+ session.getTransaction().commit();
- em.getTransaction().begin();
+ session = sessionFactory.getCurrentSession();
+ session.getTransaction().begin();
-
-
- user1 = em.find(HibernateIdentityObject.class, new Long(user1.getId()));
+ user1 = (HibernateIdentityObject)session.get(HibernateIdentityObject.class, new
Long(user1.getId()));
assertEquals(2, user1.getAttributes().size() );
// assertNotNull(user1.getProfileAttributes().get("simple1"));
// assertEquals(3, user1.getProfileAttributes().get("simple1").length);
- em.getTransaction().commit();
+ session.getTransaction().commit();
}
Modified:
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateTestBase.java
===================================================================
---
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateTestBase.java 2009-03-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateTestBase.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -26,9 +26,7 @@
import java.util.logging.Logger;
-import org.hibernate.ejb.HibernateEntityManager;
-import org.hibernate.ejb.HibernateEntityManagerFactory;
-import org.jboss.identity.idm.impl.store.hibernate.HibernateModelTestCase;
+import org.hibernate.SessionFactory;
import org.jboss.identity.idm.impl.HibernateTestSupport;
/**
@@ -39,15 +37,14 @@
{
private static Logger logger =
Logger.getLogger(HibernateModelTestCase.class.getName());
- private HibernateTestSupport hibernateSupport = new
HibernateTestSupport("unit-testing-jpa", "jboss-identity-model1");
+ private HibernateTestSupport hibernateSupport =
+ new HibernateTestSupport("unit-testing-jpa",
"hibernate-jboss-identity-classes.cfg.xml");
- protected HibernateEntityManager em;
+ protected SessionFactory sessionFactory;
- protected HibernateEntityManagerFactory emFactory;
-
public HibernateTestBase(String testName) {
super(testName);
}
@@ -56,8 +53,7 @@
protected void setUp() throws Exception {
super.setUp();
hibernateSupport.start();
- emFactory = hibernateSupport.getHibernateEntityManagerFactory();
- em = hibernateSupport.getHibernateEntityManager();
+ sessionFactory = hibernateSupport.getSessionFactory();
}
@Override
Modified:
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreTestCase.java
===================================================================
---
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreTestCase.java 2009-03-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreTestCase.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -343,7 +343,7 @@
{
populate();
- assertEquals(7, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.IDENTITY));
+ assertEquals(7, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.USER));
assertEquals(5, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.ROLE));
assertEquals(2, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.GROUP));
}
@@ -352,9 +352,9 @@
{
populate();
- assertEquals(7, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.IDENTITY));
+ assertEquals(7, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.USER));
- IdentityObject io = store.findIdentityObject(ctx, "admin",
IdentityTypeEnum.IDENTITY);
+ IdentityObject io = store.findIdentityObject(ctx, "admin",
IdentityTypeEnum.USER);
assertEquals("admin", io.getName());
assertEquals("uid=admin,ou=People,o=test,dc=portal,dc=example,dc=com",
io.getId().toString());
@@ -362,11 +362,11 @@
store.removeIdentityObject(ctx, io);
- assertEquals(6, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.IDENTITY));
+ assertEquals(6, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.USER));
- store.createIdentityObject(ctx, "newUserA", IdentityTypeEnum.IDENTITY);
+ store.createIdentityObject(ctx, "newUserA", IdentityTypeEnum.USER);
- assertEquals(7, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.IDENTITY));
+ assertEquals(7, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.USER));
//
@@ -387,8 +387,8 @@
populate();
- IdentityObject user1 = store.createIdentityObject(ctx, "Adam",
IdentityTypeEnum.IDENTITY);
- IdentityObject user2 = store.createIdentityObject(ctx, "Eva",
IdentityTypeEnum.IDENTITY);
+ IdentityObject user1 = store.createIdentityObject(ctx, "Adam",
IdentityTypeEnum.USER);
+ IdentityObject user2 = store.createIdentityObject(ctx, "Eva",
IdentityTypeEnum.USER);
//
Added: idm/trunk/idm/src/test/resources/hibernate-jboss-identity-classes.cfg.xml
===================================================================
--- idm/trunk/idm/src/test/resources/hibernate-jboss-identity-classes.cfg.xml
(rev 0)
+++ idm/trunk/idm/src/test/resources/hibernate-jboss-identity-classes.cfg.xml 2009-03-16
12:54:47 UTC (rev 368)
@@ -0,0 +1,60 @@
+<?xml version='1.0' encoding='utf-8'?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!DOCTYPE hibernate-configuration PUBLIC
+ "-//Hibernate/Hibernate Configuration DTD//EN"
+ "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+<hibernate-configuration>
+ <session-factory>
+
+ <property name="show_sql">false</property>
+ <property
name="cache.use_second_level_cache">true</property>
+ <property name="cache.use_query_cache">false</property>
+
+ <property
name="current_session_context_class">thread</property>
+
+ <!--<property
name="connection.datasource"></property>-->
+
+ <property
name="hibernate.connection.url">jdbc:hsqldb:mem:unit-testing-jpa1</property>
+ <property
name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
+ <property
name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
+ <property
name="hibernate.hbm2ddl.auto">create-drop</property>
+ <property
name="hibernate.connection.username">sa</property>
+ <property name="hibernate.connection.password"></property>
+
+ <!-- Mapping classes -->
+
+ <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"/>
+ <mapping
class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredentialType"/>
+ <mapping
class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectAttribute"/>
+ <mapping
class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectTextAttribute"/>
+ <mapping
class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectBinaryAttribute"/>
+ <mapping
class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectType"/>
+ <mapping
class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationship"/>
+ <mapping
class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipType"/>
+ <mapping
class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipName"/>
+ </session-factory>
+</hibernate-configuration>
\ No newline at end of file
Added: idm/trunk/idm/src/test/resources/hibernate-jboss-identity.cfg.xml
===================================================================
--- idm/trunk/idm/src/test/resources/hibernate-jboss-identity.cfg.xml
(rev 0)
+++ idm/trunk/idm/src/test/resources/hibernate-jboss-identity.cfg.xml 2009-03-16 12:54:47
UTC (rev 368)
@@ -0,0 +1,60 @@
+<?xml version='1.0' encoding='utf-8'?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!DOCTYPE hibernate-configuration PUBLIC
+ "-//Hibernate/Hibernate Configuration DTD//EN"
+ "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+<hibernate-configuration>
+ <session-factory>
+
+ <property name="show_sql">false</property>
+ <property
name="cache.use_second_level_cache">true</property>
+ <property name="cache.use_query_cache">false</property>
+
+ <property
name="current_session_context_class">thread</property>
+
+ <!--<property
name="connection.datasource"></property>-->
+
+ <property
name="hibernate.connection.url">jdbc:hsqldb:mem:unit-testing-jpa1</property>
+ <property
name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
+ <property
name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
+ <property
name="hibernate.hbm2ddl.auto">create-drop</property>
+ <property
name="hibernate.connection.username">sa</property>
+ <property name="hibernate.connection.password"></property>
+
+ <!-- Mapping classes -->
+
+ <!--<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"/>-->
+ <!--<mapping
class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredentialType"/>-->
+ <!--<mapping
class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectAttribute"/>-->
+ <!--<mapping
class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectTextAttribute"/>-->
+ <!--<mapping
class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectBinaryAttribute"/>-->
+ <!--<mapping
class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectType"/>-->
+ <!--<mapping
class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationship"/>-->
+ <!--<mapping
class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipType"/>-->
+ <!--<mapping
class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipName"/>-->
+ </session-factory>
+</hibernate-configuration>
\ No newline at end of file
Modified: idm/trunk/idm/src/test/resources/identity-config.xml
===================================================================
--- idm/trunk/idm/src/test/resources/identity-config.xml 2009-03-11 12:43:49 UTC (rev
367)
+++ idm/trunk/idm/src/test/resources/identity-config.xml 2009-03-16 12:54:47 UTC (rev
368)
@@ -17,7 +17,7 @@
<id></id>
<repository-id-ref></repository-id-ref>
<identity-type-mappings>
- <identity-mapping></identity-mapping>
+ <user-mapping></user-mapping>
<group-type-mapping>
<group-type-name></group-type-name>
<identity-object-type-name></identity-object-type-name>
Modified: idm/trunk/idm/src/test/resources/identity-config.xsd
===================================================================
--- idm/trunk/idm/src/test/resources/identity-config.xsd 2009-03-11 12:43:49 UTC (rev
367)
+++ idm/trunk/idm/src/test/resources/identity-config.xsd 2009-03-16 12:54:47 UTC (rev
368)
@@ -109,7 +109,7 @@
</xs:complexType>
<xs:complexType name="identity-type-mappingsType">
<xs:sequence>
- <xs:element type="xs:string" name="identity-mapping"/>
+ <xs:element type="xs:string" name="user-mapping"/>
<xs:element type="urn:group-type-mappingType"
name="group-type-mapping" maxOccurs="unbounded"
minOccurs="0"
xmlns:urn="urn:jboss:identity:idm:config:v1_0_alpha"/>
</xs:sequence>
</xs:complexType>
Modified: idm/trunk/idm/src/test/resources/organization-test-config.xml
===================================================================
--- idm/trunk/idm/src/test/resources/organization-test-config.xml 2009-03-11 12:43:49 UTC
(rev 367)
+++ idm/trunk/idm/src/test/resources/organization-test-config.xml 2009-03-16 12:54:47 UTC
(rev 368)
@@ -7,28 +7,28 @@
<id>realm://RedHat/DB</id>
<repository-id-ref>RedHat Repository DB</repository-id-ref>
<identity-type-mappings>
- <identity-mapping>IDENTITY</identity-mapping>
+ <user-mapping>USER</user-mapping>
</identity-type-mappings>
</realm>
<realm>
<id>realm://portal/SamplePortal/DB</id>
<repository-id-ref>Sample Portal Repository
DB</repository-id-ref>
<identity-type-mappings>
- <identity-mapping>IDENTITY</identity-mapping>
+ <user-mapping>USER</user-mapping>
</identity-type-mappings>
</realm>
<realm>
<id>realm://RedHat/DB_LDAP</id>
<repository-id-ref>RedHat Repository DB+LDAP</repository-id-ref>
<identity-type-mappings>
- <identity-mapping>IDENTITY</identity-mapping>
+ <user-mapping>USER</user-mapping>
</identity-type-mappings>
</realm>
<realm>
<id>realm://portal/SamplePortal/DB_LDAP</id>
<repository-id-ref>Sample Portal Repository
DB+LDAP</repository-id-ref>
<identity-type-mappings>
- <identity-mapping>IDENTITY</identity-mapping>
+ <user-mapping>USER</user-mapping>
</identity-type-mappings>
</realm>
</realms>
@@ -78,7 +78,7 @@
<identity-store-mapping>
<identity-store-id>LDAP Identity
Store</identity-store-id>
<identity-object-types>
-
<identity-object-type>IDENTITY</identity-object-type>
+ <identity-object-type>USER</identity-object-type>
<identity-object-type>ORGANIZATION</identity-object-type>
<identity-object-type>ORGANIZATION_UNIT</identity-object-type>
<identity-object-type>DEPARTMENT</identity-object-type>
@@ -124,7 +124,7 @@
<identity-store-mapping>
<identity-store-id>LDAP Identity
Store</identity-store-id>
<identity-object-types>
-
<identity-object-type>IDENTITY</identity-object-type>
+ <identity-object-type>USER</identity-object-type>
<identity-object-type>DEPARTMENT</identity-object-type>
<identity-object-type>ORGANIZATION</identity-object-type>
<identity-object-type>ORGANIZATION_UNIT</identity-object-type>
@@ -163,7 +163,7 @@
</supported-relationship-types>
<supported-identity-object-types>
<identity-object-type>
- <name>IDENTITY</name>
+ <name>USER</name>
<relationships>
<relationship>
<relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
@@ -210,7 +210,7 @@
<relationships>
<relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
-
<identity-object-type-ref>IDENTITY</identity-object-type-ref>
+
<identity-object-type-ref>USER</identity-object-type-ref>
</relationship>
<relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
@@ -234,7 +234,7 @@
<relationships>
<relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
-
<identity-object-type-ref>IDENTITY</identity-object-type-ref>
+
<identity-object-type-ref>USER</identity-object-type-ref>
</relationship>
<relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
@@ -270,7 +270,7 @@
<relationships>
<relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
-
<identity-object-type-ref>IDENTITY</identity-object-type-ref>
+
<identity-object-type-ref>USER</identity-object-type-ref>
</relationship>
<relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
@@ -290,7 +290,7 @@
<relationships>
<relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
-
<identity-object-type-ref>IDENTITY</identity-object-type-ref>
+
<identity-object-type-ref>USER</identity-object-type-ref>
</relationship>
<relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
@@ -310,7 +310,7 @@
<relationships>
<relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
-
<identity-object-type-ref>IDENTITY</identity-object-type-ref>
+
<identity-object-type-ref>USER</identity-object-type-ref>
</relationship>
</relationships>
<credentials/>
@@ -322,7 +322,7 @@
<relationships>
<relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
-
<identity-object-type-ref>IDENTITY</identity-object-type-ref>
+
<identity-object-type-ref>USER</identity-object-type-ref>
</relationship>
</relationships>
<credentials/>
@@ -334,7 +334,7 @@
<relationships>
<relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
-
<identity-object-type-ref>IDENTITY</identity-object-type-ref>
+
<identity-object-type-ref>USER</identity-object-type-ref>
</relationship>
</relationships>
<credentials/>
@@ -346,7 +346,7 @@
<relationships>
<relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
-
<identity-object-type-ref>IDENTITY</identity-object-type-ref>
+
<identity-object-type-ref>USER</identity-object-type-ref>
</relationship>
</relationships>
<credentials/>
@@ -358,7 +358,7 @@
<relationships>
<relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
-
<identity-object-type-ref>IDENTITY</identity-object-type-ref>
+
<identity-object-type-ref>USER</identity-object-type-ref>
</relationship>
</relationships>
<credentials/>
@@ -370,7 +370,7 @@
<relationships>
<relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
-
<identity-object-type-ref>IDENTITY</identity-object-type-ref>
+
<identity-object-type-ref>USER</identity-object-type-ref>
</relationship>
</relationships>
<credentials/>
@@ -382,7 +382,7 @@
<relationships>
<relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
-
<identity-object-type-ref>IDENTITY</identity-object-type-ref>
+
<identity-object-type-ref>USER</identity-object-type-ref>
</relationship>
<relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
@@ -403,9 +403,13 @@
</identity-object-type>
</supported-identity-object-types>
<options>
+ <!--<option>-->
+ <!--<name>persistenceUnit</name>-->
+ <!--<value>jboss-identity-model1</value>-->
+ <!--</option>-->
<option>
- <name>persistenceUnit</name>
- <value>jboss-identity-model1</value>
+ <name>hibernateConfiguration</name>
+ <value>hibernate-jboss-identity.cfg.xml</value>
</option>
<option>
<name>populateRelationshipTypes</name>
@@ -438,7 +442,7 @@
</supported-relationship-types>
<supported-identity-object-types>
<identity-object-type>
- <name>IDENTITY</name>
+ <name>USER</name>
<relationships/>
<credentials>
<credential-type>PASSWORD</credential-type>
@@ -500,7 +504,7 @@
<relationships>
<relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
-
<identity-object-type-ref>IDENTITY</identity-object-type-ref>
+
<identity-object-type-ref>USER</identity-object-type-ref>
</relationship>
<relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
@@ -562,7 +566,7 @@
<relationships>
<relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
-
<identity-object-type-ref>IDENTITY</identity-object-type-ref>
+
<identity-object-type-ref>USER</identity-object-type-ref>
</relationship>
<relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
@@ -620,7 +624,7 @@
<relationships>
<relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
-
<identity-object-type-ref>IDENTITY</identity-object-type-ref>
+
<identity-object-type-ref>USER</identity-object-type-ref>
</relationship>
<relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
@@ -674,7 +678,7 @@
<relationships>
<relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
-
<identity-object-type-ref>IDENTITY</identity-object-type-ref>
+
<identity-object-type-ref>USER</identity-object-type-ref>
</relationship>
</relationships>
<credentials/>
Modified: idm/trunk/idm/src/test/resources/store-test-config.xml
===================================================================
--- idm/trunk/idm/src/test/resources/store-test-config.xml 2009-03-11 12:43:49 UTC (rev
367)
+++ idm/trunk/idm/src/test/resources/store-test-config.xml 2009-03-16 12:54:47 UTC (rev
368)
@@ -7,7 +7,7 @@
<id>realm://Dymmy</id>
<repository-id-ref>X</repository-id-ref>
<identity-type-mappings>
- <identity-mapping>IDENTITY</identity-mapping>
+ <user-mapping>USER</user-mapping>
</identity-type-mappings>
</realm>
</realms>
@@ -40,7 +40,7 @@
</supported-relationship-types>
<supported-identity-object-types>
<identity-object-type>
- <name>IDENTITY</name>
+ <name>USER</name>
<relationships/>
<credentials>
<credential-type>PASSWORD</credential-type>
@@ -61,7 +61,7 @@
<relationships>
<relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
-
<identity-object-type-ref>IDENTITY</identity-object-type-ref>
+
<identity-object-type-ref>USER</identity-object-type-ref>
</relationship>
<relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
@@ -85,7 +85,7 @@
<relationships>
<relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
-
<identity-object-type-ref>IDENTITY</identity-object-type-ref>
+
<identity-object-type-ref>USER</identity-object-type-ref>
</relationship>
</relationships>
<credentials/>
@@ -94,9 +94,13 @@
</identity-object-type>
</supported-identity-object-types>
<options>
+ <!--<option>-->
+ <!--<name>persistenceUnit</name>-->
+ <!--<value>jboss-identity-model1</value>-->
+ <!--</option>-->
<option>
- <name>persistenceUnit</name>
- <value>jboss-identity-model1</value>
+ <name>hibernateConfiguration</name>
+ <value>hibernate-jboss-identity.cfg.xml</value>
</option>
<option>
<name>populateRelationshipTypes</name>
@@ -125,7 +129,7 @@
</supported-relationship-types>
<supported-identity-object-types>
<identity-object-type>
- <name>IDENTITY</name>
+ <name>USER</name>
<relationships/>
<credentials>
<credential-type>PASSWORD</credential-type>
@@ -187,7 +191,7 @@
<relationships>
<relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
-
<identity-object-type-ref>IDENTITY</identity-object-type-ref>
+
<identity-object-type-ref>USER</identity-object-type-ref>
</relationship>
<relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
@@ -245,7 +249,7 @@
<relationships>
<relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
-
<identity-object-type-ref>IDENTITY</identity-object-type-ref>
+
<identity-object-type-ref>USER</identity-object-type-ref>
</relationship>
<relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
@@ -303,7 +307,7 @@
<relationships>
<relationship>
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
-
<identity-object-type-ref>IDENTITY</identity-object-type-ref>
+
<identity-object-type-ref>USER</identity-object-type-ref>
</relationship>
</relationships>
<credentials/>
Modified: idm/trunk/idm/src/test/resources/test-config.xml
===================================================================
--- idm/trunk/idm/src/test/resources/test-config.xml 2009-03-11 12:43:49 UTC (rev 367)
+++ idm/trunk/idm/src/test/resources/test-config.xml 2009-03-16 12:54:47 UTC (rev 368)
@@ -7,7 +7,7 @@
<id>Sample Ralm</id>
<repository-id-ref>Fallback Repository - ACME</repository-id-ref>
<identity-type-mappings>
- <identity-mapping>IDENTITY</identity-mapping>
+ <user-mapping>IDENTITY</user-mapping>
</identity-type-mappings>
</realm>
</realms>
@@ -85,6 +85,7 @@
<identity-object-type>
<name>JBOSS_IDENTITY_IDENTITY</name>
<relationships/>
+ <credentials/>
<attributes>
<attribute>
<name>user.name.given</name>
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-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/AttributesManager.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -147,7 +147,7 @@
* @return
* @throws IdentityException
*/
- boolean hasPassword(Identity identity) throws IdentityException;
+ boolean hasPassword(User identity) throws IdentityException;
/**
* Validate text password for a given identity
@@ -157,7 +157,7 @@
* @return
* @throws IdentityException
*/
- boolean validatePassword(Identity identity, String password) throws
IdentityException;
+ boolean validatePassword(User identity, String password) throws IdentityException;
/**
* Update text password for a given identity
@@ -166,7 +166,7 @@
* @param password
* @throws IdentityException
*/
- void updatePassword(Identity identity, String password) throws IdentityException;
+ void updatePassword(User identity, String password) throws IdentityException;
/**
* Check if identity can be protected with a given credential type
@@ -174,7 +174,7 @@
* @param identity
* @param credentialType
*/
- boolean hasCredential(Identity identity, CredentialType credentialType) throws
IdentityException;
+ boolean hasCredential(User identity, CredentialType credentialType) throws
IdentityException;
/**
* Validate credential for a given identity
@@ -183,7 +183,7 @@
* @param credentials
* @return
*/
- boolean validateCredentials(Identity identity, Credential[] credentials) throws
IdentityException;
+ boolean validateCredentials(User identity, Credential[] credentials) throws
IdentityException;
/**
* Update credential for a given identity
@@ -191,6 +191,6 @@
* @param identity
* @param credential
*/
- void updateCredential(Identity identity, Credential credential) throws
IdentityException;
+ void updateCredential(User identity, Credential credential) throws IdentityException;
}
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-11
12:43:49 UTC (rev 367)
+++ idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/Group.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -33,10 +33,17 @@
*/
public interface Group extends IdentityType
{
+
/**
- * @return GroupType
+ * @return id of this Group. Should be in format "groupType/groupName"
*/
- GroupType getGroupType();
+ String getId();
+ /**
+ * @return group type name
+ */
+ String getGroupType();
+
+
}
\ No newline at end of file
Modified: 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-11
12:43:49 UTC (rev 367)
+++ idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/GroupType.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -1,39 +1,39 @@
-/*
- * 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
+///*
+// * 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
Deleted: idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/Identity.java
===================================================================
--- idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/Identity.java 2009-03-11
12:43:49 UTC (rev 367)
+++ idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/Identity.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -1,34 +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;
-
-/**
- * Represents an Identity
- *
- * @author Anil.Saldhana(a)redhat.com
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
- * @since Jun 30, 2008
- */
-public interface Identity extends IdentityType
-{
-
-}
\ No newline at end of file
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-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/IdentityType.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -33,19 +33,10 @@
*/
public interface IdentityType
{
- /**
- * @return id of this IdentityType object
- */
- String getId();
/**
* @return the name of the IdentityType
*/
String getName();
- /**
- * @return description of the IdentityType
- */
- String getDescription();
-
}
\ No newline at end of file
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-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -51,11 +51,11 @@
/**
* <p>Create an identity in the realm</p>
- * @param identityName
+ * @param userName
* @throws IdentityException
* @return
*/
- Identity createIdentity(String identityName) throws IdentityException;
+ User createUser(String userName) throws IdentityException;
/**
* <p>Create a group of a particular type</p>
@@ -63,7 +63,7 @@
* @param groupType
* @return
*/
- Group createGroup(String groupName, GroupType groupType)
+ Group createGroup(String groupName, String groupType)
throws IdentityException;
// Remove
@@ -71,14 +71,24 @@
/**
* Remove given identity
*
- * @param identity
+ * @param user
* @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 removeIdentity(Identity identity, boolean force) throws IdentityException;
+ void removeUser(User user, boolean force) throws IdentityException;
/**
+ * Remove given identity
+ *
+ * @param userName
+ * @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;
+
+ /**
* Remove given group
*
* @param group
@@ -88,13 +98,23 @@
*/
void removeGroup(Group group, boolean force) throws IdentityException;
+ /**
+ * Remove given group
+ *
+ * @param groupId
+ * @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 removeGroup(String groupId, boolean force) throws IdentityException;
+
// Search
/**
* @return a number of stored identities
* @throws org.jboss.identity.idm.exception.IdentityException
*/
- int getIdentityCount()
+ int getUserCount()
throws IdentityException;
/**
@@ -102,7 +122,7 @@
* @return a number of stored groups with a given type
* @throws org.jboss.identity.idm.exception.IdentityException
*/
- int getGroupTypeCount(GroupType groupType)
+ int getGroupTypeCount(String groupType)
throws IdentityException;
/**
@@ -112,7 +132,7 @@
* @return
* @throws org.jboss.identity.idm.exception.IdentityException
*/
- Identity findIdentity(String name) throws IdentityException;
+ User findUser(String name) throws IdentityException;
/**
* Find identity with a given id
@@ -121,7 +141,7 @@
* @return
* @throws org.jboss.identity.idm.exception.IdentityException
*/
- Identity findIdentityById(String id) throws IdentityException;
+ User findUserById(String id) throws IdentityException;
/**
*
@@ -129,7 +149,7 @@
* @return
* @throws IdentityException
*/
- Collection<Identity> findIdentity(IdentitySearchControl[] controls) throws
IdentityException;
+ Collection<User> findUser(IdentitySearchControl[] controls) throws
IdentityException;
// Search Groups
@@ -141,7 +161,7 @@
* @return
* @throws org.jboss.identity.idm.exception.IdentityException
*/
- Group findGroup(String name, GroupType groupType) throws IdentityException;
+ Group findGroup(String name, String groupType) throws IdentityException;
/**
* Find group with a given id
@@ -160,7 +180,7 @@
* @return
* @throws IdentityException
*/
- Collection<Group> findGroup(GroupType groupType, IdentitySearchControl[]
controls) throws IdentityException;
+ Collection<Group> findGroup(String groupType, IdentitySearchControl[] controls)
throws IdentityException;
/**
*
@@ -168,7 +188,7 @@
* @return
* @throws IdentityException
*/
- Collection<Group> findGroup(GroupType groupType) throws IdentityException;
+ Collection<Group> findGroup(String groupType) throws IdentityException;
/**
@@ -176,10 +196,7 @@
* (such as a pseudonym)
* @return true (virtual identity)
*/
- boolean isVirtual(Identity identity);
+ boolean isVirtual(User user);
-
-
-
}
Modified:
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManagerFeaturesDescription.java
===================================================================
---
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManagerFeaturesDescription.java 2009-03-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManagerFeaturesDescription.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -35,7 +35,7 @@
* Check if Identity objects can be created and removed
* @return
*/
- boolean isIdentitiesAddRemoveSupported();
+ boolean isUsersAddRemoveSupported();
/**
* Check if Group objects can be created and removed
@@ -43,7 +43,7 @@
* @param groupType
* @return
*/
- boolean isGroupsAddRemoveSupported(GroupType groupType);
+ boolean isGroupsAddRemoveSupported(String groupType);
/**
* Check if control can be used in Identity search methods
@@ -51,7 +51,7 @@
* @param control
* @return
*/
- boolean isIdentitiesSearchControlSupported(IdentitySearchControl control);
+ boolean isUsersSearchControlSupported(IdentitySearchControl control);
/**
* Check if control can be used in Identity search methods
@@ -59,7 +59,7 @@
* @param controlClazz
* @return
*/
- boolean isIdentitiesSearchControlSupported(Class<?> controlClazz);
+ boolean isUsersSearchControlSupported(Class<?> controlClazz);
/**
* Check if control can be used in Group search methods
@@ -68,7 +68,7 @@
* @param control
* @return
*/
- boolean isGroupsSearchControlSupported(GroupType groupType, IdentitySearchControl
control);
+ boolean isGroupsSearchControlSupported(String groupType, IdentitySearchControl
control);
/**
* Check if control can be used in Group search methods
@@ -77,5 +77,5 @@
* @param controlClazz
* @return
*/
- boolean isGroupsSearchControlSupported(GroupType groupType, Class<?>
controlClazz);
+ boolean isGroupsSearchControlSupported(String groupType, Class<?>
controlClazz);
}
\ No newline at end of file
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-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RelationshipManager.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -47,7 +47,7 @@
// Assignation
- /**
+ /**
* <p>Associate groups</p>
* @param parents
* @param members
@@ -58,6 +58,15 @@
/**
* <p>Associate groups</p>
+ * @param parentIds
+ * @param memberIds
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ void associateGroupsByIds(Collection<String> parentIds, Collection<String>
memberIds)
+ throws IdentityException;
+
+ /**
+ * <p>Associate groups</p>
* @param parent
* @param member
* @throws org.jboss.identity.idm.exception.IdentityException
@@ -66,12 +75,21 @@
throws IdentityException;
/**
+ * <p>Associate groups</p>
+ * @param parentId
+ * @param memberId
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ void associateGroupsByIds(String parentId, String memberId)
+ throws IdentityException;
+
+ /**
* <p>Associate identities to groups</p>
* @param parents
* @param members
* @throws org.jboss.identity.idm.exception.IdentityException
*/
- void associateIdentities(Collection<Group> parents, Collection<Identity>
members)
+ void associateUsers(Collection<Group> parents, Collection<User> members)
throws IdentityException;
/**
@@ -80,10 +98,28 @@
* @param members
* @throws org.jboss.identity.idm.exception.IdentityException
*/
- void associateIdentities(Group parents, Identity members)
+ void associateUsersByIds(Collection<String> parents, Collection<String>
members)
throws IdentityException;
/**
+ * <p>Associate identities to groups</p>
+ * @param parents
+ * @param members
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ void associateUsers(Group parents, User members)
+ throws IdentityException;
+
+ /**
+ * <p>Associate identities to groups</p>
+ * @param parentGroupId
+ * @param memberUserName
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ void associateUsersByIds(String parentGroupId, String memberUserName)
+ throws IdentityException;
+
+ /**
* <p>Disassociate groups</p>
* @param parents
* @param members
@@ -93,15 +129,33 @@
throws IdentityException;
/**
+ * <p>Disassociate groups</p>
+ * @param parents
+ * @param members
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ void disassociateGroupsByIds(Collection<String> parents,
Collection<String> members)
+ throws IdentityException;
+
+ /**
* <p>Disassociate identities from groups</p>
* @param parents
* @param members
* @throws org.jboss.identity.idm.exception.IdentityException
*/
- void disassociateIdentities(Collection<Group> parents,
Collection<Identity> members)
+ void disassociateUsers(Collection<Group> parents, Collection<User>
members)
throws IdentityException;
/**
+ * <p>Disassociate identities from groups</p>
+ * @param parents
+ * @param members
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ void disassociateUsersByIds(Collection<String> parents, Collection<String>
members)
+ throws IdentityException;
+
+ /**
* <p>Check if association is present </p>
* @param parents
* @param members
@@ -140,7 +194,7 @@
* @throws org.jboss.identity.idm.exception.IdentityException
*/
Collection<Group> findAssociatedGroups(Group group,
- GroupType groupType,
+ String groupType,
boolean parent,
boolean inherited) throws IdentityException;
@@ -161,20 +215,42 @@
* @throws org.jboss.identity.idm.exception.IdentityException
*/
Collection<Group> findAssociatedGroups(Group group,
- GroupType groupType,
+ String groupType,
boolean parent,
boolean inherited,
IdentitySearchControl[] controls) throws
IdentityException;
+ /**
+ * 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
+ * set to true and 'inherited' is set to true all nested subgroubs will be
returned.
+ *
+ * @param groupId Id of parent group
+ * @param groupType can be null
+ * @param parent defines if given identity is parent or child side in the
+ * relationship - default is true (parent)
+ * @param inherited if true also identities from subgroubs will be retreived. Matters
only when parent is set to true.
+ * Default is false
+ * @return
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ Collection<Group> findAssociatedGroups(String groupId,
+ String groupType,
+ boolean parent,
+ boolean inherited,
+ IdentitySearchControl[] controls) throws
IdentityException;
+
/**
* Find all groups that given identity is associated with.
- * @param identity child identity
+ * @param user child identity
* @param groupType can be null
* @return
* @throws org.jboss.identity.idm.exception.IdentityException
*/
- Collection<Group> findAssociatedGroups(Identity identity,
- GroupType groupType) throws IdentityException;
+ Collection<Group> findAssociatedGroups(User user,
+ String groupType) throws IdentityException;
/**
* Find all groups that given identity is associated with.
@@ -182,13 +258,13 @@
* are not supported, dedicated parameters will
* take no effect
*
- * @param identity child identity
+ * @param user child identity
* @param groupType can be null
* @return
* @throws org.jboss.identity.idm.exception.IdentityException
*/
- Collection<Group> findAssociatedGroups(Identity identity,
- GroupType groupType,
+ Collection<Group> findAssociatedGroups(User user,
+ String groupType,
IdentitySearchControl[] controls) throws
IdentityException;
/**
@@ -197,11 +273,13 @@
* are not supported, dedicated parameters will
* take no effect
*
- * @param identity child identity
+ * @param userName child identity name
+ * @param groupType can be null
* @return
* @throws org.jboss.identity.idm.exception.IdentityException
*/
- Collection<Group> findAssociatedGroups(Identity identity,
+ Collection<Group> findAssociatedGroups(String userName,
+ String groupType,
IdentitySearchControl[] controls) throws
IdentityException;
/**
@@ -210,13 +288,36 @@
* are not supported, dedicated parameters will
* take no effect
*
- * @param identity child identity
+ * @param user child identity
* @return
* @throws org.jboss.identity.idm.exception.IdentityException
*/
- Collection<Group> findAssociatedGroups(Identity identity) throws
IdentityException;
+ Collection<Group> findAssociatedGroups(User user,
+ 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
+ * @return
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ Collection<Group> findAssociatedGroups(String userName,
+ IdentitySearchControl[] controls) throws
IdentityException;
+
+ /**
+ * Find all groups that given identity is associated with.
+ *
+ * @param user child identity
+ * @return
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ Collection<Group> findAssociatedGroups(User user) 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
@@ -227,7 +328,7 @@
* @return
* @throws org.jboss.identity.idm.exception.IdentityException
*/
- Collection<Identity> findAssociatedIdentities(Group group,
+ Collection<User> findAssociatedUsers(Group group,
boolean inherited) throws IdentityException;
/**
@@ -241,9 +342,24 @@
* @return
* @throws org.jboss.identity.idm.exception.IdentityException
*/
- Collection<Identity> findAssociatedIdentities(Group group,
- boolean inherited,
- IdentitySearchControl[] controls) throws
IdentityException;
+ Collection<User> findAssociatedUsers(Group group,
+ boolean inherited,
+ 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
+ * @param inherited if true also identities from subgroubs will be retrieved. Default
is false
+ * @return
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ Collection<User> findAssociatedUsers(String groupId,
+ boolean inherited,
+ IdentitySearchControl[] controls) throws
IdentityException;
+
}
Modified:
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RelationshipManagerFeaturesDescription.java
===================================================================
---
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RelationshipManagerFeaturesDescription.java 2009-03-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RelationshipManagerFeaturesDescription.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -36,7 +36,7 @@
* @param fromGroupType
* @return
*/
- boolean isIdentityAssociationSupported(GroupType fromGroupType);
+ boolean isIdentityAssociationSupported(String fromGroupType);
/**
* Can given group types have role association
@@ -44,7 +44,7 @@
* @param toGroupType
* @return
*/
- boolean isGroupAssociationSupported(GroupType fromGroupType, GroupType toGroupType);
+ boolean isGroupAssociationSupported(String fromGroupType, String toGroupType);
/**
* Check if control can be used in Identity search methods
@@ -69,7 +69,7 @@
* @param control
* @return
*/
- boolean isGroupsSearchControlSupported(GroupType groupType, IdentitySearchControl
control);
+ boolean isGroupsSearchControlSupported(String groupType, IdentitySearchControl
control);
/**
* Check if control can be used in Group search methods
@@ -78,5 +78,5 @@
* @param controlClazz
* @return
*/
- boolean isGroupsSearchControlSupported(GroupType groupType, Class<?>
controlClazz);
+ boolean isGroupsSearchControlSupported(String groupType, Class<?>
controlClazz);
}
\ No newline at end of file
Modified: idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/Role.java
===================================================================
--- idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/Role.java 2009-03-11
12:43:49 UTC (rev 367)
+++ idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/Role.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -31,10 +31,6 @@
*/
public interface Role
{
- /**
- * @return description
- */
- String getDescription();
/**
* @return role type
@@ -44,7 +40,7 @@
/**
* @return identity participating in this role
*/
- Identity getIdentity();
+ User getIdentity();
/**
* @return group associated with this role
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-11
12:43:49 UTC (rev 367)
+++ idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RoleManager.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -90,24 +90,43 @@
/**
* Create role
* @param roleType
- * @param identity
+ * @param user
* @param group
* @return
* @throws IdentityException
*/
- Role createRole(RoleType roleType, Identity identity, Group group) throws
IdentityException;
+ Role createRole(RoleType roleType, User user, Group group) throws IdentityException;
/**
+ * Create role
+ * @param roleType
+ * @param userName
+ * @param groupId
+ * @return
+ * @throws IdentityException
+ */
+ Role createRole(RoleType roleType, String userName, String groupId) throws
IdentityException;
+
+ /**
* Remove Role
* @param roleType
- * @param identity
+ * @param user
* @param group
* @throws IdentityException
*/
- void removeRole(RoleType roleType, Identity identity, Group group) throws
IdentityException;
+ void removeRole(RoleType roleType, User user, Group group) throws IdentityException;
/**
* Remove Role
+ * @param roleType
+ * @param userName
+ * @param groupId
+ * @throws IdentityException
+ */
+ void removeRole(RoleType roleType, String userName, String groupId) throws
IdentityException;
+
+ /**
+ * Remove Role
* @param role
* @throws IdentityException
*/
@@ -115,50 +134,78 @@
/**
* Check if Role is present
- * @param identity
+ * @param user
* @param group
* @param roleType
* @return
* @throws IdentityException
*/
- boolean hasRole(Identity identity, Group group, RoleType roleType) throws
IdentityException;
+ boolean hasRole(User user, Group group, RoleType roleType) throws IdentityException;
/**
+ * Check if Role is present
+ * @param userName
+ * @param groupId
+ * @param roleType
+ * @return
+ * @throws IdentityException
+ */
+ boolean hasRole(String userName, String groupId, RoleType roleType) throws
IdentityException;
+
+ /**
* Find RoleType objects for roles associated with a given Identity and Group
- * @param identity
+ * @param user
* @param group
* @return
* @throws IdentityException
*/
- Collection<RoleType> findRoleTypes(Identity identity, Group group,
+ Collection<RoleType> findRoleTypes(User user, Group group,
IdentitySearchControl[] controls) throws
IdentityException;
/**
* Find RoleType objects for roles associated with a given Identity and Group
- * @param identity
+ * @param userName
+ * @param groupId
+ * @return
+ * @throws IdentityException
+ */
+ Collection<RoleType> findRoleTypes(String userName, String groupId,
+ IdentitySearchControl[] controls) throws
IdentityException;
+
+ /**
+ * Find RoleType objects for roles associated with a given Identity and Group
+ * @param user
* @param group
* @return
* @throws IdentityException
*/
- Collection<RoleType> findRoleTypes(Identity identity, Group group) throws
IdentityException;
+ Collection<RoleType> findRoleTypes(User user, Group group) throws
IdentityException;
/**
* Find RoleType objects for roles associated with a given Identity
- * @param identity
+ * @param user
* @return
* @throws IdentityException
*/
- Collection<RoleType> findIdentityRoleTypes(Identity identity) throws
IdentityException;
+ Collection<RoleType> findUserRoleTypes(User user) throws IdentityException;
/**
* Find RoleType objects for roles associated with a given Identity
- * @param identity
+ * @param user
* @return
* @throws IdentityException
*/
- Collection<RoleType> findIdentityRoleTypes(Identity identity,
IdentitySearchControl[] controls) throws IdentityException;
+ Collection<RoleType> findUserRoleTypes(User user, IdentitySearchControl[]
controls) throws IdentityException;
/**
+ * Find RoleType objects for roles associated with a given Identity
+ * @param userName
+ * @return
+ * @throws IdentityException
+ */
+ Collection<RoleType> findUserRoleTypes(String userName, IdentitySearchControl[]
controls) throws IdentityException;
+
+ /**
* Find RoleType objects for roles associated with a given Group
* @param group
* @return
@@ -176,30 +223,62 @@
IdentitySearchControl[] controls) throws
IdentityException;
/**
+ * Find RoleType objects for roles associated with a given Group
+ * @param groupId
+ * @return
+ * @throws IdentityException
+ */
+ Collection<RoleType> findGroupRoleTypes(String groupId,
+ IdentitySearchControl[] controls) throws
IdentityException;
+
+ /**
* Find all Groups with which Identity has a Role association
*
- * @param identity
+ * @param user
* @param controls
* @return
* @throws IdentityException
*/
- Collection<Group> findGroupsWithRelatedRole(Identity identity,
+ Collection<Group> findGroupsWithRelatedRole(User user,
IdentitySearchControl[] controls) throws
IdentityException;
+ /**
+ * Find all Groups with which Identity has a Role association
+ *
+ * @param userName
+ * @param controls
+ * @return
+ * @throws IdentityException
+ */
+ Collection<Group> findGroupsWithRelatedRole(String userName,
+ IdentitySearchControl[] controls) throws
IdentityException;
+
/**
* Find all Groups with which Identity has a Role association
*
- * @param identity
+ * @param user
* @param controls
* @return
* @throws IdentityException
*/
- Collection<Group> findGroupsWithRelatedRole(Identity identity,
- GroupType groupType,
+ Collection<Group> findGroupsWithRelatedRole(User user,
+ String groupType,
IdentitySearchControl[] controls) throws
IdentityException;
/**
+ * Find all Groups with which Identity has a Role association
+ *
+ * @param userName
+ * @param controls
+ * @return
+ * @throws IdentityException
+ */
+ Collection<Group> findGroupsWithRelatedRole(String userName,
+ String groupType,
+ IdentitySearchControl[] controls) throws
IdentityException;
+
+ /**
* Find Role objects with a given RoleType associated with a given IdentityType
* @param identityType
* @param roleType
Copied: idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/User.java (from rev
247, idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/Identity.java)
===================================================================
--- idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/User.java
(rev 0)
+++ idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/User.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -0,0 +1,34 @@
+/*
+ * 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;
+
+/**
+ * Represents an Identity
+ *
+ * @author Anil.Saldhana(a)redhat.com
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @since Jun 30, 2008
+ */
+public interface User extends IdentityType
+{
+
+}
\ No newline at end of file
Modified:
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObject.java
===================================================================
---
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObject.java 2009-03-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObject.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -33,12 +33,13 @@
{
/**
- * @return id of this identity object
+ * @return id of this identity object. String representation of natural store id
associated with identity entry.
+ * Could be FQDN in LDAP or surrogate key for DB. Can be null
*/
String getId();
/**
- * <p>Return the name of the identity</p>
+ * <p>Return the name of the identity. Name must be unique value in scope of a
IdentityObjectType</p>
* @return
*/
String getName();
Modified:
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectAttribute.java
===================================================================
---
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectAttribute.java 2009-03-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectAttribute.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -58,5 +58,5 @@
/**
* @return number of attribute values
*/
- int getSize();
+ int getSize();
}
\ No newline at end of file
Modified:
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectRelationship.java
===================================================================
---
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectRelationship.java 2009-03-11
12:43:49 UTC (rev 367)
+++
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectRelationship.java 2009-03-16
12:54:47 UTC (rev 368)
@@ -32,7 +32,9 @@
{
/**
- * @return relationship name or null if this relationship is not named
+ * @return relationship name or null if this relationship is not named.
+ * Combination of name, fromIdentityObject and toIdentityObject must be unique - two
connected
+ * IdentityObject can have only one relationship with a given name
*/
String getName();