Author: bdaw
Date: 2008-10-17 16:52:50 -0400 (Fri, 17 Oct 2008)
New Revision: 104
Added:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/AbstractManager.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/DirectIdentityObjectTypeMapperImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/EntityManagerWrapper.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/IdentityObjectTypeMapper.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/IdentityObjectTypeMapperImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/IdentitySessionContext.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/IdentitySessionContextImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/IdentitySessionFactoryImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/IdentitySessionImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/IdentityStoreInvocationContextResolver.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/PersistenceManagerImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/ProfileManagerImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/RelationshipManagerImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/RoleHandler.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/RoleManagerImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SessionWrapper.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SimpleGroupImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SimpleGroupType.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SimpleIdentityImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SimpleRoleImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SimpleRoleType.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SimpleTransactionImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/repository/
trunk/identity-impl/src/main/java/org/jboss/identity/impl/repository/AbstractIdentityStoreRepository.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/repository/WrapperIdentityStoreRepository.java
trunk/identity-impl/src/test/java/org/jboss/identity/impl/HibernateTestSupport.java
trunk/identity-impl/src/test/java/org/jboss/identity/impl/api/APITestCase.java
Removed:
trunk/identity-impl/src/test/java/org/jboss/identity/impl/api/SimpleGroupType.java
Modified:
trunk/identity-api/src/main/java/org/jboss/identity/api/IdentitySession.java
trunk/identity-api/src/main/java/org/jboss/identity/api/PersistenceManager.java
trunk/identity-api/src/main/java/org/jboss/identity/api/RoleManager.java
trunk/identity-impl/pom.xml
trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateIdentityObjectRelationshipName.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/hibernate/HibernateIdentityStoreImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/ldap/LDAPIdentityStore.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/types/SimpleIdentityObject.java
trunk/identity-impl/src/test/java/org/jboss/identity/impl/api/OrganizationTest.java
trunk/identity-impl/src/test/java/org/jboss/identity/impl/store/hibernate/HibernateTestBase.java
trunk/identity-spi/src/main/java/org/jboss/identity/spi/repository/IdentityStoreRepository.java
trunk/identity-spi/src/main/java/org/jboss/identity/spi/store/AttributeStore.java
trunk/identity-spi/src/main/java/org/jboss/identity/spi/store/IdentityStore.java
Log:
code backup
Modified: trunk/identity-api/src/main/java/org/jboss/identity/api/IdentitySession.java
===================================================================
---
trunk/identity-api/src/main/java/org/jboss/identity/api/IdentitySession.java 2008-10-15
10:59:42 UTC (rev 103)
+++
trunk/identity-api/src/main/java/org/jboss/identity/api/IdentitySession.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -41,12 +41,6 @@
String getRealmName();
/**
- * Open the session
- * @throws org.jboss.identity.exception.IdentityException
- */
- void open() throws IdentityException;
-
- /**
* Close this session
* @throws org.jboss.identity.exception.IdentityException
*/
Modified: trunk/identity-api/src/main/java/org/jboss/identity/api/PersistenceManager.java
===================================================================
---
trunk/identity-api/src/main/java/org/jboss/identity/api/PersistenceManager.java 2008-10-15
10:59:42 UTC (rev 103)
+++
trunk/identity-api/src/main/java/org/jboss/identity/api/PersistenceManager.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -135,13 +135,13 @@
* @param filterName can be null
* @param offset
* @param limit 0 means unlimited page size
- * @param orderedByAttributeName can be null
+ * @param orderedByName
* @param ascending default true
* @return
* @throws org.jboss.identity.exception.IdentityException
*/
Collection<Identity> findIdentity(String filterName, int offset, int limit,
- String orderedByAttributeName,
+ boolean orderedByName,
boolean ascending) throws IdentityException;
/**
@@ -153,14 +153,14 @@
* @param attributes
* @param offset
* @param limit 0 means unlimited page size
- * @param orderedByAttributeName can be null
+ * @param orderedByName
* @param ascending default true
* @return
* @throws org.jboss.identity.exception.IdentityException
*/
Collection<Identity> findIdentity(String filterName, Map<String, String[]>
attributes,
int offset, int limit,
- String orderedByAttributeName, boolean ascending)
throws IdentityException;
+ boolean orderedByName, boolean ascending) throws
IdentityException;
// Search Groups
@@ -193,14 +193,14 @@
* @param filterName can be null
* @param offset
* @param limit 0 means unlimited page size
- * @param orderedByAttributeName can be null
+ * @param orderedByName can be null
* @param ascending default true
* @return
* @throws org.jboss.identity.exception.IdentityException
*/
- Collection<Group> findRole(GroupType groupType, String filterName,
+ Collection<Group> findGroup(GroupType groupType, String filterName,
int offset, int limit,
- String orderedByAttributeName,
+ boolean orderedByName,
boolean ascending) throws IdentityException;
/**
@@ -209,18 +209,16 @@
* are not supported in this store implementation, dedicated parameters will take no
effect
*
* @param groupType
- * @param filterName can be null
* @param attributes
* @param offset
* @param limit 0 means unlimited page size
- * @param orderedByAttributeName can be null
+ * @param orderedByName can be null
* @param ascending default true
* @return
* @throws org.jboss.identity.exception.IdentityException
*/
- Collection<Group> findGroup(GroupType groupType, String filterName,
- Map<String, String[]> attributes,
+ Collection<Group> findGroup(GroupType groupType, Map<String, String[]>
attributes,
int offset, int limit,
- String orderedByAttributeName, boolean ascending) throws
IdentityException;
+ boolean orderedByName, boolean ascending) throws
IdentityException;
}
Modified: trunk/identity-api/src/main/java/org/jboss/identity/api/RoleManager.java
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/api/RoleManager.java 2008-10-15
10:59:42 UTC (rev 103)
+++ trunk/identity-api/src/main/java/org/jboss/identity/api/RoleManager.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -74,7 +74,6 @@
/**
* Find all RoleType objects stored
- * @param filterName
* @param offset
* @param limit
* @param orderedByName
@@ -82,9 +81,8 @@
* @return
* @throws IdentityException
*/
- Collection<RoleType> findRoleTypes(String filterName,
- int offset, int limit,
- String orderedByName,
+ Collection<RoleType> findRoleTypes(int offset, int limit,
+ boolean orderedByName,
boolean ascending) throws IdentityException;
@@ -160,7 +158,7 @@
/**
* Find RoleType objects for roles associated with a given Group
- * @param identity
+ * @param group
* @param offset
* @param limit
* @param orderedByName
@@ -168,7 +166,7 @@
* @return
* @throws IdentityException
*/
- Collection<RoleType> findGroupRoleTypes(Identity identity,
+ Collection<RoleType> findGroupRoleTypes(Group group,
int offset, int limit,
boolean orderedByName,
boolean ascending) throws IdentityException;
Modified: trunk/identity-impl/pom.xml
===================================================================
--- trunk/identity-impl/pom.xml 2008-10-15 10:59:42 UTC (rev 103)
+++ trunk/identity-impl/pom.xml 2008-10-17 20:52:50 UTC (rev 104)
@@ -27,7 +27,6 @@
<
url>http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbossidentity/trunk<...
</scm>
-
<dependencies>
<dependency>
<groupId>org.jboss.identity</groupId>
Added: trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/AbstractManager.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/AbstractManager.java
(rev 0)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/AbstractManager.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -0,0 +1,125 @@
+/*
+* 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.impl.api;
+
+import org.jboss.identity.api.IdentitySession;
+import org.jboss.identity.api.Identity;
+import org.jboss.identity.api.Group;
+import org.jboss.identity.api.GroupType;
+import org.jboss.identity.api.IdentityType;
+import org.jboss.identity.spi.repository.IdentityStoreRepository;
+import org.jboss.identity.spi.store.IdentityStoreInvocationContext;
+import org.jboss.identity.spi.model.IdentityObject;
+import org.jboss.identity.spi.model.IdentityObjectType;
+import org.jboss.identity.impl.types.SimpleIdentityObject;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public abstract class AbstractManager
+{
+ protected final IdentitySession identitySession;
+
+ protected AbstractManager(IdentitySession session)
+ {
+ this.identitySession = session;
+ }
+
+ public IdentitySession getIdentitySession()
+ {
+ return identitySession;
+ }
+
+ protected IdentitySessionContext getSessionContext()
+ {
+ if (identitySession instanceof IdentitySessionImpl)
+ {
+ return ((IdentitySessionImpl)identitySession).getSessionContext();
+ }
+ return null;
+ }
+
+ protected IdentityStoreRepository getRepository()
+ {
+ return getSessionContext().getIdentityStoreRepository();
+ }
+
+ protected IdentityStoreInvocationContext getInvocationContext()
+ {
+ return getSessionContext().resolveStoreInvocationContext();
+ }
+
+ protected Identity createIdentity(IdentityObject identityObject)
+ {
+ return new SimpleIdentityImpl(identityObject.getName(), identityObject.getId());
+ }
+
+ protected Group createGroup(IdentityObject identityObject)
+ {
+ GroupType groupType =
getSessionContext().getIdentityObjectTypeMapper().getGroupType(identityObject.getIdentityType());
+ return new SimpleGroupImpl(identityObject.getName(), identityObject.getId(),
groupType);
+ }
+
+ protected IdentityObject createIdentityObject(Identity identity)
+ {
+ IdentityObjectType iot =
getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType();
+
+ return new SimpleIdentityObject(identity.getName(), identity.getId(), iot);
+ }
+
+ protected IdentityObject createIdentityObject(Group group)
+ {
+ IdentityObjectType iot =
getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType(group.getGroupType());
+
+ return new SimpleIdentityObject(group.getName(), group.getId(), iot);
+ }
+
+ protected IdentityObject createIdentityObject(IdentityType identityType)
+ {
+ if (identityType instanceof Identity)
+ {
+ return createIdentityObject((Identity)identityType);
+ }
+ else if (identityType instanceof Group)
+ {
+ return createIdentityObject((Group)identityType);
+ }
+
+ throw new IllegalStateException("Not supported IdentityType extension: "
+ identityType.getClass());
+
+ }
+
+ protected IdentityObjectType getIdentityObjectType()
+ {
+ return getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType();
+ }
+
+ protected IdentityObjectType getIdentityObjectType(GroupType groupType)
+ {
+ return
getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType(groupType);
+ }
+
+
+
+}
Added:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/DirectIdentityObjectTypeMapperImpl.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/DirectIdentityObjectTypeMapperImpl.java
(rev 0)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/DirectIdentityObjectTypeMapperImpl.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -0,0 +1,101 @@
+/*
+* 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.impl.api;
+
+import org.jboss.identity.spi.model.IdentityObjectType;
+import org.jboss.identity.impl.types.SimpleIdentityObjectType;
+import org.jboss.identity.api.GroupType;
+
+import java.util.Map;
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class DirectIdentityObjectTypeMapperImpl implements IdentityObjectTypeMapper
+{
+
+ private final String identityTypeName;
+
+ public DirectIdentityObjectTypeMapperImpl(String identityTypeName)
+ {
+ this.identityTypeName = identityTypeName;
+ }
+
+ public IdentityObjectType getIdentityObjectType()
+ {
+ return new SimpleIdentityObjectType(identityTypeName);
+ }
+
+ public IdentityObjectType getIdentityObjectType(GroupType groupType)
+ {
+ if (groupType == null)
+ {
+ throw new IllegalArgumentException("groupType is null");
+ }
+
+ return new SimpleIdentityObjectType(groupType.getName());
+ }
+
+ public GroupType getGroupType(IdentityObjectType identityObjectType)
+ {
+ if (identityObjectType == null)
+ {
+ throw new IllegalArgumentException("identityObjectType is null");
+ }
+
+ return new SimpleGroupType(identityObjectType.getName());
+
+ }
+
+ public boolean isGroupType(IdentityObjectType identityObjectType)
+ {
+ if (identityObjectType == null)
+ {
+ throw new IllegalArgumentException("identityObjectType is null");
+ }
+
+ if (isIdentity(identityObjectType))
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+
+ public boolean isIdentity(IdentityObjectType identityObjectType)
+ {
+ if (identityObjectType == null)
+ {
+ throw new IllegalArgumentException("identityObjectType is null");
+ }
+
+ if (identityObjectType.getName().equals(identityTypeName))
+ {
+ return true;
+ }
+ return false;
+ }
+}
Added:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/EntityManagerWrapper.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/EntityManagerWrapper.java
(rev 0)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/EntityManagerWrapper.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -0,0 +1,86 @@
+/*
+* 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.impl.api;
+
+import org.jboss.identity.exception.IdentityException;
+
+import javax.persistence.EntityManager;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class EntityManagerWrapper implements SessionWrapper
+{
+ private final EntityManager em;
+
+ public EntityManagerWrapper(EntityManager entityManager)
+ {
+ this.em = entityManager;
+ }
+
+ public void close() throws IdentityException
+ {
+ em.close();
+ }
+
+ public void save() throws IdentityException
+ {
+ em.flush();
+ }
+
+ public void clear() throws IdentityException
+ {
+ em.clear();
+ }
+
+ public boolean isOpen()
+ {
+ return em.isOpen();
+ }
+
+ public boolean isTransactionSupported()
+ {
+ return true;
+ }
+
+ public void startTransaction()
+ {
+ em.getTransaction().begin();
+ }
+
+ public void commitTransaction()
+ {
+ em.getTransaction().commit();
+ }
+
+ public void rollbackTransaction()
+ {
+ em.getTransaction().rollback();
+ }
+
+ public boolean isTransactionActive()
+ {
+ return em.getTransaction().isActive();
+ }
+}
Added:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/IdentityObjectTypeMapper.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/IdentityObjectTypeMapper.java
(rev 0)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/IdentityObjectTypeMapper.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -0,0 +1,51 @@
+/*
+* 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.impl.api;
+
+import org.jboss.identity.spi.model.IdentityObject;
+import org.jboss.identity.spi.model.IdentityObjectType;
+import org.jboss.identity.api.Identity;
+import org.jboss.identity.api.GroupType;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface IdentityObjectTypeMapper
+{
+
+ IdentityObjectType getIdentityObjectType();
+
+
+ IdentityObjectType getIdentityObjectType(GroupType groupType);
+
+
+ GroupType getGroupType(IdentityObjectType identityObjectType);
+
+
+ boolean isGroupType(IdentityObjectType identityObjectType);
+
+
+ boolean isIdentity(IdentityObjectType identityObjectType);
+
+}
Added:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/IdentityObjectTypeMapperImpl.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/IdentityObjectTypeMapperImpl.java
(rev 0)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/IdentityObjectTypeMapperImpl.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -0,0 +1,128 @@
+/*
+* 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.impl.api;
+
+import org.jboss.identity.spi.model.IdentityObjectType;
+import org.jboss.identity.api.Identity;
+import org.jboss.identity.api.GroupType;
+import org.jboss.identity.impl.types.SimpleIdentityObjectType;
+
+import java.util.Map;
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class IdentityObjectTypeMapperImpl implements IdentityObjectTypeMapper
+{
+
+ /**
+ * IdentityObjectType --> GroupType
+ */
+ private final Map<String, String> groupTypeMap;
+
+ private final String identityTypeName;
+
+ public IdentityObjectTypeMapperImpl(Map<String, String> map, String
identityTypeName)
+ {
+ groupTypeMap = Collections.unmodifiableMap(map);
+ this.identityTypeName = identityTypeName;
+ }
+
+ public IdentityObjectType getIdentityObjectType()
+ {
+ return new SimpleIdentityObjectType(identityTypeName);
+ }
+
+ public IdentityObjectType getIdentityObjectType(GroupType groupType)
+ {
+ if (groupType == null)
+ {
+ throw new IllegalArgumentException("groupType is null");
+ }
+
+ for (Map.Entry<String, String> entry : groupTypeMap.entrySet())
+ {
+ if (entry.getValue().equals(groupType.getName()))
+ {
+ return new SimpleIdentityObjectType(entry.getKey());
+ }
+ }
+
+ return null;
+ }
+
+ public GroupType getGroupType(IdentityObjectType identityObjectType)
+ {
+ if (identityObjectType == null)
+ {
+ throw new IllegalArgumentException("identityObjectType is null");
+ }
+
+ String name = groupTypeMap.get(identityObjectType.getName());
+
+ if (name != null)
+ {
+ return new SimpleGroupType(name);
+ }
+
+ return null;
+
+ }
+
+ public boolean isGroupType(IdentityObjectType identityObjectType)
+ {
+ if (identityObjectType == null)
+ {
+ throw new IllegalArgumentException("identityObjectType is null");
+ }
+
+ if (isIdentity(identityObjectType))
+ {
+ return false;
+ }
+
+ if (groupTypeMap.containsKey(identityObjectType.getName()))
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+
+ public boolean isIdentity(IdentityObjectType identityObjectType)
+ {
+ if (identityObjectType == null)
+ {
+ throw new IllegalArgumentException("identityObjectType is null");
+ }
+
+ if (identityObjectType.getName().equals(identityTypeName))
+ {
+ return true;
+ }
+ return false;
+ }
+}
Added:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/IdentitySessionContext.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/IdentitySessionContext.java
(rev 0)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/IdentitySessionContext.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -0,0 +1,41 @@
+/*
+* 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.impl.api;
+
+import org.jboss.identity.spi.repository.IdentityStoreRepository;
+import org.jboss.identity.spi.store.IdentityStoreInvocationContext;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface IdentitySessionContext
+{
+
+ IdentityStoreRepository getIdentityStoreRepository();
+
+ IdentityObjectTypeMapper getIdentityObjectTypeMapper();
+
+ IdentityStoreInvocationContext resolveStoreInvocationContext();
+
+}
Added:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/IdentitySessionContextImpl.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/IdentitySessionContextImpl.java
(rev 0)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/IdentitySessionContextImpl.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -0,0 +1,62 @@
+/*
+* 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.impl.api;
+
+import org.jboss.identity.spi.repository.IdentityStoreRepository;
+import org.jboss.identity.spi.store.IdentityStoreInvocationContext;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class IdentitySessionContextImpl implements IdentitySessionContext
+{
+ private final IdentityStoreRepository identityStoreRepository;
+
+ private final IdentityObjectTypeMapper identityObjectTypeMapper;
+
+ private final IdentityStoreInvocationContextResolver contextResolver;
+
+
+ public IdentitySessionContextImpl(IdentityStoreRepository identityStoreRepository,
IdentityObjectTypeMapper identityObjectTypeMapper, IdentityStoreInvocationContextResolver
contextResolver)
+ {
+ this.identityStoreRepository = identityStoreRepository;
+ this.identityObjectTypeMapper = identityObjectTypeMapper;
+ this.contextResolver = contextResolver;
+ }
+
+ public IdentityStoreRepository getIdentityStoreRepository()
+ {
+ return identityStoreRepository;
+ }
+
+ public IdentityObjectTypeMapper getIdentityObjectTypeMapper()
+ {
+ return identityObjectTypeMapper;
+ }
+
+ public IdentityStoreInvocationContext resolveStoreInvocationContext()
+ {
+ return contextResolver.resolveInvocationContext();
+ }
+}
Added:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/IdentitySessionFactoryImpl.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/IdentitySessionFactoryImpl.java
(rev 0)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/IdentitySessionFactoryImpl.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -0,0 +1,63 @@
+/*
+* 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.impl.api;
+
+import org.jboss.identity.api.IdentitySessionFactory;
+import org.jboss.identity.api.IdentitySession;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class IdentitySessionFactoryImpl implements IdentitySessionFactory
+{
+
+ private Map<String, IdentitySession> realmMap;
+
+ public IdentitySessionFactoryImpl(Map<String, IdentitySession> realmMap)
+ {
+ this.realmMap = realmMap;
+ }
+
+ public void close()
+ {
+
+ }
+
+ public boolean isClosed()
+ {
+ return false;
+ }
+
+ public IdentitySession createIdentitySession(String realmName)
+ {
+ return realmMap.get(realmName);
+ }
+
+ public IdentitySession getCurrentIdentitySession(String realmName)
+ {
+ return realmMap.get(realmName);
+ }
+}
Added:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/IdentitySessionImpl.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/IdentitySessionImpl.java
(rev 0)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/IdentitySessionImpl.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -0,0 +1,148 @@
+/*
+* 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.impl.api;
+
+import org.jboss.identity.api.IdentitySession;
+import org.jboss.identity.api.Transaction;
+import org.jboss.identity.api.PersistenceManager;
+import org.jboss.identity.api.RelationshipManager;
+import org.jboss.identity.api.ProfileManager;
+import org.jboss.identity.api.RoleManager;
+import org.jboss.identity.exception.IdentityException;
+
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class IdentitySessionImpl implements IdentitySession
+{
+ private final String realmName;
+
+ private final IdentitySessionContext sessionContext;
+
+ private final PersistenceManager persistenceManager;
+
+ private final RelationshipManager relationshipManager;
+
+ private final ProfileManager profileManager;
+
+ private final RoleManager roleManager;
+
+ private final Set<SessionWrapper> sessionWrappers;
+
+ public IdentitySessionContext getSessionContext()
+ {
+ return sessionContext;
+ }
+
+ public IdentitySessionImpl(String realmName, IdentitySessionContext sessionContext,
+ Set<SessionWrapper> sessionWrappers)
+ {
+ this.realmName = realmName;
+ this.sessionContext = sessionContext;
+ this.sessionWrappers = sessionWrappers;
+ this.persistenceManager = new PersistenceManagerImpl(this);
+ this.relationshipManager = new RelationshipManagerImpl(this);
+ this.profileManager = new ProfileManagerImpl(this);
+ this.roleManager = new RoleManagerImpl(this);
+
+
+ }
+
+ public String getRealmName()
+ {
+ return realmName;
+ }
+
+ public void close() throws IdentityException
+ {
+ for (SessionWrapper sessionWrapper : sessionWrappers)
+ {
+ sessionWrapper.close();
+ }
+ }
+
+ public void save() throws IdentityException
+ {
+ for (SessionWrapper sessionWrapper : sessionWrappers)
+ {
+ sessionWrapper.save();
+ }
+ }
+
+ public void clear() throws IdentityException
+ {
+ for (SessionWrapper sessionWrapper : sessionWrappers)
+ {
+ sessionWrapper.clear();
+ }
+ }
+
+ public boolean isOpen()
+ {
+
+ for (SessionWrapper sessionWrapper : sessionWrappers)
+ {
+ if (sessionWrapper.isOpen())
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public Transaction beginTransaction()
+ {
+ return new SimpleTransactionImpl(sessionWrappers);
+ }
+
+ public Transaction getTransaction()
+ {
+ return new SimpleTransactionImpl(sessionWrappers);
+ }
+
+ public PersistenceManager getPersistenceManager()
+ {
+ return persistenceManager;
+ }
+
+ public RelationshipManager getRelationshipManager()
+ {
+ return relationshipManager;
+ }
+
+ public ProfileManager getProfileManager()
+ {
+ return profileManager;
+ }
+
+ //TODO: proper exception if roles are not supported
+
+ public RoleManager getRoleManager()
+ {
+ return roleManager;
+ }
+}
Added:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/IdentityStoreInvocationContextResolver.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/IdentityStoreInvocationContextResolver.java
(rev 0)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/IdentityStoreInvocationContextResolver.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -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.impl.api;
+
+import org.jboss.identity.spi.store.IdentityStoreInvocationContext;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface IdentityStoreInvocationContextResolver
+{
+
+ IdentityStoreInvocationContext resolveInvocationContext();
+
+}
Added:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/PersistenceManagerImpl.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/PersistenceManagerImpl.java
(rev 0)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/PersistenceManagerImpl.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -0,0 +1,182 @@
+/*
+* 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.impl.api;
+
+import org.jboss.identity.api.PersistenceManager;
+import org.jboss.identity.api.Identity;
+import org.jboss.identity.api.Group;
+import org.jboss.identity.api.GroupType;
+import org.jboss.identity.api.IdentityType;
+import org.jboss.identity.api.IdentitySession;
+import org.jboss.identity.exception.IdentityException;
+import org.jboss.identity.spi.model.IdentityObjectType;
+import org.jboss.identity.spi.model.IdentityObject;
+import org.jboss.identity.impl.types.SimpleIdentityObject;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.List;
+import java.util.LinkedList;
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class PersistenceManagerImpl extends AbstractManager implements
PersistenceManager
+{
+
+ public PersistenceManagerImpl(IdentitySession session)
+ {
+ super(session);
+ }
+
+ public Identity createIdentity(String identityName) throws IdentityException
+ {
+ IdentityObjectType iot = getIdentityObjectType();
+
+ IdentityObject identityObject =
getRepository().createIdentityObject(getInvocationContext(), identityName, iot);
+
+ return createIdentity(identityObject);
+ }
+
+ public Group createGroup(String groupName, GroupType groupType) throws
IdentityException
+ {
+ IdentityObjectType iot = getIdentityObjectType(groupType);
+
+ IdentityObject identityObject =
getRepository().createIdentityObject(getInvocationContext(), groupName, iot);
+
+ return createGroup(identityObject);
+ }
+
+ public void removeIdentity(Identity identity, boolean force) throws IdentityException
+ {
+ IdentityObjectType iot = getIdentityObjectType();
+
+ getRepository().removeIdentityObject(getInvocationContext(),
createIdentityObject(identity));
+
+ }
+
+ public void removeGroup(Group group, boolean force) throws IdentityException
+ {
+ //TODO: force
+
+ getRepository().removeIdentityObject(getInvocationContext(),
createIdentityObject(group));
+ }
+
+ public void refreshIdentityType(IdentityType it) throws IdentityException
+ {
+ //TODO: remove this method from the interface
+ }
+
+ public int getIdentityCount() throws IdentityException
+ {
+ IdentityObjectType iot = getIdentityObjectType();
+
+ return getRepository().getIdentityObjectsCount(getInvocationContext(), iot);
+ }
+
+ public int getGroupTypeCount(GroupType groupType) throws IdentityException
+ {
+ IdentityObjectType iot = getIdentityObjectType(groupType);
+
+ return getRepository().getIdentityObjectsCount(getInvocationContext(), iot);
+ }
+
+ public Identity findIdentity(String name) throws IdentityException
+ {
+ return createIdentity(getRepository().findIdentityObject(getInvocationContext(),
name, getIdentityObjectType()));
+ }
+
+ public Identity findIdentity(Object id) throws IdentityException
+ {
+ return createIdentity(getRepository().findIdentityObject(getInvocationContext(),
id));
+ }
+
+ public Collection<Identity> findIdentity(String filterName, int offset, int
limit, boolean orderedByName, boolean ascending) throws IdentityException
+ {
+ Collection<IdentityObject> ios =
getRepository().findIdentityObject(getInvocationContext(), getIdentityObjectType(),
filterName, offset, limit, orderedByName, ascending);
+ List<Identity> identities = new LinkedList<Identity>();
+
+ for (Iterator<IdentityObject> iterator = ios.iterator();
iterator.hasNext();)
+ {
+ IdentityObject identityObject = iterator.next();
+ identities.add(createIdentity(identityObject));
+ }
+
+ return identities;
+
+ }
+
+ public Collection<Identity> findIdentity(String filterName, Map<String,
String[]> attributes, int offset, int limit, boolean orderedByName, boolean ascending)
throws IdentityException
+ {
+ Collection<IdentityObject> ios =
getRepository().findIdentityObject(getInvocationContext(), getIdentityObjectType(),
attributes, offset, limit, orderedByName, ascending);
+ List<Identity> identities = new LinkedList<Identity>();
+
+ for (Iterator<IdentityObject> iterator = ios.iterator();
iterator.hasNext();)
+ {
+ IdentityObject identityObject = iterator.next();
+ identities.add(createIdentity(identityObject));
+ }
+
+ return identities;
+ }
+
+ public Group findGroup(String name, GroupType groupType) throws IdentityException
+ {
+ return createGroup(getRepository().findIdentityObject(getInvocationContext(), name,
getIdentityObjectType(groupType)));
+ }
+
+ public Group findGroup(Object id) throws IdentityException
+ {
+ return createGroup(getRepository().findIdentityObject(getInvocationContext(),
id));
+ }
+
+ public Collection<Group> findGroup(GroupType groupType, String filterName, int
offset, int limit, boolean orderedByName, boolean ascending) throws IdentityException
+ {
+ Collection<IdentityObject> ios =
getRepository().findIdentityObject(getInvocationContext(),
getIdentityObjectType(groupType), filterName, offset, limit, orderedByName, ascending);
+ List<Group> groups = new LinkedList<Group>();
+
+ for (Iterator<IdentityObject> iterator = ios.iterator();
iterator.hasNext();)
+ {
+ IdentityObject identityObject = iterator.next();
+ groups.add(createGroup(identityObject));
+ }
+
+ return groups;
+ }
+
+ public Collection<Group> findGroup(GroupType groupType, Map<String,
String[]> attributes, int offset, int limit, boolean orderedByName, boolean ascending)
throws IdentityException
+ {
+ Collection<IdentityObject> ios =
getRepository().findIdentityObject(getInvocationContext(),
getIdentityObjectType(groupType), attributes, offset, limit, orderedByName, ascending);
+ List<Group> groups = new LinkedList<Group>();
+
+ for (Iterator<IdentityObject> iterator = ios.iterator();
iterator.hasNext();)
+ {
+ IdentityObject identityObject = iterator.next();
+ groups.add(createGroup(identityObject));
+ }
+
+ return groups;
+ }
+}
Added:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/ProfileManagerImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/ProfileManagerImpl.java
(rev 0)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/ProfileManagerImpl.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -0,0 +1,111 @@
+/*
+* 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.impl.api;
+
+import org.jboss.identity.api.IdentitySession;
+import org.jboss.identity.api.ProfileManager;
+import org.jboss.identity.api.IdentityType;
+import org.jboss.identity.exception.IdentityException;
+
+import java.util.Set;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.HashSet;
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class ProfileManagerImpl extends AbstractManager implements ProfileManager
+{
+ public ProfileManagerImpl(IdentitySession session)
+ {
+ super(session);
+ }
+
+ //TODO: fix to have similar signatures in API/SPI for String[]
+
+ public Set<String> getSupportedAttributeNames(IdentityType identityType) throws
IdentityException
+ {
+ return getRepository().getSupportedAttributeNames(getInvocationContext(),
createIdentityObject(identityType).getIdentityType());
+ }
+
+ public Map<String, String[]> getAttributes(IdentityType identity) throws
IdentityException
+ {
+ Map<String, Set<String>> attributes =
getRepository().getAttributes(getInvocationContext(), createIdentityObject(identity));
+
+ Map<String, String[]> attrs = new HashMap<String, String[]>();
+
+ for (Map.Entry<String, Set<String>> entry : attributes.entrySet())
+ {
+ attrs.put(entry.getKey(), entry.getValue().toArray(new
String[entry.getValue().size()]));
+ }
+
+ return attrs;
+ }
+
+ public void updateAttributes(IdentityType identity, Map<String, String[]>
attributes) throws IdentityException
+ {
+ Map<String, Set<String>> attrs = new HashMap<String,
Set<String>>();
+
+ for (Map.Entry<String, String[]> entry : attributes.entrySet())
+ {
+ Set<String> vals = new HashSet<String>();
+ for (String s : entry.getValue())
+ {
+ vals.add(s);
+ }
+
+ attrs.put(entry.getKey(),vals);
+ }
+
+ getRepository().updateAttributes(getInvocationContext(),
createIdentityObject(identity), attrs);
+
+ }
+
+ public void addAttributes(IdentityType identity, Map<String, String[]>
attributes) throws IdentityException
+ {
+ Map<String, Set<String>> attrs = new HashMap<String,
Set<String>>();
+
+ for (Map.Entry<String, String[]> entry : attributes.entrySet())
+ {
+ Set<String> vals = new HashSet<String>();
+ for (String s : entry.getValue())
+ {
+ vals.add(s);
+ }
+
+ attrs.put(entry.getKey(),vals);
+ }
+
+ getRepository().addAttributes(getInvocationContext(),
createIdentityObject(identity), attrs);
+ }
+
+ public void removeAttributes(IdentityType identity, Set<String> attributes)
throws IdentityException
+ {
+ getRepository().removeAttributes(getInvocationContext(),
createIdentityObject(identity), attributes);
+
+ }
+}
Added:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/RelationshipManagerImpl.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/RelationshipManagerImpl.java
(rev 0)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/RelationshipManagerImpl.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -0,0 +1,179 @@
+/*
+* 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.impl.api;
+
+import org.jboss.identity.api.RelationshipManager;
+import org.jboss.identity.api.IdentitySession;
+import org.jboss.identity.api.Group;
+import org.jboss.identity.api.Identity;
+import org.jboss.identity.api.IdentityType;
+import org.jboss.identity.api.GroupType;
+import org.jboss.identity.exception.IdentityException;
+import org.jboss.identity.spi.model.IdentityObjectRelationshipType;
+import org.jboss.identity.spi.model.IdentityObjectRelationship;
+import org.jboss.identity.impl.NotYetImplementedException;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class RelationshipManagerImpl extends AbstractManager implements
RelationshipManager
+{
+
+ public static final IdentityObjectRelationshipType MEMBER = new
IdentityObjectRelationshipType()
+ {
+ public String getName()
+ {
+ return "JBOSS_IDENTITY_MEMBERSHIP";
+ }
+ };
+
+ public RelationshipManagerImpl(IdentitySession session)
+ {
+ super(session);
+ }
+
+ public void associateGroups(Collection<Group> parents, Collection<Group>
members) throws IdentityException
+ {
+ for (Iterator<Group> parentsIterator = parents.iterator();
parentsIterator.hasNext();)
+ {
+ Group parent = parentsIterator.next();
+
+ for (Iterator<Group> membersIterator = members.iterator();
membersIterator.hasNext();)
+ {
+ Group member = membersIterator.next();
+
+ associateGroups(parent, member);
+ }
+ }
+ }
+
+ public void associateGroups(Group parent, Group member) throws IdentityException
+ {
+ getRepository().createRelationship(getInvocationContext(),
createIdentityObject(parent), createIdentityObject(member), MEMBER, null, true);
+ }
+
+ public void associateIdentities(Collection<Group> parents,
Collection<Identity> members) throws IdentityException
+ {
+ for (Iterator<Group> parentsIterator = parents.iterator();
parentsIterator.hasNext();)
+ {
+ Group parent = parentsIterator.next();
+
+ for (Iterator<Identity> membersIterator = members.iterator();
membersIterator.hasNext();)
+ {
+ Identity member = membersIterator.next();
+
+ associateIdentities(parent, member);
+ }
+ }
+ }
+
+ public void associateIdentities(Group parent, Identity member) throws
IdentityException
+ {
+ getRepository().createRelationship(getInvocationContext(),
createIdentityObject(parent), createIdentityObject(member), MEMBER, null, true);
+ }
+
+ public void disassociateGroups(Collection<Group> parents,
Collection<Group> members) throws IdentityException
+ {
+ for (Iterator<Group> parentsIterator = parents.iterator();
parentsIterator.hasNext();)
+ {
+ Group parent = parentsIterator.next();
+
+ for (Iterator<Group> membersIterator = members.iterator();
membersIterator.hasNext();)
+ {
+ Group member = membersIterator.next();
+
+ getRepository().removeRelationship(getInvocationContext(),
createIdentityObject(parent), createIdentityObject(member), MEMBER, null);
+ }
+ }
+ }
+
+ public void disassociateIdentities(Collection<Group> parents,
Collection<Identity> members) throws IdentityException
+ {
+ for (Iterator<Group> parentsIterator = parents.iterator();
parentsIterator.hasNext();)
+ {
+ Group parent = parentsIterator.next();
+
+ for (Iterator<Identity> membersIterator = members.iterator();
membersIterator.hasNext();)
+ {
+ Identity member = membersIterator.next();
+
+ getRepository().removeRelationship(getInvocationContext(),
createIdentityObject(parent), createIdentityObject(member), MEMBER, null);
+ }
+ }
+
+ }
+
+ public <G extends IdentityType, I extends IdentityType> boolean
isAssociated(Collection<G> parents, Collection<I> members) throws
IdentityException
+ {
+ //TODO: IdentityStore should have isRelationshipPresent method to improve this
+
+ for (Iterator<G> parentsIterator = parents.iterator();
parentsIterator.hasNext();)
+ {
+ IdentityType parent = parentsIterator.next();
+
+ for (Iterator<I> membersIterator = members.iterator();
membersIterator.hasNext();)
+ {
+ IdentityType member = membersIterator.next();
+
+ Collection<IdentityObjectRelationship> relationships =
getRepository().resolveRelationships(getInvocationContext(), createIdentityObject(parent),
createIdentityObject(member));
+
+ boolean isRelated = false;
+
+ for (Iterator<IdentityObjectRelationship>
identityObjectRelationshipIterator = relationships.iterator();
identityObjectRelationshipIterator.hasNext();)
+ {
+ IdentityObjectRelationship rel =
identityObjectRelationshipIterator.next();
+ if (rel.getType().getName().equals(MEMBER.getName()))
+ {
+ isRelated = true;
+ }
+ }
+
+ if (!isRelated)
+ {
+ return false;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ public Collection<Group> findAssociatedGroups(Group group, GroupType groupType,
boolean parent, boolean inherited, int offset, int limit, String orderedByAttributeName,
boolean ascending) throws IdentityException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public Collection<Group> findAssociatedGroups(Identity identity, GroupType
groupType, int offset, int limit, String orderedByAttributeName, boolean ascending) throws
IdentityException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public Collection<Identity> findAssociatedIdentities(Group group, boolean
inherited, int offset, int limit, String orderedByAttributeName, boolean ascending) throws
IdentityException
+ {
+ throw new NotYetImplementedException();
+ }
+}
Added: trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/RoleHandler.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/RoleHandler.java
(rev 0)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/RoleHandler.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -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.impl.api;
+
+import org.jboss.identity.spi.model.IdentityObjectRelationship;
+import org.jboss.identity.spi.model.IdentityObjectRelationshipType;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class RoleHandler
+{
+
+ boolean isNamedRole(IdentityObjectRelationshipType rt)
+ {
+ return false;
+ }
+
+ IdentityObjectRelationshipType createRelationshipType(String roleName)
+ {
+ return null;
+ }
+
+ String resolveRoleName(IdentityObjectRelationshipType rt)
+ {
+ return null;
+ }
+
+}
Added: trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/RoleManagerImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/RoleManagerImpl.java
(rev 0)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/RoleManagerImpl.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -0,0 +1,246 @@
+/*
+* 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.impl.api;
+
+import org.jboss.identity.api.RoleManager;
+import org.jboss.identity.api.IdentitySession;
+import org.jboss.identity.api.RoleType;
+import org.jboss.identity.api.Role;
+import org.jboss.identity.api.Identity;
+import org.jboss.identity.api.Group;
+import org.jboss.identity.api.IdentityType;
+import org.jboss.identity.exception.IdentityException;
+import org.jboss.identity.spi.model.IdentityObjectRelationshipType;
+import org.jboss.identity.spi.model.IdentityObjectRelationship;
+import org.jboss.identity.spi.exception.OperationNotSupportedException;
+import org.jboss.identity.impl.NotYetImplementedException;
+
+import java.util.Collection;
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class RoleManagerImpl extends AbstractManager implements RoleManager
+{
+ public static final IdentityObjectRelationshipType ROLE = new
IdentityObjectRelationshipType()
+ {
+ public String getName()
+ {
+ return "JBOSS_IDENTITY_ROLE";
+ }
+ };
+
+ public RoleManagerImpl(IdentitySession session)
+ {
+ super(session);
+ }
+
+ public RoleType createRoleType(String name) throws IdentityException
+ {
+ String roleType = null;
+
+ try
+ {
+ roleType = getRepository().createRelationshipName(getInvocationContext(),
name);
+ }
+ catch (OperationNotSupportedException e)
+ {
+ throw new IdentityException("Role management not supported");
+ }
+
+ return new SimpleRoleType(roleType);
+ }
+
+ public void removeRoleType(String name) throws IdentityException
+ {
+ try
+ {
+ getRepository().removeRelationshipName(getInvocationContext(), name);
+ }
+ catch (OperationNotSupportedException e)
+ {
+ throw new IdentityException("Role management not supported");
+ }
+ }
+
+ public void removeRoleType(RoleType roleType) throws IdentityException
+ {
+ removeRoleType(roleType.getName());
+ }
+
+ public RoleType getRoleType(String name) throws IdentityException
+ {
+ try
+ {
+ Set<String> names =
getRepository().getRelationshipNames(getInvocationContext(), 0, 0, false, false);
+ if (names.contains(name))
+ {
+ return new SimpleRoleType(name);
+ }
+ }
+ catch (OperationNotSupportedException e)
+ {
+ throw new IdentityException("Role management not supported");
+ }
+
+ return null;
+ }
+
+ public Collection<RoleType> findRoleTypes(int offset, int limit, boolean
orderedByName, boolean ascending) throws IdentityException
+ {
+
+ try
+ {
+ Set<String> names =
getRepository().getRelationshipNames(getInvocationContext(), offset, limit, orderedByName,
ascending);
+ Set<RoleType> types = new HashSet<RoleType>();
+
+ for (String name : names)
+ {
+ types.add(new SimpleRoleType(name));
+ }
+
+ return types;
+ }
+ catch (OperationNotSupportedException e)
+ {
+ throw new IdentityException("Role management not supported");
+ }
+
+ }
+
+ public Role createRole(RoleType roleType, Identity identity, Group group) throws
IdentityException
+ {
+ //TODO: add createRoleType switch to the API
+
+ IdentityObjectRelationship rel =
getRepository().createRelationship(getInvocationContext(), createIdentityObject(identity),
createIdentityObject(group), ROLE, roleType.getName(), false);
+
+ //TODO: null id - IdentityObjectRelationship doesn't have id
+ return new SimpleRoleImpl(null, new SimpleRoleType(rel.getName()),
createIdentity(rel.getFromIdentityObject()), createGroup(rel.getToIdentityObject()));
+
+ }
+
+ public void removeRole(RoleType roleType, Identity identity, Group group) throws
IdentityException
+ {
+ getRepository().removeRelationship(getInvocationContext(),
createIdentityObject(identity), createIdentityObject(group), ROLE, roleType.getName());
+ }
+
+ public void removeRole(Role role) throws IdentityException
+ {
+ getRepository().removeRelationship(getInvocationContext(),
createIdentityObject(role.getIdentity()), createIdentityObject(role.getGroup()), ROLE,
role.getRoleType().getName());
+ }
+
+ public boolean hasRole(Identity identity, Group group, RoleType roleType) throws
IdentityException
+ {
+ //TODO: add hasRelationship to IdentityStore
+
+ Set<IdentityObjectRelationship> rels =
getRepository().resolveRelationships(getInvocationContext(),
createIdentityObject(identity), createIdentityObject(group));
+
+ for (IdentityObjectRelationship rel : rels)
+ {
+ if (rel.getType().getName().equals(ROLE.getName()) && rel.getName() !=
null && rel.getName().equals(roleType.getName()))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public Collection<RoleType> findRoleTypes(Identity identity, Group group, int
offset, int limit, boolean orderedByName, boolean ascending) throws IdentityException
+ {
+ //TODO: improve IdentityStore SPI....
+
+
+ Set<IdentityObjectRelationship> rels =
getRepository().resolveRelationships(getInvocationContext(),
createIdentityObject(identity), createIdentityObject(group));
+ Set<RoleType> types = new HashSet<RoleType>();
+
+ for (IdentityObjectRelationship rel : rels)
+ {
+ if (rel.getType().getName().equals(ROLE.getName()))
+ {
+ types.add(new SimpleRoleType(rel.getName()));
+ }
+ }
+
+ return types;
+
+
+ }
+
+ public Collection<RoleType> findIdentityRoleTypes(Identity identity, int offset,
int limit, boolean orderedByName, boolean ascending) throws IdentityException
+ {
+ Set<RoleType> types = new HashSet<RoleType>();
+
+ try
+ {
+ Collection<String> names =
getRepository().getRelationshipNames(getInvocationContext(),
createIdentityObject(identity), offset, limit, orderedByName, ascending);
+
+ for (String name : names)
+ {
+ types.add(new SimpleRoleType(name));
+ }
+
+ return types;
+
+ }
+ catch (OperationNotSupportedException e)
+ {
+ throw new IdentityException("Role management not supported");
+ }
+
+
+
+
+ }
+
+ public Collection<RoleType> findGroupRoleTypes(Group group, int offset, int
limit, boolean orderedByName, boolean ascending) throws IdentityException
+ {
+ Set<RoleType> types = new HashSet<RoleType>();
+
+ try
+ {
+ Collection<String> names =
getRepository().getRelationshipNames(getInvocationContext(), createIdentityObject(group),
offset, limit, orderedByName, ascending);
+
+ for (String name : names)
+ {
+ types.add(new SimpleRoleType(name));
+ }
+
+ return types;
+
+ }
+ catch (OperationNotSupportedException e)
+ {
+ throw new IdentityException("Role management not supported");
+ }
+
+ }
+
+ public <T extends IdentityType> Collection<Role> findRoles(T identityType,
RoleType roleType, int offset, int limit, boolean orderedByName, boolean ascending) throws
IdentityException
+ {
+ throw new NotYetImplementedException();
+ }
+}
Added: trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SessionWrapper.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SessionWrapper.java
(rev 0)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SessionWrapper.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -0,0 +1,83 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+package org.jboss.identity.impl.api;
+
+import org.jboss.identity.exception.IdentityException;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface SessionWrapper
+{
+
+ /**
+ * Close this session
+ * @throws org.jboss.identity.exception.IdentityException
+ */
+ void close() throws IdentityException;
+
+ /**
+ * Save all pending changes
+ * @throws org.jboss.identity.exception.IdentityException
+ */
+ void save() throws IdentityException;
+
+ /**
+ * Clear this session
+ * @throws org.jboss.identity.exception.IdentityException
+ */
+ void clear() throws IdentityException;
+
+ /**
+ * Check if this session is open
+ * @return
+ */
+ boolean isOpen();
+
+
+ boolean isTransactionSupported();
+
+ /**
+ * Begin new transaction
+ */
+ void startTransaction();
+
+ /**
+ * Commit transaction - flush associated session
+ */
+ void commitTransaction();
+
+ /**
+ * Rollback transaction
+ */
+ void rollbackTransaction();
+
+ /**
+ *
+ * @return
+ */
+ boolean isTransactionActive();
+
+
+}
Added: trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SimpleGroupImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SimpleGroupImpl.java
(rev 0)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SimpleGroupImpl.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -0,0 +1,67 @@
+/*
+* 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.impl.api;
+
+import org.jboss.identity.api.Group;
+import org.jboss.identity.api.GroupType;
+import org.jboss.identity.spi.model.IdentityObject;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class SimpleGroupImpl implements Group
+{
+ private final String name;
+
+ private final Object id;
+
+ private final GroupType groupType;
+
+ public SimpleGroupImpl(String name, Object id, GroupType groupType)
+ {
+ this.name = name;
+ this.id = id;
+ this.groupType = groupType;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public GroupType getGroupType()
+ {
+ return groupType;
+ }
+
+ public Object getId()
+ {
+ return id;
+ }
+
+ public String getDescription()
+ {
+ return null;
+ }
+}
Added: trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SimpleGroupType.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SimpleGroupType.java
(rev 0)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SimpleGroupType.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -0,0 +1,47 @@
+/*
+* 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.impl.api;
+
+import org.jboss.identity.api.GroupType;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class SimpleGroupType implements GroupType
+{
+
+ private final String name;
+
+ public SimpleGroupType(String name)
+ {
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+
+}
Added:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SimpleIdentityImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SimpleIdentityImpl.java
(rev 0)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SimpleIdentityImpl.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -0,0 +1,63 @@
+/*
+* 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.impl.api;
+
+import org.jboss.identity.api.Identity;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class SimpleIdentityImpl implements Identity
+{
+ private final String name;
+
+ private final Object id;
+
+
+ public SimpleIdentityImpl(String name, Object id)
+ {
+ this.name = name;
+ this.id = id;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public boolean isVirtual()
+ {
+ return false;
+ }
+
+ public Object getId()
+ {
+ return id;
+ }
+
+ public String getDescription()
+ {
+ return null;
+ }
+}
Added: trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SimpleRoleImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SimpleRoleImpl.java
(rev 0)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SimpleRoleImpl.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -0,0 +1,76 @@
+/*
+* 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.impl.api;
+
+import org.jboss.identity.api.Role;
+import org.jboss.identity.api.RoleType;
+import org.jboss.identity.api.Identity;
+import org.jboss.identity.api.Group;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class SimpleRoleImpl implements Role
+{
+ private final Object id;
+
+ private final RoleType type;
+
+ private final Identity identity;
+
+ private final Group group;
+
+ public SimpleRoleImpl(Object id, RoleType type, Identity identity, Group group)
+ {
+ this.id = id;
+ this.type = type;
+ this.identity = identity;
+ this.group = group;
+ }
+
+ public Object getId()
+ {
+ return id;
+ }
+
+ public Identity getIdentity()
+ {
+ return identity;
+ }
+
+ public Group getGroup()
+ {
+ return group;
+ }
+
+ public String getDescription()
+ {
+ return null;
+ }
+
+ public RoleType getRoleType()
+ {
+ return type;
+ }
+}
Added: trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SimpleRoleType.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SimpleRoleType.java
(rev 0)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SimpleRoleType.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -0,0 +1,74 @@
+/*
+* 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.impl.api;
+
+import org.jboss.identity.api.RoleType;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class SimpleRoleType implements RoleType
+{
+ private final String name;
+
+ public SimpleRoleType(String name)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("name cannot be null");
+ }
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ SimpleRoleType that = (SimpleRoleType)o;
+
+ if (name != null ? !name.equals(that.name) : that.name != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ return (name != null ? name.hashCode() : 0);
+ }
+}
Added:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SimpleTransactionImpl.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SimpleTransactionImpl.java
(rev 0)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SimpleTransactionImpl.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -0,0 +1,79 @@
+/*
+* 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.impl.api;
+
+import org.jboss.identity.api.Transaction;
+
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class SimpleTransactionImpl implements Transaction
+{
+ private final Set<SessionWrapper> sessionWrappers;
+
+ public SimpleTransactionImpl(Set<SessionWrapper> sessionWrappers)
+ {
+ this.sessionWrappers = sessionWrappers;
+ }
+
+ public void start()
+ {
+ for (SessionWrapper sessionWrapper : sessionWrappers)
+ {
+ sessionWrapper.startTransaction();
+ }
+ }
+
+ public void commit()
+ {
+ for (SessionWrapper sessionWrapper : sessionWrappers)
+ {
+ sessionWrapper.commitTransaction();
+ }
+ }
+
+ public void rollback()
+ {
+ for (SessionWrapper sessionWrapper : sessionWrappers)
+ {
+ sessionWrapper.rollbackTransaction();
+ }
+ }
+
+ public boolean isActive()
+ {
+
+ for (SessionWrapper sessionWrapper : sessionWrappers)
+ {
+ if (sessionWrapper.isTransactionActive())
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+}
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateIdentityObjectRelationshipName.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateIdentityObjectRelationshipName.java 2008-10-15
10:59:42 UTC (rev 103)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateIdentityObjectRelationshipName.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -28,6 +28,7 @@
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
@@ -52,6 +53,7 @@
public class HibernateIdentityObjectRelationshipName
{
@Id
+ @GeneratedValue
Long id;
@Column(nullable = false, unique = true, name = "NAME")
Added:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/repository/AbstractIdentityStoreRepository.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/repository/AbstractIdentityStoreRepository.java
(rev 0)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/repository/AbstractIdentityStoreRepository.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -0,0 +1,97 @@
+/*
+* 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.impl.repository;
+
+import org.jboss.identity.spi.repository.IdentityStoreRepository;
+import org.jboss.identity.spi.store.IdentityStore;
+import org.jboss.identity.spi.store.AttributeStore;
+import org.jboss.identity.spi.model.IdentityObjectType;
+
+import java.util.Set;
+import java.util.Map;
+import java.util.HashSet;
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public abstract class AbstractIdentityStoreRepository implements IdentityStoreRepository
+{
+
+ private final Map<String, IdentityStore> identityStoreMappings;
+
+ private final Map<String, AttributeStore> attributeStoreMappings;
+
+ public AbstractIdentityStoreRepository(Map<String, IdentityStore>
identityStoreMappings, Map<String, AttributeStore> attributeStoreMappings)
+ {
+ if (identityStoreMappings != null)
+ {
+ this.identityStoreMappings =
Collections.unmodifiableMap(identityStoreMappings);
+ }
+ else
+ {
+ this.identityStoreMappings = null;
+ }
+
+ if (attributeStoreMappings != null)
+ {
+ this.attributeStoreMappings =
Collections.unmodifiableMap(attributeStoreMappings);
+ }
+ else
+ {
+ this.attributeStoreMappings = null;
+ }
+
+ }
+
+ public Set<IdentityStore> getConfiguredIdentityStores()
+ {
+ return new HashSet<IdentityStore>(identityStoreMappings.values());
+ }
+
+ public Set<AttributeStore> getConfiguredAttributeStores()
+ {
+ return new HashSet<AttributeStore>(attributeStoreMappings.values());
+ }
+
+ public Map<String, IdentityStore> getIdentityStoreMappings()
+ {
+ return identityStoreMappings;
+ }
+
+ public Map<String, AttributeStore> getAttributeStoreMappings()
+ {
+ return attributeStoreMappings;
+ }
+
+ public IdentityStore getIdentityStore(IdentityObjectType identityObjectType)
+ {
+ return identityStoreMappings.get(identityObjectType.getName());
+ }
+
+ public AttributeStore getAttributeStore(IdentityObjectType identityObjectType)
+ {
+ return attributeStoreMappings.get(identityObjectType.getName());
+ }
+}
Added:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/repository/WrapperIdentityStoreRepository.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/repository/WrapperIdentityStoreRepository.java
(rev 0)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/repository/WrapperIdentityStoreRepository.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -0,0 +1,198 @@
+/*
+* 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.impl.repository;
+
+import org.jboss.identity.spi.repository.IdentityStoreRepository;
+import org.jboss.identity.spi.store.IdentityStore;
+import org.jboss.identity.spi.store.AttributeStore;
+import org.jboss.identity.spi.store.FeaturesDescription;
+import org.jboss.identity.spi.store.IdentityStoreInvocationContext;
+import org.jboss.identity.spi.model.IdentityObject;
+import org.jboss.identity.spi.model.IdentityObjectType;
+import org.jboss.identity.spi.model.IdentityObjectRelationshipType;
+import org.jboss.identity.spi.model.IdentityObjectRelationship;
+import org.jboss.identity.spi.exception.OperationNotSupportedException;
+import org.jboss.identity.exception.IdentityException;
+
+import java.util.Map;
+import java.util.Collection;
+import java.util.Set;
+import java.io.IOException;
+
+/**
+ * Simply wraps IdentityStore and AttributeStore and delegates all the calls
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class WrapperIdentityStoreRepository extends AbstractIdentityStoreRepository
+{
+
+ private final IdentityStore identityStore;
+
+ private final AttributeStore attributeStore;
+
+ public WrapperIdentityStoreRepository(IdentityStore identityStore, AttributeStore
attributeStore,
+ Map<String, IdentityStore>
identityStoreMappings, Map<String, AttributeStore> attributeStoreMappings)
+ {
+ super(identityStoreMappings, attributeStoreMappings);
+
+ this.identityStore = identityStore;
+ this.attributeStore = attributeStore;
+ }
+
+ public void bootstrap() throws IOException
+ {
+
+ }
+
+ public String getId()
+ {
+ return null;
+ }
+
+ public FeaturesDescription getSupportedFeatures()
+ {
+ return null;
+ }
+
+ public IdentityObject createIdentityObject(IdentityStoreInvocationContext
invocationCtx, String name, IdentityObjectType identityObjectType) throws
IdentityException
+ {
+ return identityStore.createIdentityObject(invocationCtx, name,
identityObjectType);
+ }
+
+ public void removeIdentityObject(IdentityStoreInvocationContext invocationCtx,
IdentityObject identity) throws IdentityException
+ {
+ identityStore.removeIdentityObject(invocationCtx, identity);
+ }
+
+ public int getIdentityObjectsCount(IdentityStoreInvocationContext invocationCtx,
IdentityObjectType identityType) throws IdentityException
+ {
+ return identityStore.getIdentityObjectsCount(invocationCtx, identityType);
+ }
+
+ public IdentityObject findIdentityObject(IdentityStoreInvocationContext
invocationContext, String name, IdentityObjectType identityObjectType) throws
IdentityException
+ {
+ return identityStore.findIdentityObject(invocationContext, name,
identityObjectType);
+ }
+
+ public IdentityObject findIdentityObject(IdentityStoreInvocationContext
invocationContext, Object id) throws IdentityException
+ {
+ return identityStore.findIdentityObject(invocationContext, id);
+ }
+
+ public Collection<IdentityObject>
findIdentityObject(IdentityStoreInvocationContext invocationCtx, IdentityObjectType
identityType, String nameFilter, int offset, int limit, boolean orderByName, boolean
ascending) throws IdentityException
+ {
+ return identityStore.findIdentityObject(invocationCtx, identityType, nameFilter,
offset, limit, orderByName, ascending);
+ }
+
+ public Collection<IdentityObject>
findIdentityObject(IdentityStoreInvocationContext invocationCtx, IdentityObjectType
identityType, Map<String, String[]> attributes, int offset, int limit, boolean
orderByName, boolean ascending) throws IdentityException
+ {
+ return identityStore.findIdentityObject(invocationCtx, identityType, attributes,
offset, limit, orderByName, ascending);
+ }
+
+ public Collection<IdentityObject>
findIdentityObject(IdentityStoreInvocationContext invocationCxt, IdentityObject identity,
IdentityObjectRelationshipType relationshipType, boolean parent, int offset, int limit,
boolean orderByName, boolean ascending) throws IdentityException
+ {
+ return identityStore.findIdentityObject(invocationCxt, identity, relationshipType,
parent, offset, limit, orderByName, ascending);
+ }
+
+ public IdentityObjectRelationship createRelationship(IdentityStoreInvocationContext
invocationCxt, IdentityObject fromIdentity, IdentityObject toIdentity,
IdentityObjectRelationshipType relationshipType, String relationshipName, boolean
createNames) throws IdentityException
+ {
+ return identityStore.createRelationship(invocationCxt, fromIdentity, toIdentity,
relationshipType, relationshipName, createNames);
+ }
+
+ public void removeRelationship(IdentityStoreInvocationContext invocationCxt,
IdentityObject fromIdentity, IdentityObject toIdentity, IdentityObjectRelationshipType
relationshipType, String relationshipName) throws IdentityException
+ {
+ identityStore.removeRelationship(invocationCxt, fromIdentity, toIdentity,
relationshipType, relationshipName);
+ }
+
+ public void removeRelationships(IdentityStoreInvocationContext invocationCtx,
IdentityObject identity1, IdentityObject identity2, boolean named) throws
IdentityException
+ {
+ identityStore.removeRelationships(invocationCtx, identity1, identity2, named);
+ }
+
+ public Set<IdentityObjectRelationship>
resolveRelationships(IdentityStoreInvocationContext invocationCxt, IdentityObject
fromIdentity, IdentityObject toIdentity) throws IdentityException
+ {
+ return identityStore.resolveRelationships(invocationCxt, fromIdentity,
toIdentity);
+ }
+
+ public String createRelationshipName(IdentityStoreInvocationContext ctx, String name)
throws IdentityException, OperationNotSupportedException
+ {
+ return identityStore.createRelationshipName(ctx, name);
+ }
+
+ public String removeRelationshipName(IdentityStoreInvocationContext ctx, String name)
throws IdentityException, OperationNotSupportedException
+ {
+ return identityStore.removeRelationshipName(ctx, name);
+ }
+
+ public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx, int
offset, int limit, boolean orderByName, boolean ascending) throws IdentityException,
OperationNotSupportedException
+ {
+ return identityStore.getRelationshipNames(ctx, offset, limit, orderByName,
ascending);
+ }
+
+ public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx,
IdentityObject identity, int offset, int limit, boolean orderByName, boolean ascending)
throws IdentityException, OperationNotSupportedException
+ {
+ return identityStore.getRelationshipNames(ctx, identity, offset, limit,
orderByName, ascending);
+ }
+
+ public boolean hasPasswordAttribute(IdentityStoreInvocationContext ctx,
IdentityObjectType type) throws IdentityException
+ {
+ return identityStore.hasPasswordAttribute(ctx, type);
+ }
+
+ public boolean validatePassword(IdentityStoreInvocationContext ctx, IdentityObject
identityObject, String password) throws IdentityException
+ {
+ return identityStore.validatePassword(ctx, identityObject, password);
+ }
+
+ public void updatePassword(IdentityStoreInvocationContext ctx, IdentityObject
identityObject, String password) throws IdentityException
+ {
+ identityStore.updatePassword(ctx, identityObject, password);
+ }
+
+ public <T extends IdentityObjectType> Set<String>
getSupportedAttributeNames(IdentityStoreInvocationContext invocationContext, T
identityType) throws IdentityException
+ {
+ return attributeStore.getSupportedAttributeNames(invocationContext, identityType);
+ }
+
+ public Map<String, Set<String>>
getAttributes(IdentityStoreInvocationContext invocationContext, IdentityObject identity)
throws IdentityException
+ {
+ return attributeStore.getAttributes(invocationContext, identity);
+ }
+
+ public void updateAttributes(IdentityStoreInvocationContext invocationCtx,
IdentityObject identity, Map<String, Set<String>> attributes) throws
IdentityException
+ {
+ attributeStore.updateAttributes(invocationCtx, identity, attributes);
+ }
+
+ public void addAttributes(IdentityStoreInvocationContext invocationCtx, IdentityObject
identity, Map<String, Set<String>> attributes) throws IdentityException
+ {
+ attributeStore.addAttributes(invocationCtx, identity, attributes);
+ }
+
+ public void removeAttributes(IdentityStoreInvocationContext invocationCtx,
IdentityObject identity, Set<String> attributes) throws IdentityException
+ {
+ attributeStore.removeAttributes(invocationCtx, identity, attributes);
+ }
+}
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/hibernate/HibernateIdentityStoreImpl.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/hibernate/HibernateIdentityStoreImpl.java 2008-10-15
10:59:42 UTC (rev 103)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/hibernate/HibernateIdentityStoreImpl.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -74,6 +74,10 @@
"select r from HibernateIdentityObjectRelationship r where
r.fromIdentityObject like :fromIO and " +
"r.toIdentityObject like :toIO and r.type.name like :typeName";
+ private final String QUERY_RELATIONSHIP_BY_FROM_TO_TYPE_NAME =
+ "select r from HibernateIdentityObjectRelationship r where
r.fromIdentityObject like :fromIO and " +
+ "r.toIdentityObject like :toIO and r.type.name like :typeName and
r.name.name like :name";
+
private final String QUERY_RELATIONSHIP_BY_IDENTITIES =
"select r from HibernateIdentityObjectRelationship r where " +
"(r.fromIdentityObject like :IO1 and r.toIdentityObject like :IO2) or
" +
@@ -364,7 +368,7 @@
return results;
}
- public void createRelationship(IdentityStoreInvocationContext ctx, IdentityObject
fromIdentity, IdentityObject toIdentity,
+ public IdentityObjectRelationship createRelationship(IdentityStoreInvocationContext
ctx, IdentityObject fromIdentity, IdentityObject toIdentity,
IdentityObjectRelationshipType relationshipType,
String name, boolean createNames) throws
IdentityException
{
@@ -382,10 +386,11 @@
getSupportedFeatures().isRelationshipTypeSupported(fromIO.getIdentityType(),
toIO.getIdentityType(), relationshipType);
- org.hibernate.Query query =
getHibernateEntityManager(ctx).getSession().createQuery(QUERY_RELATIONSHIP_BY_FROM_TO_TYPE)
+ org.hibernate.Query query =
getHibernateEntityManager(ctx).getSession().createQuery(QUERY_RELATIONSHIP_BY_FROM_TO_TYPE_NAME)
.setParameter("fromIO", fromIO)
.setParameter("toIO", toIO)
- .setParameter("typeName", type.getName());
+ .setParameter("typeName", type.getName())
+ .setParameter("name", name);
List results = query.list();
@@ -394,8 +399,23 @@
throw new IdentityException("Relationship already present");
}
- HibernateIdentityObjectRelationship relationship = new
HibernateIdentityObjectRelationship(type, fromIO, toIO);
+ HibernateIdentityObjectRelationship relationship = null;
+
+ if (name != null)
+ {
+
+ HibernateIdentityObjectRelationshipName relationshipName =
(HibernateIdentityObjectRelationshipName)getHibernateEntityManager(ctx).getSession().createCriteria(HibernateIdentityObjectRelationshipName.class).add(Restrictions.eq("name",
name)).uniqueResult();
+
+ relationship = new HibernateIdentityObjectRelationship(type, fromIO, toIO,
relationshipName);
+ }
+ else
+ {
+ relationship = new HibernateIdentityObjectRelationship(type, fromIO, toIO);
+ }
+
getHibernateEntityManager(ctx).persist(relationship);
+
+ return relationship;
}
@@ -414,12 +434,25 @@
getSupportedFeatures().isRelationshipTypeSupported(fromIO.getIdentityType(),
toIO.getIdentityType(), relationshipType);
+ org.hibernate.Query query = null;
- org.hibernate.Query query =
getHibernateEntityManager(ctx).getSession().createQuery(QUERY_RELATIONSHIP_BY_FROM_TO_TYPE)
- .setParameter("fromIO", fromIO)
- .setParameter("toIO", toIO)
- .setParameter("typeName", type.getName());
+ if (name == null)
+ {
+ query =
getHibernateEntityManager(ctx).getSession().createQuery(QUERY_RELATIONSHIP_BY_FROM_TO_TYPE)
+ .setParameter("fromIO", fromIO)
+ .setParameter("toIO", toIO)
+ .setParameter("typeName", type.getName());
+ }
+ else
+ {
+ query =
getHibernateEntityManager(ctx).getSession().createQuery(QUERY_RELATIONSHIP_BY_FROM_TO_TYPE_NAME)
+ .setParameter("fromIO", fromIO)
+ .setParameter("toIO", toIO)
+ .setParameter("typeName", type.getName())
+ .setParameter("name", name);
+ }
+
List results = query.list();
if (results == null)
@@ -755,7 +788,7 @@
}
catch (NoResultException e)
{
- throw new IdentityException("IdentityObjectType[ " + type.getName() +
"] not present in the store.");
+ throw new IdentityException("IdentityObjectType[" + type.getName() +
"] not present in the store.");
}
return hibernateType;
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/ldap/LDAPIdentityStore.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/ldap/LDAPIdentityStore.java 2008-10-15
10:59:42 UTC (rev 103)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/ldap/LDAPIdentityStore.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -673,7 +673,7 @@
return objects;
}
- public void createRelationship(IdentityStoreInvocationContext ctx, IdentityObject
fromIdentity, IdentityObject toIdentity,
+ public IdentityObjectRelationship createRelationship(IdentityStoreInvocationContext
ctx, IdentityObject fromIdentity, IdentityObject toIdentity,
IdentityObjectRelationshipType relationshipType,
String name, boolean createNames) throws
IdentityException
{
@@ -689,6 +689,8 @@
);
}
+ LDAPIdentityObjectRelationshipImpl relationship = null;
+
LDAPIdentityObjectImpl ldapFromIO = getSafeLDAPIO(ctx, fromIdentity);
LDAPIdentityObjectImpl ldapToIO = getSafeLDAPIO(ctx, toIdentity);
@@ -725,6 +727,8 @@
ldapContext.modifyAttributes(ldapFromIO.getDn(), DirContext.REPLACE_ATTRIBUTE,
attrs);
+ relationship = new LDAPIdentityObjectRelationshipImpl(name, ldapFromIO,
ldapToIO);
+
}
catch (NamingException e)
{
@@ -741,6 +745,9 @@
throw new IdentityException("Failed to close LDAP connection", e);
}
}
+
+
+ return relationship;
}
public void removeRelationship(IdentityStoreInvocationContext ctx, IdentityObject
fromIdentity, IdentityObject toIdentity, IdentityObjectRelationshipType relationshipType,
String name) throws IdentityException
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/types/SimpleIdentityObject.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/types/SimpleIdentityObject.java 2008-10-15
10:59:42 UTC (rev 103)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/types/SimpleIdentityObject.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -35,8 +35,7 @@
/**
- * Very simple identity
- * @author Anil.Saldhana(a)redhat.com
+ * Very simple identity object
* @author boleslaw dot dawidowicz at redhat anotherdot com
*
* @since Aug 6, 2008
@@ -44,51 +43,40 @@
public class SimpleIdentityObject implements IdentityObject
{
- public IdentityObjectType getIdentityType()
+
+ private final String name;
+
+ private final Object id;
+
+ private final IdentityObjectType type;
+
+ public SimpleIdentityObject(String name, Object id, IdentityObjectType type)
{
- return null;
+ this.name = name;
+ this.id = id;
+ this.type = type;
}
- protected String name;
- protected List<IdentityObjectAttribute> attributes = Collections.emptyList();
- protected List<Group> groups = Collections.emptyList();
- protected List<Role> roles = Collections.emptyList();
-
- public SimpleIdentityObject(String n)
+ public String getName()
{
- this.name = n;
+ return name;
}
public Object getId()
{
- return null;
+ return id;
}
- public String getFQDN()
+ public IdentityObjectType getIdentityType()
{
- return null;
+ return type;
}
- public Map<String, Set<String>> getAttributes()
+ public String getFQDN()
{
return null;
}
- public List<Group> getGroups()
- {
- return Collections.unmodifiableList(groups);
- }
-
- public List<Role> getRoles()
- {
- return Collections.unmodifiableList(roles);
- }
-
- public String getName()
- {
- return name;
- }
-
public void validatePolicy() throws PolicyValidationException
{
Added:
trunk/identity-impl/src/test/java/org/jboss/identity/impl/HibernateTestSupport.java
===================================================================
--- trunk/identity-impl/src/test/java/org/jboss/identity/impl/HibernateTestSupport.java
(rev 0)
+++
trunk/identity-impl/src/test/java/org/jboss/identity/impl/HibernateTestSupport.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -0,0 +1,130 @@
+/*
+* 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.impl;
+
+import org.jboss.identity.impl.model.hibernate.HibernateIdentityObjectRelationshipType;
+import org.jboss.identity.impl.model.hibernate.HibernateIdentityObjectType;
+import org.hibernate.ejb.HibernateEntityManagerFactory;
+import org.hibernate.ejb.HibernateEntityManager;
+
+import javax.persistence.Persistence;
+import java.util.logging.Logger;
+import java.sql.Connection;
+import java.sql.DriverManager;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class HibernateTestSupport
+{
+ private static Logger logger =
Logger.getLogger(HibernateTestSupport.class.getName());
+
+ private HibernateEntityManagerFactory emFactory;
+
+ protected HibernateEntityManager em;
+
+ private Connection connection;
+
+ public HibernateEntityManager getHibernateEntityManager()
+ {
+ return em;
+ }
+
+
+ public void start() throws Exception {
+ try {
+ logger.info("Starting in-memory HSQL database for unit tests");
+ Class.forName("org.hsqldb.jdbcDriver");
+ connection =
DriverManager.getConnection("jdbc:hsqldb:mem:unit-testing-jpa", "sa",
"");
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ logger.fine("Exception during HSQL database startup.");
+ throw ex;
+ }
+ try
+ {
+ logger.info("Building JPA EntityManager for unit tests");
+ emFactory =
(HibernateEntityManagerFactory)Persistence.createEntityManagerFactory("jboss-identity-model");
+ em = (HibernateEntityManager)emFactory.createEntityManager();
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ logger.fine("Exception during JPA EntityManager instanciation.");
+ throw ex;
+ }
+ }
+
+ public void stop() throws Exception {
+ logger.info("Shuting down Hibernate JPA layer.");
+ if (em != null)
+ {
+ em.close();
+ }
+ if (emFactory != null)
+ {
+ emFactory.close();
+ }
+ logger.info("Stopping in-memory HSQL database.");
+ try
+ {
+ connection.createStatement().execute("SHUTDOWN");
+ }
+ catch (Exception ex) {
+ throw ex;
+ }
+ }
+
+ public void populateObjectTypes(String[] typeNames) throws Exception
+ {
+
+ em.getTransaction().begin();
+
+ for (String typeName : typeNames)
+ {
+ HibernateIdentityObjectType hibernateType = new
HibernateIdentityObjectType(typeName);
+ em.persist(hibernateType);
+ }
+
+ em.getTransaction().commit();
+ }
+
+ public void populateRelationshipTypes(String[] typeNames) throws Exception
+ {
+
+ em.getTransaction().begin();
+
+ for (String typeName : typeNames)
+ {
+ HibernateIdentityObjectRelationshipType hibernateType = new
HibernateIdentityObjectRelationshipType(typeName);
+ em.persist(hibernateType);
+ }
+
+ em.getTransaction().commit();
+ }
+
+
+}
Added: trunk/identity-impl/src/test/java/org/jboss/identity/impl/api/APITestCase.java
===================================================================
--- trunk/identity-impl/src/test/java/org/jboss/identity/impl/api/APITestCase.java
(rev 0)
+++
trunk/identity-impl/src/test/java/org/jboss/identity/impl/api/APITestCase.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -0,0 +1,132 @@
+/*
+* 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.impl.api;
+
+import junit.framework.TestCase;
+import org.jboss.identity.impl.HibernateTestSupport;
+import org.jboss.identity.impl.store.hibernate.HibernateIdentityStoreImpl;
+import org.jboss.identity.impl.store.hibernate.HibernateIdentityStoreInvocationContext;
+import org.jboss.identity.impl.repository.WrapperIdentityStoreRepository;
+import org.jboss.identity.api.IdentitySessionFactory;
+import org.jboss.identity.api.IdentitySession;
+import org.jboss.identity.spi.repository.IdentityStoreRepository;
+import org.jboss.identity.spi.store.IdentityStoreInvocationContext;
+import org.hibernate.ejb.HibernateEntityManager;
+
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class APITestCase extends TestCase implements APITestContext
+{
+ HibernateTestSupport hibernateSupport = new HibernateTestSupport();
+
+ OrganizationTest orgTest;
+
+ IdentitySessionFactory identitySessionFactory;
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ hibernateSupport.start();
+ orgTest = new OrganizationTest(this);
+
+ }
+
+ protected void tearDown() throws Exception
+ {
+ hibernateSupport.stop();
+ }
+
+ public void testOrganization() throws Exception
+ {
+ prepareRealm(OrganizationTest.RED_HAT_REALM, new String[]{"IDENTITY",
"ORGANIZATION", "ORGANIZATION_UNIT", "DIVISION",
"DEPARTMENT", "PROJECT", "PEOPLE"});
+ orgTest.testRedHatOrganization();
+ }
+
+ public void testSamplePortal() throws Exception
+ {
+ prepareRealm(OrganizationTest.PORTAL_REALM, new String[]{"IDENTITY",
"SYSTEM", "ADMINISTRATION", "COMMUNITY",
"ORGANIZATION", "ORGANIZATION_UNIT", "OFFICE",
"DIVISION", "DEPARTMENT", "SECURITY", "PEOPLE"});
+ orgTest.testSamplePortal();
+ }
+
+ private void prepareRealm(String realmName, String[] objectTypes) throws Exception
+ {
+
+ Set<SessionWrapper> sessionWrappers = new HashSet<SessionWrapper>();
+ sessionWrappers.add(new
EntityManagerWrapper(hibernateSupport.getHibernateEntityManager()));
+
+ hibernateSupport.populateObjectTypes(objectTypes);
+ hibernateSupport.populateRelationshipTypes(new
String[]{"JBOSS_IDENTITY_MEMBERSHIP", "JBOSS_IDENTITY_ROLE"});
+
+ HibernateIdentityStoreImpl store = new HibernateIdentityStoreImpl();
+
+ ;
+
+ IdentityStoreRepository repository = new WrapperIdentityStoreRepository(store,
store, null, null);
+
+ IdentityObjectTypeMapper iotMapper = new
DirectIdentityObjectTypeMapperImpl("IDENTITY");
+
+ final HibernateIdentityStoreInvocationContext hibernateInvocationContext = new
HibernateIdentityStoreInvocationContext()
+ {
+ public HibernateEntityManager getHibernateEntityManager()
+ {
+ return hibernateSupport.getHibernateEntityManager();
+ }
+ };
+
+ IdentityStoreInvocationContextResolver contextResolver = new
IdentityStoreInvocationContextResolver()
+ {
+ public IdentityStoreInvocationContext resolveInvocationContext()
+ {
+ return hibernateInvocationContext;
+ }
+ };
+
+ IdentitySessionContext identitySessionContext = new
IdentitySessionContextImpl(repository, iotMapper, contextResolver);
+
+ IdentitySession identitySession = new IdentitySessionImpl(realmName,
identitySessionContext, sessionWrappers);
+
+ Map<String, IdentitySession> sessionMap = new HashMap<String,
IdentitySession>();
+
+ sessionMap.put(realmName, identitySession);
+
+ identitySessionFactory = new IdentitySessionFactoryImpl(sessionMap);
+
+ }
+
+
+
+ public IdentitySessionFactory getIdentitySessionFactory()
+ {
+ return identitySessionFactory;
+ }
+
+
+}
+
Modified:
trunk/identity-impl/src/test/java/org/jboss/identity/impl/api/OrganizationTest.java
===================================================================
---
trunk/identity-impl/src/test/java/org/jboss/identity/impl/api/OrganizationTest.java 2008-10-15
10:59:42 UTC (rev 103)
+++
trunk/identity-impl/src/test/java/org/jboss/identity/impl/api/OrganizationTest.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -42,6 +42,10 @@
public class OrganizationTest extends Assert
{
+ public static final String RED_HAT_REALM = "realm://RedHat";
+
+ public static final String PORTAL_REALM = "realm://portal/SamplePortal";
+
APITestContext ctx;
public OrganizationTest(APITestContext ctx)
@@ -73,7 +77,7 @@
IdentitySessionFactory factory = ctx.getIdentitySessionFactory();
- IdentitySession session =
factory.createIdentitySession("realm://RedHat");
+ IdentitySession session = factory.createIdentitySession(RED_HAT_REALM);
session.getTransaction().start();
@@ -136,7 +140,6 @@
session.getRelationshipManager().associateIdentities(employeesGroup, theuteUser);
session.getRelationshipManager().associateIdentities(employeesGroup, mlittleUser);
- session.getRelationshipManager().associateIdentities(employeesGroup, theuteUser);
session.getRelationshipManager().associateIdentities(employeesGroup,
asaldhanaUser);
session.getRelationshipManager().associateIdentities(employeesGroup,
bdawidowUser);
session.getRelationshipManager().associateIdentities(employeesGroup, claprunUser);
@@ -226,7 +229,7 @@
//TODO: alter realm policies to make ORGANIZATION, ORGANIZATION_UNIT, DIVISION,
DEPARTMENT and OFFICE hierarchical groups
- IdentitySession session =
factory.createIdentitySession("realm://portal/SamplePortal");
+ IdentitySession session = factory.createIdentitySession(PORTAL_REALM);
session.getTransaction().start();
@@ -247,7 +250,7 @@
Group communityRootGroup =
session.getPersistenceManager().createGroup("COMMUNITY_ROOT", SYSTEM);
Group securityRootGroup =
session.getPersistenceManager().createGroup("SECURITY_ROOT", SYSTEM);
Group organizationRootGroup =
session.getPersistenceManager().createGroup("ORGANIZATION_ROOT",SYSTEM);
- Group usersROOTGroup =
session.getPersistenceManager().createGroup("ORGANIZATION_ROOT",SYSTEM);
+ Group usersROOTGroup =
session.getPersistenceManager().createGroup("USERS_ROOT",SYSTEM);
// Communities
Deleted:
trunk/identity-impl/src/test/java/org/jboss/identity/impl/api/SimpleGroupType.java
===================================================================
---
trunk/identity-impl/src/test/java/org/jboss/identity/impl/api/SimpleGroupType.java 2008-10-15
10:59:42 UTC (rev 103)
+++
trunk/identity-impl/src/test/java/org/jboss/identity/impl/api/SimpleGroupType.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -1,44 +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.impl.api;
-
-import org.jboss.identity.api.GroupType;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
- * @version : 0.1 $
- */
-public class SimpleGroupType implements GroupType
-{
- private String name;
-
- public SimpleGroupType(String name)
- {
- this.name = name;
- }
-
- public String getName()
- {
- return name;
- }
-}
Modified:
trunk/identity-impl/src/test/java/org/jboss/identity/impl/store/hibernate/HibernateTestBase.java
===================================================================
---
trunk/identity-impl/src/test/java/org/jboss/identity/impl/store/hibernate/HibernateTestBase.java 2008-10-15
10:59:42 UTC (rev 103)
+++
trunk/identity-impl/src/test/java/org/jboss/identity/impl/store/hibernate/HibernateTestBase.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -32,6 +32,7 @@
import org.hibernate.ejb.HibernateEntityManager;
import org.hibernate.ejb.HibernateEntityManagerFactory;
import org.jboss.identity.impl.store.hibernate.HibernateModelTestCase;
+import org.jboss.identity.impl.HibernateTestSupport;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
@@ -41,13 +42,11 @@
{
private static Logger logger =
Logger.getLogger(HibernateModelTestCase.class.getName());
- private HibernateEntityManagerFactory emFactory;
+ private HibernateTestSupport hibernateSupport = new HibernateTestSupport();
protected HibernateEntityManager em;
- private Connection connection;
-
public HibernateTestBase(String testName) {
super(testName);
}
@@ -55,46 +54,13 @@
@Override
protected void setUp() throws Exception {
super.setUp();
- try {
- logger.info("Starting in-memory HSQL database for unit tests");
- Class.forName("org.hsqldb.jdbcDriver");
- connection =
DriverManager.getConnection("jdbc:hsqldb:mem:unit-testing-jpa", "sa",
"");
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- fail("Exception during HSQL database startup.");
- }
- try
- {
- logger.info("Building JPA EntityManager for unit tests");
- emFactory =
(HibernateEntityManagerFactory)Persistence.createEntityManagerFactory("jboss-identity-model");
- em = (HibernateEntityManager)emFactory.createEntityManager();
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- fail("Exception during JPA EntityManager instanciation.");
- }
+ hibernateSupport.start();
+ em = hibernateSupport.getHibernateEntityManager();
}
@Override
protected void tearDown() throws Exception {
super.tearDown();
- logger.info("Shuting down Hibernate JPA layer.");
- if (em != null)
- {
- em.close();
- }
- if (emFactory != null)
- {
- emFactory.close();
- }
- logger.info("Stopping in-memory HSQL database.");
- try
- {
- connection.createStatement().execute("SHUTDOWN");
- }
- catch (Exception ex) {}
+ hibernateSupport.stop();
}
}
Modified:
trunk/identity-spi/src/main/java/org/jboss/identity/spi/repository/IdentityStoreRepository.java
===================================================================
---
trunk/identity-spi/src/main/java/org/jboss/identity/spi/repository/IdentityStoreRepository.java 2008-10-15
10:59:42 UTC (rev 103)
+++
trunk/identity-spi/src/main/java/org/jboss/identity/spi/repository/IdentityStoreRepository.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -27,6 +27,7 @@
import org.jboss.identity.spi.model.IdentityObjectType;
import org.jboss.identity.spi.store.IdentityStore;
+import org.jboss.identity.spi.store.AttributeStore;
import org.jboss.identity.spi.policy.RelationshipPolicy;
/**
@@ -46,21 +47,37 @@
Set<IdentityStore> getConfiguredIdentityStores();
/**
- * @return mapping of IdentityType to the specific identity store
+ * @return a set of configured attribute stores
*/
- Map<IdentityObjectType, IdentityStore> getIdentityStoreMappings();
+ Set<AttributeStore> getConfiguredAttributeStores();
/**
+ * @return mapping of IdentityType name to the specific identity store
+ */
+ Map<String, IdentityStore> getIdentityStoreMappings();
+
+ /**
+ * @return mapping of IdentityType name to the specific attribute store
+ */
+ Map<String, AttributeStore> getAttributeStoreMappings();
+
+ /**
* @param identityObjectType
* @return proper identity store to store given identity type
*/
IdentityStore getIdentityStore(IdentityObjectType identityObjectType);
+ /**
+ * @param identityObjectType
+ * @return proper identity store to store given identity type
+ */
+ AttributeStore getAttributeStore(IdentityObjectType identityObjectType);
- /**
- * Return a list of relationship policies
- * @return
- */
- List<RelationshipPolicy<IdentityObjectType, IdentityObjectType>>
getRelationshipPolicies(IdentityObjectType identityObjectType);
+
+ /**
+ * Return a list of relationship policies
+ * @return
+ */
+ //List<RelationshipPolicy<IdentityObjectType, IdentityObjectType>>
getRelationshipPolicies(IdentityObjectType identityObjectType);
}
\ No newline at end of file
Modified:
trunk/identity-spi/src/main/java/org/jboss/identity/spi/store/AttributeStore.java
===================================================================
---
trunk/identity-spi/src/main/java/org/jboss/identity/spi/store/AttributeStore.java 2008-10-15
10:59:42 UTC (rev 103)
+++
trunk/identity-spi/src/main/java/org/jboss/identity/spi/store/AttributeStore.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -39,6 +39,8 @@
public interface AttributeStore
{
+ //TODO: replace Set<String> with String[] in method signatures
+
/**
* @param invocationContext
* @param identityType @return names of supported attributes
Modified:
trunk/identity-spi/src/main/java/org/jboss/identity/spi/store/IdentityStore.java
===================================================================
---
trunk/identity-spi/src/main/java/org/jboss/identity/spi/store/IdentityStore.java 2008-10-15
10:59:42 UTC (rev 103)
+++
trunk/identity-spi/src/main/java/org/jboss/identity/spi/store/IdentityStore.java 2008-10-17
20:52:50 UTC (rev 104)
@@ -191,7 +191,8 @@
* @param createNames
* @throws IdentityException
*/
- void createRelationship(IdentityStoreInvocationContext invocationCxt, IdentityObject
fromIdentity,
+ IdentityObjectRelationship createRelationship(IdentityStoreInvocationContext
invocationCxt, IdentityObject fromIdentity,
+
IdentityObject toIdentity,
IdentityObjectRelationshipType relationshipType, String
relationshipName, boolean createNames) throws IdentityException;