JBoss Identity SVN: r380 - idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api.
by jboss-identity-commits@lists.jboss.org
Author: bdaw
Date: 2009-03-18 16:27:31 -0400 (Wed, 18 Mar 2009)
New Revision: 380
Modified:
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestCase.java
Log:
bobo
Modified: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestCase.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestCase.java 2009-03-18 20:22:52 UTC (rev 379)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestCase.java 2009-03-18 20:27:31 UTC (rev 380)
@@ -64,52 +64,52 @@
super.tearDown();
}
-// public void testDBPersistenceManager() throws Exception
-// {
-// identitySessionFactory = new IdentityConfigurationImpl().
-// configure(new File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
-//
-// persistenceManagerTest.testMethods("realm://RedHat/DB");
-// }
-//
-// public void testLDAPMixedPersistenceManager() throws Exception
-// {
-// populateClean();
-//
-// identitySessionFactory = new IdentityConfigurationImpl().
-// configure(new File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
-//
-//
-// persistenceManagerTest.testMethods("realm://RedHat/DB_LDAP");
-// }
-//
-// public void testDBRelationshipManager() throws Exception
-// {
-// identitySessionFactory = new IdentityConfigurationImpl().
-// configure(new File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
-//
-// relationshipManagerTest.testMethods("realm://RedHat/DB");
-// }
-//
-// public void testLDAPMixedRelationshipManager() throws Exception
-// {
-// populateClean();
-//
-// identitySessionFactory = new IdentityConfigurationImpl().
-// configure(new File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
-//
-//
-// relationshipManagerTest.testMethods("realm://RedHat/DB_LDAP");
-// }
-//
-// public void testDBRoleManager() throws Exception
-// {
-// identitySessionFactory = new IdentityConfigurationImpl().
-// configure(new File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
-//
-// roleManagerTest.testMethods("realm://RedHat/DB");
-// }
+ public void testDBPersistenceManager() throws Exception
+ {
+ identitySessionFactory = new IdentityConfigurationImpl().
+ configure(new File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
+ persistenceManagerTest.testMethods("realm://RedHat/DB");
+ }
+
+ public void testLDAPMixedPersistenceManager() throws Exception
+ {
+ populateClean();
+
+ identitySessionFactory = new IdentityConfigurationImpl().
+ configure(new File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
+
+
+ persistenceManagerTest.testMethods("realm://RedHat/DB_LDAP");
+ }
+
+ public void testDBRelationshipManager() throws Exception
+ {
+ identitySessionFactory = new IdentityConfigurationImpl().
+ configure(new File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
+
+ relationshipManagerTest.testMethods("realm://RedHat/DB");
+ }
+
+ public void testLDAPMixedRelationshipManager() throws Exception
+ {
+ populateClean();
+
+ identitySessionFactory = new IdentityConfigurationImpl().
+ configure(new File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
+
+
+ relationshipManagerTest.testMethods("realm://RedHat/DB_LDAP");
+ }
+
+ public void testDBRoleManager() throws Exception
+ {
+ identitySessionFactory = new IdentityConfigurationImpl().
+ configure(new File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
+
+ roleManagerTest.testMethods("realm://RedHat/DB");
+ }
+
public void testLDAPMixedRoleManager() throws Exception
{
populateClean();
15 years, 9 months
JBoss Identity SVN: r379 - in idm/trunk: idm/src/main/java/org/jboss/identity/idm/impl/cache and 6 other directories.
by jboss-identity-commits@lists.jboss.org
Author: bdaw
Date: 2009-03-18 16:22:52 -0400 (Wed, 18 Mar 2009)
New Revision: 379
Added:
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RoleManagerTest.java
Modified:
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RoleManager.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/RoleManagerImpl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/IdentityStoreCacheSupport.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/FallbackIdentityStoreRepository.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreImpl.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestCase.java
idm/trunk/idm/src/test/resources/organization-test-config.xml
Log:
- More and more test cases and bug fixes
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AbstractManager.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AbstractManager.java 2009-03-18 15:20:34 UTC (rev 378)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AbstractManager.java 2009-03-18 20:22:52 UTC (rev 379)
@@ -259,5 +259,13 @@
}
}
+ protected void checkNotNullArgument(Object arg, String name)
+ {
+ if (arg == null)
+ {
+ throw new IllegalArgumentException(name + " cannot be null");
+ }
+ }
+
}
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RoleManagerImpl.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RoleManagerImpl.java 2009-03-18 15:20:34 UTC (rev 378)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RoleManagerImpl.java 2009-03-18 20:22:52 UTC (rev 379)
@@ -341,7 +341,7 @@
Collection<IdentityObject> ios = null;
- ios = getRepository().findIdentityObject(getInvocationContext(), createIdentityObject(identity), null, true, convertSearchControls(controls));
+ ios = getRepository().findIdentityObject(getInvocationContext(), createIdentityObject(identity), ROLE, true, convertSearchControls(controls));
for (IdentityObject io : ios)
{
@@ -367,7 +367,7 @@
Collection<IdentityObject> ios = null;
- ios = getRepository().findIdentityObject(getInvocationContext(), createIdentityObject(identity), null, true, convertSearchControls(controls));
+ ios = getRepository().findIdentityObject(getInvocationContext(), createIdentityObject(identity), ROLE, true, convertSearchControls(controls));
for (IdentityObject io : ios)
{
@@ -416,5 +416,8 @@
}
-
+ public <T extends IdentityType> Collection<Role> findRoles(String id, String roleTypeName) throws IdentityException
+ {
+ return findRoles(createIdentityTypeFromId(id), new SimpleRoleType(roleTypeName));
+ }
}
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/IdentityStoreCacheSupport.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/IdentityStoreCacheSupport.java 2009-03-18 15:20:34 UTC (rev 378)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/IdentityStoreCacheSupport.java 2009-03-18 20:22:52 UTC (rev 379)
@@ -175,7 +175,7 @@
private Fqn createIOSearchNodeFQN(IdentityObject io, IdentityObjectRelationshipType relationshipType, boolean parent, Object searchId)
{
- return Fqn.fromElements(OBJECT_TYPES_SEARCH_NODE, io.getIdentityType().getName(), relationshipType.getName(),
+ return Fqn.fromElements(OBJECT_TYPES_SEARCH_NODE, io.getIdentityType().getName(), relationshipType == null ? "null" : relationshipType.getName(),
io.getName() + "_" + parent, searchId);
}
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/FallbackIdentityStoreRepository.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/FallbackIdentityStoreRepository.java 2009-03-18 15:20:34 UTC (rev 378)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/FallbackIdentityStoreRepository.java 2009-03-18 20:22:52 UTC (rev 379)
@@ -45,6 +45,7 @@
import org.jboss.identity.idm.impl.store.SimpleIdentityStoreInvocationContext;
import org.jboss.identity.idm.impl.api.PageSearchControl;
import org.jboss.identity.idm.impl.api.SortByNameSearchControl;
+import org.jboss.identity.idm.impl.api.session.managers.RoleManagerImpl;
import java.util.Map;
import java.util.Collection;
@@ -438,8 +439,14 @@
return defaultIdentityStore.findIdentityObject(defaultCtx, identity, relationshipType, parent, controls);
}
- Collection<IdentityObject> results = mappedStore.findIdentityObject(mappedCtx, identity, relationshipType, parent, controls);
+ Collection<IdentityObject> results = new LinkedList<IdentityObject>();
+ if (!RoleManagerImpl.ROLE.getName().equals(relationshipType.getName()) ||
+ mappedStore.getSupportedFeatures().isNamedRelationshipsSupported())
+ {
+ results = mappedStore.findIdentityObject(mappedCtx, identity, relationshipType, parent, controls);
+ }
+
IdentityObject defaultStoreIdentityObject = null;
try
@@ -606,7 +613,9 @@
IdentityStoreInvocationContext defaultTargetCtx = resolveInvocationContext(defaultIdentityStore, invocationCxt);
- if (fromStore == toStore)
+ if (fromStore == toStore &&
+ (!RoleManagerImpl.ROLE.getName().equals(relationshipType.getName()) ||
+ fromStore.getSupportedFeatures().isNamedRelationshipsSupported()))
{
return fromStore.resolveRelationships(toTargetCtx, fromIdentity, toIdentity, relationshipType);
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-18 15:20:34 UTC (rev 378)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java 2009-03-18 20:22:52 UTC (rev 379)
@@ -769,14 +769,14 @@
StringBuilder hqlString = new StringBuilder("");
- if (orderByName)
- {
- hqlString.append(" orderBy ior.toIdentityObject.name");
- if (ascending)
- {
- hqlString.append(" asc");
- }
- }
+// if (orderByName)
+// {
+// hqlString.append(" orderBy ior.toIdentityObject.name");
+// if (ascending)
+// {
+// hqlString.append(" asc");
+// }
+// }
if (parent)
{
@@ -784,12 +784,12 @@
if (relationshipType != null)
{
- hqlString.append("select ior.toIdentityObject from HibernateIdentityObjectRelationship ior where " +
+ hqlString.append("select distinct ior.toIdentityObject from HibernateIdentityObjectRelationship ior where " +
"ior.toIdentityObject.name like :nameFilter and ior.type.name like :relType and ior.fromIdentityObject like :identity");
}
else
{
- hqlString.append("select ior.toIdentityObject from HibernateIdentityObjectRelationship ior where " +
+ hqlString.append("select distinct ior.toIdentityObject from HibernateIdentityObjectRelationship ior where " +
"ior.toIdentityObject.name like :nameFilter and ior.fromIdentityObject like :identity");
}
if (orderByName)
@@ -805,12 +805,12 @@
{
if (relationshipType != null)
{
- hqlString.append("select ior.fromIdentityObject from HibernateIdentityObjectRelationship ior where " +
+ hqlString.append("select distinct ior.fromIdentityObject from HibernateIdentityObjectRelationship ior where " +
"ior.fromIdentityObject.name like :nameFilter and ior.type.name like :relType and ior.toIdentityObject like :identity");
}
else
{
- hqlString.append("select ior.fromIdentityObject from HibernateIdentityObjectRelationship ior where " +
+ hqlString.append("select distinct ior.fromIdentityObject from HibernateIdentityObjectRelationship ior where " +
"ior.fromIdentityObject.name like :nameFilter and ior.toIdentityObject like :identity");
}
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreImpl.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreImpl.java 2009-03-18 15:20:34 UTC (rev 378)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreImpl.java 2009-03-18 20:22:52 UTC (rev 379)
@@ -784,6 +784,12 @@
// If parent simply look for all its members
if (parent)
{
+ if (typeConfig.getMembershipAttributeName() == null)
+ {
+ throw new IdentityException("Membership attribute name not configured. Given IdentityObjectType cannot have" +
+ "members: " + identity.getIdentityType().getName());
+ }
+
Attributes attrs = ldapContext.getAttributes(ldapFromIO.getDn());
Attribute member = attrs.get(typeConfig.getMembershipAttributeName());
Modified: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestCase.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestCase.java 2009-03-18 15:20:34 UTC (rev 378)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestCase.java 2009-03-18 20:22:52 UTC (rev 379)
@@ -49,11 +49,14 @@
RelationshipManagerTest relationshipManagerTest;
+ RoleManagerTest roleManagerTest;
+
protected void setUp() throws Exception
{
super.setUp();
persistenceManagerTest = new PersistenceManagerTest(this);
relationshipManagerTest = new RelationshipManagerTest(this);
+ roleManagerTest = new RoleManagerTest(this);
}
protected void tearDown() throws Exception
@@ -61,15 +64,53 @@
super.tearDown();
}
- public void testDBPersistenceManager() throws Exception
- {
- identitySessionFactory = new IdentityConfigurationImpl().
- configure(new File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
+// public void testDBPersistenceManager() throws Exception
+// {
+// identitySessionFactory = new IdentityConfigurationImpl().
+// configure(new File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
+//
+// persistenceManagerTest.testMethods("realm://RedHat/DB");
+// }
+//
+// public void testLDAPMixedPersistenceManager() throws Exception
+// {
+// populateClean();
+//
+// identitySessionFactory = new IdentityConfigurationImpl().
+// configure(new File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
+//
+//
+// persistenceManagerTest.testMethods("realm://RedHat/DB_LDAP");
+// }
+//
+// public void testDBRelationshipManager() throws Exception
+// {
+// identitySessionFactory = new IdentityConfigurationImpl().
+// configure(new File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
+//
+// relationshipManagerTest.testMethods("realm://RedHat/DB");
+// }
+//
+// public void testLDAPMixedRelationshipManager() throws Exception
+// {
+// populateClean();
+//
+// identitySessionFactory = new IdentityConfigurationImpl().
+// configure(new File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
+//
+//
+// relationshipManagerTest.testMethods("realm://RedHat/DB_LDAP");
+// }
+//
+// public void testDBRoleManager() throws Exception
+// {
+// identitySessionFactory = new IdentityConfigurationImpl().
+// configure(new File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
+//
+// roleManagerTest.testMethods("realm://RedHat/DB");
+// }
- persistenceManagerTest.testMethods("realm://RedHat/DB");
- }
-
- public void testLDAPMixedPersistenceManager() throws Exception
+ public void testLDAPMixedRoleManager() throws Exception
{
populateClean();
@@ -77,27 +118,8 @@
configure(new File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
- persistenceManagerTest.testMethods("realm://RedHat/DB_LDAP");
+ roleManagerTest.testMethods("realm://RedHat/DB_LDAP");
}
- public void testDBRelationshipManager() throws Exception
- {
- identitySessionFactory = new IdentityConfigurationImpl().
- configure(new File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
-
- relationshipManagerTest.testMethods("realm://RedHat/DB");
- }
-
- public void testLDAPMixedRelationshipManager() throws Exception
- {
- populateClean();
-
- identitySessionFactory = new IdentityConfigurationImpl().
- configure(new File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
-
-
- relationshipManagerTest.testMethods("realm://RedHat/DB_LDAP");
- }
-
}
Copied: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RoleManagerTest.java (from rev 378, idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RelationshipManagerTest.java)
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RoleManagerTest.java (rev 0)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RoleManagerTest.java 2009-03-18 20:22:52 UTC (rev 379)
@@ -0,0 +1,234 @@
+/*
+* 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 org.jboss.identity.idm.api.IdentitySession;
+import org.jboss.identity.idm.api.Group;
+import org.jboss.identity.idm.api.User;
+import org.jboss.identity.idm.api.RoleType;
+import org.jboss.identity.idm.api.IdentitySessionFactory;
+import org.jboss.identity.idm.api.Attribute;
+import org.jboss.identity.idm.api.AttributeDescription;
+import org.jboss.identity.idm.api.IdentitySearchControl;
+import org.jboss.identity.idm.api.RoleManager;
+import org.jboss.identity.idm.api.Role;
+import org.jboss.identity.idm.p3p.P3PConstants;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Random;
+import java.util.Arrays;
+import java.util.LinkedList;
+
+import junit.framework.Assert;
+
+/**
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class RoleManagerTest extends Assert
+{
+ //TODO:
+ //TODO: - exception handling
+ //TODO: - search controls
+ //TODO: - features description
+
+ APITestContext ctx;
+
+ private String ORGANIZATION = "ORGANIZATION";
+ private String ORGANIZATION_UNIT = "ORGANIZATION_UNIT";
+ private String DIVISION = "DIVISION";
+ private String DEPARTMENT = "DEPARTMENT";
+ private String PROJECT = "PROJECT";
+ private String PEOPLE = "PEOPLE";
+
+ public RoleManagerTest(APITestContext ctx)
+ {
+ this.ctx = ctx;
+ }
+
+ public void setCtx(APITestContext ctx)
+ {
+ this.ctx = ctx;
+ }
+
+ public APITestContext getCtx()
+ {
+ return ctx;
+ }
+
+ public void testMethods(String realmName) throws Exception
+ {
+ IdentitySessionFactory factory = ctx.getIdentitySessionFactory();
+
+ IdentitySession session = factory.createIdentitySession(realmName);
+
+ session.getTransaction().start();
+
+
+
+ // RoleTypes - pure
+ assertEquals(0, session.getRoleManager().findRoleTypes(null).size());
+
+ // Create / remove
+ RoleType rt1 = session.getRoleManager().createRoleType("rt1");
+ RoleType rt2 = session.getRoleManager().createRoleType("rt2");
+ RoleType rt3 = session.getRoleManager().createRoleType("rt3");
+ RoleType rt4 = session.getRoleManager().createRoleType("rt4");
+
+ assertEquals(4, session.getRoleManager().findRoleTypes(null).size());
+
+ session.getRoleManager().removeRoleType(rt1);
+ session.getRoleManager().removeRoleType(rt2);
+
+ assertEquals(2, session.getRoleManager().findRoleTypes(null).size());
+
+ session.getRoleManager().removeRoleType("rt3");
+ session.getRoleManager().removeRoleType("rt4");
+
+ assertEquals(0, session.getRoleManager().findRoleTypes(null).size());
+
+ // Create all entities for tests
+
+ User user1 = session.getPersistenceManager().createUser("user1");
+ User user2 = session.getPersistenceManager().createUser("user2");
+ User user3 = session.getPersistenceManager().createUser("user3");
+ User user4 = session.getPersistenceManager().createUser("user4");
+
+ Group group1 = session.getPersistenceManager().createGroup("group1", ORGANIZATION);
+ Group group2 = session.getPersistenceManager().createGroup("group2", ORGANIZATION_UNIT);
+ Group group3 = session.getPersistenceManager().createGroup("group3", ORGANIZATION_UNIT);
+ Group group4 = session.getPersistenceManager().createGroup("group4", DEPARTMENT);
+ Group group5 = session.getPersistenceManager().createGroup("group5", DEPARTMENT);
+
+ rt1 = session.getRoleManager().createRoleType("rt1");
+ rt2 = session.getRoleManager().createRoleType("rt2");
+ rt3 = session.getRoleManager().createRoleType("rt3");
+ rt4 = session.getRoleManager().createRoleType("rt4");
+
+ assertEquals(4, session.getRoleManager().findRoleTypes(null).size());
+
+ // Create/remove and find roles
+
+ Role role1 = session.getRoleManager().createRole(rt1, user1, group1);
+ Role role2 = session.getRoleManager().createRole(rt1, user1, group2);
+ Role role3 = session.getRoleManager().createRole("rt2", user1.getName(), group1.getId());
+
+ //
+
+ assertEquals(2, session.getRoleManager().findRoles(user1, rt1).size());
+ assertEquals(1, session.getRoleManager().findRoles(user1, rt2).size());
+ assertEquals(1, session.getRoleManager().findRoles(group1, rt1).size());
+ assertEquals(1, session.getRoleManager().findRoles(group1, rt2).size());
+
+ //
+
+ assertEquals(2, session.getRoleManager().findGroupRoleTypes(group1).size());
+ assertEquals(1, session.getRoleManager().findGroupRoleTypes(group2.getId(), null).size());
+
+ //
+
+ assertEquals(2, session.getRoleManager().findRoles(user1, rt1).size());
+ assertEquals(1, session.getRoleManager().findRoles(user1.getName(), "rt2").size());
+ assertEquals(1, session.getRoleManager().findRoles(group1.getId(), "rt1").size());
+ assertEquals(1, session.getRoleManager().findRoles(group1, rt1).size());
+
+ //
+
+ assertEquals(2, session.getRoleManager().findGroupsWithRelatedRole(user1, null).size());
+ assertEquals(1, session.getRoleManager().findGroupsWithRelatedRole(user1.getName(), ORGANIZATION, null).size());
+
+ //
+
+ assertEquals(2, session.getRoleManager().findRoleTypes(user1, group1).size());
+ assertEquals(1, session.getRoleManager().findRoleTypes(user1.getName(), group2.getId(), null).size());
+
+ //
+
+ assertEquals(2, session.getRoleManager().findUserRoleTypes(user1).size());
+ assertEquals(0, session.getRoleManager().findUserRoleTypes(user2.getName(), null).size());
+
+ //
+ assertTrue(session.getRoleManager().hasRole(user1, group1, rt1));
+ assertTrue(session.getRoleManager().hasRole(user1, group1, rt2));
+ assertTrue(session.getRoleManager().hasRole("user1", group2.getId(), "rt1"));
+ assertFalse(session.getRoleManager().hasRole("user2", group2.getId(), "rt1"));
+ assertFalse(session.getRoleManager().hasRole(user1, group1, rt3));
+ assertFalse(session.getRoleManager().hasRole(user1, group4, rt3));
+
+
+ // Remove roles
+
+ session.getRoleManager().removeRole(rt1, user1, group1);
+ session.getRoleManager().removeRole(role2);
+ session.getRoleManager().removeRole("rt2", user1.getName(), group1.getId());
+
+ assertFalse(session.getRoleManager().hasRole(user1, group1, rt1));
+ assertFalse(session.getRoleManager().hasRole(user1, group1, rt2));
+ assertFalse(session.getRoleManager().hasRole("user1", group2.getId(), "rt1"));
+
+ //
+
+ assertEquals(0, session.getRoleManager().findRoles(user1, rt1).size());
+ assertEquals(0, session.getRoleManager().findRoles(user1, rt2).size());
+ assertEquals(0, session.getRoleManager().findRoles(group1, rt1).size());
+ assertEquals(0, session.getRoleManager().findRoles(group1, rt2).size());
+
+ //
+
+ assertEquals(0, session.getRoleManager().findGroupRoleTypes(group1).size());
+ assertEquals(0, session.getRoleManager().findGroupRoleTypes(group2.getId(), null).size());
+
+ //
+
+ assertEquals(0, session.getRoleManager().findRoles(user1, rt1).size());
+ assertEquals(0, session.getRoleManager().findRoles(user1.getName(), "rt2").size());
+ assertEquals(0, session.getRoleManager().findRoles(group1.getId(), "rt1").size());
+ assertEquals(0, session.getRoleManager().findRoles(group1, rt1).size());
+
+ //
+
+ assertEquals(0, session.getRoleManager().findGroupsWithRelatedRole(user1, null).size());
+ assertEquals(0, session.getRoleManager().findGroupsWithRelatedRole(user1.getName(), ORGANIZATION, null).size());
+
+ //
+
+ assertEquals(0, session.getRoleManager().findRoleTypes(user1, group1).size());
+ assertEquals(0, session.getRoleManager().findRoleTypes(user1.getName(), group2.getId(), null).size());
+
+ //
+
+ assertEquals(0, session.getRoleManager().findUserRoleTypes(user1).size());
+ assertEquals(0, session.getRoleManager().findUserRoleTypes(user2.getName(), null).size());
+
+
+
+
+ session.getTransaction().commit();
+
+ }
+
+
+
+}
\ No newline at end of file
Modified: idm/trunk/idm/src/test/resources/organization-test-config.xml
===================================================================
--- idm/trunk/idm/src/test/resources/organization-test-config.xml 2009-03-18 15:20:34 UTC (rev 378)
+++ idm/trunk/idm/src/test/resources/organization-test-config.xml 2009-03-18 20:22:52 UTC (rev 379)
@@ -167,6 +167,10 @@
<relationships>
<relationship>
<relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+ <identity-object-type-ref>ORGANIZATION</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
<identity-object-type-ref>COMMUNITY</identity-object-type-ref>
</relationship>
<relationship>
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-18 15:20:34 UTC (rev 378)
+++ idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RoleManager.java 2009-03-18 20:22:52 UTC (rev 379)
@@ -288,4 +288,14 @@
<T extends IdentityType> Collection<Role> findRoles(T identityType,
RoleType roleType) throws IdentityException;
+ /**
+ * Find Role objects with a given RoleType name associated with IdentityType for a given id (Group) or name (User)
+ * @param id
+ * @param roleTypeName
+ * @return
+ * @throws IdentityException
+ */
+ <T extends IdentityType> Collection<Role> findRoles(String id,
+ String roleTypeName) throws IdentityException;
+
}
15 years, 9 months
JBoss Identity SVN: r378 - in idm/trunk: idm/src/main/java/org/jboss/identity/idm/impl/cache and 3 other directories.
by jboss-identity-commits@lists.jboss.org
Author: bdaw
Date: 2009-03-18 11:20:34 -0400 (Wed, 18 Mar 2009)
New Revision: 378
Added:
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestBase.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTestCase.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/PersistenceManagerTest.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RelationshipManagerTest.java
Modified:
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AbstractManager.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/PersistenceManagerImpl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/IdentityStoreCacheSupport.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheIdentityStoreWrapper.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreImpl.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestCase.java
Log:
- More test cases and bug fixes
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-17 21:38:45 UTC (rev 377)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AbstractManager.java 2009-03-18 15:20:34 UTC (rev 378)
@@ -203,7 +203,7 @@
}
- protected IdentityObjectType getIdentityObjectType()
+ protected IdentityObjectType getUserObjectType()
{
return getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType();
}
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-17 21:38:45 UTC (rev 377)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/PersistenceManagerImpl.java 2009-03-18 15:20:34 UTC (rev 378)
@@ -126,7 +126,7 @@
public User createUser(String identityName) throws IdentityException
{
- IdentityObjectType iot = getIdentityObjectType();
+ IdentityObjectType iot = getUserObjectType();
IdentityObject identityObject = getRepository().createIdentityObject(getInvocationContext(), identityName, iot);
@@ -173,7 +173,7 @@
public int getUserCount() throws IdentityException
{
- IdentityObjectType iot = getIdentityObjectType();
+ IdentityObjectType iot = getUserObjectType();
return getRepository().getIdentityObjectsCount(getInvocationContext(), iot);
}
@@ -187,19 +187,14 @@
public User findUser(String name) throws IdentityException
{
- return createUser(getRepository().findIdentityObject(getInvocationContext(), name, getIdentityObjectType()));
+ return createUser(getRepository().findIdentityObject(getInvocationContext(), name, getUserObjectType()));
}
- public User findUserById(String id) throws IdentityException
- {
- return createUser(getRepository().findIdentityObject(getInvocationContext(), id));
- }
-
public Collection<User> findUser(IdentitySearchControl[] controls) throws IdentityException
{
- Collection<IdentityObject> ios = getRepository().findIdentityObject(getInvocationContext(), getIdentityObjectType(), convertSearchControls(controls));
+ Collection<IdentityObject> ios = getRepository().findIdentityObject(getInvocationContext(), getUserObjectType(), convertSearchControls(controls));
List<User> identities = new LinkedList<User>();
for (Iterator<IdentityObject> iterator = ios.iterator(); iterator.hasNext();)
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-17 21:38:45 UTC (rev 377)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java 2009-03-18 15:20:34 UTC (rev 378)
@@ -472,11 +472,14 @@
Collection<IdentityObject> ios = getRepository().findIdentityObject(getInvocationContext(), createIdentityObject(group), MEMBER, true, convertSearchControls(controls));
- //TODO: filter out groups....
+ String userTypeName = getUserObjectType().getName();
for (IdentityObject io : ios)
{
- identities.add(createUser(io));
+ if (io.getIdentityType().getName().equals(userTypeName))
+ {
+ identities.add(createUser(io));
+ }
}
return identities;
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/IdentityStoreCacheSupport.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/IdentityStoreCacheSupport.java 2009-03-17 21:38:45 UTC (rev 377)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/IdentityStoreCacheSupport.java 2009-03-18 15:20:34 UTC (rev 378)
@@ -727,7 +727,10 @@
// Simple
- Fqn fqn = Fqn.fromElements(RELATIONSHIPS_SEARCH_SIMPLE_NODE, fromName, toName, relationshipType.getName());
+// Fqn fqn = Fqn.fromElements(RELATIONSHIPS_SEARCH_SIMPLE_NODE, fromName, toName, relationshipType.getName());
+// getCache().getRoot().removeChild(fqn);
+
+ Fqn fqn = createRelationshipsSimpleSearchFqn(fromIdentity, toIdentity, relationshipType);
getCache().getRoot().removeChild(fqn);
// Complex
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheIdentityStoreWrapper.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheIdentityStoreWrapper.java 2009-03-17 21:38:45 UTC (rev 377)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheIdentityStoreWrapper.java 2009-03-18 15:20:34 UTC (rev 378)
@@ -260,8 +260,12 @@
String relationshipName,
boolean createNames) throws IdentityException
{
+ invalidateCachedRelationshipSearches(fromIdentity, toIdentity, relationshipType, relationshipName);
+
return identityStore.createRelationship(invocationCxt,
fromIdentity, toIdentity, relationshipType, relationshipName, createNames);
+
+
}
public void removeRelationship(IdentityStoreInvocationContext invocationCxt,
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreImpl.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreImpl.java 2009-03-17 21:38:45 UTC (rev 377)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreImpl.java 2009-03-18 15:20:34 UTC (rev 378)
@@ -1341,7 +1341,6 @@
//TODO: impl lacks support for rel type
relationships.add(new LDAPIdentityObjectRelationshipImpl(null, ldapFromIO, ldapToIO));
}
- break;
}
}
Copied: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestBase.java (from rev 377, 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/APITestBase.java (rev 0)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestBase.java 2009-03-18 15:20:34 UTC (rev 378)
@@ -0,0 +1,157 @@
+/*
+* 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.HibernateTestSupport;
+import org.jboss.identity.idm.impl.configuration.IdentityConfigurationImpl;
+import org.jboss.identity.idm.api.IdentitySessionFactory;
+import org.jboss.identity.idm.api.cfg.IdentityConfiguration;
+import org.jboss.identity.idm.opends.OpenDSService;
+import org.opends.server.tools.LDAPModify;
+
+import javax.naming.directory.DirContext;
+import javax.naming.Context;
+import javax.naming.NamingEnumeration;
+import javax.naming.Binding;
+import javax.naming.ldap.InitialLdapContext;
+import java.util.Hashtable;
+import java.io.File;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class APITestBase extends TestCase implements APITestContext
+{
+ HibernateTestSupport hibernateSupport =
+ new HibernateTestSupport("unit-testing-jpa1", "hibernate-jboss-identity-classes.cfg.xml");
+
+ IdentitySessionFactory identitySessionFactory;
+
+ public static final String LDAP_HOST = "localhost";
+
+ public static final String LDAP_PORT = "10389";
+
+ public static final String LDAP_PROVIDER_URL = "ldap://" + LDAP_HOST + ":" + LDAP_PORT;
+
+ public static final String LDAP_PRINCIPAL = "cn=Directory Manager";
+
+ public static final String LDAP_CREDENTIALS = "password";
+
+ static Hashtable<String,String> env = new Hashtable<String,String>();
+
+ static
+ {
+ env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
+ env.put(Context.PROVIDER_URL, LDAP_PROVIDER_URL);
+ env.put(Context.SECURITY_AUTHENTICATION, "simple");
+ env.put(Context.SECURITY_PRINCIPAL, LDAP_PRINCIPAL);
+ env.put(Context.SECURITY_CREDENTIALS, LDAP_CREDENTIALS);
+ }
+
+ OpenDSService openDSService = new OpenDSService("target/test-classes/opends");
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ hibernateSupport.start();
+ openDSService.start();
+
+ }
+
+ protected void tearDown() throws Exception
+ {
+ hibernateSupport.stop();
+
+ cleanUp(new InitialLdapContext(env, null));
+
+ openDSService.stop();
+ }
+
+ public IdentitySessionFactory getIdentitySessionFactory()
+ {
+ return identitySessionFactory;
+ }
+
+ public void populate() throws Exception
+ {
+ populateLDIF("target/test-classes/ldap/initial-opends.ldif");
+ }
+
+ public void populateClean() throws Exception
+ {
+ populateLDIF("target/test-classes/ldap/initial-empty-opends.ldif");
+ }
+
+ public void populateLDIF(String ldifRelativePath) throws Exception
+ {
+ File ldif = new File(ldifRelativePath);
+
+ System.out.println("LDIF: " + ldif.getAbsolutePath());
+
+ String[] cmd = new String[] {"-h", LDAP_HOST,
+ "-p", LDAP_PORT,
+ "-D", LDAP_PRINCIPAL,
+ "-w", LDAP_CREDENTIALS,
+ "-a", "-f", ldif.getPath()};
+
+ System.out.println("Populate success: " + (LDAPModify.mainModify(cmd, false, System.out, System.err) == 0));
+
+ }
+
+ protected void cleanUp(DirContext ldapCtx) throws Exception
+ {
+ try
+ {
+ String dn = "dc=portal,dc=example,dc=com";
+
+ System.out.println("Removing: " + dn);
+
+ removeContext(ldapCtx, dn);
+ }
+ catch (Exception e)
+ {
+ //
+ }
+ }
+
+ //subsequent remove of javax.naming.Context
+ protected void removeContext(Context mainCtx, String name) throws Exception
+ {
+ Context deleteCtx = (Context)mainCtx.lookup(name);
+ NamingEnumeration subDirs = mainCtx.listBindings(name);
+
+ while (subDirs.hasMoreElements())
+ {
+ Binding binding = (Binding)subDirs.nextElement();
+ String subName = binding.getName();
+
+ removeContext(deleteCtx, subName);
+ }
+
+ mainCtx.unbind(name);
+ }
+
+
+}
\ No newline at end of file
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-17 21:38:45 UTC (rev 377)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestCase.java 2009-03-18 15:20:34 UTC (rev 378)
@@ -42,159 +42,62 @@
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
* @version : 0.1 $
*/
-public class APITestCase extends TestCase implements APITestContext
+public class APITestCase extends APITestBase
{
- HibernateTestSupport hibernateSupport =
- new HibernateTestSupport("unit-testing-jpa1", "hibernate-jboss-identity-classes.cfg.xml");
- OrganizationTest orgTest;
+ PersistenceManagerTest persistenceManagerTest;
- IdentitySessionFactory identitySessionFactory;
+ RelationshipManagerTest relationshipManagerTest;
- public static final String LDAP_HOST = "localhost";
-
- public static final String LDAP_PORT = "10389";
-
- public static final String LDAP_PROVIDER_URL = "ldap://" + LDAP_HOST + ":" + LDAP_PORT;
-
- public static final String LDAP_PRINCIPAL = "cn=Directory Manager";
-
- public static final String LDAP_CREDENTIALS = "password";
-
- static Hashtable<String,String> env = new Hashtable<String,String>();
-
- static
- {
- env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
- env.put(Context.PROVIDER_URL, LDAP_PROVIDER_URL);
- env.put(Context.SECURITY_AUTHENTICATION, "simple");
- env.put(Context.SECURITY_PRINCIPAL, LDAP_PRINCIPAL);
- env.put(Context.SECURITY_CREDENTIALS, LDAP_CREDENTIALS);
- }
-
- OpenDSService openDSService = new OpenDSService("target/test-classes/opends");
-
protected void setUp() throws Exception
{
super.setUp();
- hibernateSupport.start();
- orgTest = new OrganizationTest(this);
- openDSService.start();
-
+ persistenceManagerTest = new PersistenceManagerTest(this);
+ relationshipManagerTest = new RelationshipManagerTest(this);
}
protected void tearDown() throws Exception
{
- hibernateSupport.stop();
-
- cleanUp(new InitialLdapContext(env, null));
-
- openDSService.stop();
+ super.tearDown();
}
- public void testDBOrganization() throws Exception
+ public void testDBPersistenceManager() throws Exception
{
identitySessionFactory = new IdentityConfigurationImpl().
configure(new File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
- orgTest.testRedHatOrganization("realm://RedHat/DB");
+ persistenceManagerTest.testMethods("realm://RedHat/DB");
}
- public void testDBSamplePortal() throws Exception
+ public void testLDAPMixedPersistenceManager() throws Exception
{
+ populateClean();
identitySessionFactory = new IdentityConfigurationImpl().
configure(new File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
- orgTest.testSamplePortal("realm://portal/SamplePortal/DB");
+
+ persistenceManagerTest.testMethods("realm://RedHat/DB_LDAP");
}
- public void testLDAPMixedOrganization() throws Exception
+ public void testDBRelationshipManager() throws Exception
{
- populateClean();
-
identitySessionFactory = new IdentityConfigurationImpl().
configure(new File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
-
- orgTest.testRedHatOrganization("realm://RedHat/DB_LDAP");
+ relationshipManagerTest.testMethods("realm://RedHat/DB");
}
- public void testLDAPMixedSamplePortal() throws Exception
+ public void testLDAPMixedRelationshipManager() throws Exception
{
populateClean();
identitySessionFactory = new IdentityConfigurationImpl().
configure(new File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
-
- orgTest.testSamplePortal("realm://portal/SamplePortal/DB_LDAP");
- }
- public IdentitySessionFactory getIdentitySessionFactory()
- {
- return identitySessionFactory;
+ relationshipManagerTest.testMethods("realm://RedHat/DB_LDAP");
}
- public void populate() throws Exception
- {
- populateLDIF("target/test-classes/ldap/initial-opends.ldif");
- }
-
- public void populateClean() throws Exception
- {
- populateLDIF("target/test-classes/ldap/initial-empty-opends.ldif");
- }
-
- public void populateLDIF(String ldifRelativePath) throws Exception
- {
- File ldif = new File(ldifRelativePath);
-
- System.out.println("LDIF: " + ldif.getAbsolutePath());
-
- String[] cmd = new String[] {"-h", LDAP_HOST,
- "-p", LDAP_PORT,
- "-D", LDAP_PRINCIPAL,
- "-w", LDAP_CREDENTIALS,
- "-a", "-f", ldif.getPath()};
-
- System.out.println("Populate success: " + (LDAPModify.mainModify(cmd, false, System.out, System.err) == 0));
-
- }
-
- protected void cleanUp(DirContext ldapCtx) throws Exception
- {
- try
- {
- String dn = "dc=portal,dc=example,dc=com";
-
- System.out.println("Removing: " + dn);
-
- removeContext(ldapCtx, dn);
- }
- catch (Exception e)
- {
- //
- }
- }
-
- //subsequent remove of javax.naming.Context
- protected void removeContext(Context mainCtx, String name) throws Exception
- {
- Context deleteCtx = (Context)mainCtx.lookup(name);
- NamingEnumeration subDirs = mainCtx.listBindings(name);
-
- while (subDirs.hasMoreElements())
- {
- Binding binding = (Binding)subDirs.nextElement();
- String subName = binding.getName();
-
- removeContext(deleteCtx, subName);
- }
-
- mainCtx.unbind(name);
- }
-
-
}
Copied: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTestCase.java (from rev 377, 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/OrganizationTestCase.java (rev 0)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTestCase.java 2009-03-18 15:20:34 UTC (rev 378)
@@ -0,0 +1,102 @@
+/*
+* 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.HibernateTestSupport;
+import org.jboss.identity.idm.impl.configuration.IdentityConfigurationImpl;
+import org.jboss.identity.idm.api.IdentitySessionFactory;
+import org.jboss.identity.idm.api.cfg.IdentityConfiguration;
+import org.jboss.identity.idm.opends.OpenDSService;
+import org.opends.server.tools.LDAPModify;
+
+import javax.naming.directory.DirContext;
+import javax.naming.Context;
+import javax.naming.NamingEnumeration;
+import javax.naming.Binding;
+import javax.naming.ldap.InitialLdapContext;
+import java.util.Hashtable;
+import java.io.File;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class OrganizationTestCase extends APITestBase
+{
+ OrganizationTest orgTest;
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ orgTest = new OrganizationTest(this);
+ }
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ public void testDBOrganization() throws Exception
+ {
+ identitySessionFactory = new IdentityConfigurationImpl().
+ configure(new File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
+
+ orgTest.testRedHatOrganization("realm://RedHat/DB");
+ }
+
+ public void testDBSamplePortal() throws Exception
+ {
+
+ identitySessionFactory = new IdentityConfigurationImpl().
+ configure(new File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
+
+ orgTest.testSamplePortal("realm://portal/SamplePortal/DB");
+ }
+
+ public void testLDAPMixedOrganization() throws Exception
+ {
+ populateClean();
+
+ identitySessionFactory = new IdentityConfigurationImpl().
+ configure(new File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
+
+
+ orgTest.testRedHatOrganization("realm://RedHat/DB_LDAP");
+ }
+
+ public void testLDAPMixedSamplePortal() throws Exception
+ {
+ populateClean();
+
+ identitySessionFactory = new IdentityConfigurationImpl().
+ configure(new File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
+
+
+ orgTest.testSamplePortal("realm://portal/SamplePortal/DB_LDAP");
+ }
+
+
+
+
+}
\ No newline at end of file
Added: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/PersistenceManagerTest.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/PersistenceManagerTest.java (rev 0)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/PersistenceManagerTest.java 2009-03-18 15:20:34 UTC (rev 378)
@@ -0,0 +1,165 @@
+/*
+* 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 org.jboss.identity.idm.api.IdentitySession;
+import org.jboss.identity.idm.api.Group;
+import org.jboss.identity.idm.api.User;
+import org.jboss.identity.idm.api.RoleType;
+import org.jboss.identity.idm.api.IdentitySessionFactory;
+import org.jboss.identity.idm.api.Attribute;
+import org.jboss.identity.idm.api.AttributeDescription;
+import org.jboss.identity.idm.api.IdentitySearchControl;
+import org.jboss.identity.idm.p3p.P3PConstants;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Random;
+import java.util.Arrays;
+
+import junit.framework.Assert;
+
+/**
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class PersistenceManagerTest extends Assert
+{
+ //TODO:
+ //TODO: - force in removeGroup (NYI)
+ //TODO: - exception handling
+ //TODO: - search controls
+ //TODO: - features description
+
+ APITestContext ctx;
+
+ private String ORGANIZATION = "ORGANIZATION";
+ private String ORGANIZATION_UNIT = "ORGANIZATION_UNIT";
+ private String DIVISION = "DIVISION";
+ private String DEPARTMENT = "DEPARTMENT";
+ private String PROJECT = "PROJECT";
+ private String PEOPLE = "PEOPLE";
+
+ public PersistenceManagerTest(APITestContext ctx)
+ {
+ this.ctx = ctx;
+ }
+
+ public void setCtx(APITestContext ctx)
+ {
+ this.ctx = ctx;
+ }
+
+ public APITestContext getCtx()
+ {
+ return ctx;
+ }
+
+ public void testMethods(String realmName) throws Exception
+ {
+ IdentitySessionFactory factory = ctx.getIdentitySessionFactory();
+
+ IdentitySession session = factory.createIdentitySession(realmName);
+
+
+
+ session.getTransaction().start();
+
+ // Create / Remove
+
+ // Group
+ Group group1 = session.getPersistenceManager().createGroup("groupName1", ORGANIZATION);
+
+ assertNotNull(group1);
+ assertEquals(group1.getGroupType(), ORGANIZATION);
+ assertEquals(group1.getName(), "groupName1");
+
+
+ String group1Id = session.getPersistenceManager().createGroupId("groupName1", ORGANIZATION);
+
+ assertEquals(group1Id, group1.getId());
+
+ session.getPersistenceManager().createGroup("groupName2", ORGANIZATION);
+ session.getPersistenceManager().createGroup("groupName3", PROJECT);
+
+ assertEquals(2, session.getPersistenceManager().getGroupTypeCount(ORGANIZATION));
+ assertEquals(1, session.getPersistenceManager().getGroupTypeCount(PROJECT));
+ assertEquals(0, session.getPersistenceManager().getGroupTypeCount(DEPARTMENT));
+
+ assertEquals(2, session.getPersistenceManager().findGroup(ORGANIZATION).size());
+ assertEquals(1, session.getPersistenceManager().findGroup(PROJECT).size());
+ assertEquals(0, session.getPersistenceManager().findGroup(DEPARTMENT).size());
+
+ session.getPersistenceManager().removeGroup(group1, false);
+ String id = session.getPersistenceManager().createGroupId("groupName2", ORGANIZATION);
+ session.getPersistenceManager().removeGroup(id, false);
+ id = session.getPersistenceManager().createGroupId("groupName3", PROJECT);
+ session.getPersistenceManager().removeGroup(id, false);
+
+ assertEquals(0, session.getPersistenceManager().findGroup(ORGANIZATION, (IdentitySearchControl[])null).size());
+ assertEquals(0, session.getPersistenceManager().findGroup(PROJECT).size());
+ assertEquals(0, session.getPersistenceManager().findGroup(DEPARTMENT).size());
+
+ assertEquals(0, session.getPersistenceManager().getGroupTypeCount(ORGANIZATION));
+ assertEquals(0, session.getPersistenceManager().getGroupTypeCount(PROJECT));
+ assertEquals(0, session.getPersistenceManager().getGroupTypeCount(DEPARTMENT));
+
+
+ //User
+
+ User u1 = session.getPersistenceManager().createUser("olo");
+
+ assertNotNull(u1);
+ assertEquals(u1.getName(), "olo");
+
+ session.getPersistenceManager().createUser("anna");
+
+ assertEquals(2, session.getPersistenceManager().getUserCount());
+
+ assertNotNull(session.getPersistenceManager().findUser("olo"));
+ assertNotNull(session.getPersistenceManager().findUser("anna"));
+
+ //TODO: this should throw some meaningfull exception or simply return null
+ //assertNull(session.getPersistenceManager().findUser("olaf"));
+
+ assertEquals(2, session.getPersistenceManager().findUser((IdentitySearchControl[])null).size());
+
+ session.getPersistenceManager().removeUser(u1, false);
+
+ assertEquals(1, session.getPersistenceManager().getUserCount());
+
+ session.getPersistenceManager().removeUser("anna", false);
+
+ assertEquals(0, session.getPersistenceManager().getUserCount());
+
+ assertEquals(0, session.getPersistenceManager().findUser((IdentitySearchControl[])null).size());
+
+
+ session.getTransaction().commit();
+
+ }
+
+
+
+}
\ No newline at end of file
Added: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RelationshipManagerTest.java
===================================================================
--- idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RelationshipManagerTest.java (rev 0)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RelationshipManagerTest.java 2009-03-18 15:20:34 UTC (rev 378)
@@ -0,0 +1,322 @@
+/*
+* 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 org.jboss.identity.idm.api.IdentitySession;
+import org.jboss.identity.idm.api.Group;
+import org.jboss.identity.idm.api.User;
+import org.jboss.identity.idm.api.RoleType;
+import org.jboss.identity.idm.api.IdentitySessionFactory;
+import org.jboss.identity.idm.api.Attribute;
+import org.jboss.identity.idm.api.AttributeDescription;
+import org.jboss.identity.idm.api.IdentitySearchControl;
+import org.jboss.identity.idm.p3p.P3PConstants;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Random;
+import java.util.Arrays;
+import java.util.LinkedList;
+
+import junit.framework.Assert;
+
+/**
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class RelationshipManagerTest extends Assert
+{
+ //TODO:
+ //TODO: - inheritence in find methods
+ //TODO: - creating forbidden associations
+ //TODO: - exception handling
+ //TODO: - search controls
+ //TODO: - features description
+
+ APITestContext ctx;
+
+ private String ORGANIZATION = "ORGANIZATION";
+ private String ORGANIZATION_UNIT = "ORGANIZATION_UNIT";
+ private String DIVISION = "DIVISION";
+ private String DEPARTMENT = "DEPARTMENT";
+ private String PROJECT = "PROJECT";
+ private String PEOPLE = "PEOPLE";
+
+ public RelationshipManagerTest(APITestContext ctx)
+ {
+ this.ctx = ctx;
+ }
+
+ public void setCtx(APITestContext ctx)
+ {
+ this.ctx = ctx;
+ }
+
+ public APITestContext getCtx()
+ {
+ return ctx;
+ }
+
+ public void testMethods(String realmName) throws Exception
+ {
+ IdentitySessionFactory factory = ctx.getIdentitySessionFactory();
+
+ IdentitySession session = factory.createIdentitySession(realmName);
+
+ session.getTransaction().start();
+
+ // Create stuff
+ User user1 = session.getPersistenceManager().createUser("user1");
+ User user2 = session.getPersistenceManager().createUser("user2");
+ User user3 = session.getPersistenceManager().createUser("user3");
+ User user4 = session.getPersistenceManager().createUser("user4");
+
+ Group group1 = session.getPersistenceManager().createGroup("group1", ORGANIZATION);
+ Group group2 = session.getPersistenceManager().createGroup("group2", ORGANIZATION_UNIT);
+ Group group3 = session.getPersistenceManager().createGroup("group3", ORGANIZATION_UNIT);
+ Group group4 = session.getPersistenceManager().createGroup("group4", DEPARTMENT);
+ Group group5 = session.getPersistenceManager().createGroup("group5", DEPARTMENT);
+
+
+ // Associate groups
+
+ session.getRelationshipManager().associateGroups(group1, group2);
+ session.getRelationshipManager().associateGroups(group1, group3);
+
+ // Assert
+
+ // isAssociated
+
+ assertTrue(session.getRelationshipManager().isAssociated(group1, group2));
+ assertTrue(session.getRelationshipManager().isAssociated(group1, group3));
+ assertFalse(session.getRelationshipManager().isAssociated(group1, group4));
+ assertFalse(session.getRelationshipManager().isAssociated(group2, group1));
+ assertFalse(session.getRelationshipManager().isAssociated(group2, group3));
+
+ assertTrue(session.getRelationshipManager().isAssociated(Arrays.asList(group1), Arrays.asList(group2, group3)));
+ assertFalse(session.getRelationshipManager().isAssociated(Arrays.asList(group1, group2), Arrays.asList(group2, group3)));
+ assertFalse(session.getRelationshipManager().isAssociated(Arrays.asList(group2, group3), Arrays.asList(group1)));
+
+ assertTrue(session.getRelationshipManager().isAssociatedByIds(group1.getId(), group2.getId()));
+ assertTrue(session.getRelationshipManager().isAssociatedByIds(group1.getId(), group3.getId()));
+ assertFalse(session.getRelationshipManager().isAssociatedByIds(group1.getId(), group4.getId()));
+ assertFalse(session.getRelationshipManager().isAssociatedByIds(group2.getId(), group1.getId()));
+ assertFalse(session.getRelationshipManager().isAssociatedByIds(group2.getId(), group3.getId()));
+
+ assertTrue(session.getRelationshipManager().
+ isAssociatedByIds(Arrays.asList(group1.getId()), Arrays.asList(group2.getId(), group3.getId())));
+ assertFalse(session.getRelationshipManager().
+ isAssociatedByIds(Arrays.asList(group1.getId(), group2.getId()), Arrays.asList(group2.getId(), group3.getId())));
+ assertFalse(session.getRelationshipManager().
+ isAssociatedByIds(Arrays.asList(group2.getId(), group3.getId()), Arrays.asList(group1.getId())));
+
+
+ // Associate groups - other methods
+
+ // First disassociate and assert
+ session.getRelationshipManager().disassociateGroups(Arrays.asList(group1), Arrays.asList(group2, group3));
+
+ assertFalse(session.getRelationshipManager().isAssociated(group1, group2));
+ assertFalse(session.getRelationshipManager().isAssociated(group1, group3));
+
+ // reassociate #1
+ session.getRelationshipManager().associateGroups(Arrays.asList(group1), Arrays.asList(group2, group3));
+ assertTrue(session.getRelationshipManager().isAssociated(Arrays.asList(group1), Arrays.asList(group2, group3)));
+
+ session.getRelationshipManager().disassociateGroupsByIds(Arrays.asList(group1.getId()), Arrays.asList(group2.getId(), group3.getId()));
+
+ // reassociate #2
+ session.getRelationshipManager().associateGroupsByIds(Arrays.asList(group1.getId()), Arrays.asList(group2.getId(), group3.getId()));
+ assertTrue(session.getRelationshipManager().isAssociated(Arrays.asList(group1), Arrays.asList(group2, group3)));
+
+ session.getRelationshipManager().disassociateGroups(Arrays.asList(group1), Arrays.asList(group2, group3));
+
+ // reassociate #3
+ session.getRelationshipManager().associateGroupsByIds(group1.getId(), group2.getId());
+ session.getRelationshipManager().associateGroupsByIds(group1.getId(), group3.getId());
+ assertTrue(session.getRelationshipManager().isAssociated(Arrays.asList(group1), Arrays.asList(group2, group3)));
+
+ session.getRelationshipManager().disassociateGroups(Arrays.asList(group1), Arrays.asList(group2, group3));
+
+
+ // Associate Group and Users
+
+ session.getRelationshipManager().associateUsers(group1, user1);
+ session.getRelationshipManager().associateUsers(group1, user2);
+
+ // isAssociated
+
+ assertTrue(session.getRelationshipManager().isAssociated(group1, user1));
+ assertTrue(session.getRelationshipManager().isAssociated(group1, user2));
+ assertFalse(session.getRelationshipManager().isAssociated(group1, user3));
+ assertFalse(session.getRelationshipManager().isAssociated(group2, user1));
+ assertFalse(session.getRelationshipManager().isAssociated(group2, user3));
+
+ assertTrue(session.getRelationshipManager().isAssociated(Arrays.asList(group1), Arrays.asList(user1, user2)));
+ assertFalse(session.getRelationshipManager().isAssociated(Arrays.asList(group1, group2), Arrays.asList(user1, user2)));
+ assertFalse(session.getRelationshipManager().isAssociated(Arrays.asList(group2), Arrays.asList(user3)));
+
+ assertTrue(session.getRelationshipManager().isAssociatedByIds(group1.getId(), user1.getName()));
+ assertTrue(session.getRelationshipManager().isAssociatedByIds(group1.getId(), user2.getName()));
+ assertFalse(session.getRelationshipManager().isAssociatedByIds(group1.getId(), user3.getName()));
+ assertFalse(session.getRelationshipManager().isAssociatedByIds(group2.getId(), user1.getName()));
+ assertFalse(session.getRelationshipManager().isAssociatedByIds(group2.getId(), user3.getName()));
+
+ assertTrue(session.getRelationshipManager().
+ isAssociatedByIds(Arrays.asList(group1.getId()), Arrays.asList(user1.getName(), user2.getName())));
+ assertFalse(session.getRelationshipManager().
+ isAssociatedByIds(Arrays.asList(group1.getId(), group2.getId()), Arrays.asList(user1.getName(), user2.getName())));
+ assertFalse(session.getRelationshipManager().
+ isAssociatedByIds(Arrays.asList(group2.getId(), group3.getId()), Arrays.asList(user1.getName())));
+
+
+ // Associate groups / users - other methods
+
+ // First disassociate and assert
+ session.getRelationshipManager().disassociateUsers(Arrays.asList(group1), Arrays.asList(user1, user2));
+
+ assertFalse(session.getRelationshipManager().isAssociated(group1, user1));
+ assertFalse(session.getRelationshipManager().isAssociated(group1, user2));
+
+ // reassociate #1
+ session.getRelationshipManager().associateUsers(Arrays.asList(group1), Arrays.asList(user1, user2));
+ assertTrue(session.getRelationshipManager().isAssociated(Arrays.asList(group1), Arrays.asList(user1, user2)));
+
+ session.getRelationshipManager().disassociateUsers(Arrays.asList(group1), Arrays.asList(user1, user2));
+
+ // reassociate #2
+ session.getRelationshipManager().associateUsersByIds(Arrays.asList(group1.getId()), Arrays.asList(user1.getName(), user2.getName()));
+ assertTrue(session.getRelationshipManager().isAssociated(Arrays.asList(group1), Arrays.asList(user1, user2)));
+
+ session.getRelationshipManager().disassociateUsersByIds(Arrays.asList(group1.getId()), Arrays.asList(user1.getName(), user2.getName()));
+
+ // reassociate #3
+ session.getRelationshipManager().associateUsersByIds(group1.getId(), user1.getName());
+ session.getRelationshipManager().associateUsersByIds(group1.getId(), user2.getName());
+
+ assertTrue(session.getRelationshipManager().isAssociated(Arrays.asList(group1), Arrays.asList(user1, user2)));
+
+ session.getRelationshipManager().disassociateUsers(Arrays.asList(group1), Arrays.asList(user1, user2));
+
+
+ session.getTransaction().commit();
+
+ session.getTransaction().start();
+
+
+ // Find methods - prepopulate
+
+ session.getRelationshipManager().associateUsers(Arrays.asList(group1), Arrays.asList(user1, user2, user3));
+ session.getRelationshipManager().associateUsers(Arrays.asList(group3), Arrays.asList(user2, user3));
+ session.getRelationshipManager().associateGroups(Arrays.asList(group2), Arrays.asList(group3, group4, group5));
+
+ assertTrue(session.getRelationshipManager().isAssociated(Arrays.asList(group1), Arrays.asList(user1, user2, user3)));
+ assertTrue(session.getRelationshipManager().isAssociated(Arrays.asList(group2), Arrays.asList(group3, group4, group5)));
+ assertTrue(session.getRelationshipManager().isAssociated(Arrays.asList(group3), Arrays.asList(user2, user3)));
+
+ session.getTransaction().commit();
+ session.getTransaction().start();
+
+ // Find users
+ //TODO: check if collections contain correct objects (not only size)
+
+ assertEquals(3, session.getRelationshipManager().findAssociatedUsers(group1, false).size());
+ assertEquals(0, session.getRelationshipManager().findAssociatedUsers(group2, false).size());
+
+ assertEquals(3, session.getRelationshipManager().findAssociatedUsers(group1, false, null).size());
+ assertEquals(0, session.getRelationshipManager().findAssociatedUsers(group2, false, null).size());
+
+ assertEquals(3, session.getRelationshipManager().findAssociatedUsers(group1.getId(), false, null).size());
+ assertEquals(0, session.getRelationshipManager().findAssociatedUsers(group2.getId(), false, null).size());
+
+ // Find groups
+
+ // #1
+ assertEquals(2, session.getRelationshipManager().findAssociatedGroups(group2, DEPARTMENT, true, false).size());
+ assertEquals(1, session.getRelationshipManager().findAssociatedGroups(group2, ORGANIZATION_UNIT, true, false).size());
+ assertEquals(0, session.getRelationshipManager().findAssociatedGroups(group2, ORGANIZATION, true, false).size());
+
+ // #1
+ assertEquals(2, session.getRelationshipManager().findAssociatedGroups(group2.getId(), DEPARTMENT, true, false, null).size());
+ assertEquals(1, session.getRelationshipManager().findAssociatedGroups(group2.getId(), ORGANIZATION_UNIT, true, false, null).size());
+ assertEquals(0, session.getRelationshipManager().findAssociatedGroups(group2.getId(), ORGANIZATION, true, false, null).size());
+
+ // #3
+ assertEquals(1, session.getRelationshipManager().findAssociatedGroups(group3, ORGANIZATION_UNIT, false, false).size());
+ assertEquals(1, session.getRelationshipManager().findAssociatedGroups(group4, ORGANIZATION_UNIT, false, false).size());
+ assertEquals(0, session.getRelationshipManager().findAssociatedGroups(group2, ORGANIZATION, false, false).size());
+
+ // #4
+ assertEquals(1, session.getRelationshipManager().findAssociatedGroups(group3.getId(), ORGANIZATION_UNIT, false, false, null).size());
+ assertEquals(1, session.getRelationshipManager().findAssociatedGroups(group4.getId(), ORGANIZATION_UNIT, false, false, null).size());
+ assertEquals(0, session.getRelationshipManager().findAssociatedGroups(group2.getId(), ORGANIZATION, false, false, null).size());
+
+ // #5
+ assertEquals(1, session.getRelationshipManager().findAssociatedGroups(user1).size());
+ assertEquals(2, session.getRelationshipManager().findAssociatedGroups(user2).size());
+ assertEquals(2, session.getRelationshipManager().findAssociatedGroups(user3).size());
+ assertEquals(0, session.getRelationshipManager().findAssociatedGroups(user4).size());
+
+ // #6
+ assertEquals(1, session.getRelationshipManager().findAssociatedGroups(user1.getName(), null).size());
+ assertEquals(2, session.getRelationshipManager().findAssociatedGroups(user2.getName(), null).size());
+ assertEquals(2, session.getRelationshipManager().findAssociatedGroups(user3.getName(), null).size());
+ assertEquals(0, session.getRelationshipManager().findAssociatedGroups(user4.getName(), null).size());
+
+ // #7
+ assertEquals(1, session.getRelationshipManager().findAssociatedGroups(user1, ORGANIZATION).size());
+ assertEquals(0, session.getRelationshipManager().findAssociatedGroups(user1, ORGANIZATION_UNIT).size());
+ assertEquals(1, session.getRelationshipManager().findAssociatedGroups(user2, ORGANIZATION).size());
+ assertEquals(1, session.getRelationshipManager().findAssociatedGroups(user2, ORGANIZATION_UNIT).size());
+ assertEquals(1, session.getRelationshipManager().findAssociatedGroups(user3, ORGANIZATION).size());
+ assertEquals(1, session.getRelationshipManager().findAssociatedGroups(user3, ORGANIZATION_UNIT).size());
+ assertEquals(0, session.getRelationshipManager().findAssociatedGroups(user4, ORGANIZATION).size());
+ assertEquals(0, session.getRelationshipManager().findAssociatedGroups(user4, ORGANIZATION_UNIT).size());
+
+ // #7
+ assertEquals(1, session.getRelationshipManager().findAssociatedGroups(user1.getName(), ORGANIZATION, null).size());
+ assertEquals(0, session.getRelationshipManager().findAssociatedGroups(user1.getName(), ORGANIZATION_UNIT, null).size());
+ assertEquals(1, session.getRelationshipManager().findAssociatedGroups(user2.getName(), ORGANIZATION, null).size());
+ assertEquals(1, session.getRelationshipManager().findAssociatedGroups(user2.getName(), ORGANIZATION_UNIT, null).size());
+ assertEquals(1, session.getRelationshipManager().findAssociatedGroups(user3.getName(), ORGANIZATION, null).size());
+ assertEquals(1, session.getRelationshipManager().findAssociatedGroups(user3.getName(), ORGANIZATION_UNIT, null).size());
+ assertEquals(0, session.getRelationshipManager().findAssociatedGroups(user4.getName(), ORGANIZATION, null).size());
+ assertEquals(0, session.getRelationshipManager().findAssociatedGroups(user4.getName(), ORGANIZATION_UNIT, null).size());
+
+ // Cleanup and check
+ session.getRelationshipManager().disassociateUsers(Arrays.asList(group1), Arrays.asList(user1, user2, user3));
+ session.getRelationshipManager().disassociateUsers(Arrays.asList(group3), Arrays.asList(user2, user3));
+ session.getRelationshipManager().disassociateGroups(Arrays.asList(group2), Arrays.asList(group3, group4));
+
+ assertFalse(session.getRelationshipManager().isAssociated(Arrays.asList(group1), Arrays.asList(user1, user2, user3)));
+ assertFalse(session.getRelationshipManager().isAssociated(Arrays.asList(group2), Arrays.asList(group3, group4, group5)));
+ assertFalse(session.getRelationshipManager().isAssociated(Arrays.asList(group3), Arrays.asList(user2, user3)));
+
+ session.getTransaction().commit();
+
+ }
+
+
+
+}
\ 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-17 21:38:45 UTC (rev 377)
+++ idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java 2009-03-18 15:20:34 UTC (rev 378)
@@ -143,16 +143,7 @@
User findUser(String name) throws IdentityException;
/**
- * Find identity with a given id
*
- * @param id
- * @return
- * @throws org.jboss.identity.idm.exception.IdentityException
- */
- User findUserById(String id) throws IdentityException;
-
- /**
- *
* @param controls
* @return
* @throws IdentityException
15 years, 9 months
JBoss Identity SVN: r377 - in idm/trunk: example/maven2/src/test/resources and 22 other directories.
by jboss-identity-commits@lists.jboss.org
Author: bdaw
Date: 2009-03-17 17:38:45 -0400 (Tue, 17 Mar 2009)
New Revision: 377
Added:
idm/trunk/example/maven2/src/test/java/org/jboss/identity/idm/example/InjectSFTestCase.java
idm/trunk/example/maven2/src/test/resources/example-db-inject-sf-config.xml
idm/trunk/example/maven2/src/test/resources/hibernate-jboss-identity-classes.cfg.xml
idm/trunk/example/maven2/src/test/resources/hibernate-jboss-identity.cfg.xml
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/cfg/
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/cfg/IdentityConfiguration.java
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/cfg/IdentityConfigurationRegistry.java
idm/trunk/idm-common/src/main/java/org/jboss/identity/idm/exception/IdentityConfigurationException.java
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/configuration/IdentityConfigurationContext.java
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/configuration/IdentityConfigurationContextRegistry.java
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/configuration/IdentityRepositoryConfigurationContext.java
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/configuration/IdentityStoreConfigurationContext.java
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/configuration/RealmConfigurationContext.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/IdentityConfigurationContextImpl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/IdentityConfigurationImpl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/IdentityRepositoryConfigurationContextImpl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/IdentityStoreConfigurationContextImpl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/RealmConfigurationContextImpl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/helper/CopyOnWriteRegistry.java
Removed:
idm/trunk/example/maven2/src/test/resources/META-INF/
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/exception/IdentityConfigurationException.java
Modified:
idm/trunk/example/maven2/src/test/java/org/jboss/identity/idm/example/DBTestCase.java
idm/trunk/example/maven2/src/test/java/org/jboss/identity/idm/example/LDAPTestCase.java
idm/trunk/example/maven2/src/test/java/org/jboss/identity/idm/example/MixedTestCase.java
idm/trunk/example/maven2/src/test/java/org/jboss/identity/idm/example/TestBase.java
idm/trunk/example/maven2/src/test/resources/example-db-config.xml
idm/trunk/example/maven2/src/test/resources/example-ldap-config.xml
idm/trunk/example/maven2/src/test/resources/example-mixed-config.xml
idm/trunk/example/maven2/src/test/resources/identity-config.xsd
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/PersistenceManager.java
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RelationshipManager.java
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RoleManager.java
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/repository/IdentityStoreRepository.java
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityStore.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/IdentitySessionFactoryImpl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/model/GroupId.java
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/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/cache/JBossCacheIdentityStoreWrapper.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/JAXB2IdentityConfiguration.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/AbstractIdentityStoreRepository.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/FallbackIdentityStoreRepository.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/WrapperIdentityStoreRepository.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/ldap/LDAPIdentityStoreImpl.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/api/APITestCase.java
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/store/hibernate/HibernateIdentityStoreTestCase.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreTestCase.java
idm/trunk/idm/src/test/resources/hibernate-jboss-identity.cfg.xml
idm/trunk/idm/src/test/resources/organization-test-config.xml
idm/trunk/idm/src/test/resources/store-test-config.xml
Log:
- A way to inject object instances referenced from xml config. Main use case is to provide SessionFactory manually
- Additional API changes
Modified: idm/trunk/example/maven2/src/test/java/org/jboss/identity/idm/example/DBTestCase.java
===================================================================
--- idm/trunk/example/maven2/src/test/java/org/jboss/identity/idm/example/DBTestCase.java 2009-03-17 15:45:09 UTC (rev 376)
+++ idm/trunk/example/maven2/src/test/java/org/jboss/identity/idm/example/DBTestCase.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -31,17 +31,15 @@
import org.jboss.identity.idm.api.IdentitySessionFactory;
import org.jboss.identity.idm.api.IdentitySession;
-import org.jboss.identity.idm.api.Identity;
-import org.jboss.identity.idm.api.GroupType;
import org.jboss.identity.idm.api.Group;
import org.jboss.identity.idm.api.RoleType;
import org.jboss.identity.idm.api.AttributeDescription;
import org.jboss.identity.idm.api.Attribute;
import org.jboss.identity.idm.api.IdentitySearchControl;
+import org.jboss.identity.idm.api.User;
import org.jboss.identity.idm.impl.api.IdentitySessionFactoryImpl;
import org.jboss.identity.idm.impl.api.SimpleAttribute;
-import org.jboss.identity.idm.impl.api.model.SimpleGroupType;
-import org.jboss.identity.idm.p3p.P3PConstants;
+import org.jboss.identity.idm.impl.configuration.IdentityConfigurationImpl;
/**
@@ -72,21 +70,22 @@
public void testJBossIdentity() throws Exception
{
- IdentitySessionFactory identitySessionFactory = new IdentitySessionFactoryImpl(new File("src/test/resources/example-db-config.xml"));
+ IdentitySessionFactory identitySessionFactory = new IdentityConfigurationImpl().
+ configure(new File("src/test/resources/example-db-config.xml")).buildIdentitySessionFactory();
IdentitySession identitySession = identitySessionFactory.createIdentitySession("realm://JBossIdentityExample/SampleRealm");
identitySession.beginTransaction();
- Collection<Identity> identities = identitySession
+ Collection<User> users = identitySession
.getPersistenceManager()
- .findIdentity((IdentitySearchControl[])null);
+ .findUser((IdentitySearchControl[])null);
- GroupType ORGANIZATION = new SimpleGroupType("ORGANIZATION");
- GroupType GROUP = new SimpleGroupType("GROUP");
+ String ORGANIZATION = "ORGANIZATION";
+ String GROUP = "GROUP";
- Identity johnDoe = identitySession.getPersistenceManager().createIdentity("John Doe");
- Identity alice = identitySession.getPersistenceManager().createIdentity("Alice");
- Identity eva = identitySession.getPersistenceManager().createIdentity("Eva");
+ User johnDoe = identitySession.getPersistenceManager().createUser("John Doe");
+ User alice = identitySession.getPersistenceManager().createUser("Alice");
+ User eva = identitySession.getPersistenceManager().createUser("Eva");
Group acmeOrg = identitySession.getPersistenceManager().createGroup("ACME", ORGANIZATION);
@@ -96,10 +95,10 @@
identitySession.getRelationshipManager().associateGroups(acmeOrg, itGroup);
identitySession.getRelationshipManager().associateGroups(acmeOrg, hrGroup);
- identitySession.getRelationshipManager().associateIdentities(itGroup, johnDoe);
- identitySession.getRelationshipManager().associateIdentities(itGroup, alice);
+ identitySession.getRelationshipManager().associateUsers(itGroup, johnDoe);
+ identitySession.getRelationshipManager().associateUsers(itGroup, alice);
- identitySession.getRelationshipManager().associateIdentities(hrGroup, eva);
+ identitySession.getRelationshipManager().associateUsers(hrGroup, eva);
RoleType managerRT = identitySession.getRoleManager().createRoleType("manager");
@@ -135,7 +134,7 @@
assertTrue(Arrays.equals((byte[])attributes.get("picture").getValue(), picture));
- Identity xUser = identitySession.getPersistenceManager().createIdentity("x");
+ User xUser = identitySession.getPersistenceManager().createUser("x");
Group someGroup = identitySession.getPersistenceManager().createGroup("someGroup", GROUP);
identitySession.getRoleManager().createRole(managerRT, xUser, someGroup);
@@ -146,7 +145,7 @@
Group otherGroup = identitySession.getPersistenceManager().createGroup("otherGroup", GROUP);
- identitySession.getRelationshipManager().associateIdentities(otherGroup, xUser);
+ identitySession.getRelationshipManager().associateUsers(otherGroup, xUser);
assertEquals(1, identitySession.getRelationshipManager().findAssociatedGroups(xUser, GROUP).size());
assertEquals(1, identitySession.getRoleManager().findGroupsWithRelatedRole(xUser, GROUP, null).size());
Added: idm/trunk/example/maven2/src/test/java/org/jboss/identity/idm/example/InjectSFTestCase.java
===================================================================
--- idm/trunk/example/maven2/src/test/java/org/jboss/identity/idm/example/InjectSFTestCase.java (rev 0)
+++ idm/trunk/example/maven2/src/test/java/org/jboss/identity/idm/example/InjectSFTestCase.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -0,0 +1,168 @@
+/*
+* 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.example;
+
+import org.jboss.identity.idm.api.IdentitySessionFactory;
+import org.jboss.identity.idm.api.IdentitySession;
+import org.jboss.identity.idm.api.User;
+import org.jboss.identity.idm.api.IdentitySearchControl;
+import org.jboss.identity.idm.api.Attribute;
+import org.jboss.identity.idm.api.AttributeDescription;
+import org.jboss.identity.idm.api.cfg.IdentityConfiguration;
+import org.jboss.identity.idm.impl.configuration.IdentityConfigurationImpl;
+import org.jboss.identity.idm.impl.api.SimpleAttribute;
+import org.hibernate.SessionFactory;
+import org.hibernate.cfg.AnnotationConfiguration;
+
+import java.util.logging.Logger;
+import java.util.Collection;
+import java.util.Random;
+import java.util.Map;
+import java.util.Arrays;
+import java.io.File;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class InjectSFTestCase extends TestBase
+{
+ private static Logger logger = Logger.getLogger(InjectSFTestCase.class.getName());
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ startDatabase();
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+
+ stopDatabase();
+ }
+
+
+ public void testInjectSessionFactory() throws Exception
+ {
+ IdentityConfiguration identityConfiguration = new IdentityConfigurationImpl().
+ configure(new File("src/test/resources/example-db-config.xml"));
+
+ SessionFactory hibernateSessionFactory = new AnnotationConfiguration().configure("hibernate-jboss-identity-classes.cfg.xml")
+ .buildSessionFactory();
+
+ identityConfiguration.getIdentityConfigurationRegistry().register(hibernateSessionFactory, "registeredSessionFactory1");
+
+ IdentitySessionFactory identitySessionFactory = identityConfiguration.buildIdentitySessionFactory();
+
+ IdentitySession identitySession = identitySessionFactory.createIdentitySession("realm://JBossIdentityExample/SampleRealm");
+ identitySession.beginTransaction();
+
+ Collection<User> users = identitySession
+ .getPersistenceManager()
+ .findUser((IdentitySearchControl[])null);
+
+ String ORGANIZATION = "ORGANIZATION";
+ String GROUP = "GROUP";
+
+ // Use username nad group ids instead of objects
+
+ String johnDoeUser = identitySession.getPersistenceManager().createUser("John Doe").getName();
+ String aliceUser = identitySession.getPersistenceManager().createUser("Alice").getName();
+ String evaUser = identitySession.getPersistenceManager().createUser("Eva").getName();
+
+ String acmeOrgId = identitySession.getPersistenceManager().createGroup("ACME", ORGANIZATION).getId();
+
+ String itGroupId = identitySession.getPersistenceManager().createGroup("IT", GROUP).getId();
+ String hrGroupId = identitySession.getPersistenceManager().createGroup("HR", GROUP).getId();
+
+ identitySession.getRelationshipManager().associateGroupsByIds(acmeOrgId, itGroupId);
+ identitySession.getRelationshipManager().associateGroupsByIds(acmeOrgId, hrGroupId);
+
+ identitySession.getRelationshipManager().associateUsersByIds(itGroupId, johnDoeUser);
+ identitySession.getRelationshipManager().associateUsersByIds(itGroupId, aliceUser);
+
+ identitySession.getRelationshipManager().associateUsersByIds(hrGroupId, evaUser);
+
+ identitySession.getRoleManager().createRoleType("manager");
+
+ identitySession.getRoleManager().createRole("manager", johnDoeUser, itGroupId);
+
+ // John belongs to IT and not HR
+ assertTrue(identitySession.getRelationshipManager().isAssociatedByIds(itGroupId, johnDoeUser));
+ assertFalse(identitySession.getRelationshipManager().isAssociatedByIds(hrGroupId, johnDoeUser));
+
+ // John is manager of IT and not HR
+ assertTrue(identitySession.getRoleManager().hasRole(johnDoeUser, itGroupId, "manager"));
+ assertFalse(identitySession.getRoleManager().hasRole(johnDoeUser, hrGroupId, "manager"));
+
+// Check that binary attribute picture is mapped
+//
+ AttributeDescription attributeDescription = identitySession.getAttributesManager().getAttributeDescription(johnDoeUser, "picture");
+ assertNotNull(attributeDescription);
+ assertEquals("binary", attributeDescription.getType());
+
+
+ // Generate random binary data for binary attribute
+ Random random = new Random();
+
+ byte[] picture = new byte[5120];
+ random.nextBytes(picture);
+
+ identitySession.getAttributesManager().addAttributes(johnDoeUser, new Attribute[] {new SimpleAttribute("picture", new byte[][]{picture})});
+
+ // Assert picture
+
+ Map<String, Attribute> attributes = identitySession.getAttributesManager().getAttributes(johnDoeUser);
+ assertEquals(1, attributes.keySet().size());
+ assertTrue(Arrays.equals((byte[])attributes.get("picture").getValue(), picture));
+
+
+ String xUser = identitySession.getPersistenceManager().createUser("x").getName();
+ String someGroupId = identitySession.getPersistenceManager().createGroup("someGroup", GROUP).getId();
+
+ identitySession.getRoleManager().createRole("manager", xUser, someGroupId);
+
+ assertEquals(0, identitySession.getRelationshipManager().findAssociatedGroups(xUser, GROUP, null).size());
+ assertEquals(1, identitySession.getRoleManager().findGroupsWithRelatedRole(xUser, GROUP, null).size());
+ assertEquals(1, identitySession.getRoleManager().findGroupsWithRelatedRole(xUser, null).size());
+
+ String otherGroupId = identitySession.getPersistenceManager().createGroup("otherGroup", GROUP).getId();
+
+ identitySession.getRelationshipManager().associateUsersByIds(otherGroupId, xUser);
+
+ assertEquals(1, identitySession.getRelationshipManager().findAssociatedGroups(xUser, GROUP, null).size());
+ assertEquals(1, identitySession.getRoleManager().findGroupsWithRelatedRole(xUser, GROUP, null).size());
+ assertEquals(1, identitySession.getRoleManager().findGroupsWithRelatedRole(xUser, null).size());
+
+
+ identitySession.getTransaction().commit();
+ identitySession.close();
+
+
+ }
+
+}
Modified: idm/trunk/example/maven2/src/test/java/org/jboss/identity/idm/example/LDAPTestCase.java
===================================================================
--- idm/trunk/example/maven2/src/test/java/org/jboss/identity/idm/example/LDAPTestCase.java 2009-03-17 15:45:09 UTC (rev 376)
+++ idm/trunk/example/maven2/src/test/java/org/jboss/identity/idm/example/LDAPTestCase.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -30,10 +30,11 @@
import org.jboss.identity.idm.api.IdentitySessionFactory;
import org.jboss.identity.idm.api.IdentitySession;
-import org.jboss.identity.idm.api.Identity;
import org.jboss.identity.idm.api.Attribute;
+import org.jboss.identity.idm.api.User;
import org.jboss.identity.idm.impl.api.IdentitySessionFactoryImpl;
import org.jboss.identity.idm.impl.api.SimpleAttribute;
+import org.jboss.identity.idm.impl.configuration.IdentityConfigurationImpl;
/**
@@ -67,12 +68,13 @@
public void testJBossIdentity() throws Exception
{
- IdentitySessionFactory identitySessionFactory = new IdentitySessionFactoryImpl(new File("src/test/resources/example-ldap-config.xml"));
+ IdentitySessionFactory identitySessionFactory = new IdentityConfigurationImpl().
+ configure(new File("src/test/resources/example-ldap-config.xml")).buildIdentitySessionFactory();
IdentitySession identitySession = identitySessionFactory.createIdentitySession("realm://JBossIdentityExample/SampleRealm");
identitySession.beginTransaction();
- Identity johnDoe = identitySession.getPersistenceManager().createIdentity("John Doe");
+ User johnDoe = identitySession.getPersistenceManager().createUser("John Doe");
Attribute[] userInfo = new Attribute[] {
new SimpleAttribute("phone", "777 77 77"),
Modified: idm/trunk/example/maven2/src/test/java/org/jboss/identity/idm/example/MixedTestCase.java
===================================================================
--- idm/trunk/example/maven2/src/test/java/org/jboss/identity/idm/example/MixedTestCase.java 2009-03-17 15:45:09 UTC (rev 376)
+++ idm/trunk/example/maven2/src/test/java/org/jboss/identity/idm/example/MixedTestCase.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -24,8 +24,9 @@
import org.jboss.identity.idm.api.IdentitySessionFactory;
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.impl.api.IdentitySessionFactoryImpl;
+import org.jboss.identity.idm.impl.configuration.IdentityConfigurationImpl;
import java.io.File;
@@ -63,12 +64,13 @@
public void testJBossIdentity() throws Exception
{
- IdentitySessionFactory identitySessionFactory = new IdentitySessionFactoryImpl(new File("src/test/resources/example-mixed-config.xml"));
+ IdentitySessionFactory identitySessionFactory = new IdentityConfigurationImpl().
+ configure(new File("src/test/resources/example-mixed-config.xml")).buildIdentitySessionFactory();
IdentitySession identitySession = identitySessionFactory.createIdentitySession("realm://JBossIdentityExample/SampleRealm");
identitySession.getTransaction().start();
- Identity johnDoe = identitySession.getPersistenceManager().createIdentity("John Doe");
+ User johnDoe = identitySession.getPersistenceManager().createUser("John Doe");
// Play with the API...
Modified: idm/trunk/example/maven2/src/test/java/org/jboss/identity/idm/example/TestBase.java
===================================================================
--- idm/trunk/example/maven2/src/test/java/org/jboss/identity/idm/example/TestBase.java 2009-03-17 15:45:09 UTC (rev 376)
+++ idm/trunk/example/maven2/src/test/java/org/jboss/identity/idm/example/TestBase.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -70,7 +70,7 @@
connection = DriverManager.getConnection("jdbc:hsqldb:mem:sample-test-db", "sa", "");
}
catch (Exception ex)
- {
+ {
ex.printStackTrace();
logger.fine("Exception during HSQL database startup.");
throw ex;
Modified: idm/trunk/example/maven2/src/test/resources/example-db-config.xml
===================================================================
--- idm/trunk/example/maven2/src/test/resources/example-db-config.xml 2009-03-17 15:45:09 UTC (rev 376)
+++ idm/trunk/example/maven2/src/test/resources/example-db-config.xml 2009-03-17 21:38:45 UTC (rev 377)
@@ -7,7 +7,7 @@
<id>realm://JBossIdentityExample/SampleRealm</id>
<repository-id-ref>Sample Repository</repository-id-ref>
<identity-type-mappings>
- <identity-mapping>IDENTITY</identity-mapping>
+ <user-mapping>USER</user-mapping>
</identity-type-mappings>
</realm>
</realms>
@@ -33,7 +33,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>
@@ -64,7 +64,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>
@@ -80,7 +80,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>
@@ -94,8 +94,8 @@
</supported-identity-object-types>
<options>
<option>
- <name>persistenceUnit</name>
- <value>sample-persistence-unit</value>
+ <name>hibernateConfiguration</name>
+ <value>hibernate-jboss-identity.cfg.xml</value>
</option>
<option>
<name>populateRelationshipTypes</name>
Copied: idm/trunk/example/maven2/src/test/resources/example-db-inject-sf-config.xml (from rev 367, idm/trunk/example/maven2/src/test/resources/example-db-config.xml)
===================================================================
--- idm/trunk/example/maven2/src/test/resources/example-db-inject-sf-config.xml (rev 0)
+++ idm/trunk/example/maven2/src/test/resources/example-db-inject-sf-config.xml 2009-03-17 21:38:45 UTC (rev 377)
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jboss-identity xmlns="urn:jboss:identity:idm:config:v1_0_alpha"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:identity:idm:config:v1_0_alpha identity-config.xsd">
+ <realms>
+ <realm>
+ <id>realm://JBossIdentityExample/SampleRealm</id>
+ <repository-id-ref>Sample Repository</repository-id-ref>
+ <identity-type-mappings>
+ <user-mapping>USER</user-mapping>
+ </identity-type-mappings>
+ </realm>
+ </realms>
+ <repositories>
+ <repository>
+ <id>Sample Repository</id>
+ <class>org.jboss.identity.idm.impl.repository.WrapperIdentityStoreRepository</class>
+ <external-config/>
+ <default-identity-store-id>Sample DB Store</default-identity-store-id>
+ <default-attribute-store-id>Sample DB Store</default-attribute-store-id>
+ </repository>
+ </repositories>
+ <stores>
+ <attribute-stores/>
+ <identity-stores>
+ <identity-store>
+ <id>Sample DB Store</id>
+ <class>org.jboss.identity.idm.impl.store.hibernate.HibernateIdentityStoreImpl</class>
+ <external-config/>
+ <supported-relationship-types>
+ <relationship-type>JBOSS_IDENTITY_MEMBERSHIP</relationship-type>
+ <relationship-type>JBOSS_IDENTITY_ROLE</relationship-type>
+ </supported-relationship-types>
+ <supported-identity-object-types>
+ <identity-object-type>
+ <name>USER</name>
+ <relationships>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+ <identity-object-type-ref>ORGANIZATION</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+ <identity-object-type-ref>GROUP</identity-object-type-ref>
+ </relationship>
+ </relationships>
+ <credentials>
+ <credential-type>PASSWORD</credential-type>
+ </credentials>
+ <attributes>
+ <attribute>
+ <name>picture</name>
+ <mapping>user.picture</mapping>
+ <type>binary</type>
+ <isRequired>false</isRequired>
+ <isMultivalued>false</isMultivalued>
+ <isReadOnly>false</isReadOnly>
+ </attribute>
+ </attributes>
+ <options/>
+ </identity-object-type>
+ <identity-object-type>
+ <name>ORGANIZATION</name>
+ <relationships>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>GROUP</identity-object-type-ref>
+ </relationship>
+ </relationships>
+ <credentials/>
+ <attributes/>
+ <options/>
+ </identity-object-type>
+ <identity-object-type>
+ <name>GROUP</name>
+ <relationships>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>GROUP</identity-object-type-ref>
+ </relationship>
+ </relationships>
+ <credentials/>
+ <attributes/>
+ <options/>
+ </identity-object-type>
+ </supported-identity-object-types>
+ <options>
+ <option>
+ <name>hibernateSessionFactoryRegistryName</name>
+ <value>registeredSessionFactory1</value>
+ </option>
+ <option>
+ <name>populateRelationshipTypes</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>populateIdentityObjectTypes</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>allowNotDefinedAttributes</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>isRealmAware</name>
+ <value>true</value>
+ </option>
+ </options>
+ </identity-store>
+ </identity-stores>
+ </stores>
+</jboss-identity>
\ No newline at end of file
Modified: idm/trunk/example/maven2/src/test/resources/example-ldap-config.xml
===================================================================
--- idm/trunk/example/maven2/src/test/resources/example-ldap-config.xml 2009-03-17 15:45:09 UTC (rev 376)
+++ idm/trunk/example/maven2/src/test/resources/example-ldap-config.xml 2009-03-17 21:38:45 UTC (rev 377)
@@ -7,7 +7,7 @@
<id>realm://JBossIdentityExample/SampleRealm</id>
<repository-id-ref>Sample Repository</repository-id-ref>
<identity-type-mappings>
- <identity-mapping>IDENTITY</identity-mapping>
+ <user-mapping>USER</user-mapping>
</identity-type-mappings>
</realm>
</realms>
@@ -32,7 +32,7 @@
</supported-relationship-types>
<supported-identity-object-types>
<identity-object-type>
- <name>IDENTITY</name>
+ <name>USER</name>
<relationships/>
<credentials>
<credential-type>PASSWORD</credential-type>
@@ -94,7 +94,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>
@@ -148,7 +148,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>
Modified: idm/trunk/example/maven2/src/test/resources/example-mixed-config.xml
===================================================================
--- idm/trunk/example/maven2/src/test/resources/example-mixed-config.xml 2009-03-17 15:45:09 UTC (rev 376)
+++ idm/trunk/example/maven2/src/test/resources/example-mixed-config.xml 2009-03-17 21:38:45 UTC (rev 377)
@@ -7,7 +7,7 @@
<id>realm://JBossIdentityExample/SampleRealm</id>
<repository-id-ref>Sample Repository</repository-id-ref>
<identity-type-mappings>
- <identity-mapping>IDENTITY</identity-mapping>
+ <user-mapping>USER</user-mapping>
</identity-type-mappings>
</realm>
</realms>
@@ -30,7 +30,7 @@
<identity-store-mapping>
<identity-store-id>Sample LDAP Store</identity-store-id>
<identity-object-types>
- <identity-object-type>IDENTITY</identity-object-type>
+ <identity-object-type>USER</identity-object-type>
</identity-object-types>
<options/>
</identity-store-mapping>
@@ -56,7 +56,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>
@@ -87,7 +87,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>
@@ -103,7 +103,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>
@@ -117,8 +117,8 @@
</supported-identity-object-types>
<options>
<option>
- <name>persistenceUnit</name>
- <value>sample-persistence-unit</value>
+ <name>hibernateConfiguration</name>
+ <value>hibernate-jboss-identity.cfg.xml</value>
</option>
<option>
<name>populateRelationshipTypes</name>
@@ -151,7 +151,7 @@
</supported-relationship-types>
<supported-identity-object-types>
<identity-object-type>
- <name>IDENTITY</name>
+ <name>USER</name>
<relationships/>
<credentials>
<credential-type>PASSWORD</credential-type>
@@ -213,7 +213,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>
@@ -267,7 +267,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>
Added: idm/trunk/example/maven2/src/test/resources/hibernate-jboss-identity-classes.cfg.xml
===================================================================
--- idm/trunk/example/maven2/src/test/resources/hibernate-jboss-identity-classes.cfg.xml (rev 0)
+++ idm/trunk/example/maven2/src/test/resources/hibernate-jboss-identity-classes.cfg.xml 2009-03-17 21:38:45 UTC (rev 377)
@@ -0,0 +1,61 @@
+<?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 -->
+ <!-- all nessesary mappings are added programatically to the configuration -->
+ <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/example/maven2/src/test/resources/hibernate-jboss-identity.cfg.xml
===================================================================
--- idm/trunk/example/maven2/src/test/resources/hibernate-jboss-identity.cfg.xml (rev 0)
+++ idm/trunk/example/maven2/src/test/resources/hibernate-jboss-identity.cfg.xml 2009-03-17 21:38:45 UTC (rev 377)
@@ -0,0 +1,61 @@
+<?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 -->
+ <!-- all nessesary mappings are added programatically to the configuration -->
+ <!--<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/example/maven2/src/test/resources/identity-config.xsd
===================================================================
--- idm/trunk/example/maven2/src/test/resources/identity-config.xsd 2009-03-17 15:45:09 UTC (rev 376)
+++ idm/trunk/example/maven2/src/test/resources/identity-config.xsd 2009-03-17 21:38:45 UTC (rev 377)
@@ -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/main/java/org/jboss/identity/idm/impl/api/IdentitySessionFactoryImpl.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/IdentitySessionFactoryImpl.java 2009-03-17 15:45:09 UTC (rev 376)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/IdentitySessionFactoryImpl.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -58,121 +58,8 @@
this.realmMap = realmMap;
}
- public IdentitySessionFactoryImpl(IdentityConfigurationMetaData configMD) throws Exception
- {
- realmMap = createSessionMap(configMD);
- }
+
- public IdentitySessionFactoryImpl(File configFile) throws Exception
- {
- IdentityConfigurationMetaData configMD = JAXB2IdentityConfiguration.createConfigurationMetaData(configFile);
-
- realmMap = createSessionMap(configMD);
-
- }
-
- public IdentitySessionFactoryImpl(String configResource) throws Exception
- {
- IdentityConfigurationMetaData configMD = JAXB2IdentityConfiguration.createConfigurationMetaData(configResource);
-
- realmMap = createSessionMap(configMD);
-
- }
-
- private Map<String, IdentitySession> createSessionMap(IdentityConfigurationMetaData configMD) throws Exception
- {
- //TODO: some validation, sanity checks and error reporting
-
- // IdentityStore
-
- Map<String, IdentityStore> bootstrappedIdentityStores = new HashMap<String, IdentityStore>();
- Map<String, AttributeStore> bootstrappedAttributeStores = new HashMap<String, AttributeStore>();
-
- for (IdentityStoreConfigurationMetaData metaData : configMD.getIdentityStores())
- {
- Class storeClass = null;
- try
- {
- storeClass = Class.forName(metaData.getClassName());
- }
- catch (ClassNotFoundException e)
- {
- throw new IdentityException("Cannot instantiate identity store:" + metaData.getClassName(), e);
- }
- Class partypes[] = new Class[1];
- partypes[0] = String.class;
-
- Constructor ct = storeClass.getConstructor(partypes);
- Object argList[] = new Object[1];
- argList[0] = metaData.getId();
-
- IdentityStore store = (IdentityStore)ct.newInstance(argList);
-
- store.bootstrap(metaData);
-
- bootstrappedIdentityStores.put(store.getId(), store);
- bootstrappedAttributeStores.put(store.getId(), store);
- }
-
- // IdentityRepository
-
- Map<String, IdentityStoreRepository> bootstrappedRepositories = new HashMap<String, IdentityStoreRepository>();
-
- for (IdentityRepositoryConfigurationMetaData metaData : configMD.getRepositories())
- {
- Class repoClass = null;
- try
- {
- repoClass = Class.forName(metaData.getClassName());
- }
- catch (ClassNotFoundException e)
- {
- throw new IdentityException("Cannot instantiate identity store:" + metaData.getClassName(), e);
- }
- Class partypes[] = new Class[1];
- partypes[0] = String.class;
-
- Constructor ct = repoClass.getConstructor(partypes);
- Object argList[] = new Object[1];
- argList[0] = metaData.getId();
-
- IdentityStoreRepository repo = (IdentityStoreRepository)ct.newInstance(argList);
-
- repo.bootstrap(metaData, bootstrappedIdentityStores, bootstrappedAttributeStores);
-
- bootstrappedRepositories.put(repo.getId(), repo);
- }
-
- // Realms
-
- Map<String, IdentitySession> sessionMap = new HashMap<String, IdentitySession>();
-
- for (RealmConfigurationMetaData metaData : configMD.getRealms())
- {
- String realmName = metaData.getId();
-
- IdentityStoreRepository repo = bootstrappedRepositories.get(metaData.getIdentityRepositoryIdRef());
-
- IdentityObjectTypeMapper mapper = null;
-
- if (metaData.getGroupTypeMappings() == null || metaData.getGroupTypeMappings().isEmpty())
- {
- // use direct type mapper
- mapper = new DirectIdentityObjectTypeMapperImpl(metaData.getIdentityMapping());
- }
- else
- {
- mapper = new IdentityObjectTypeMapperImpl(metaData.getGroupTypeMappings(), metaData.getIdentityMapping());
- }
-
- IdentitySession session = new IdentitySessionImpl(realmName, repo, mapper);
-
- sessionMap.put(realmName, session);
- }
-
- return sessionMap;
- }
-
public void close()
{
Modified: 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 2009-03-17 15:45:09 UTC (rev 376)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/model/GroupId.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -28,6 +28,7 @@
*/
public class GroupId
{
+ public static final String PREFIX = "group:/";
private String name;
@@ -57,15 +58,27 @@
String[] parts = id.split("/");
- if (parts == null || parts.length != 2)
+ if (!validateId(id))
{
- throw new IllegalArgumentException("group id not following required format: type/name: " + id);
+ throw new IllegalArgumentException("group id not following required format: group/type/name: " + id);
}
- name = parts[1];
- type = parts[0];
+ name = parts[2];
+ type = parts[1];
}
+ public static boolean validateId(String id)
+ {
+ String[] parts = id.split("/");
+
+ if (parts == null || parts.length != 3 || parts[0].equals(PREFIX.substring(0, PREFIX.length())))
+ {
+ return false;
+ }
+
+ return true;
+ }
+
public String getName()
{
return name;
@@ -78,6 +91,6 @@
public String getId()
{
- return type + "/" + name;
+ return PREFIX + 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-17 15:45:09 UTC (rev 376)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleGroup.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -37,11 +37,12 @@
private final String groupType;
- public SimpleGroup(String name, String id, String groupType)
+ public SimpleGroup(String name, String groupType)
{
this.name = name;
- this.id = id;
this.groupType = groupType;
+ this.id = new GroupId(name, groupType).getId();
+
}
public SimpleGroup(GroupId groupId)
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-17 15:45:09 UTC (rev 376)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AbstractManager.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -95,9 +95,23 @@
protected Group createGroup(IdentityObject identityObject)
{
String groupType = getSessionContext().getIdentityObjectTypeMapper().getGroupType(identityObject.getIdentityType());
- return new SimpleGroup(identityObject.getName(), identityObject.getId(), groupType);
+ return new SimpleGroup(identityObject.getName(), groupType);
}
+ protected IdentityType createIdentityTypeFromId(String id)
+ {
+ if (GroupId.validateId(id))
+ {
+ GroupId groupId = new GroupId(id);
+
+ return new SimpleGroup(groupId);
+ }
+ else
+ {
+ return new SimpleUser(id);
+ }
+ }
+
protected IdentityObject createIdentityObject(User identity)
{
IdentityObjectType iot = getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType();
@@ -143,6 +157,20 @@
}
+ protected IdentityObject createIdentityObject(String id)
+ {
+ if (GroupId.validateId(id))
+ {
+ GroupId groupId = new GroupId(id);
+
+ return createIdentityObjectForGroupId(id);
+ }
+ else
+ {
+ return createIdentityObjectForUserName(id);
+ }
+ }
+
protected Group createGroupFromId(String id)
{
return new SimpleGroup(new GroupId(id));
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-17 15:45:09 UTC (rev 376)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AttributesManagerImpl.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -79,6 +79,14 @@
}
+ public AttributeDescription getAttributeDescription(String id, String attributeName)
+ {
+ IdentityType identityType = createIdentityTypeFromId(id);
+
+ return getAttributeDescription(identityType, attributeName);
+
+ }
+
public Map<String, AttributeDescription> getSupportedAttributesDescriptions(IdentityType identityType)
{
@@ -105,11 +113,25 @@
return descriptionMap;
}
+ public Map<String, AttributeDescription> getSupportedAttributesDescriptions(String id)
+ {
+ IdentityType identityType = createIdentityTypeFromId(id);
+
+ return getSupportedAttributesDescriptions(identityType);
+ }
+
public Set<String> getSupportedAttributeNames(IdentityType identityType) throws IdentityException
{
return getRepository().getSupportedAttributeNames(getInvocationContext(), createIdentityObject(identityType).getIdentityType());
}
+ public Set<String> getSupportedAttributeNames(String id) throws IdentityException
+ {
+ IdentityType identityType = createIdentityTypeFromId(id);
+
+ return getSupportedAttributeNames(identityType);
+ }
+
public Map<String, Attribute> getAttributes(IdentityType identity) throws IdentityException
{
Map<String, IdentityObjectAttribute> map = getRepository().getAttributes(getInvocationContext(), createIdentityObject(identity));
@@ -123,23 +145,52 @@
return newMap;
}
+ public Map<String, Attribute> getAttributes(String id) throws IdentityException
+ {
+ IdentityType identityType = createIdentityTypeFromId(id);
+
+ return getAttributes(identityType);
+ }
+
public void updateAttributes(IdentityType identity, Attribute[] attributes) throws IdentityException
{
getRepository().updateAttributes(getInvocationContext(), createIdentityObject(identity), convertAttributes(attributes));
}
+ public void updateAttributes(String id, Attribute[] attributes) throws IdentityException
+ {
+ IdentityType identityType = createIdentityTypeFromId(id);
+
+ updateAttributes(identityType, attributes);
+
+ }
+
public Attribute getAttribute(IdentityType identity, String attributeName) throws IdentityException
{
return getAttributes(identity).get(attributeName);
}
+ public Attribute getAttribute(String id, String attributeName) throws IdentityException
+ {
+ IdentityType identityType = createIdentityTypeFromId(id);
+
+ return getAttribute(identityType, attributeName);
+ }
+
public void addAttribute(IdentityType identity, String attributeName, Object[] values) throws IdentityException
{
Attribute[] attrs = new Attribute[]{new SimpleAttribute(attributeName, values)};
addAttributes(identity, attrs);
+ }
+ public void addAttributes(String id, Attribute[] attributes) throws IdentityException
+ {
+ IdentityType identityType = createIdentityTypeFromId(id);
+
+ addAttributes(identityType, attributes);
+
}
public void addAttribute(IdentityType identity, String attributeName, Object value) throws IdentityException
@@ -151,16 +202,42 @@
}
+ public void addAttribute(String id, String attributeName, Object[] values) throws IdentityException
+ {
+ IdentityType identityType = createIdentityTypeFromId(id);
+
+ addAttribute(identityType, attributeName, values);
+
+ }
+
+ public void addAttribute(String id, String attributeName, Object value) throws IdentityException
+ {
+ IdentityType identityType = createIdentityTypeFromId(id);
+
+ addAttribute(identityType, attributeName, value);
+
+ }
+
public void addAttributes(IdentityType identity, Attribute[] attributes) throws IdentityException
{
getRepository().addAttributes(getInvocationContext(), createIdentityObject(identity), convertAttributes(attributes));
}
+
+
public void removeAttributes(IdentityType identity, String[] attributeNames) throws IdentityException
{
getRepository().removeAttributes(getInvocationContext(), createIdentityObject(identity), attributeNames);
}
+ public void removeAttributes(String id, String[] attributeNames) throws IdentityException
+ {
+ IdentityType identityType = createIdentityTypeFromId(id);
+
+ removeAttributes(identityType, attributeNames);
+
+ }
+
public boolean hasPassword(User identity) throws IdentityException
{
return getRepository().getSupportedFeatures().isCredentialSupported(createIdentityObject(identity).getIdentityType(), PasswordCredential.TYPE);
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-17 15:45:09 UTC (rev 376)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/PersistenceManagerImpl.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -34,6 +34,7 @@
import org.jboss.identity.idm.spi.searchcontrol.IdentityObjectSearchControl;
import org.jboss.identity.idm.impl.NotYetImplementedException;
import org.jboss.identity.idm.impl.api.session.managers.AbstractManager;
+import org.jboss.identity.idm.impl.api.model.GroupId;
import java.util.Collection;
import java.util.List;
@@ -141,6 +142,11 @@
return createGroup(identityObject);
}
+ public String createGroupId(String groupName, String groupType)
+ {
+ return new GroupId(groupName, groupType).getId();
+ }
+
public void removeUser(User identity, boolean force) throws IdentityException
{
getRepository().removeIdentityObject(getInvocationContext(), createIdentityObject(identity));
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-17 15:45:09 UTC (rev 376)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -232,7 +232,7 @@
public void associateUsersByIds(String parentId, String memberId) throws IdentityException
{
- getRepository().createRelationship(getInvocationContext(), createIdentityObjectForUserName(parentId), createIdentityObjectForUserName(memberId), MEMBER, null, true);
+ getRepository().createRelationship(getInvocationContext(), createIdentityObjectForGroupId(parentId), createIdentityObjectForUserName(memberId), MEMBER, null, true);
}
@@ -321,6 +321,27 @@
return true;
}
+ public boolean isAssociatedByIds(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();
+
+ Collection<IdentityObjectRelationship> relationships = getRepository().resolveRelationships(getInvocationContext(), createIdentityObject(parent), createIdentityObject(member), MEMBER);
+
+ if (relationships.size() == 0)
+ {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
public <G extends IdentityType, I extends IdentityType> boolean isAssociated(G parent, I member) throws IdentityException
{
Set<G> parents = new HashSet<G>();
@@ -331,6 +352,18 @@
return isAssociated(parents, members);
}
+ public boolean isAssociatedByIds(String parent, String member) throws IdentityException
+ {
+ Collection<IdentityObjectRelationship> relationships = getRepository().resolveRelationships(getInvocationContext(), createIdentityObject(parent), createIdentityObject(member), MEMBER);
+
+ if (relationships.size() == 0)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
public Collection<Group> findAssociatedGroups(Group group, String groupType, boolean parent, boolean inherited, IdentitySearchControl[] controls) throws IdentityException
{
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-17 15:45:09 UTC (rev 376)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RoleManagerImpl.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -184,12 +184,12 @@
}
- public Role createRole(RoleType roleType, String userName, String groupId) throws IdentityException
+ public Role createRole(String roleTypeName, String userName, String groupId) throws IdentityException
{
User user = createUserFromId(userName);
Group group = createGroupFromId(groupId);
- return createRole(roleType, user, group);
+ return createRole(new SimpleRoleType(roleTypeName), user, group);
}
public void removeRole(RoleType roleType, User identity, Group group) throws IdentityException
@@ -197,12 +197,12 @@
getRepository().removeRelationship(getInvocationContext(), createIdentityObject(identity), createIdentityObject(group), ROLE, roleType.getName());
}
- public void removeRole(RoleType roleType, String userName, String groupId) throws IdentityException
+ public void removeRole(String roleTypeName, String userName, String groupId) throws IdentityException
{
User user = createUserFromId(userName);
Group group = createGroupFromId(groupId);
- removeRole(roleType, user, group);
+ removeRole(new SimpleRoleType(roleTypeName), user, group);
}
public void removeRole(Role role) throws IdentityException
@@ -227,12 +227,12 @@
return false;
}
- public boolean hasRole(String userName, String groupId, RoleType roleType) throws IdentityException
+ public boolean hasRole(String userName, String groupId, String roleTypeName) throws IdentityException
{
User user = createUserFromId(userName);
Group group = createGroupFromId(groupId);
- return hasRole(user, group, roleType);
+ return hasRole(user, group, new SimpleRoleType(roleTypeName));
}
public Collection<RoleType> findRoleTypes(User identity, Group group) throws IdentityException
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheIdentityStoreWrapper.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheIdentityStoreWrapper.java 2009-03-17 15:45:09 UTC (rev 376)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheIdentityStoreWrapper.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -36,6 +36,7 @@
import org.jboss.identity.idm.spi.exception.OperationNotSupportedException;
import org.jboss.identity.idm.spi.configuration.metadata.IdentityObjectAttributeMetaData;
import org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.IdentityStoreConfigurationContext;
import org.jboss.identity.idm.exception.IdentityException;
import org.jboss.cache.Cache;
import org.jboss.cache.DefaultCacheFactory;
@@ -84,9 +85,9 @@
}
- public void bootstrap(IdentityStoreConfigurationMetaData configurationMD) throws IdentityException
+ public void bootstrap(IdentityStoreConfigurationContext configurationContext) throws IdentityException
{
- identityStore.bootstrap(configurationMD);
+ identityStore.bootstrap(configurationContext);
}
Added: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/IdentityConfigurationContextImpl.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/IdentityConfigurationContextImpl.java (rev 0)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/IdentityConfigurationContextImpl.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -0,0 +1,54 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.impl.configuration;
+
+import org.jboss.identity.idm.spi.configuration.IdentityConfigurationContext;
+import org.jboss.identity.idm.spi.configuration.IdentityConfigurationContextRegistry;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityConfigurationMetaData;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class IdentityConfigurationContextImpl implements IdentityConfigurationContext
+{
+ private final IdentityConfigurationMetaData configurationMD;
+
+ private final IdentityConfigurationContextRegistry configurationRegistry;
+
+ public IdentityConfigurationContextImpl(IdentityConfigurationMetaData configurationMD, IdentityConfigurationContextRegistry configurationRegistry)
+ {
+ this.configurationMD = configurationMD;
+ this.configurationRegistry = configurationRegistry;
+ }
+
+ public IdentityConfigurationMetaData getConfigurationMetaData()
+ {
+ return configurationMD;
+ }
+
+ public IdentityConfigurationContextRegistry getConfigurationRegistry()
+ {
+ return configurationRegistry;
+ }
+}
Added: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/IdentityConfigurationImpl.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/IdentityConfigurationImpl.java (rev 0)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/IdentityConfigurationImpl.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -0,0 +1,260 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.impl.configuration;
+
+import org.jboss.identity.idm.api.cfg.IdentityConfiguration;
+import org.jboss.identity.idm.api.cfg.IdentityConfigurationRegistry;
+import org.jboss.identity.idm.api.IdentitySession;
+import org.jboss.identity.idm.api.IdentitySessionFactory;
+import org.jboss.identity.idm.impl.helper.CopyOnWriteRegistry;
+import org.jboss.identity.idm.impl.configuration.jaxb2.JAXB2IdentityConfiguration;
+import org.jboss.identity.idm.impl.api.session.mapper.IdentityObjectTypeMapper;
+import org.jboss.identity.idm.impl.api.session.mapper.DirectIdentityObjectTypeMapperImpl;
+import org.jboss.identity.idm.impl.api.session.mapper.IdentityObjectTypeMapperImpl;
+import org.jboss.identity.idm.impl.api.session.IdentitySessionImpl;
+import org.jboss.identity.idm.impl.api.IdentitySessionFactoryImpl;
+import org.jboss.identity.idm.exception.IdentityException;
+import org.jboss.identity.idm.exception.IdentityConfigurationException;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityRepositoryConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.RealmConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.IdentityConfigurationContextRegistry;
+import org.jboss.identity.idm.spi.configuration.IdentityConfigurationContext;
+import org.jboss.identity.idm.spi.configuration.IdentityStoreConfigurationContext;
+import org.jboss.identity.idm.spi.configuration.IdentityRepositoryConfigurationContext;
+import org.jboss.identity.idm.spi.store.IdentityStore;
+import org.jboss.identity.idm.spi.store.AttributeStore;
+import org.jboss.identity.idm.spi.repository.IdentityStoreRepository;
+
+import java.util.logging.Logger;
+import java.util.logging.Level;
+import java.util.Map;
+import java.util.HashMap;
+import java.io.File;
+import java.lang.reflect.Constructor;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class IdentityConfigurationImpl
+ implements IdentityConfiguration, IdentityConfigurationRegistry, IdentityConfigurationContextRegistry
+{
+
+ private static final Logger log = Logger.getLogger(IdentityConfigurationImpl.class.getName());
+
+ private IdentityConfigurationMetaData configMD;
+
+ private final CopyOnWriteRegistry registry;
+
+ public IdentityConfigurationImpl()
+ {
+ registry = new CopyOnWriteRegistry();
+ }
+
+ public void register(Object object, String name) throws IdentityException
+ {
+ if (!registry.register(name, object))
+ {
+ throw new IdentityException("Cannot register object in IdentityContext with name: " + name);
+ }
+ if (log.isLoggable(Level.FINER)) log.finer("registering object: " + name + " ; " + object.getClass());
+ }
+
+ public void unregister(String name)
+ {
+ if (registry.unregister(name) == null)
+ {
+ log.info("Cannot unregister object from IdentityContext with name: " + name);
+ }
+ if (log.isLoggable(Level.FINER)) log.finer("unregistering object: " + name);
+ }
+
+ public Object getObject(String name) throws IdentityException
+ {
+ Object o = registry.getRegistration(name);
+ if (o == null)
+ {
+ throw new IdentityException("No such mapping in IdentityContext: " + name);
+ }
+ return o;
+ }
+
+ public IdentityConfigurationRegistry getIdentityConfigurationRegistry()
+ {
+ return this;
+ }
+
+ public IdentityConfiguration configure(IdentityConfigurationMetaData configMD)
+ {
+ this.configMD = configMD;
+
+ return this;
+ }
+
+ public IdentityConfiguration configure(File configFile) throws IdentityConfigurationException
+ {
+ IdentityConfigurationMetaData configMD = JAXB2IdentityConfiguration.createConfigurationMetaData(configFile);
+
+ this.configMD = configMD;
+
+ return this;
+
+ }
+
+ public IdentityConfiguration configure(String configResource) throws IdentityConfigurationException
+ {
+ IdentityConfigurationMetaData configMD = JAXB2IdentityConfiguration.createConfigurationMetaData(configResource);
+
+ this.configMD = configMD;
+
+ return this;
+
+ }
+
+ public IdentitySessionFactory buildIdentitySessionFactory() throws IdentityConfigurationException
+ {
+ Map<String, IdentitySession> realmMap = null;
+
+ if (configMD == null)
+ {
+ throw new IdentityConfigurationException("Failed to build IdentitySessionFactory. Configuration not initialized");
+ }
+
+ try
+ {
+ realmMap = createSessionMap(configMD);
+ }
+ catch (Exception e)
+ {
+ throw new IdentityConfigurationException("Failed to build IdentitySessionFactory", e);
+ }
+
+ return new IdentitySessionFactoryImpl(realmMap);
+ }
+
+ private Map<String, IdentitySession> createSessionMap(IdentityConfigurationMetaData configMD) throws Exception
+ {
+ //TODO: some validation, sanity checks and error reporting
+
+
+ IdentityConfigurationContext configurationContext = new IdentityConfigurationContextImpl(configMD, this);
+
+ // IdentityStore
+
+ Map<String, IdentityStore> bootstrappedIdentityStores = new HashMap<String, IdentityStore>();
+ Map<String, AttributeStore> bootstrappedAttributeStores = new HashMap<String, AttributeStore>();
+
+ for (IdentityStoreConfigurationMetaData metaData : configMD.getIdentityStores())
+ {
+ Class storeClass = null;
+ try
+ {
+ storeClass = Class.forName(metaData.getClassName());
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new IdentityException("Cannot instantiate identity store:" + metaData.getClassName(), e);
+ }
+ Class partypes[] = new Class[1];
+ partypes[0] = String.class;
+
+ Constructor ct = storeClass.getConstructor(partypes);
+ Object argList[] = new Object[1];
+ argList[0] = metaData.getId();
+
+ IdentityStore store = (IdentityStore)ct.newInstance(argList);
+
+ IdentityStoreConfigurationContext storeConfigurationCtx =
+ new IdentityStoreConfigurationContextImpl(configMD, this, metaData);
+
+ store.bootstrap(storeConfigurationCtx);
+
+ bootstrappedIdentityStores.put(store.getId(), store);
+ bootstrappedAttributeStores.put(store.getId(), store);
+ }
+
+ // IdentityRepository
+
+ Map<String, IdentityStoreRepository> bootstrappedRepositories = new HashMap<String, IdentityStoreRepository>();
+
+ for (IdentityRepositoryConfigurationMetaData metaData : configMD.getRepositories())
+ {
+ Class repoClass = null;
+ try
+ {
+ repoClass = Class.forName(metaData.getClassName());
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new IdentityException("Cannot instantiate identity store:" + metaData.getClassName(), e);
+ }
+ Class partypes[] = new Class[1];
+ partypes[0] = String.class;
+
+ Constructor ct = repoClass.getConstructor(partypes);
+ Object argList[] = new Object[1];
+ argList[0] = metaData.getId();
+
+ IdentityStoreRepository repo = (IdentityStoreRepository)ct.newInstance(argList);
+
+ IdentityRepositoryConfigurationContext repoConfigurationContext =
+ new IdentityRepositoryConfigurationContextImpl(configMD, this, metaData);
+
+ repo.bootstrap(repoConfigurationContext, bootstrappedIdentityStores, bootstrappedAttributeStores);
+
+ bootstrappedRepositories.put(repo.getId(), repo);
+ }
+
+ // Realms
+
+ Map<String, IdentitySession> sessionMap = new HashMap<String, IdentitySession>();
+
+ for (RealmConfigurationMetaData metaData : configMD.getRealms())
+ {
+ String realmName = metaData.getId();
+
+ IdentityStoreRepository repo = bootstrappedRepositories.get(metaData.getIdentityRepositoryIdRef());
+
+ IdentityObjectTypeMapper mapper = null;
+
+ if (metaData.getGroupTypeMappings() == null || metaData.getGroupTypeMappings().isEmpty())
+ {
+ // use direct type mapper
+ mapper = new DirectIdentityObjectTypeMapperImpl(metaData.getIdentityMapping());
+ }
+ else
+ {
+ mapper = new IdentityObjectTypeMapperImpl(metaData.getGroupTypeMappings(), metaData.getIdentityMapping());
+ }
+
+ IdentitySession session = new IdentitySessionImpl(realmName, repo, mapper);
+
+ sessionMap.put(realmName, session);
+ }
+
+ return sessionMap;
+ }
+
+}
Added: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/IdentityRepositoryConfigurationContextImpl.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/IdentityRepositoryConfigurationContextImpl.java (rev 0)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/IdentityRepositoryConfigurationContextImpl.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -0,0 +1,50 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.impl.configuration;
+
+import org.jboss.identity.idm.spi.configuration.IdentityRepositoryConfigurationContext;
+import org.jboss.identity.idm.spi.configuration.IdentityConfigurationContextRegistry;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityRepositoryConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityConfigurationMetaData;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class IdentityRepositoryConfigurationContextImpl
+ extends IdentityConfigurationContextImpl implements IdentityRepositoryConfigurationContext
+{
+
+ public IdentityRepositoryConfigurationContextImpl(IdentityConfigurationMetaData configurationMD, IdentityConfigurationContextRegistry configurationRegistry, IdentityRepositoryConfigurationMetaData repoMD)
+ {
+ super(configurationMD, configurationRegistry);
+ this.repoMD = repoMD;
+ }
+
+ private final IdentityRepositoryConfigurationMetaData repoMD;
+
+ public IdentityRepositoryConfigurationMetaData getRepositoryConfigurationMetaData()
+ {
+ return repoMD;
+ }
+}
Added: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/IdentityStoreConfigurationContextImpl.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/IdentityStoreConfigurationContextImpl.java (rev 0)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/IdentityStoreConfigurationContextImpl.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -0,0 +1,50 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.impl.configuration;
+
+import org.jboss.identity.idm.spi.configuration.IdentityStoreConfigurationContext;
+import org.jboss.identity.idm.spi.configuration.IdentityConfigurationContextRegistry;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityConfigurationMetaData;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class IdentityStoreConfigurationContextImpl
+ extends IdentityConfigurationContextImpl implements IdentityStoreConfigurationContext
+{
+
+ private final IdentityStoreConfigurationMetaData storeMD;
+
+ public IdentityStoreConfigurationContextImpl(IdentityConfigurationMetaData configurationMD, IdentityConfigurationContextRegistry configurationRegistry, IdentityStoreConfigurationMetaData storeMD)
+ {
+ super(configurationMD, configurationRegistry);
+ this.storeMD = storeMD;
+ }
+
+ public IdentityStoreConfigurationMetaData getStoreConfigurationMetaData()
+ {
+ return storeMD;
+ }
+}
Added: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/RealmConfigurationContextImpl.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/RealmConfigurationContextImpl.java (rev 0)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/RealmConfigurationContextImpl.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -0,0 +1,50 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.impl.configuration;
+
+import org.jboss.identity.idm.spi.configuration.metadata.RealmConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.IdentityConfigurationContextRegistry;
+import org.jboss.identity.idm.spi.configuration.RealmConfigurationContext;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class RealmConfigurationContextImpl
+ extends IdentityConfigurationContextImpl implements RealmConfigurationContext
+{
+
+ private final RealmConfigurationMetaData realmMD;
+
+ public RealmConfigurationContextImpl(IdentityConfigurationMetaData configurationMD, IdentityConfigurationContextRegistry configurationRegistry, RealmConfigurationMetaData realmMD)
+ {
+ super(configurationMD, configurationRegistry);
+ this.realmMD = realmMD;
+ }
+
+ public RealmConfigurationMetaData getRealmConfigurationMetaData()
+ {
+ return realmMD;
+ }
+}
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/JAXB2IdentityConfiguration.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/JAXB2IdentityConfiguration.java 2009-03-17 15:45:09 UTC (rev 376)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/JAXB2IdentityConfiguration.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -37,7 +37,7 @@
import org.jboss.identity.idm.spi.configuration.metadata.RelationshipMetaData;
import org.jboss.identity.idm.spi.configuration.metadata.IdentityObjectAttributeMetaData;
import org.jboss.identity.idm.spi.configuration.metadata.IdentityObjectTypeMetaData;
-import org.jboss.identity.idm.spi.exception.IdentityConfigurationException;
+import org.jboss.identity.idm.exception.IdentityConfigurationException;
import org.jboss.identity.idm.impl.api.attribute.IdentityObjectAttributeMetaDataImpl;
import org.jboss.identity.idm.impl.configuration.jaxb2.generated.JbossIdentityType;
import org.jboss.identity.idm.impl.configuration.jaxb2.generated.IdentityStoreType;
Added: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/helper/CopyOnWriteRegistry.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/helper/CopyOnWriteRegistry.java (rev 0)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/helper/CopyOnWriteRegistry.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -0,0 +1,135 @@
+/*
+* 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.helper;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Set;
+import java.util.Collections;
+import java.util.Collection;
+
+/**
+ * Implementation of a registry that implements copy on write semantics.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class CopyOnWriteRegistry
+{
+
+ /** . */
+ private volatile Map content;
+
+ public CopyOnWriteRegistry()
+ {
+ content = new HashMap();
+ }
+
+ /**
+ * Register an object.
+ *
+ * @param key the registration key
+ * @param object the registered object
+ * @return true if the registration was made
+ * @throws IllegalArgumentException if the one argument is null
+ */
+ public synchronized boolean register(Object key, Object object) throws IllegalArgumentException
+ {
+ if (key == null)
+ {
+ throw new IllegalArgumentException("No null key accepted");
+ }
+ if (object == null)
+ {
+ throw new IllegalArgumentException("No null value accepted");
+ }
+ if (content.containsKey(key))
+ {
+ return false;
+ }
+ Map tmp = new HashMap(content);
+ tmp.put(key, object);
+ content = tmp;
+ return true;
+ }
+
+ /**
+ * Unregister an object.
+ *
+ * @param key the registration key
+ * @return true if the unregistration was made
+ * @throws IllegalArgumentException if the key is null
+ */
+ public synchronized Object unregister(Object key) throws IllegalArgumentException
+ {
+ if (key == null)
+ {
+ throw new IllegalArgumentException("No null key accepted");
+ }
+ if (content.containsKey(key))
+ {
+ Map tmp = new HashMap(content);
+ Object registration = tmp.remove(key);
+ content = tmp;
+ return registration;
+ }
+ return null;
+ }
+
+ /**
+ * Return an unmodifiable set containing the keys.
+ *
+ * @return the keys
+ */
+ public Set getKeys()
+ {
+ return Collections.unmodifiableSet(content.keySet());
+ }
+
+ /**
+ * Return an unmodifable collection containing the registrations.
+ *
+ * @return the registrations
+ */
+ public Collection getRegistrations()
+ {
+ return Collections.unmodifiableCollection(content.values());
+ }
+
+ /**
+ * Return a registration or null if it does not exist.
+ *
+ * @param key the registration key
+ * @return the registeted object
+ * @throws IllegalArgumentException if the key is null
+ */
+ public Object getRegistration(Object key) throws IllegalArgumentException
+ {
+ if (key == null)
+ {
+ throw new IllegalArgumentException("No null key accepted");
+ }
+ return content.get(key);
+ }
+}
+
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/AbstractIdentityStoreRepository.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/AbstractIdentityStoreRepository.java 2009-03-17 15:45:09 UTC (rev 376)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/AbstractIdentityStoreRepository.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -30,6 +30,7 @@
import org.jboss.identity.idm.spi.model.IdentityObject;
import org.jboss.identity.idm.spi.configuration.metadata.IdentityRepositoryConfigurationMetaData;
import org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreMappingMetaData;
+import org.jboss.identity.idm.spi.configuration.IdentityRepositoryConfigurationContext;
import org.jboss.identity.idm.exception.IdentityException;
import org.jboss.identity.idm.impl.cache.JBossCacheIdentityStoreWrapper;
@@ -60,11 +61,13 @@
public static final String CACHE_CONFIG_FILE_OPTION = "cache.config-file";
- public void bootstrap(IdentityRepositoryConfigurationMetaData configurationMD,
+ public void bootstrap(IdentityRepositoryConfigurationContext configurationContext,
Map<String, IdentityStore> bootstrappedIdentityStores,
Map<String, AttributeStore> bootstrappedAttributeStores) throws IdentityException
{
+ IdentityRepositoryConfigurationMetaData configurationMD = configurationContext.getRepositoryConfigurationMetaData();
+
String asId = configurationMD.getDefaultAttributeStoreId();
String isId = configurationMD.getDefaultIdentityStoreId();
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/FallbackIdentityStoreRepository.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/FallbackIdentityStoreRepository.java 2009-03-17 15:45:09 UTC (rev 376)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/FallbackIdentityStoreRepository.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -36,6 +36,8 @@
import org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
import org.jboss.identity.idm.spi.configuration.metadata.IdentityRepositoryConfigurationMetaData;
import org.jboss.identity.idm.spi.configuration.metadata.IdentityObjectAttributeMetaData;
+import org.jboss.identity.idm.spi.configuration.IdentityRepositoryConfigurationContext;
+import org.jboss.identity.idm.spi.configuration.IdentityStoreConfigurationContext;
import org.jboss.identity.idm.spi.model.IdentityObjectCredential;
import org.jboss.identity.idm.spi.model.IdentityObjectCredentialType;
import org.jboss.identity.idm.spi.model.IdentityObjectAttribute;
@@ -94,11 +96,11 @@
}
@Override
- public void bootstrap(IdentityRepositoryConfigurationMetaData configurationMD,
+ public void bootstrap(IdentityRepositoryConfigurationContext configurationContext,
Map<String, IdentityStore> bootstrappedIdentityStores,
Map<String, AttributeStore> bootstrappedAttributeStores) throws IdentityException
{
- super.bootstrap(configurationMD, bootstrappedIdentityStores, bootstrappedAttributeStores);
+ super.bootstrap(configurationContext, bootstrappedIdentityStores, bootstrappedAttributeStores);
// Helper collection to keep all identity stores in use
@@ -109,7 +111,7 @@
- this.configurationMD = configurationMD;
+ this.configurationMD = configurationContext.getRepositoryConfigurationMetaData();
String isId = configurationMD.getDefaultIdentityStoreId();
@@ -261,7 +263,7 @@
}
- public void bootstrap(IdentityStoreConfigurationMetaData configurationMD) throws IdentityException
+ public void bootstrap(IdentityStoreConfigurationContext configurationContext) throws IdentityException
{
// Nothing
}
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/WrapperIdentityStoreRepository.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/WrapperIdentityStoreRepository.java 2009-03-17 15:45:09 UTC (rev 376)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/WrapperIdentityStoreRepository.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -30,6 +30,8 @@
import org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
import org.jboss.identity.idm.spi.configuration.metadata.IdentityObjectAttributeMetaData;
import org.jboss.identity.idm.spi.configuration.metadata.IdentityRepositoryConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.IdentityRepositoryConfigurationContext;
+import org.jboss.identity.idm.spi.configuration.IdentityStoreConfigurationContext;
import org.jboss.identity.idm.spi.model.IdentityObject;
import org.jboss.identity.idm.spi.model.IdentityObjectType;
import org.jboss.identity.idm.spi.model.IdentityObjectRelationshipType;
@@ -64,14 +66,14 @@
}
@Override
- public void bootstrap(IdentityRepositoryConfigurationMetaData configurationMD,
+ public void bootstrap(IdentityRepositoryConfigurationContext configurationContext,
Map<String, IdentityStore> bootstrappedIdentityStores,
Map<String, AttributeStore> bootstrappedAttributeStores) throws IdentityException
{
- super.bootstrap(configurationMD, bootstrappedIdentityStores, bootstrappedAttributeStores);
+ super.bootstrap(configurationContext, bootstrappedIdentityStores, bootstrappedAttributeStores);
}
- public void bootstrap(IdentityStoreConfigurationMetaData configurationMD) throws IdentityException
+ public void bootstrap(IdentityStoreConfigurationContext configurationContext) throws IdentityException
{
//Nothing
}
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-17 15:45:09 UTC (rev 376)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -38,10 +38,8 @@
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.jboss.identity.idm.exception.IdentityException;
import org.jboss.identity.idm.impl.api.AttributeFilterSearchControl;
import org.jboss.identity.idm.impl.api.NameFilterSearchControl;
@@ -62,6 +60,7 @@
import org.jboss.identity.idm.spi.configuration.metadata.IdentityObjectAttributeMetaData;
import org.jboss.identity.idm.spi.configuration.metadata.IdentityObjectTypeMetaData;
import org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.IdentityStoreConfigurationContext;
import org.jboss.identity.idm.spi.exception.OperationNotSupportedException;
import org.jboss.identity.idm.spi.model.IdentityObject;
import org.jboss.identity.idm.spi.model.IdentityObjectAttribute;
@@ -107,10 +106,12 @@
"(r.fromIdentityObject like :IO1 and r.toIdentityObject like :IO2) or " +
"(r.fromIdentityObject like :IO2 and r.toIdentityObject like :IO1)";
- public static final String PERSISTENCE_UNIT = "persistenceUnit";
+ public static final String HIBERNATE_SESSION_FACTORY_REGISTRY_NAME = "hibernateSessionFactoryRegistryName";
public static final String HIBERNATE_CONFIGURATION = "hibernateConfiguration";
+ public static final String ADD_MAPPED_CLASSES = "addMappedClasses";
+
public static final String HIBERNATE_SESSION_FACTORY_JNDI_NAME = "hibernateSessionFactoryJNDIName";
public static final String POPULATE_MEMBERSHIP_TYPES = "populateRelationshipTypes";
@@ -172,9 +173,9 @@
this.id = id;
}
- public void bootstrap(IdentityStoreConfigurationMetaData configurationMD) throws IdentityException
+ public void bootstrap(IdentityStoreConfigurationContext configurationContext) throws IdentityException
{
- this.configurationMD = configurationMD;
+ this.configurationMD = configurationContext.getStoreConfigurationMetaData();
id = configurationMD.getId();
@@ -184,7 +185,7 @@
String populateMembershipTypes = configurationMD.getOptionSingleValue(POPULATE_MEMBERSHIP_TYPES);
String populateIdentityObjectTypes = configurationMD.getOptionSingleValue(POPULATE_IDENTITY_OBJECT_TYPES);
- sessionFactory = bootstrapHibernateSessionFactory(configurationMD);
+ sessionFactory = bootstrapHibernateSessionFactory(configurationContext);
Session hibernateSession = sessionFactory.openSession();
@@ -313,12 +314,17 @@
}
- protected SessionFactory bootstrapHibernateSessionFactory(IdentityStoreConfigurationMetaData configurationMD) throws IdentityException
+ protected SessionFactory bootstrapHibernateSessionFactory(IdentityStoreConfigurationContext configurationContext) throws IdentityException
{
- String sfJNDIName = configurationMD.getOptionSingleValue(HIBERNATE_SESSION_FACTORY_JNDI_NAME);
- String persistenceUnit = configurationMD.getOptionSingleValue(PERSISTENCE_UNIT);
- String hibernateConfiguration = configurationMD.getOptionSingleValue(HIBERNATE_CONFIGURATION);
+ String sfJNDIName = configurationContext.getStoreConfigurationMetaData().
+ getOptionSingleValue(HIBERNATE_SESSION_FACTORY_JNDI_NAME);
+ String sfRegistryName = configurationContext.getStoreConfigurationMetaData().
+ getOptionSingleValue(HIBERNATE_SESSION_FACTORY_REGISTRY_NAME);
+ String addMappedClasses = configurationContext.getStoreConfigurationMetaData().
+ getOptionSingleValue(ADD_MAPPED_CLASSES);
+ String hibernateConfiguration = configurationContext.getStoreConfigurationMetaData().
+ getOptionSingleValue(HIBERNATE_CONFIGURATION);
if (sfJNDIName != null)
{
@@ -331,6 +337,25 @@
throw new IdentityException("Cannot obtain hibernate SessionFactory from provided JNDI name: " + sfJNDIName, e);
}
}
+ else if (sfRegistryName != null)
+ {
+ Object registryObject = configurationContext.getConfigurationRegistry().getObject(sfRegistryName);
+
+ if (registryObject == null)
+ {
+ throw new IdentityException("Cannot obtain hibernate SessionFactory from provided registry name: " + sfRegistryName);
+ }
+
+ if (!(registryObject instanceof SessionFactory))
+ {
+ throw new IdentityException("Cannot obtain hibernate SessionFactory from provided registry name: " + sfRegistryName
+ + "; Registered object is not an instance of SessionFactory: " + registryObject.getClass().getName());
+ }
+
+ return (SessionFactory)registryObject;
+
+
+ }
else if (hibernateConfiguration != null)
{
@@ -338,19 +363,27 @@
{
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();
+ //TODO: make it optional to add annotated classes here
-
+ if (addMappedClasses != null && addMappedClasses.equals("false"))
+ {
+ return config.buildSessionFactory();
+ }
+ else
+ {
+
+ 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)
{
@@ -358,22 +391,8 @@
}
}
-// 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);
+ + HIBERNATE_SESSION_FACTORY_JNDI_NAME + ", " + HIBERNATE_SESSION_FACTORY_REGISTRY_NAME + ", " + HIBERNATE_CONFIGURATION);
}
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreImpl.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreImpl.java 2009-03-17 15:45:09 UTC (rev 376)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreImpl.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -70,6 +70,7 @@
import org.jboss.identity.idm.spi.configuration.metadata.IdentityObjectAttributeMetaData;
import org.jboss.identity.idm.spi.configuration.metadata.IdentityObjectTypeMetaData;
import org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.IdentityStoreConfigurationContext;
import org.jboss.identity.idm.spi.exception.OperationNotSupportedException;
import org.jboss.identity.idm.spi.model.IdentityObject;
import org.jboss.identity.idm.spi.model.IdentityObjectAttribute;
@@ -124,14 +125,14 @@
this.id = id;
}
- public void bootstrap(IdentityStoreConfigurationMetaData configurationMD) throws IdentityException
+ public void bootstrap(IdentityStoreConfigurationContext configurationContext) throws IdentityException
{
- if (configurationMD == null)
+ if (configurationContext == null)
{
- throw new IllegalArgumentException("Configuration is null");
+ throw new IllegalArgumentException("Configuration context is null");
}
- this.configurationMD = configurationMD;
+ this.configurationMD = configurationContext.getStoreConfigurationMetaData();
configuration = new SimpleLDAPIdentityStoreConfiguration(configurationMD);
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-17 15:45:09 UTC (rev 376)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/types/SimpleIdentityObject.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -50,10 +50,6 @@
{
throw new IllegalArgumentException("name is null");
}
- if (id == null)
- {
- throw new IllegalArgumentException("id is null");
- }
if (type == null)
{
throw new IllegalArgumentException("type is null");
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-17 15:45:09 UTC (rev 376)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/APITestCase.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -24,7 +24,9 @@
import junit.framework.TestCase;
import org.jboss.identity.idm.impl.HibernateTestSupport;
+import org.jboss.identity.idm.impl.configuration.IdentityConfigurationImpl;
import org.jboss.identity.idm.api.IdentitySessionFactory;
+import org.jboss.identity.idm.api.cfg.IdentityConfiguration;
import org.jboss.identity.idm.opends.OpenDSService;
import org.opends.server.tools.LDAPModify;
@@ -92,7 +94,8 @@
public void testDBOrganization() throws Exception
{
- identitySessionFactory = new IdentitySessionFactoryImpl(new File("src/test/resources/organization-test-config.xml"));
+ identitySessionFactory = new IdentityConfigurationImpl().
+ configure(new File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
orgTest.testRedHatOrganization("realm://RedHat/DB");
}
@@ -100,7 +103,8 @@
public void testDBSamplePortal() throws Exception
{
- identitySessionFactory = new IdentitySessionFactoryImpl(new File("src/test/resources/organization-test-config.xml"));
+ identitySessionFactory = new IdentityConfigurationImpl().
+ configure(new File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
orgTest.testSamplePortal("realm://portal/SamplePortal/DB");
}
@@ -109,7 +113,8 @@
{
populateClean();
- identitySessionFactory = new IdentitySessionFactoryImpl(new File("src/test/resources/organization-test-config.xml"));
+ identitySessionFactory = new IdentityConfigurationImpl().
+ configure(new File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
orgTest.testRedHatOrganization("realm://RedHat/DB_LDAP");
@@ -119,7 +124,8 @@
{
populateClean();
- identitySessionFactory = new IdentitySessionFactoryImpl(new File("src/test/resources/organization-test-config.xml"));
+ identitySessionFactory = new IdentityConfigurationImpl().
+ configure(new File("src/test/resources/organization-test-config.xml")).buildIdentitySessionFactory();
orgTest.testSamplePortal("realm://portal/SamplePortal/DB_LDAP");
Modified: 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 2009-03-17 15:45:09 UTC (rev 376)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/ModelTestCase.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -34,10 +34,15 @@
public void testGroupId() throws Exception
{
- GroupId id = new GroupId("groupTypeName/groupName");
+
+ GroupId id = new GroupId(GroupId.PREFIX + "groupTypeName/groupName");
assertEquals("groupName", id.getName());
assertEquals("groupTypeName", id.getType());
+ id = new GroupId("groupName", "groupTypeName");
+ assertEquals("groupName", id.getName());
+ assertEquals("groupTypeName", id.getType());
+
}
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-17 15:45:09 UTC (rev 376)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreTestCase.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -29,14 +29,19 @@
import org.jboss.identity.idm.spi.store.IdentityStoreSession;
import org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
import org.jboss.identity.idm.spi.configuration.metadata.IdentityConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.IdentityStoreConfigurationContext;
+import org.jboss.identity.idm.spi.configuration.IdentityConfigurationContextRegistry;
import org.jboss.identity.idm.impl.store.hibernate.HibernateIdentityStoreImpl;
import org.jboss.identity.idm.impl.store.hibernate.HibernateTestBase;
import org.jboss.identity.idm.impl.store.IdentityTypeEnum;
import org.jboss.identity.idm.impl.store.CommonIdentityStoreTest;
import org.jboss.identity.idm.impl.store.IdentityStoreTestContext;
import org.jboss.identity.idm.impl.configuration.jaxb2.JAXB2IdentityConfiguration;
+import org.jboss.identity.idm.impl.configuration.IdentityStoreConfigurationContextImpl;
+import org.jboss.identity.idm.impl.configuration.IdentityConfigurationImpl;
import org.jboss.identity.idm.impl.api.SimpleAttribute;
import org.jboss.identity.idm.exception.IdentityException;
+import org.jboss.identity.idm.api.cfg.IdentityConfiguration;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
@@ -72,6 +77,11 @@
IdentityConfigurationMetaData configurationMD = JAXB2IdentityConfiguration
.createConfigurationMetaData(new File("src/test/resources/store-test-config.xml"));
+ IdentityConfigurationContextRegistry identityConfiguration = (IdentityConfigurationContextRegistry)
+ new IdentityConfigurationImpl().configure(configurationMD);
+
+
+
IdentityStoreConfigurationMetaData storeMD = null;
for (IdentityStoreConfigurationMetaData metaData : configurationMD.getIdentityStores())
@@ -83,6 +93,9 @@
}
}
+ IdentityStoreConfigurationContext context =
+ new IdentityStoreConfigurationContextImpl(configurationMD, identityConfiguration, storeMD);
+
store = new HibernateIdentityStoreImpl("HibernateTestStore")
{
@@ -93,14 +106,14 @@
}
@Override
- protected SessionFactory bootstrapHibernateSessionFactory(IdentityStoreConfigurationMetaData configurationMD) throws IdentityException
+ protected SessionFactory bootstrapHibernateSessionFactory(IdentityStoreConfigurationContext configurationContext) throws IdentityException
{
return sessionFactory;
}
};
- store.bootstrap(storeMD);
+ store.bootstrap(context);
ctx = new IdentityStoreInvocationContext()
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-17 15:45:09 UTC (rev 376)
+++ idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreTestCase.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -31,10 +31,14 @@
import org.jboss.identity.idm.spi.model.IdentityObjectAttribute;
import org.jboss.identity.idm.spi.configuration.metadata.IdentityConfigurationMetaData;
import org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.IdentityConfigurationContextRegistry;
+import org.jboss.identity.idm.spi.configuration.IdentityStoreConfigurationContext;
import org.jboss.identity.idm.impl.store.IdentityTypeEnum;
import org.jboss.identity.idm.impl.store.CommonIdentityStoreTest;
import org.jboss.identity.idm.impl.store.IdentityStoreTestContext;
import org.jboss.identity.idm.impl.configuration.jaxb2.JAXB2IdentityConfiguration;
+import org.jboss.identity.idm.impl.configuration.IdentityConfigurationImpl;
+import org.jboss.identity.idm.impl.configuration.IdentityStoreConfigurationContextImpl;
import org.jboss.identity.idm.impl.api.SimpleAttribute;
import org.jboss.identity.idm.exception.IdentityException;
import org.opends.server.tools.LDAPModify;
@@ -91,6 +95,9 @@
IdentityConfigurationMetaData configurationMD = JAXB2IdentityConfiguration
.createConfigurationMetaData(new File("src/test/resources/store-test-config.xml"));
+ IdentityConfigurationContextRegistry registry = (IdentityConfigurationContextRegistry) new IdentityConfigurationImpl().
+ configure(configurationMD);
+
IdentityStoreConfigurationMetaData storeMD = null;
for (IdentityStoreConfigurationMetaData metaData : configurationMD.getIdentityStores())
@@ -102,6 +109,8 @@
}
}
+ IdentityStoreConfigurationContext context = new IdentityStoreConfigurationContextImpl(configurationMD, registry, storeMD);
+
ctx = new IdentityStoreInvocationContext()
{
public IdentityStoreSession getIdentityStoreSession()
@@ -177,7 +186,7 @@
store = new LDAPIdentityStoreImpl("LDAPTestStore");
- store.bootstrap(storeMD);
+ store.bootstrap(context);
}
protected void tearDown() throws Exception
Modified: idm/trunk/idm/src/test/resources/hibernate-jboss-identity.cfg.xml
===================================================================
--- idm/trunk/idm/src/test/resources/hibernate-jboss-identity.cfg.xml 2009-03-17 15:45:09 UTC (rev 376)
+++ idm/trunk/idm/src/test/resources/hibernate-jboss-identity.cfg.xml 2009-03-17 21:38:45 UTC (rev 377)
@@ -44,7 +44,7 @@
<property name="hibernate.connection.password"></property>
<!-- Mapping classes -->
-
+ <!-- all nessesary mappings are added programatically to the configuration -->
<!--<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"/>-->
@@ -56,5 +56,6 @@
<!--<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/organization-test-config.xml
===================================================================
--- idm/trunk/idm/src/test/resources/organization-test-config.xml 2009-03-17 15:45:09 UTC (rev 376)
+++ idm/trunk/idm/src/test/resources/organization-test-config.xml 2009-03-17 21:38:45 UTC (rev 377)
@@ -403,10 +403,6 @@
</identity-object-type>
</supported-identity-object-types>
<options>
- <!--<option>-->
- <!--<name>persistenceUnit</name>-->
- <!--<value>jboss-identity-model1</value>-->
- <!--</option>-->
<option>
<name>hibernateConfiguration</name>
<value>hibernate-jboss-identity.cfg.xml</value>
Modified: idm/trunk/idm/src/test/resources/store-test-config.xml
===================================================================
--- idm/trunk/idm/src/test/resources/store-test-config.xml 2009-03-17 15:45:09 UTC (rev 376)
+++ idm/trunk/idm/src/test/resources/store-test-config.xml 2009-03-17 21:38:45 UTC (rev 377)
@@ -94,10 +94,6 @@
</identity-object-type>
</supported-identity-object-types>
<options>
- <!--<option>-->
- <!--<name>persistenceUnit</name>-->
- <!--<value>jboss-identity-model1</value>-->
- <!--</option>-->
<option>
<name>hibernateConfiguration</name>
<value>hibernate-jboss-identity.cfg.xml</value>
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-17 15:45:09 UTC (rev 376)
+++ idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/AttributesManager.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -51,14 +51,31 @@
AttributeDescription getAttributeDescription(IdentityType identityType, String name);
/**
- * Get AttributeDesciption object for all attributes supported with a given IdentityType
+ * Get AttributeDesciption object for single attribute supported with a given group id or userName
*
+ * @param id
+ * @return
+ */
+ AttributeDescription getAttributeDescription(String id, String attributeName);
+
+ /**
+ * Get AttributeDesciption objects for all attributes supported with a given IdentityType
+ *
* @param identityType
* @return
*/
Map<String, AttributeDescription> getSupportedAttributesDescriptions(IdentityType identityType);
/**
+ * Get AttributeDesciption objects for all attributes supported with an IdentityType object with a given id (for a Group)
+ * or username (for User)
+ *
+ * @param id
+ * @return
+ */
+ Map<String, AttributeDescription> getSupportedAttributesDescriptions(String id);
+
+ /**
* @param identityType
* @return names of supported attributes
* @throws org.jboss.identity.idm.exception.IdentityException
@@ -67,6 +84,14 @@
throws IdentityException;
/**
+ * @param id - name of User object or id of a Group
+ * @return names of supported attributes
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ Set<String> getSupportedAttributeNames(String id)
+ throws IdentityException;
+
+ /**
* Get attributes for the given IdentityType
*
* @param identity
@@ -76,6 +101,15 @@
Map<String, Attribute> getAttributes(IdentityType identity) throws IdentityException;
/**
+ * Get attributes for the given IdentityType
+ *
+ * @param id
+ * @return
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ Map<String, Attribute> getAttributes(String id) throws IdentityException;
+
+ /**
* Get attribute values for the given IdentityType
*
* @param identity
@@ -86,6 +120,16 @@
Attribute getAttribute(IdentityType identity, String attributeName) throws IdentityException;
/**
+ * Get attribute values for the given IdentityType
+ *
+ * @param id
+ * @param attributeName
+ * @return
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ Attribute getAttribute(String id, String attributeName) throws IdentityException;
+
+ /**
* Update attributes with new values - previous values will be overwritten. All the other attributes are not changed -
* method doesn't overwrite whole attribute set connected with a given IdentityType object.
*
@@ -97,6 +141,17 @@
throws IdentityException;
/**
+ * Update attributes with new values - previous values will be overwritten. All the other attributes are not changed -
+ * method doesn't overwrite whole attribute set connected with a given IdentityType object.
+ *
+ * @param id
+ * @param attributes
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ void updateAttributes(String id, Attribute[] attributes)
+ throws IdentityException;
+
+ /**
* Add new attributes - if attribute with given name already exists the values
* will be appended
*
@@ -108,6 +163,17 @@
throws IdentityException;
/**
+ * Add new attributes - if attribute with given name already exists the values
+ * will be appended
+ *
+ * @param id
+ * @param attributes
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ void addAttributes(String id, Attribute[] attributes)
+ throws IdentityException;
+
+ /**
* Add new attribute - if attribute with given name already exists the values
* will be appended
*
@@ -123,6 +189,18 @@
* Add new attribute - if attribute with given name already exists the values
* will be appended
*
+ * @param id
+ * @param attributeName
+ * @param values
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ void addAttribute(String id, String attributeName, Object[] values)
+ throws IdentityException;
+
+ /**
+ * Add new attribute - if attribute with given name already exists the values
+ * will be appended
+ *
* @param identity
* @param attributeName
* @param value
@@ -132,6 +210,18 @@
throws IdentityException;
/**
+ * Add new attribute - if attribute with given name already exists the values
+ * will be appended
+ *
+ * @param id
+ * @param attributeName
+ * @param value
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ void addAttribute(String id, String attributeName, Object value)
+ throws IdentityException;
+
+ /**
* Remove attributes
*
* @param identity
@@ -141,6 +231,15 @@
throws IdentityException;
/**
+ * Remove attributes
+ *
+ * @param id
+ * @param attributeNames
+ */
+ void removeAttributes(String id, String[] attributeNames)
+ throws IdentityException;
+
+ /**
* Check if given identity can be protected with text password
*
* @param identity
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-17 15:45:09 UTC (rev 376)
+++ idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -66,6 +66,14 @@
Group createGroup(String groupName, String groupType)
throws IdentityException;
+ /**
+ * <p>Create a group Id</p>
+ * @param groupName
+ * @param groupType
+ * @return
+ */
+ String createGroupId(String groupName, String groupType);
+
// Remove
/**
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-17 15:45:09 UTC (rev 376)
+++ idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RelationshipManager.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -167,6 +167,16 @@
/**
* <p>Check if association is present </p>
+ * @param parents
+ * @param members
+ * @return
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ boolean isAssociatedByIds(Collection<String> parents, Collection<String> members)
+ throws IdentityException;
+
+ /**
+ * <p>Check if association is present </p>
* @param parent
* @param member
* @return
@@ -175,6 +185,16 @@
<G extends IdentityType, I extends IdentityType> boolean isAssociated(G parent, I member)
throws IdentityException;
+ /**
+ * <p>Check if association is present </p>
+ * @param parent
+ * @param member
+ * @return
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ boolean isAssociatedByIds(String parent, String member)
+ throws IdentityException;
+
// Resolve relationships
/**
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-17 15:45:09 UTC (rev 376)
+++ idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RoleManager.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -99,13 +99,13 @@
/**
* Create role
- * @param roleType
+ * @param roleTypeName
* @param userName
* @param groupId
* @return
* @throws IdentityException
*/
- Role createRole(RoleType roleType, String userName, String groupId) throws IdentityException;
+ Role createRole(String roleTypeName, String userName, String groupId) throws IdentityException;
/**
* Remove Role
@@ -118,12 +118,12 @@
/**
* Remove Role
- * @param roleType
+ * @param roleTypeName
* @param userName
* @param groupId
* @throws IdentityException
*/
- void removeRole(RoleType roleType, String userName, String groupId) throws IdentityException;
+ void removeRole(String roleTypeName, String userName, String groupId) throws IdentityException;
/**
* Remove Role
@@ -146,11 +146,11 @@
* Check if Role is present
* @param userName
* @param groupId
- * @param roleType
+ * @param roleTypeName
* @return
* @throws IdentityException
*/
- boolean hasRole(String userName, String groupId, RoleType roleType) throws IdentityException;
+ boolean hasRole(String userName, String groupId, String roleTypeName) throws IdentityException;
/**
* Find RoleType objects for roles associated with a given Identity and Group
Added: idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/cfg/IdentityConfiguration.java
===================================================================
--- idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/cfg/IdentityConfiguration.java (rev 0)
+++ idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/cfg/IdentityConfiguration.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -0,0 +1,45 @@
+/*
+* 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.api.cfg;
+
+import org.jboss.identity.idm.api.*;
+import org.jboss.identity.idm.exception.IdentityConfigurationException;
+
+import java.io.File;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface IdentityConfiguration
+{
+
+ IdentityConfiguration configure(File configFile) throws IdentityConfigurationException;
+
+ IdentityConfiguration configure(String configResource) throws IdentityConfigurationException;
+
+ IdentitySessionFactory buildIdentitySessionFactory() throws IdentityConfigurationException;
+
+ IdentityConfigurationRegistry getIdentityConfigurationRegistry();
+
+}
Added: idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/cfg/IdentityConfigurationRegistry.java
===================================================================
--- idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/cfg/IdentityConfigurationRegistry.java (rev 0)
+++ idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/cfg/IdentityConfigurationRegistry.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -0,0 +1,56 @@
+/*
+* 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.api.cfg;
+
+import org.jboss.identity.idm.exception.IdentityException;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface IdentityConfigurationRegistry
+{
+
+ /**
+ * Retister object in context
+ * @param object representing object
+ * @param name to map object
+ * @throws org.jboss.identity.idm.exception.IdentityException thrown if such object is already registered or operation fail.
+ */
+ public void register(Object object, String name) throws IdentityException;
+
+ /**
+ * Remove object from context
+ * @param name of identity object
+ */
+ public void unregister(String name);
+
+ /**
+ * Retrieve registered object
+ * @param name
+ * @return
+ * @throws org.jboss.identity.idm.exception.IdentityException thrown if no such object exists in context
+ */
+ public Object getObject(String name) throws IdentityException;
+
+}
\ No newline at end of file
Copied: idm/trunk/idm-common/src/main/java/org/jboss/identity/idm/exception/IdentityConfigurationException.java (from rev 367, idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/exception/IdentityConfigurationException.java)
===================================================================
--- idm/trunk/idm-common/src/main/java/org/jboss/identity/idm/exception/IdentityConfigurationException.java (rev 0)
+++ idm/trunk/idm-common/src/main/java/org/jboss/identity/idm/exception/IdentityConfigurationException.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -0,0 +1,55 @@
+/*
+* 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.exception;
+
+import org.jboss.identity.idm.exception.IdentityException;
+
+/**
+ * Exception indicating some issue in configuration
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class IdentityConfigurationException extends IdentityException
+{
+ private static final long serialVersionUID = 1L;
+
+ public IdentityConfigurationException()
+ {
+ super();
+ }
+
+ public IdentityConfigurationException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public IdentityConfigurationException(String msg)
+ {
+ super(msg);
+ }
+
+ public IdentityConfigurationException(Throwable cause)
+ {
+ super(cause);
+ }
+}
\ No newline at end of file
Added: idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/configuration/IdentityConfigurationContext.java
===================================================================
--- idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/configuration/IdentityConfigurationContext.java (rev 0)
+++ idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/configuration/IdentityConfigurationContext.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -0,0 +1,38 @@
+/*
+* 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.spi.configuration;
+
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityConfigurationMetaData;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface IdentityConfigurationContext
+{
+
+ IdentityConfigurationMetaData getConfigurationMetaData();
+
+ IdentityConfigurationContextRegistry getConfigurationRegistry();
+
+}
Added: idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/configuration/IdentityConfigurationContextRegistry.java
===================================================================
--- idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/configuration/IdentityConfigurationContextRegistry.java (rev 0)
+++ idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/configuration/IdentityConfigurationContextRegistry.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -0,0 +1,55 @@
+/*
+* 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.spi.configuration;
+
+import org.jboss.identity.idm.exception.IdentityException;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface IdentityConfigurationContextRegistry
+{
+
+ /**
+ * Retister object in context
+ * @param object representing object
+ * @param name to map object
+ * @throws org.jboss.identity.idm.exception.IdentityException thrown if such object is already registered or operation fail.
+ */
+ public void register(Object object, String name) throws IdentityException;
+
+ /**
+ * Remove object from context
+ * @param name of identity object
+ */
+ public void unregister(String name);
+
+ /**
+ * Retrieve registered object
+ * @param name
+ * @return
+ * @throws org.jboss.identity.idm.exception.IdentityException thrown if no such object exists in context
+ */
+ public Object getObject(String name) throws IdentityException;
+}
Added: idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/configuration/IdentityRepositoryConfigurationContext.java
===================================================================
--- idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/configuration/IdentityRepositoryConfigurationContext.java (rev 0)
+++ idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/configuration/IdentityRepositoryConfigurationContext.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -0,0 +1,36 @@
+/*
+* 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.spi.configuration;
+
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityRepositoryConfigurationMetaData;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface IdentityRepositoryConfigurationContext extends IdentityConfigurationContext
+{
+
+ IdentityRepositoryConfigurationMetaData getRepositoryConfigurationMetaData();
+
+}
Added: idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/configuration/IdentityStoreConfigurationContext.java
===================================================================
--- idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/configuration/IdentityStoreConfigurationContext.java (rev 0)
+++ idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/configuration/IdentityStoreConfigurationContext.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -0,0 +1,35 @@
+/*
+* 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.spi.configuration;
+
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface IdentityStoreConfigurationContext extends IdentityConfigurationContext
+{
+ IdentityStoreConfigurationMetaData getStoreConfigurationMetaData();
+
+}
Added: idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/configuration/RealmConfigurationContext.java
===================================================================
--- idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/configuration/RealmConfigurationContext.java (rev 0)
+++ idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/configuration/RealmConfigurationContext.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -0,0 +1,36 @@
+/*
+* 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.spi.configuration;
+
+import org.jboss.identity.idm.spi.configuration.metadata.RealmConfigurationMetaData;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface RealmConfigurationContext extends IdentityConfigurationContext
+{
+
+ RealmConfigurationMetaData getRealmConfigurationMetaData();
+
+}
Deleted: idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/exception/IdentityConfigurationException.java
===================================================================
--- idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/exception/IdentityConfigurationException.java 2009-03-17 15:45:09 UTC (rev 376)
+++ idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/exception/IdentityConfigurationException.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -1,55 +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.spi.exception;
-
-import org.jboss.identity.idm.exception.IdentityException;
-
-/**
- * Exception indicating some issue in configuration
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class IdentityConfigurationException extends IdentityException
-{
- private static final long serialVersionUID = 1L;
-
- public IdentityConfigurationException()
- {
- super();
- }
-
- public IdentityConfigurationException(String message, Throwable cause)
- {
- super(message, cause);
- }
-
- public IdentityConfigurationException(String msg)
- {
- super(msg);
- }
-
- public IdentityConfigurationException(Throwable cause)
- {
- super(cause);
- }
-}
\ No newline at end of file
Modified: idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/repository/IdentityStoreRepository.java
===================================================================
--- idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/repository/IdentityStoreRepository.java 2009-03-17 15:45:09 UTC (rev 376)
+++ idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/repository/IdentityStoreRepository.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -28,6 +28,7 @@
import org.jboss.identity.idm.spi.store.IdentityStore;
import org.jboss.identity.idm.spi.store.AttributeStore;
import org.jboss.identity.idm.spi.configuration.metadata.IdentityRepositoryConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.IdentityRepositoryConfigurationContext;
import org.jboss.identity.idm.exception.IdentityException;
/**
@@ -44,7 +45,7 @@
public interface IdentityStoreRepository extends IdentityStore
{
- public void bootstrap(IdentityRepositoryConfigurationMetaData configurationMD,
+ public void bootstrap(IdentityRepositoryConfigurationContext configurationContext,
Map<String, IdentityStore> bootstrappedIdentityStores,
Map<String, AttributeStore> bootstrappedAttributeStores) throws IdentityException;
Modified: idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityStore.java
===================================================================
--- idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityStore.java 2009-03-17 15:45:09 UTC (rev 376)
+++ idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityStore.java 2009-03-17 21:38:45 UTC (rev 377)
@@ -32,6 +32,7 @@
import org.jboss.identity.idm.spi.model.IdentityObjectRelationship;
import org.jboss.identity.idm.spi.exception.OperationNotSupportedException;
import org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.IdentityStoreConfigurationContext;
import org.jboss.identity.idm.spi.model.IdentityObjectCredential;
import org.jboss.identity.idm.spi.searchcontrol.IdentityObjectSearchControl;
import org.jboss.identity.idm.exception.IdentityException;
@@ -49,10 +50,10 @@
/**
* Set up the store
*
- * @param configurationMD
+ * @param configurationContext
* @throws IOException
*/
- void bootstrap(IdentityStoreConfigurationMetaData configurationMD) throws IdentityException;
+ void bootstrap(IdentityStoreConfigurationContext configurationContext) throws IdentityException;
/**
* @return id of this identity store
15 years, 9 months
JBoss Identity SVN: r376 - in identity-federation/trunk: identity-fed-model and 1 other directories.
by jboss-identity-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2009-03-17 11:45:09 -0400 (Tue, 17 Mar 2009)
New Revision: 376
Modified:
identity-federation/trunk/identity-bindings-jboss/.classpath
identity-federation/trunk/identity-fed-model/.classpath
identity-federation/trunk/identity-xmlsecmodel/.classpath
Log:
cp
Modified: identity-federation/trunk/identity-bindings-jboss/.classpath
===================================================================
--- identity-federation/trunk/identity-bindings-jboss/.classpath 2009-03-17 15:44:59 UTC (rev 375)
+++ identity-federation/trunk/identity-bindings-jboss/.classpath 2009-03-17 15:45:09 UTC (rev 376)
@@ -31,5 +31,5 @@
<classpathentry kind="var" path="M2_REPO/sun-jaxws/jaxws-api/2.1.1/jaxws-api-2.1.1.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/identity-bindings"/>
<classpathentry kind="var" path="M2_REPO/org/jboss/security/jbosssx/2.0.2.SP6/jbosssx-2.0.2.SP6.jar"/>
- <classpathentry kind="output" path="target/classes"/>
+ <classpathentry kind="output" path="target-eclipse/classes"/>
</classpath>
Modified: identity-federation/trunk/identity-fed-model/.classpath
===================================================================
--- identity-federation/trunk/identity-fed-model/.classpath 2009-03-17 15:44:59 UTC (rev 375)
+++ identity-federation/trunk/identity-fed-model/.classpath 2009-03-17 15:45:09 UTC (rev 376)
@@ -17,5 +17,5 @@
<classpathentry kind="var" path="M2_REPO/stax/stax-api/1.0/stax-api-1.0.jar"/>
<classpathentry kind="var" path="M2_REPO/org/apache/xmlsec/1.4.1/xmlsec-1.4.1.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/identity-xmlsecmodel"/>
- <classpathentry kind="output" path="target/classes"/>
+ <classpathentry kind="output" path="target-eclipse/classes"/>
</classpath>
Modified: identity-federation/trunk/identity-xmlsecmodel/.classpath
===================================================================
--- identity-federation/trunk/identity-xmlsecmodel/.classpath 2009-03-17 15:44:59 UTC (rev 375)
+++ identity-federation/trunk/identity-xmlsecmodel/.classpath 2009-03-17 15:45:09 UTC (rev 376)
@@ -1,12 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="src/main/java"/>
- <classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
- <classpathentry kind="output" path="target/classes"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="var" path="M2_REPO/sun-jaf/activation/1.1/activation-1.1.jar"/>
- <classpathentry kind="var" path="M2_REPO/sun-jaxb/jaxb-api/2.1.9/jaxb-api-2.1.9.jar" sourcepath="M2_REPO/sun-jaxb/jaxb-api/2.1.9/jaxb-api-2.1.9-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/junit/junit/4.4/junit-4.4.jar"/>
- <classpathentry kind="var" path="M2_REPO/apache-log4j/log4j/1.2.14/log4j-1.2.14.jar" sourcepath="M2_REPO/apache-log4j/log4j/1.2.14/log4j-1.2.14-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/codehaus-stax/stax/1.1.1/stax-1.1.1.jar"/>
- <classpathentry kind="var" path="M2_REPO/stax/stax-api/1.0/stax-api-1.0.jar"/>
-</classpath>
\ No newline at end of file
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry excluding="**/*.java" kind="src" path="src/main/resources"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="var" path="M2_REPO/sun-jaf/activation/1.1/activation-1.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/sun-jaxb/jaxb-api/2.1.9/jaxb-api-2.1.9.jar" sourcepath="M2_REPO/sun-jaxb/jaxb-api/2.1.9/jaxb-api-2.1.9-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/junit/junit/4.4/junit-4.4.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-log4j/log4j/1.2.14/log4j-1.2.14.jar" sourcepath="M2_REPO/apache-log4j/log4j/1.2.14/log4j-1.2.14-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/codehaus-stax/stax/1.1.1/stax-1.1.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/stax/stax-api/1.0/stax-api-1.0.jar"/>
+ <classpathentry kind="output" path="target-eclipse/classes"/>
+</classpath>
15 years, 9 months
JBoss Identity SVN: r375 - identity-federation/trunk.
by jboss-identity-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2009-03-17 11:44:59 -0400 (Tue, 17 Mar 2009)
New Revision: 375
Modified:
identity-federation/trunk/pom.xml
Log:
javadoc plug
Modified: identity-federation/trunk/pom.xml
===================================================================
--- identity-federation/trunk/pom.xml 2009-03-17 15:44:37 UTC (rev 374)
+++ identity-federation/trunk/pom.xml 2009-03-17 15:44:59 UTC (rev 375)
@@ -24,4 +24,16 @@
<module>assembly</module>
</modules>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <aggregate>true</aggregate>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+
</project>
15 years, 9 months
JBoss Identity SVN: r374 - in identity-federation/trunk/identity-fed-api: src/test/java/org/jboss/test/identity/federation/api/util and 1 other directory.
by jboss-identity-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2009-03-17 11:44:37 -0400 (Tue, 17 Mar 2009)
New Revision: 374
Modified:
identity-federation/trunk/identity-fed-api/.classpath
identity-federation/trunk/identity-fed-api/src/test/java/org/jboss/test/identity/federation/api/util/XMLEncryptionUnitTestCase.java
Log:
decrypt
Modified: identity-federation/trunk/identity-fed-api/.classpath
===================================================================
--- identity-federation/trunk/identity-fed-api/.classpath 2009-03-17 15:44:06 UTC (rev 373)
+++ identity-federation/trunk/identity-fed-api/.classpath 2009-03-17 15:44:37 UTC (rev 374)
@@ -24,5 +24,5 @@
<classpathentry kind="lib" path="src/test/resources/endorsed/xalan.jar"/>
<classpathentry kind="lib" path="src/test/resources/endorsed/xercesImpl.jar"/>
<classpathentry kind="lib" path="src/test/resources/endorsed/xml-apis.jar"/>
- <classpathentry kind="output" path="target/classes"/>
+ <classpathentry kind="output" path="target-eclipse/classes"/>
</classpath>
Modified: identity-federation/trunk/identity-fed-api/src/test/java/org/jboss/test/identity/federation/api/util/XMLEncryptionUnitTestCase.java
===================================================================
--- identity-federation/trunk/identity-fed-api/src/test/java/org/jboss/test/identity/federation/api/util/XMLEncryptionUnitTestCase.java 2009-03-17 15:44:06 UTC (rev 373)
+++ identity-federation/trunk/identity-fed-api/src/test/java/org/jboss/test/identity/federation/api/util/XMLEncryptionUnitTestCase.java 2009-03-17 15:44:37 UTC (rev 374)
@@ -25,6 +25,7 @@
import java.io.StringWriter;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
+import java.security.PrivateKey;
import java.security.PublicKey;
import java.util.ArrayList;
import java.util.List;
@@ -156,6 +157,11 @@
assertEquals(wrappedNode.getLocalName(),qname.getLocalPart());
assertEquals(wrappedNode.getNamespaceURI(), qname.getNamespaceURI());
assertEquals(wrappedNode.getPrefix(), qname.getPrefix());
+
+ //Let us decrypt the document
+ PrivateKey privateKey = kp.getPrivate();
+ Element decryptedElement = XMLEncryptionUtil.decryptElementInDocument(doc, privateKey);
+ assertEquals("a", decryptedElement.getLocalName());
}
public void testArbitraryXMLWithOuterKeyInfo() throws Exception
15 years, 9 months
JBoss Identity SVN: r373 - identity-federation/trunk/identity-fed-core.
by jboss-identity-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2009-03-17 11:44:06 -0400 (Tue, 17 Mar 2009)
New Revision: 373
Modified:
identity-federation/trunk/identity-fed-core/.classpath
Log:
cp
Modified: identity-federation/trunk/identity-fed-core/.classpath
===================================================================
--- identity-federation/trunk/identity-fed-core/.classpath 2009-03-17 15:43:56 UTC (rev 372)
+++ identity-federation/trunk/identity-fed-core/.classpath 2009-03-17 15:44:06 UTC (rev 373)
@@ -17,5 +17,5 @@
<classpathentry kind="var" path="M2_REPO/org/apache/xmlsec/1.4.1/xmlsec-1.4.1.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/identity-fed-model"/>
<classpathentry combineaccessrules="false" kind="src" path="/identity-xmlsecmodel"/>
- <classpathentry kind="output" path="target/classes"/>
+ <classpathentry kind="output" path="target-eclipse/classes"/>
</classpath>
15 years, 9 months
JBoss Identity SVN: r372 - identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/util.
by jboss-identity-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2009-03-17 11:43:56 -0400 (Tue, 17 Mar 2009)
New Revision: 372
Modified:
identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/util/SOAPSAMLXACMLUtil.java
Log:
workaround method
Modified: identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/util/SOAPSAMLXACMLUtil.java
===================================================================
--- identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/util/SOAPSAMLXACMLUtil.java 2009-03-17 15:43:03 UTC (rev 371)
+++ identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/util/SOAPSAMLXACMLUtil.java 2009-03-17 15:43:56 UTC (rev 372)
@@ -21,13 +21,19 @@
*/
package org.jboss.identity.federation.core.saml.v2.util;
+import java.io.StringReader;
+
import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
+import org.apache.log4j.Logger;
import org.jboss.identity.federation.saml.v2.profiles.xacml.assertion.ObjectFactory;
import org.jboss.identity.federation.saml.v2.profiles.xacml.assertion.XACMLAuthzDecisionStatementType;
+import org.jboss.identity.federation.saml.v2.profiles.xacml.protocol.XACMLAuthzDecisionQueryType;
+import org.w3c.dom.Element;
/**
* Utility associated with SOAP 1.1 Envelope,
@@ -37,6 +43,8 @@
*/
public class SOAPSAMLXACMLUtil
{
+ private static Logger log = Logger.getLogger(SOAPSAMLXACMLUtil.class);
+
private static String SOAP_PKG = "org.jboss.identity.federation.org.xmlsoap.schemas.soap.envelope";
private static String SAML_PROTO_PKG = "org.jboss.identity.federation.saml.v2.protocol";
private static String XACML_CTX_PKG = "org.jboss.security.xacml.core.model.context";
@@ -54,11 +62,28 @@
}
public static Unmarshaller getUnmarshaller() throws JAXBException
{
- JAXBContext jaxb = JAXBContext.newInstance(collectivePackage);
- Unmarshaller un = jaxb.createUnmarshaller();
+ JAXBContext jaxb = JAXBContext.newInstance(collectivePackage);
+ Unmarshaller un = jaxb.createUnmarshaller();
return un;
}
+ /**
+ * When the input xacml request has issues, try to work around
+ * @param element
+ * @return
+ * @throws Exception
+ */
+ public static XACMLAuthzDecisionQueryType getWorkaround(Element element) throws Exception
+ {
+ String str = DocumentUtil.getDOMElementAsString(element);
+ str = str.replaceFirst(":XACMLAuthzDecisionQuery", ":XACMLAuthzDecisionQueryType");
+ str = str.replaceFirst("xacml-context:Request", "xacml-context:Request xmlns=\"urn:oasis:names:tc:xacml:2.0:context:schema:os\"" );
+ log.trace("Updated Element="+str);
+ //Reparse
+ JAXBElement<?> jx = (JAXBElement<?>) getUnmarshaller().unmarshal(new StringReader(str));
+ return (XACMLAuthzDecisionQueryType) jx.getValue();
+ }
+
public static XACMLAuthzDecisionStatementType createXACMLAuthzDecisionStatementType()
{
ObjectFactory of = new ObjectFactory();
15 years, 9 months
JBoss Identity SVN: r371 - in identity-federation/trunk/identity-bindings: src/test/java/org/jboss/test/identity/federation/bindings/servlets and 2 other directories.
by jboss-identity-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2009-03-17 11:43:03 -0400 (Tue, 17 Mar 2009)
New Revision: 371
Added:
identity-federation/trunk/identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/servlets/InteropEndpointDebugTestCase.java
identity-federation/trunk/identity-bindings/src/test/resources/xacml/requests/samlxacml.xml
identity-federation/trunk/identity-bindings/src/test/resources/xacml/requests/soap-request.xml
Modified:
identity-federation/trunk/identity-bindings/.classpath
identity-federation/trunk/identity-bindings/src/test/java/org/jboss/test/tomcat/bindings/Tomcat5TestCase.java
Log:
cp
Modified: identity-federation/trunk/identity-bindings/.classpath
===================================================================
--- identity-federation/trunk/identity-bindings/.classpath 2009-03-17 15:41:08 UTC (rev 370)
+++ identity-federation/trunk/identity-bindings/.classpath 2009-03-17 15:43:03 UTC (rev 371)
@@ -1,32 +1,32 @@
<classpath>
- <classpathentry kind="src" path="src/main/java"/>
- <classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
- <classpathentry kind="src" path="src/test/java" output="target/test-classes"/>
- <classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>
- <classpathentry kind="output" path="target/classes"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="var" path="M2_REPO/sun-jaf/activation/1.1/activation-1.1.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/apache/tomcat/annotations-api/6.0.18/annotations-api-6.0.18.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/apache/tomcat/catalina/6.0.18/catalina-6.0.18.jar"/>
- <classpathentry kind="var" path="M2_REPO/apache-logging/commons-logging-api/1.0.3/commons-logging-api-1.0.3.jar"/>
- <classpathentry kind="var" path="M2_REPO/apache-modeler/commons-modeler/1.1patch/commons-modeler-1.1patch.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/apache/tomcat/coyote/6.0.18/coyote-6.0.18.jar"/>
- <classpathentry kind="var" path="M2_REPO/sun-jaxb/jaxb-api/2.1.9/jaxb-api-2.1.9.jar" sourcepath="M2_REPO/sun-jaxb/jaxb-api/2.1.9/jaxb-api-2.1.9-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/sun-jaxb/jaxb-impl/2.1.9/jaxb-impl-2.1.9.jar" sourcepath="M2_REPO/sun-jaxb/jaxb-impl/2.1.9/jaxb-impl-2.1.9-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/sun-jaxws/jaxws-api/2.1.1/jaxws-api-2.1.1.jar"/>
- <classpathentry kind="src" path="/jboss-identity-fed-api"/>
- <classpathentry kind="src" path="/jboss-identity-fed-core"/>
- <classpathentry kind="src" path="/jboss-identity-fed-model"/>
- <classpathentry kind="src" path="/jboss-identity-xmlsec-model"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/security/jbossxacml/2.0.3.CR1/jbossxacml-2.0.3.CR1.jar" sourcepath="M2_REPO/org/jboss/security/jbossxacml/2.0.3.CR1/jbossxacml-2.0.3.CR1-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/apache/tomcat/juli/6.0.18/juli-6.0.18.jar"/>
- <classpathentry kind="var" path="M2_REPO/junit/junit/4.4/junit-4.4.jar"/>
- <classpathentry kind="var" path="M2_REPO/apache-log4j/log4j/1.2.14/log4j-1.2.14.jar" sourcepath="M2_REPO/apache-log4j/log4j/1.2.14/log4j-1.2.14-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/apache-tomcat/naming-resources/5.5.12/naming-resources-5.5.12.jar"/>
- <classpathentry kind="var" path="M2_REPO/javax/servlet/servlet-api/2.4/servlet-api-2.4.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/apache/tomcat/servlet-api/6.0.18/servlet-api-6.0.18.jar"/>
- <classpathentry kind="var" path="M2_REPO/stax/stax-api/1.0/stax-api-1.0.jar"/>
- <classpathentry kind="var" path="M2_REPO/apache-tomcat/tomcat-http/5.5.12/tomcat-http-5.5.12.jar"/>
- <classpathentry kind="var" path="M2_REPO/apache-tomcat/tomcat-util/5.5.12/tomcat-util-5.5.12.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/apache/xmlsec/1.4.1/xmlsec-1.4.1.jar"/>
-</classpath>
\ No newline at end of file
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry excluding="**/*.java" kind="src" path="src/main/resources"/>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+ <classpathentry excluding="**/*.java" kind="src" output="target/test-classes" path="src/test/resources"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="var" path="M2_REPO/sun-jaf/activation/1.1/activation-1.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/tomcat/annotations-api/6.0.18/annotations-api-6.0.18.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/tomcat/catalina/6.0.18/catalina-6.0.18.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-logging/commons-logging-api/1.0.3/commons-logging-api-1.0.3.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-modeler/commons-modeler/1.1patch/commons-modeler-1.1patch.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/tomcat/coyote/6.0.18/coyote-6.0.18.jar"/>
+ <classpathentry kind="var" path="M2_REPO/sun-jaxb/jaxb-api/2.1.9/jaxb-api-2.1.9.jar" sourcepath="M2_REPO/sun-jaxb/jaxb-api/2.1.9/jaxb-api-2.1.9-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/sun-jaxb/jaxb-impl/2.1.9/jaxb-impl-2.1.9.jar" sourcepath="M2_REPO/sun-jaxb/jaxb-impl/2.1.9/jaxb-impl-2.1.9-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/security/jbossxacml/2.0.3.CR1/jbossxacml-2.0.3.CR1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/tomcat/juli/6.0.18/juli-6.0.18.jar"/>
+ <classpathentry kind="var" path="M2_REPO/junit/junit/4.4/junit-4.4.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-log4j/log4j/1.2.14/log4j-1.2.14.jar" sourcepath="M2_REPO/apache-log4j/log4j/1.2.14/log4j-1.2.14-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-tomcat/naming-resources/5.5.12/naming-resources-5.5.12.jar"/>
+ <classpathentry kind="var" path="M2_REPO/javax/servlet/servlet-api/2.4/servlet-api-2.4.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/tomcat/servlet-api/6.0.18/servlet-api-6.0.18.jar"/>
+ <classpathentry kind="var" path="M2_REPO/stax/stax-api/1.0/stax-api-1.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-tomcat/tomcat-http/5.5.12/tomcat-http-5.5.12.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-tomcat/tomcat-util/5.5.12/tomcat-util-5.5.12.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/xmlsec/1.4.1/xmlsec-1.4.1.jar"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/identity-fed-api"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/identity-fed-core"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/identity-fed-model"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/identity-xmlsecmodel"/>
+ <classpathentry kind="var" path="M2_REPO/sun-jaxws/jaxws-api/2.1.1/jaxws-api-2.1.1.jar"/>
+ <classpathentry kind="output" path="target-eclipse/classes"/>
+</classpath>
Added: identity-federation/trunk/identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/servlets/InteropEndpointDebugTestCase.java
===================================================================
--- identity-federation/trunk/identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/servlets/InteropEndpointDebugTestCase.java (rev 0)
+++ identity-federation/trunk/identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/servlets/InteropEndpointDebugTestCase.java 2009-03-17 15:43:03 UTC (rev 371)
@@ -0,0 +1,135 @@
+/*
+ * 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.test.identity.federation.bindings.servlets;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+
+import junit.framework.TestCase;
+
+import org.jboss.identity.federation.core.saml.v2.util.SOAPSAMLXACMLUtil;
+import org.jboss.identity.federation.org.xmlsoap.schemas.soap.envelope.Envelope;
+import org.jboss.identity.federation.org.xmlsoap.schemas.soap.envelope.Fault;
+import org.jboss.identity.federation.saml.v2.assertion.AssertionType;
+import org.jboss.identity.federation.saml.v2.profiles.xacml.assertion.XACMLAuthzDecisionStatementType;
+import org.jboss.identity.federation.saml.v2.profiles.xacml.protocol.XACMLAuthzDecisionQueryType;
+import org.jboss.identity.federation.saml.v2.protocol.ResponseType;
+import org.jboss.security.xacml.core.model.context.DecisionType;
+import org.jboss.security.xacml.core.model.context.RequestType;
+import org.jboss.security.xacml.core.model.context.ResultType;
+
+
+/**
+ * Test Case that acts as a debug tool
+ * for the endpoint for interop
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Mar 16, 2009
+ */
+public class InteropEndpointDebugTestCase extends TestCase
+{
+ String endpoint = null;
+ // String endpoint = "http://interop.demo.jboss.com/test/SOAPServlet";
+ //String endpoint = "http://localhost:8080/test/SOAPServlet";
+
+ public void testUseCase1() throws Exception
+ {
+ if(endpoint != null)
+ {
+ JAXBElement<?> jb = getResponse("xacml/requests/interop-request.xml");
+ Envelope env = (Envelope) jb.getValue();
+ check(env, true);
+ }
+ }
+
+ public void testUseCase2() throws Exception
+ {
+ if(endpoint != null)
+ {
+ JAXBElement<?> jb = getResponse("xacml/requests/soap-request.xml");
+ Envelope env = (Envelope) jb.getValue();
+ check(env, true);
+ }
+ }
+
+ public void testSAMLXACML() throws Exception
+ {
+ //Read the saml request from the file
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ InputStream is = tcl.getResourceAsStream("xacml/requests/samlxacml.xml");
+
+ Unmarshaller um = SOAPSAMLXACMLUtil.getUnmarshaller();
+ um.setEventHandler(new javax.xml.bind.helpers.DefaultValidationEventHandler());
+
+ JAXBElement<?> obj = (JAXBElement<?>) um.unmarshal(is);
+ XACMLAuthzDecisionQueryType xat = (XACMLAuthzDecisionQueryType) obj.getValue();
+ assertNotNull(xat);
+ RequestType requestType = xat.getRequest();
+ assertTrue(requestType.getEnvironment().getAttribute().size() > 0);
+ }
+
+ private void check(Envelope env, boolean permit)
+ {
+ JAXBElement<?> samlResponse = (JAXBElement<?>) env.getBody().getAny().get(0);
+ Object response = samlResponse.getValue();
+ if(response instanceof Fault)
+ {
+ Fault fault = (Fault) response;
+ System.out.println(fault.getFaultstring());
+ fail("fault");
+ }
+ ResponseType responseType = (ResponseType) response;
+ AssertionType at = (AssertionType) responseType.getAssertionOrEncryptedAssertion().get(0);
+ XACMLAuthzDecisionStatementType xst = (XACMLAuthzDecisionStatementType) at.getStatementOrAuthnStatementOrAuthzDecisionStatement().get(0);
+ ResultType rt = xst.getResponse().getResult().get(0);
+ DecisionType dt = rt.getDecision();
+ assertEquals(DecisionType.PERMIT, dt);
+
+ if(permit)
+ assertEquals(DecisionType.PERMIT, dt);
+ else
+ assertEquals(DecisionType.DENY, dt);
+ }
+
+ private JAXBElement<?> getResponse(String fileName) throws Exception
+ {
+ //Read the saml request from the file
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ InputStream is = tcl.getResourceAsStream(fileName);
+
+ Unmarshaller um = SOAPSAMLXACMLUtil.getUnmarshaller();
+ Object soapRequest = um.unmarshal(is);
+
+ Marshaller m = SOAPSAMLXACMLUtil.getMarshaller();
+
+ URL url = new URL(endpoint);
+ URLConnection conn = url.openConnection();
+ conn.setDoOutput(true);
+ m.marshal(soapRequest, conn.getOutputStream());
+
+ return (JAXBElement<?>) um.unmarshal(conn.getInputStream());
+ }
+}
\ No newline at end of file
Modified: identity-federation/trunk/identity-bindings/src/test/java/org/jboss/test/tomcat/bindings/Tomcat5TestCase.java
===================================================================
--- identity-federation/trunk/identity-bindings/src/test/java/org/jboss/test/tomcat/bindings/Tomcat5TestCase.java 2009-03-17 15:41:08 UTC (rev 370)
+++ identity-federation/trunk/identity-bindings/src/test/java/org/jboss/test/tomcat/bindings/Tomcat5TestCase.java 2009-03-17 15:43:03 UTC (rev 371)
@@ -32,19 +32,23 @@
*/
public class Tomcat5TestCase extends TestCase
{
+ boolean enable = false;
+
public void testTomcat5() throws Exception
{
- Tomcat5Embedded emb = new Tomcat5Embedded();
- emb.setHomePath("target/tomcat");
- emb.startServer();
- Thread.sleep(2000);
- assertTrue("Tomcat5 started", emb.hasStarted());
-
- // emb.createContext("target/../identity-samples/samples/employee/target/employee.war");
-
+ if(enable)
+ {
+ Tomcat5Embedded emb = new Tomcat5Embedded();
+ emb.setHomePath("target/tomcat");
+ emb.startServer();
+ Thread.sleep(2000);
+ assertTrue("Tomcat5 started", emb.hasStarted());
- emb.stopServer();
- Thread.sleep(1000);
- assertTrue(emb.hasStopped());
+ // emb.createContext("target/../identity-samples/samples/employee/target/employee.war");
+
+ emb.stopServer();
+ Thread.sleep(1000);
+ assertTrue(emb.hasStopped());
+ }
}
}
\ No newline at end of file
Added: identity-federation/trunk/identity-bindings/src/test/resources/xacml/requests/samlxacml.xml
===================================================================
--- identity-federation/trunk/identity-bindings/src/test/resources/xacml/requests/samlxacml.xml (rev 0)
+++ identity-federation/trunk/identity-bindings/src/test/resources/xacml/requests/samlxacml.xml 2009-03-17 15:43:03 UTC (rev 371)
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<samlp:RequestAbstract xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
+ xmlns:xacml-samlp="urn:oasis:xacml:2.0:saml:protocol:schema:os"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Consent="consent-uri"
+ Destination="destination-uri" ID="s292657a1c39f12d36dd1f1ba2cf834bb2ebad825c"
+ IssueInstant="2009-03-16T19:01:52Z" Version="2.0"
+ xacml-samlp:InputContextOnly="true" xacml-samlp:ReturnContext="true"
+ xsi:type="xacml-samlp:XACMLAuthzDecisionQueryType">
+ <saml:Issuer xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">vaPepEntity
+ </saml:Issuer>
+ <xacml-context:Request xmlns="urn:oasis:names:tc:xacml:2.0:context:schema:os" xmlns:xacml-context="urn:oasis:names:tc:xacml:2.0:context:schema:os"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance/"
+ xsi:schemaLocation="urn:oasis:names:tc:xacml:2.0:context:schema:os http://docs.oasis-open.org/xacml/access_control-xacml-2.0-context-schema-...">
+ <Subject
+ SubjectCategory="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject">
+ <Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:subject:subject-id"
+ DataType="http://www.w3.org/2001/XMLSchema#string">
+ <AttributeValue>Doctor,Bob</AttributeValue>
+ </Attribute>
+ <Attribute AttributeId="urn:va:xacml:2.0:interop:rsa8:subject:role"
+ DataType="http://www.w3.org/2001/XMLSchema#string">
+ <AttributeValue>physician</AttributeValue>
+ </Attribute>
+ <Attribute AttributeId="urn:va:xacml:2.0:interop:rsa8:subject:hl7:permission"
+ DataType="http://www.w3.org/2001/XMLSchema#string">
+ <AttributeValue>urn:va:xacml:2.0:interop:rsa8:hl7:prd-010
+ </AttributeValue>
+ <AttributeValue>urn:va:xacml:2.0:interop:rsa8:hl7:prd-012
+ </AttributeValue>
+ <AttributeValue>urn:va:xacml:2.0:interop:rsa8:hl7:prd-017
+ </AttributeValue>
+ <AttributeValue>urn:va:xacml:2.0:interop:rsa8:hl7:prd-005
+ </AttributeValue>
+ <AttributeValue>urn:va:xacml:2.0:interop:rsa8:hl7:prd-003
+ </AttributeValue>
+ <AttributeValue>urn:va:xacml:2.0:interop:rsa8:hl7:prd-009
+ </AttributeValue>
+ <AttributeValue>urn:va:xacml:2.0:interop:rsa8:hl7:prd-006
+ </AttributeValue>
+ </Attribute>
+ <Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:subject:locality"
+ DataType="http://www.w3.org/2001/XMLSchema#string">
+ <AttributeValue>Healthcare Domain A</AttributeValue>
+ </Attribute>
+ </Subject>
+ <xacml-context:Resource>
+ <Attribute AttributeId="urn:va:xacml:2.0:interop:rsa8:resource:hl7:type"
+ DataType="http://www.w3.org/2001/XMLSchema#string">
+ <AttributeValue>
+ urn:va:xacml:2.0:interop:rsa8:resource:hl7:medical-record
+ </AttributeValue>
+ </Attribute>
+ <Attribute AttributeId="urn:va:xacml:2.0:interop:rsa8:resource:hl7:permission"
+ DataType="http://www.w3.org/2001/XMLSchema#string">
+ <AttributeValue>urn:va:xacml:2.0:interop:rsa8:hl7:prd-010
+ </AttributeValue>
+ <AttributeValue>urn:va:xacml:2.0:interop:rsa8:hl7:prd-012
+ </AttributeValue>
+ <AttributeValue>urn:va:xacml:2.0:interop:rsa8:hl7:prd-005
+ </AttributeValue>
+ <AttributeValue>urn:va:xacml:2.0:interop:rsa8:hl7:prd-003
+ </AttributeValue>
+ </Attribute>
+ <Attribute
+ AttributeId="urn:va:xacml:2.0:interop:rsa8:resource:hl7:confidentiality-code"
+ DataType="http://www.w3.org/2001/XMLSchema#string">
+ <AttributeValue>MA</AttributeValue>
+ </Attribute>
+ <Attribute
+ AttributeId="urn:va:xacml:2.0:interop:rsa8:resource:hl7:medications:dissented-subject-id"
+ DataType="http://www.w3.org/2001/XMLSchema#string">
+ <AttributeValue>Doctor, Bob I</AttributeValue>
+ </Attribute>
+ </xacml-context:Resource>
+ <xacml-context:Action>
+ <Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id"
+ DataType="http://www.w3.org/2001/XMLSchema#string">
+ <AttributeValue>read</AttributeValue>
+ </Attribute>
+ </xacml-context:Action>
+ <xacml-context:Environment>
+ <Attribute AttributeId="urn:va:xacml:2.0:interop:rsa8:environment:locality"
+ DataType="http://www.w3.org/2001/XMLSchema#string">
+ <AttributeValue>Healthcare Domain A</AttributeValue>
+ </Attribute>
+ </xacml-context:Environment>
+ </xacml-context:Request>
+
+</samlp:RequestAbstract>
\ No newline at end of file
Added: identity-federation/trunk/identity-bindings/src/test/resources/xacml/requests/soap-request.xml
===================================================================
--- identity-federation/trunk/identity-bindings/src/test/resources/xacml/requests/soap-request.xml (rev 0)
+++ identity-federation/trunk/identity-bindings/src/test/resources/xacml/requests/soap-request.xml 2009-03-17 15:43:03 UTC (rev 371)
@@ -0,0 +1,56 @@
+<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"><soap-env:Body>
+<samlp:RequestAbstract xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xsi:type="xacml-samlp:XACMLAuthzDecisionQuery" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xacml-samlp="urn:oasis:xacml:2.0:saml:protocol:schema:os" xacml-samlp:InputContextOnly="true" xacml-samlp:ReturnContext="true" ID="s292657a1c39f12d36dd1f1ba2cf834bb2ebad825c" Version="2.0" IssueInstant="2009-03-16T19:01:52Z" Destination="destination-uri" Consent="consent-uri">
+<saml:Issuer xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">vaPepEntity</saml:Issuer>
+<xacml-context:Request
+ xmlns="urn:oasis:names:tc:xacml:2.0:context:schema:os" xmlns:xacml-context="urn:oasis:names:tc:xacml:2.0:context:schema:os" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance/" xsi:schemaLocation="urn:oasis:names:tc:xacml:2.0:context:schema:os http://docs.oasis-open.org/xacml/access_control-xacml-2.0-context-schema-...">
+<Subject SubjectCategory="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject">
+<Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:subject:subject-id" DataType="http://www.w3.org/2001/XMLSchema#string" >
+<AttributeValue>Doctor,Bob</AttributeValue>
+</Attribute>
+<Attribute AttributeId="urn:va:xacml:2.0:interop:rsa8:subject:role" DataType="http://www.w3.org/2001/XMLSchema#string" >
+<AttributeValue>physician</AttributeValue>
+</Attribute>
+<Attribute AttributeId="urn:va:xacml:2.0:interop:rsa8:subject:hl7:permission" DataType="http://www.w3.org/2001/XMLSchema#string" >
+<AttributeValue>urn:va:xacml:2.0:interop:rsa8:hl7:prd-010</AttributeValue>
+<AttributeValue>urn:va:xacml:2.0:interop:rsa8:hl7:prd-012</AttributeValue>
+<AttributeValue>urn:va:xacml:2.0:interop:rsa8:hl7:prd-017</AttributeValue>
+<AttributeValue>urn:va:xacml:2.0:interop:rsa8:hl7:prd-005</AttributeValue>
+<AttributeValue>urn:va:xacml:2.0:interop:rsa8:hl7:prd-003</AttributeValue>
+<AttributeValue>urn:va:xacml:2.0:interop:rsa8:hl7:prd-009</AttributeValue>
+<AttributeValue>urn:va:xacml:2.0:interop:rsa8:hl7:prd-006</AttributeValue>
+</Attribute>
+<Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:subject:locality" DataType="http://www.w3.org/2001/XMLSchema#string" >
+<AttributeValue>Healthcare Domain A</AttributeValue>
+</Attribute>
+</Subject>
+<xacml-context:Resource>
+<Attribute AttributeId="urn:va:xacml:2.0:interop:rsa8:resource:hl7:type" DataType="http://www.w3.org/2001/XMLSchema#string" >
+<AttributeValue>urn:va:xacml:2.0:interop:rsa8:resource:hl7:medical-record</AttributeValue>
+</Attribute>
+<Attribute AttributeId="urn:va:xacml:2.0:interop:rsa8:resource:hl7:permission" DataType="http://www.w3.org/2001/XMLSchema#string" >
+<AttributeValue>urn:va:xacml:2.0:interop:rsa8:hl7:prd-010</AttributeValue>
+<AttributeValue>urn:va:xacml:2.0:interop:rsa8:hl7:prd-012</AttributeValue>
+<AttributeValue>urn:va:xacml:2.0:interop:rsa8:hl7:prd-005</AttributeValue>
+<AttributeValue>urn:va:xacml:2.0:interop:rsa8:hl7:prd-003</AttributeValue>
+</Attribute>
+<Attribute AttributeId="urn:va:xacml:2.0:interop:rsa8:resource:hl7:confidentiality-code" DataType="http://www.w3.org/2001/XMLSchema#string" >
+<AttributeValue>MA</AttributeValue>
+</Attribute>
+<Attribute AttributeId="urn:va:xacml:2.0:interop:rsa8:resource:hl7:medications:dissented-subject-id" DataType="http://www.w3.org/2001/XMLSchema#string" >
+<AttributeValue>Doctor, Bob I</AttributeValue>
+</Attribute>
+</xacml-context:Resource>
+<xacml-context:Action>
+<Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" DataType="http://www.w3.org/2001/XMLSchema#string" >
+<AttributeValue>read</AttributeValue>
+</Attribute>
+</xacml-context:Action>
+<xacml-context:Environment>
+<Attribute AttributeId="urn:va:xacml:2.0:interop:rsa8:environment:locality" DataType="http://www.w3.org/2001/XMLSchema#string" >
+<AttributeValue>Healthcare Domain A</AttributeValue>
+</Attribute>
+</xacml-context:Environment>
+</xacml-context:Request>
+
+</samlp:RequestAbstract>
+</soap-env:Body></soap-env:Envelope>
\ No newline at end of file
15 years, 9 months