Author: bdaw
Date: 2008-09-03 11:44:20 -0400 (Wed, 03 Sep 2008)
New Revision: 60
Added:
trunk/identity-api/src/main/java/org/jboss/identity/api/Transaction.java
Modified:
trunk/identity-api/src/main/java/org/jboss/identity/api/managers/IdentityManager.java
trunk/identity-api/src/main/java/org/jboss/identity/api/managers/PersistenceManager.java
trunk/identity-api/src/main/java/org/jboss/identity/api/managers/RelationshipManager.java
trunk/identity-api/src/main/java/org/jboss/identity/api/session/Session.java
trunk/identity-api/src/main/java/org/jboss/identity/api/store/IdentityStore.java
trunk/identity-api/src/main/java/org/jboss/identity/api/store/IdentityStoreRepository.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/FileBasedIdentityStore.java
Log:
- Connect Session with a Realm in IdentityManager
- Add simple notion of Transaction to Session
- In IdentityManager leave only methods managing Realm
- Remove references to the IdentityStore and IdentityStoreRepository from main API -
IdentityManager
- Move all methods managing identity objects (CRUD and relationships) to Session
- Minor improvements in IdentityStore methods
- Make IdentityStoreRepository extends IdentityStore so expose all identity objects
management methods to route them to actual store implementations
- Comment out RelationshipManager for now
Added: trunk/identity-api/src/main/java/org/jboss/identity/api/Transaction.java
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/api/Transaction.java
(rev 0)
+++ trunk/identity-api/src/main/java/org/jboss/identity/api/Transaction.java 2008-09-03
15:44:20 UTC (rev 60)
@@ -0,0 +1,53 @@
+/*
+* 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.api;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface Transaction
+{
+
+ /**
+ * Begin new transaction
+ */
+ void start();
+
+ /**
+ * Commit transaction - flush associated session
+ */
+ void commit();
+
+ /**
+ * Rollback transaction
+ */
+ void rollback();
+
+ /**
+ *
+ * @return
+ */
+ boolean isActive();
+
+}
Modified:
trunk/identity-api/src/main/java/org/jboss/identity/api/managers/IdentityManager.java
===================================================================
---
trunk/identity-api/src/main/java/org/jboss/identity/api/managers/IdentityManager.java 2008-09-03
07:49:37 UTC (rev 59)
+++
trunk/identity-api/src/main/java/org/jboss/identity/api/managers/IdentityManager.java 2008-09-03
15:44:20 UTC (rev 60)
@@ -44,6 +44,9 @@
*/
public interface IdentityManager
{
+
+ // Realm operations
+
/**
* <p>Create a Realm or return an already
* created realm. Bootstrapping includes generating
@@ -60,61 +63,8 @@
* @return
*/
Realm bootstrap(String realmName, InputStream config);
-
- /**
- * Create a Session
- * @param sessionType
- * @param identityName
- * @return
- */
- Session createSession(String sessionType, String identityName);
-
- /**
- * <p>Return a realm</p>
- * @param realmName
- * @param shouldBootstrap Should we bootstrap if a realm does not exist?
- * @return
- */
- Realm getRealm(String realmName, boolean shouldBootstrap);
-
- /**
- * <p>Create an identity in the realm</p>
- * @param realm
- * @param identityName
- * @return
- */
- Identity createIdentity(Realm realm, String identityName) throws IdentityException;
-
- /**
- * <p>Create a group in the realm</p>
- * @param realm
- * @param groupName
- * @return
- */
- Group createGroup(Realm realm, String groupName) throws IdentityException;
-
- /**
- * Create a group of a particular type
- * @param realm
- * @param groupName
- * @param groupType
- * @return
- */
- Group createGroup(Realm realm, String groupName, GroupType groupType)
- throws IdentityException;
-
- /**
- * <p>Create a role in the realm</p>
- * @param realm
- * @param roleName name of role
- * @param roleType Type of Role
- * @return
- */
- Role createRole(Realm realm, String roleName, RoleType roleType)
- throws IdentityException;
-
- /**
+ /**
* <p>Associate a relationship between two realms</p>
* @param realmA
* @param realmB
@@ -144,25 +94,30 @@
RelationshipType getRelationship(Realm fromRealm, Realm toRealm);
/**
- * <p>Returns relationship manager for a given realm</p>
- * @param realm
+ * <p>Return a realm</p>
+ * @param realmName
+ * @param shouldBootstrap Should we bootstrap if a realm does not exist?
* @return
- * @throws IdentityException
*/
- RelationshipManager getRelationshipManager(Realm realm) throws IdentityException;
+ Realm getRealm(String realmName, boolean shouldBootstrap);
+
+ // Session
+
/**
- * <p>Return the configured PersistenceManager</p>
+ * Create a Session
+ * @param realm
* @return
*/
- PersistenceManager getPersistenceManager();
-
+ Session createSession(Realm realm);
+
+
/**
- * Return the IdentityStoreRepository associated with
- * a particular realm
+ * Get current open session associated with a realm
* @param realm
* @return
*/
- IdentityStoreRepository getRepository(Realm realm);
+ Session getCurrentSession(Realm realm);
+
}
\ No newline at end of file
Modified:
trunk/identity-api/src/main/java/org/jboss/identity/api/managers/PersistenceManager.java
===================================================================
---
trunk/identity-api/src/main/java/org/jboss/identity/api/managers/PersistenceManager.java 2008-09-03
07:49:37 UTC (rev 59)
+++
trunk/identity-api/src/main/java/org/jboss/identity/api/managers/PersistenceManager.java 2008-09-03
15:44:20 UTC (rev 60)
@@ -2,7 +2,7 @@
* JBoss, Home of Professional Open Source.
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
+ * 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
@@ -41,7 +41,7 @@
* @return
*/
IdentityStoreRepository getIdentityStoreRepository(Realm realm);
-
+
/**
* <p>Get the Identity Store configured for an identity type
* at the realm level </p>
@@ -51,5 +51,5 @@
* @return
*/
IdentityStore getIdentityStore(Realm realm, IdentityType identityType);
-
+
}
\ No newline at end of file
Modified:
trunk/identity-api/src/main/java/org/jboss/identity/api/managers/RelationshipManager.java
===================================================================
---
trunk/identity-api/src/main/java/org/jboss/identity/api/managers/RelationshipManager.java 2008-09-03
07:49:37 UTC (rev 59)
+++
trunk/identity-api/src/main/java/org/jboss/identity/api/managers/RelationshipManager.java 2008-09-03
15:44:20 UTC (rev 60)
@@ -1,181 +1,181 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.identity.api.managers;
-
-import java.util.List;
-import java.util.Set;
-
-import org.jboss.identity.api.exception.PersistenceManagerNotFoundException;
-import org.jboss.identity.api.exception.SessionNotOpenException;
-import org.jboss.identity.model.Identity;
-import org.jboss.identity.model.roles.Role;
-import org.jboss.identity.model.groups.Group;
-import org.jboss.identity.model.relation.RelationshipType;
-
-/**
- * <p>Manages the relationships between
- * roles, groups and identities within a realm</p>
- * @author Anil.Saldhana(a)redhat.com
- * @author boleslaw dot dawidowicz at redhat anotherdot com
- * @since Jul 10, 2008
- */
-public interface RelationshipManager
-{
- /**
- * <p>Associate a relationship between two groups</p>
- * @param groupA
- * @param groupB
- * @param relationshipType
- * @throws PersistenceManagerNotFoundException PM not set
- * @throws SessionNotOpenException session is not open
- */
- void associate(Group groupA, Group groupB, RelationshipType relationshipType)
- throws PersistenceManagerNotFoundException,SessionNotOpenException;
-
- /**
- * Associate a relationship between one group and a list of other groups
- * @param groupA
- * @param groupB a list of groups which are related to groupA
- * @param relationshipType
- * @throws PersistenceManagerNotFoundException
- * @throws SessionNotOpenException
- */
- void associate(Group groupA, List<Group> groupB, RelationshipType
relationshipType)
- throws PersistenceManagerNotFoundException,SessionNotOpenException;
-
-
-
- /**
- * <p>Associate a role with an Identity</p>
- * @param identity
- * @param aRole
- * @throws PersistenceManagerNotFoundException PM not set
- * @throws SessionNotOpenException session is not open
- */
- void associate(Identity identity, Role aRole)
- throws PersistenceManagerNotFoundException,SessionNotOpenException;
-
- /**
- * <p>Associate a list of roles with an Identity</p>
- * @param identity
- * @param aRoleList
- * @throws PersistenceManagerNotFoundException PM not set
- * @throws SessionNotOpenException session is not open
- */
- void associate(Identity identity, List<Role> aRoleList)
- throws PersistenceManagerNotFoundException,SessionNotOpenException;
-
- /**
- * <p>Associate a group with an identity</p>
- * @param identity
- * @param aGroup
- * @throws PersistenceManagerNotFoundException PM not set
- * @throws SessionNotOpenException session is not open
- */
- void associate(Identity identity, Group aGroup)
- throws PersistenceManagerNotFoundException,SessionNotOpenException;
-
- /**
- * <p>Associate a set of groups with an identity</p>
- * @param identity
- * @param aGroupSet
- * @throws PersistenceManagerNotFoundException PM not set
- * @throws SessionNotOpenException session is not open
- */
- void associate(Identity identity, Set<Group> aGroupSet)
- throws PersistenceManagerNotFoundException,SessionNotOpenException;
-
- /**
- * <p>Disassociate a relationship between two groups</p>
- * @param groupA
- * @param groupB
- * @param relationshipType
- * @throws PersistenceManagerNotFoundException PM not set
- * @throws SessionNotOpenException session is not open
- */
- void disassociate(Group groupA, Group groupB, RelationshipType relationshipType)
- throws PersistenceManagerNotFoundException,SessionNotOpenException;
-
- /**
- * Disassociate a relationship between one group and a list of other groups
- * @param groupA
- * @param groupB
- * @param relationshipType
- * @throws PersistenceManagerNotFoundException
- * @throws SessionNotOpenException
- */
- void disassociate(Group groupA, List<Group> groupB, RelationshipType
relationshipType)
- throws PersistenceManagerNotFoundException,SessionNotOpenException;
-
-
-
- /**
- * <p>Disassociate a role with an Identity</p>
- * @param identity
- * @param aRole
- * @throws PersistenceManagerNotFoundException PM not set
- * @throws SessionNotOpenException session is not open
- */
- void disassociate(Identity identity, Role aRole)
- throws PersistenceManagerNotFoundException,SessionNotOpenException;
-
- /**
- * <p>Disassociate a list of roles with an Identity</p>
- * @param identity
- * @param aRoleList
- * @throws PersistenceManagerNotFoundException PM not set
- * @throws SessionNotOpenException session is not open
- */
- void disassociate(Identity identity, List<Role> aRoleList)
- throws PersistenceManagerNotFoundException,SessionNotOpenException;
-
- /**
- * <p>Disassociate a group with an identity</p>
- * @param identity
- * @param aGroup
- * @throws PersistenceManagerNotFoundException PM not set
- * @throws SessionNotOpenException session is not open
- */
- void disassociate(Identity identity, Group aGroup)
- throws PersistenceManagerNotFoundException,SessionNotOpenException;
-
- /**
- * <p>Disassociate a set of groups with an identity</p>
- * @param identity
- * @param aGroupSet
- * @throws PersistenceManagerNotFoundException PM not set
- * @throws SessionNotOpenException session is not open
- */
- void disassociate(Identity identity, Set<Group> aGroupSet)
- throws PersistenceManagerNotFoundException,SessionNotOpenException;
-
- /**
- * @param fromGroup
- * @param toGroup
- * @return returns a relationship type between this and given group.
- */
- RelationshipType getRelationship(Group fromGroup, Group toGroup);
-
-
-
-
-}
\ No newline at end of file
+///*
+// * JBoss, Home of Professional Open Source.
+// * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+// * as indicated by the @author tags. See the copyright.txt file in the
+// * distribution for a full listing of individual contributors.
+// *
+// * This is free software; you can redistribute it and/or modify it
+// * under the terms of the GNU Lesser General Public License as
+// * published by the Free Software Foundation; either version 2.1 of
+// * the License, or (at your option) any later version.
+// *
+// * This software is distributed in the hope that it will be useful,
+// * but WITHOUT ANY WARRANTY; without even the implied warranty of
+// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// * Lesser General Public License for more details.
+// *
+// * You should have received a copy of the GNU Lesser General Public
+// * License along with this software; if not, write to the Free
+// * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+// * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+// */
+//package org.jboss.identity.api.managers;
+//
+//import java.util.List;
+//import java.util.Set;
+//
+//import org.jboss.identity.api.exception.PersistenceManagerNotFoundException;
+//import org.jboss.identity.api.exception.SessionNotOpenException;
+//import org.jboss.identity.model.Identity;
+//import org.jboss.identity.model.roles.Role;
+//import org.jboss.identity.model.groups.Group;
+//import org.jboss.identity.model.relation.RelationshipType;
+//
+///**
+// * <p>Manages the relationships between
+// * roles, groups and identities within a realm</p>
+// * @author Anil.Saldhana(a)redhat.com
+// * @author boleslaw dot dawidowicz at redhat anotherdot com
+// * @since Jul 10, 2008
+// */
+//public interface RelationshipManager
+//{
+// /**
+// * <p>Associate a relationship between two groups</p>
+// * @param groupA
+// * @param groupB
+// * @param relationshipType
+// * @throws PersistenceManagerNotFoundException PM not set
+// * @throws SessionNotOpenException session is not open
+// */
+// void associate(Group groupA, Group groupB, RelationshipType relationshipType)
+// throws PersistenceManagerNotFoundException,SessionNotOpenException;
+//
+// /**
+// * Associate a relationship between one group and a list of other groups
+// * @param groupA
+// * @param groupB a list of groups which are related to groupA
+// * @param relationshipType
+// * @throws PersistenceManagerNotFoundException
+// * @throws SessionNotOpenException
+// */
+// void associate(Group groupA, List<Group> groupB, RelationshipType
relationshipType)
+// throws PersistenceManagerNotFoundException,SessionNotOpenException;
+//
+//
+//
+// /**
+// * <p>Associate a role with an Identity</p>
+// * @param identity
+// * @param aRole
+// * @throws PersistenceManagerNotFoundException PM not set
+// * @throws SessionNotOpenException session is not open
+// */
+// void associate(Identity identity, Role aRole)
+// throws PersistenceManagerNotFoundException,SessionNotOpenException;
+//
+// /**
+// * <p>Associate a list of roles with an Identity</p>
+// * @param identity
+// * @param aRoleList
+// * @throws PersistenceManagerNotFoundException PM not set
+// * @throws SessionNotOpenException session is not open
+// */
+// void associate(Identity identity, List<Role> aRoleList)
+// throws PersistenceManagerNotFoundException,SessionNotOpenException;
+//
+// /**
+// * <p>Associate a group with an identity</p>
+// * @param identity
+// * @param aGroup
+// * @throws PersistenceManagerNotFoundException PM not set
+// * @throws SessionNotOpenException session is not open
+// */
+// void associate(Identity identity, Group aGroup)
+// throws PersistenceManagerNotFoundException,SessionNotOpenException;
+//
+// /**
+// * <p>Associate a set of groups with an identity</p>
+// * @param identity
+// * @param aGroupSet
+// * @throws PersistenceManagerNotFoundException PM not set
+// * @throws SessionNotOpenException session is not open
+// */
+// void associate(Identity identity, Set<Group> aGroupSet)
+// throws PersistenceManagerNotFoundException,SessionNotOpenException;
+//
+// /**
+// * <p>Disassociate a relationship between two groups</p>
+// * @param groupA
+// * @param groupB
+// * @param relationshipType
+// * @throws PersistenceManagerNotFoundException PM not set
+// * @throws SessionNotOpenException session is not open
+// */
+// void disassociate(Group groupA, Group groupB, RelationshipType relationshipType)
+// throws PersistenceManagerNotFoundException,SessionNotOpenException;
+//
+// /**
+// * Disassociate a relationship between one group and a list of other groups
+// * @param groupA
+// * @param groupB
+// * @param relationshipType
+// * @throws PersistenceManagerNotFoundException
+// * @throws SessionNotOpenException
+// */
+// void disassociate(Group groupA, List<Group> groupB, RelationshipType
relationshipType)
+// throws PersistenceManagerNotFoundException,SessionNotOpenException;
+//
+//
+//
+// /**
+// * <p>Disassociate a role with an Identity</p>
+// * @param identity
+// * @param aRole
+// * @throws PersistenceManagerNotFoundException PM not set
+// * @throws SessionNotOpenException session is not open
+// */
+// void disassociate(Identity identity, Role aRole)
+// throws PersistenceManagerNotFoundException,SessionNotOpenException;
+//
+// /**
+// * <p>Disassociate a list of roles with an Identity</p>
+// * @param identity
+// * @param aRoleList
+// * @throws PersistenceManagerNotFoundException PM not set
+// * @throws SessionNotOpenException session is not open
+// */
+// void disassociate(Identity identity, List<Role> aRoleList)
+// throws PersistenceManagerNotFoundException,SessionNotOpenException;
+//
+// /**
+// * <p>Disassociate a group with an identity</p>
+// * @param identity
+// * @param aGroup
+// * @throws PersistenceManagerNotFoundException PM not set
+// * @throws SessionNotOpenException session is not open
+// */
+// void disassociate(Identity identity, Group aGroup)
+// throws PersistenceManagerNotFoundException,SessionNotOpenException;
+//
+// /**
+// * <p>Disassociate a set of groups with an identity</p>
+// * @param identity
+// * @param aGroupSet
+// * @throws PersistenceManagerNotFoundException PM not set
+// * @throws SessionNotOpenException session is not open
+// */
+// void disassociate(Identity identity, Set<Group> aGroupSet)
+// throws PersistenceManagerNotFoundException,SessionNotOpenException;
+//
+// /**
+// * @param fromGroup
+// * @param toGroup
+// * @return returns a relationship type between this and given group.
+// */
+// RelationshipType getRelationship(Group fromGroup, Group toGroup);
+//
+//
+//
+//
+//}
\ No newline at end of file
Modified: trunk/identity-api/src/main/java/org/jboss/identity/api/session/Session.java
===================================================================
---
trunk/identity-api/src/main/java/org/jboss/identity/api/session/Session.java 2008-09-03
07:49:37 UTC (rev 59)
+++
trunk/identity-api/src/main/java/org/jboss/identity/api/session/Session.java 2008-09-03
15:44:20 UTC (rev 60)
@@ -22,7 +22,23 @@
package org.jboss.identity.api.session;
import org.jboss.identity.api.exception.IdentityException;
+import org.jboss.identity.api.exception.SessionNotOpenException;
+import org.jboss.identity.api.Transaction;
+import org.jboss.identity.model.Identity;
+import org.jboss.identity.model.IdentityObject;
+import org.jboss.identity.model.IdentityType;
+import org.jboss.identity.model.relation.RelationshipType;
+import org.jboss.identity.model.roles.Role;
+import org.jboss.identity.model.roles.RoleType;
+import org.jboss.identity.model.groups.Group;
+import org.jboss.identity.model.groups.GroupType;
+import org.jboss.identity.model.domain.Realm;
+import java.util.List;
+import java.util.Set;
+import java.util.Collection;
+import java.util.Map;
+
/**
* <p>An Identity Session</p>
* @author boleslaw dot dawidowicz at redhat anotherdot com
@@ -60,4 +76,375 @@
* @return
*/
boolean isOpen();
+
+ /**
+ *
+ * @return
+ */
+ Transaction beginTransaction();
+
+ /**
+ * Transaction instance assosiated with this session
+ * @return
+ */
+ Transaction getTransaction();
+
+
+ // IDM methods
+
+ // Create
+
+ /**
+ * <p>Create an identity in the realm</p>
+ * @param identityName
+ * @return
+ */
+ Identity createIdentity(String identityName) throws IdentityException;
+
+ /**
+ * Create a group of a particular type
+ * @param groupName
+ * @param groupType
+ * @return
+ */
+ Group createGroup(String groupName, GroupType groupType)
+ throws IdentityException;
+
+ /**
+ * <p>Create a role in the realm</p>
+ * @param roleName name of role
+ * @param roleType Type of Role
+ * @return
+ */
+ Role createRole(String roleName, RoleType roleType)
+ throws IdentityException;
+
+ // Remove
+
+ /**
+ * Remove given identity
+ *
+ * @param identity
+ * @throws IdentityException
+ */
+ void removeIdentity(IdentityObject identity) throws IdentityException;
+
+ // Realtionships
+
+ /**
+ * <p>Associate a relationship between two groups</p>
+ * @param groupA
+ * @param groupB
+ * @param relationshipType
+ * @throws IdentityException
+ */
+ void associate(Group groupA, Group groupB, RelationshipType relationshipType)
+ throws IdentityException;
+
+ /**
+ * Associate a relationship between one group and a list of other groups
+ * @param groupA
+ * @param groupB a list of groups which are related to groupA
+ * @param relationshipType
+ * @throws IdentityException
+ */
+ void associate(Group groupA, List<Group> groupB, RelationshipType
relationshipType)
+ throws IdentityException;
+
+
+
+ /**
+ * <p>Associate a role with an Identity</p>
+ * @param identity
+ * @param aRole
+ * @throws IdentityException
+ */
+ void associate(Identity identity, Role aRole)
+ throws IdentityException;
+
+ /**
+ * <p>Associate a list of roles with an Identity</p>
+ * @param identity
+ * @param aRoleList
+ * @throws IdentityException
+ */
+ void associate(Identity identity, List<Role> aRoleList)
+ throws IdentityException;
+
+ /**
+ * <p>Associate a group with an identity</p>
+ * @param identity
+ * @param aGroup
+ * @throws IdentityException
+ */
+ void associate(Identity identity, Group aGroup)
+ throws IdentityException;
+
+ /**
+ * <p>Associate a set of groups with an identity</p>
+ * @param identity
+ * @param aGroupSet
+ * @throws IdentityException
+ */
+ void associate(Identity identity, Set<Group> aGroupSet)
+ throws IdentityException;
+
+ /**
+ * <p>Disassociate a relationship between two groups</p>
+ * @param groupA
+ * @param groupB
+ * @param relationshipType
+ * @throws IdentityException
+ */
+ void disassociate(Group groupA, Group groupB, RelationshipType relationshipType)
+ throws IdentityException;
+
+ /**
+ * Disassociate a relationship between one group and a list of other groups
+ * @param groupA
+ * @param groupB
+ * @param relationshipType
+ * @throws IdentityException
+ */
+ void disassociate(Group groupA, List<Group> groupB, RelationshipType
relationshipType)
+ throws IdentityException;
+
+
+
+ /**
+ * <p>Disassociate a role with an Identity</p>
+ * @param identity
+ * @param aRole
+ * @throws IdentityException
+ */
+ void disassociate(Identity identity, Role aRole)
+ throws IdentityException;
+
+ /**
+ * <p>Disassociate a list of roles with an Identity</p>
+ * @param identity
+ * @param aRoleList
+ * @throws IdentityException
+ */
+ void disassociate(Identity identity, List<Role> aRoleList)
+ throws IdentityException;
+
+ /**
+ * <p>Disassociate a group with an identity</p>
+ * @param identity
+ * @param aGroup
+ * @throws IdentityException
+ */
+ void disassociate(Identity identity, Group aGroup)
+ throws IdentityException;
+
+ /**
+ * <p>Disassociate a set of groups with an identity</p>
+ * @param identity
+ * @param aGroupSet
+ * @throws org.jboss.identity.api.exception.PersistenceManagerNotFoundException PM not
set
+ * @throws SessionNotOpenException session is not open
+ */
+ void disassociate(Identity identity, Set<Group> aGroupSet)
+ throws IdentityException;
+
+ /**
+ * @param fromGroup
+ * @param toGroup
+ * @return returns a relationship type between this and given group.
+ */
+ RelationshipType getRelationship(Group fromGroup, Group toGroup);
+
+ // Relationship - abstract methods
+
+ /**
+ * Create directional relationship of a given type between identities
+ *
+ * @param fromIdentity
+ * @param toIdentity
+ * @param relationshipType
+ * @throws IdentityException
+ */
+ <R extends RelationshipType> void createRelationship(IdentityObject
fromIdentity,
+ IdentityObject toIdentity,
+ R relationshipType) throws IdentityException;
+
+ /**
+ * Remove relationship between identities. Relationships can be directional so
+ * order of parameters matters
+ *
+ * @param fromIdentity
+ * @param toIdentity
+ * @param relationshipType
+ * @throws IdentityException
+ */
+ <R extends RelationshipType> void removeRelationship(IdentityObject
fromIdentity,
+ IdentityObject toIdentity,
+ R relationshipType) throws IdentityException;
+
+ /**
+ * Remove all relationships between identities. Direction of relationships
doesn't
+ * matter - all active relationships
+ * will be removed
+ *
+ * @param identity1
+ * @param identity2
+ * @throws IdentityException
+ */
+ void removeRelationships(IdentityObject identity1, IdentityObject identity2)
+ throws IdentityException;
+
+ /**
+ * Resolve relationship types between two identities. Relationships can be
directional
+ * so order of parameters matters
+ *
+ * @param fromIdentity
+ * @param toIdentity
+ * @return
+ * @throws IdentityException
+ */
+ Set<RelationshipType> resolveRelationships(IdentityObject fromIdentity,
IdentityObject toIdentity)
+ throws IdentityException;
+
+
+ // Search operations
+
+ /**
+ * @param identityType
+ * @return a number of stored identities with a given type
+ * @throws IdentityException
+ */
+ <T extends IdentityType> int getIdentityTypeCount(T identityType)
+ throws IdentityException;
+
+ /**
+ * Find identity with a given name
+ *
+ * @param name
+ * @param identityType
+ * @return
+ * @throws IdentityException
+ */
+ IdentityObject findIdentityObject(String name, IdentityType identityType) throws
IdentityException;
+
+ /**
+ * Find identity with a given id
+ *
+ * @param id
+ * @return
+ * @throws IdentityException
+ */
+ IdentityObject findIdentityObject(Object id) throws IdentityException;
+
+ /**
+ * Find identities with a given type paginated and ordered.
+ * If the paginatedSearch or orderedSearch operations
+ * are not supported in this store implementation, dedicated
+ * parameters will take no effect
+ *
+ * @param identityType
+ * @param offset
+ * @param limit 0 means unlimited page size
+ * @param orderedByAttributeName can be null
+ * @param ascending default true
+ * @return
+ * @throws IdentityException
+ */
+ <T extends IdentityType> Collection<IdentityObject> findIdentityObject(T
identityType,
+ int offset, int limit,
+ String orderedByAttributeName,
+ boolean ascending) throws IdentityException;
+
+ /**
+ * Find identities with a given attributes values. If the paginatedSearch or
+ * orderedSearch operations
+ * are not supported in this store implementation, dedicated parameters will take no
effect
+ *
+ * @param identityType
+ * @param attributes
+ * @param offset
+ * @param limit 0 means unlimited page size
+ * @param orderedByAttributeName can be null
+ * @param ascending default true
+ * @return
+ * @throws IdentityException
+ */
+ <T extends IdentityType> Collection<IdentityObject> findIdentityObject(T
identityType,
+ Map<String, String[]> attributes,
+ int offset, int limit,
+ String orderedByAttributeName, boolean ascending)
throws IdentityException;
+
+ /**
+ * Find identites that have relationship with given identity. Relationships are
directional (from parent to child).
+ * If the paginatedSearch or orderedSearch operations
+ * are not supported in this store implementation, dedicated parameters will
+ * take no effect
+ *
+ * @param identity
+ * @param relationshipType
+ * @param parent defines if given identity is parent or child side in the
+ * relationship - default is true (parent)
+ * @param offset
+ * @param limit 0 means unlimited page size
+ * @param orderedByAttributeName can be null
+ * @param ascending default true
+ * @return
+ * @throws IdentityException
+ */
+ <R extends RelationshipType>Collection<IdentityObject>
findIdentityObject(IdentityObject identity,
+ R relationshipType,
+ boolean parent,
+ int offset, int limit,
+ String orderedByAttributeName,
+ boolean ascending) throws IdentityException;
+
+ // Attributes
+
+ /**
+ * @param identityType
+ * @return names of supported attributes
+ * @throws IdentityException
+ */
+ <T extends IdentityType> Set<String> getSupportedAttributeNames(T
identityType)
+ throws IdentityException;
+
+ /**
+ * Get attributes for the given identity
+ *
+ * @param identity
+ * @return
+ * @throws IdentityException
+ */
+ Map<String, String[]> getAttributes(IdentityObject identity) throws
IdentityException;
+
+ /**
+ * Update attributes with new values - previous values will be overwritten
+ * @param identity
+ * @param attributes
+ * @throws IdentityException
+ */
+ void updateAttributes(IdentityObject identity, Map<String, String[]>
attributes)
+ throws IdentityException;
+
+ /**
+ * Add new attributes - if attribute with given name already exists the values
+ * will be appended
+ *
+ * @param identity
+ * @param attributes
+ * @throws IdentityException
+ */
+ void addAttributes(IdentityObject identity, Map<String, String[]> attributes)
+ throws IdentityException;
+
+ /**
+ * Remove attributes
+ *
+ * @param identity
+ * @param attributes
+ */
+ void removeAttributes(IdentityObject identity, Set<String> attributes)
+ throws IdentityException;
+
+
}
\ No newline at end of file
Modified:
trunk/identity-api/src/main/java/org/jboss/identity/api/store/IdentityStore.java
===================================================================
---
trunk/identity-api/src/main/java/org/jboss/identity/api/store/IdentityStore.java 2008-09-03
07:49:37 UTC (rev 59)
+++
trunk/identity-api/src/main/java/org/jboss/identity/api/store/IdentityStore.java 2008-09-03
15:44:20 UTC (rev 60)
@@ -64,10 +64,11 @@
* Create new identity with a given name
*
* @param name
+ * @param identityType
* @return
* @throws IdentityException
*/
- IdentityObject createIdentity(String name) throws IdentityException;
+ IdentityObject createIdentity(String name, IdentityType identityType) throws
IdentityException;
/**
* Remove given identity
@@ -89,10 +90,11 @@
* Find identity with a given name
*
* @param name
+ * @param identityType
* @return
* @throws IdentityException
*/
- IdentityObject findIdentity(String name) throws IdentityException;
+ IdentityObject findIdentity(String name, IdentityType identityType) throws
IdentityException;
/**
* Find identity with a given id
Modified:
trunk/identity-api/src/main/java/org/jboss/identity/api/store/IdentityStoreRepository.java
===================================================================
---
trunk/identity-api/src/main/java/org/jboss/identity/api/store/IdentityStoreRepository.java 2008-09-03
07:49:37 UTC (rev 59)
+++
trunk/identity-api/src/main/java/org/jboss/identity/api/store/IdentityStoreRepository.java 2008-09-03
15:44:20 UTC (rev 60)
@@ -35,7 +35,7 @@
* @author Anil.Saldhana(a)redhat.com
* @since Jul 10, 2008
*/
-public interface IdentityStoreRepository
+public interface IdentityStoreRepository extends IdentityStore
{
/**
* @return a set of configured identity stores
@@ -53,10 +53,4 @@
*/
IdentityStore getIdentityStore(IdentityType identityType);
- /**
- * Register an identity store for a given identity type
- * @param identityType
- * @param identityStore
- */
- void register(IdentityType identityType, IdentityStore identityStore);
}
\ No newline at end of file
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/FileBasedIdentityStore.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/FileBasedIdentityStore.java 2008-09-03
07:49:37 UTC (rev 59)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/FileBasedIdentityStore.java 2008-09-03
15:44:20 UTC (rev 60)
@@ -61,14 +61,14 @@
- public IdentityObject createIdentity(String name) throws IdentityException
+ public IdentityObject createIdentity(String name, IdentityType type) throws
IdentityException
{
//Is there one already available?
IdentityObject identity = this.findIdentity(name);
if(identity == null)
{
- identity = new SimpleIdentity(name);
- identities.add(identity);
+ identity = new SimpleIdentity(name);
+ identities.add(identity);
}
return identity;
}
@@ -101,13 +101,8 @@
return null;
}
- public IdentityObject findIdentity(String name) throws IdentityException
+ public IdentityObject findIdentity(String name, IdentityType identityType) throws
IdentityException
{
- for(IdentityObject identity: identities)
- {
- if(name.equals(identity.getName()))
- return identity;
- }
return null;
}