Author: bdaw
Date: 2009-03-18 17:22:32 -0400 (Wed, 18 Mar 2009)
New Revision: 381
Modified:
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AbstractManager.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/PersistenceManagerImpl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RoleManagerImpl.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/PersistenceManagerTest.java
Log:
dummy sanity checks
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AbstractManager.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AbstractManager.java 2009-03-18
20:27:31 UTC (rev 380)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AbstractManager.java 2009-03-18
21:22:32 UTC (rev 381)
@@ -267,5 +267,14 @@
}
}
+ protected void checkObjectName(String name)
+ {
+ //TODO: extract this, let to define broader set of constraints and apply also in
the
+ //TODO: SPI to filter what comes fromdata stores
+ if (name.contains("/"))
+ {
+ throw new IllegalArgumentException("name cannot contain '/'
character");
+ }
+ }
}
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/PersistenceManagerImpl.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/PersistenceManagerImpl.java 2009-03-18
20:27:31 UTC (rev 380)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/PersistenceManagerImpl.java 2009-03-18
21:22:32 UTC (rev 381)
@@ -126,6 +126,9 @@
public User createUser(String identityName) throws IdentityException
{
+ checkNotNullArgument(identityName, "Identity name");
+ checkObjectName(identityName);
+
IdentityObjectType iot = getUserObjectType();
IdentityObject identityObject =
getRepository().createIdentityObject(getInvocationContext(), identityName, iot);
@@ -135,6 +138,11 @@
public Group createGroup(String groupName, String groupType) throws IdentityException
{
+ checkNotNullArgument(groupName, "Group name");
+ checkNotNullArgument(groupType, "Group type");
+ checkObjectName(groupName);
+ checkObjectName(groupType);
+
IdentityObjectType iot = getIdentityObjectType(groupType);
IdentityObject identityObject =
getRepository().createIdentityObject(getInvocationContext(), groupName, iot);
@@ -144,21 +152,30 @@
public String createGroupId(String groupName, String groupType)
{
+ checkNotNullArgument(groupName, "Group name");
+ checkNotNullArgument(groupType, "Group type");
+ checkObjectName(groupName);
+ checkObjectName(groupType);
+
return new GroupId(groupName, groupType).getId();
}
- public void removeUser(User identity, boolean force) throws IdentityException
+ public void removeUser(User user, boolean force) throws IdentityException
{
- getRepository().removeIdentityObject(getInvocationContext(),
createIdentityObject(identity));
+ checkNotNullArgument(user, "User");
+ getRepository().removeIdentityObject(getInvocationContext(),
createIdentityObject(user));
}
public void removeUser(String userName, boolean force) throws IdentityException
{
+ checkNotNullArgument(userName, "User name");
getRepository().removeIdentityObject(getInvocationContext(),
createIdentityObjectForUserName(userName));
}
public void removeGroup(Group group, boolean force) throws IdentityException
{
+ checkNotNullArgument(group, "Group");
+
//TODO: force
getRepository().removeIdentityObject(getInvocationContext(),
createIdentityObject(group));
@@ -166,6 +183,8 @@
public void removeGroup(String groupId, boolean force) throws IdentityException
{
+ checkNotNullArgument(groupId, "Group Id");
+
//TODO: force
getRepository().removeIdentityObject(getInvocationContext(),
createIdentityObjectForGroupId(groupId));
@@ -180,6 +199,8 @@
public int getGroupTypeCount(String groupType) throws IdentityException
{
+ checkNotNullArgument(groupType, "Group type");
+
IdentityObjectType iot = getIdentityObjectType(groupType);
return getRepository().getIdentityObjectsCount(getInvocationContext(), iot);
@@ -187,6 +208,8 @@
public User findUser(String name) throws IdentityException
{
+ checkNotNullArgument(name, "User name");
+
return createUser(getRepository().findIdentityObject(getInvocationContext(), name,
getUserObjectType()));
}
@@ -208,16 +231,22 @@
public Group findGroup(String name, String groupType) throws IdentityException
{
+ checkNotNullArgument(name, "Group name");
+ checkNotNullArgument(groupType, "Group type");
+
return createGroup(getRepository().findIdentityObject(getInvocationContext(), name,
getIdentityObjectType(groupType)));
}
public Group findGroupById(String id) throws IdentityException
{
+ checkNotNullArgument(id, "Group id");
return createGroup(getRepository().findIdentityObject(getInvocationContext(),
id));
}
public Collection<Group> findGroup(String groupType, IdentitySearchControl[]
controls) throws IdentityException
{
+ checkNotNullArgument(groupType, "Group type");
+
Collection<IdentityObject> ios =
getRepository().findIdentityObject(getInvocationContext(),
getIdentityObjectType(groupType), convertSearchControls(controls));
List<Group> groups = new LinkedList<Group>();
@@ -232,12 +261,14 @@
public Collection<Group> findGroup(String groupType) throws IdentityException
{
+ checkNotNullArgument(groupType, "Group type");
+
return findGroup(groupType, (IdentitySearchControl[]) null);
}
- public boolean isVirtual(User identity)
- {
- //TODO:NYI
- throw new NotYetImplementedException("Postponed");
- }
+// public boolean isVirtual(User identity)
+// {
+// //TODO:NYI
+// throw new NotYetImplementedException("Postponed");
+// }
}
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java 2009-03-18
20:27:31 UTC (rev 380)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java 2009-03-18
21:22:32 UTC (rev 381)
@@ -154,6 +154,9 @@
public void associateGroups(Collection<Group> parents, Collection<Group>
members) throws IdentityException
{
+ checkNotNullArgument(parents, "parents");
+ checkNotNullArgument(members, "members");
+
for (Iterator<Group> parentsIterator = parents.iterator();
parentsIterator.hasNext();)
{
Group parent = parentsIterator.next();
@@ -169,6 +172,9 @@
public void associateGroupsByIds(Collection<String> parentIds,
Collection<String> memberIds) throws IdentityException
{
+ checkNotNullArgument(parentIds, "Parents Ids");
+ checkNotNullArgument(memberIds, "Members Ids");
+
for (Iterator<String> parentsIterator = parentIds.iterator();
parentsIterator.hasNext();)
{
String parentId = parentsIterator.next();
@@ -184,17 +190,26 @@
public void associateGroups(Group parent, Group member) throws IdentityException
{
+ checkNotNullArgument(parent, "Parent group");
+ checkNotNullArgument(member, "Member group");
+
getRepository().createRelationship(getInvocationContext(),
createIdentityObject(parent), createIdentityObject(member), MEMBER, null, true);
}
public void associateGroupsByIds(String parentId, String memberId) throws
IdentityException
{
+ checkNotNullArgument(parentId, "Parent Id");
+ checkNotNullArgument(memberId, "Member Id");
+
getRepository().createRelationship(getInvocationContext(),
createIdentityObjectForGroupId(parentId), createIdentityObjectForGroupId(memberId),
MEMBER, null, true);
}
public void associateUsers(Collection<Group> parents, Collection<User>
members) throws IdentityException
{
+ checkNotNullArgument(parents, "parents");
+ checkNotNullArgument(members, "members");
+
for (Iterator<Group> parentsIterator = parents.iterator();
parentsIterator.hasNext();)
{
Group parent = parentsIterator.next();
@@ -210,6 +225,10 @@
public void associateUsersByIds(Collection<String> parents,
Collection<String> members) throws IdentityException
{
+
+ checkNotNullArgument(parents, "parents");
+ checkNotNullArgument(members, "members");
+
for (Iterator<String> parentsIterator = parents.iterator();
parentsIterator.hasNext();)
{
String parent = parentsIterator.next();
@@ -226,18 +245,27 @@
public void associateUsers(Group parent, User member) throws IdentityException
{
+ checkNotNullArgument(parent, "Parent group");
+ checkNotNullArgument(member, "Member user");
+
getRepository().createRelationship(getInvocationContext(),
createIdentityObject(parent), createIdentityObject(member), MEMBER, null, true);
}
public void associateUsersByIds(String parentId, String memberId) throws
IdentityException
{
+ checkNotNullArgument(parentId, "Parent group Id");
+ checkNotNullArgument(memberId, "Member user Id");
+
getRepository().createRelationship(getInvocationContext(),
createIdentityObjectForGroupId(parentId), createIdentityObjectForUserName(memberId),
MEMBER, null, true);
}
public void disassociateGroups(Collection<Group> parents,
Collection<Group> members) throws IdentityException
{
+ checkNotNullArgument(parents, "parents");
+ checkNotNullArgument(members, "members");
+
for (Iterator<Group> parentsIterator = parents.iterator();
parentsIterator.hasNext();)
{
Group parent = parentsIterator.next();
@@ -253,6 +281,9 @@
public void disassociateGroupsByIds(Collection<String> parents,
Collection<String> members) throws IdentityException
{
+ checkNotNullArgument(parents, "parents");
+ checkNotNullArgument(members, "members");
+
for (Iterator<String> parentsIterator = parents.iterator();
parentsIterator.hasNext();)
{
String parent = parentsIterator.next();
@@ -268,6 +299,9 @@
public void disassociateUsers(Collection<Group> parents, Collection<User>
members) throws IdentityException
{
+ checkNotNullArgument(parents, "parents");
+ checkNotNullArgument(members, "members");
+
for (Iterator<Group> parentsIterator = parents.iterator();
parentsIterator.hasNext();)
{
Group parent = parentsIterator.next();
@@ -284,6 +318,10 @@
public void disassociateUsersByIds(Collection<String> parents,
Collection<String> members) throws IdentityException
{
+ checkNotNullArgument(parents, "parents");
+ checkNotNullArgument(members, "members");
+
+
for (Iterator<String> parentsIterator = parents.iterator();
parentsIterator.hasNext();)
{
String parent = parentsIterator.next();
@@ -301,6 +339,10 @@
{
//TODO: maybe IdentityStore should have isRelationshipPresent method to improve
this?
+ checkNotNullArgument(parents, "parents");
+ checkNotNullArgument(members, "members");
+
+
for (Iterator<G> parentsIterator = parents.iterator();
parentsIterator.hasNext();)
{
IdentityType parent = parentsIterator.next();
@@ -323,6 +365,10 @@
public boolean isAssociatedByIds(Collection<String> parents,
Collection<String> members) throws IdentityException
{
+ checkNotNullArgument(parents, "parents");
+ checkNotNullArgument(members, "members");
+
+
for (Iterator<String> parentsIterator = parents.iterator();
parentsIterator.hasNext();)
{
String parent = parentsIterator.next();
@@ -344,6 +390,10 @@
public <G extends IdentityType, I extends IdentityType> boolean isAssociated(G
parent, I member) throws IdentityException
{
+ checkNotNullArgument(parent, "Parent IdentityType");
+ checkNotNullArgument(member, "Member IdentityType");
+
+
Set<G> parents = new HashSet<G>();
parents.add(parent);
Set<I> members = new HashSet<I>();
@@ -354,6 +404,10 @@
public boolean isAssociatedByIds(String parent, String member) throws
IdentityException
{
+ checkNotNullArgument(parent, "Parent Id");
+ checkNotNullArgument(member, "Member Id");
+
+
Collection<IdentityObjectRelationship> relationships =
getRepository().resolveRelationships(getInvocationContext(), createIdentityObject(parent),
createIdentityObject(member), MEMBER);
if (relationships.size() == 0)
@@ -366,6 +420,8 @@
public Collection<Group> findAssociatedGroups(Group group, String groupType,
boolean parent, boolean inherited, IdentitySearchControl[] controls) throws
IdentityException
{
+ checkNotNullArgument(group, "Group");
+ checkNotNullArgument(groupType, "Group type");
List<Group> identities = new LinkedList<Group>();
@@ -393,6 +449,9 @@
public Collection<Group> findAssociatedGroups(String groupId, String groupType,
boolean parent, boolean inherited, IdentitySearchControl[] controls) throws
IdentityException
{
+ checkNotNullArgument(groupId, "Group Id");
+ checkNotNullArgument(groupType, "Group type");
+
Group group = createGroupFromId(groupId);
return findAssociatedGroups(group, groupType, parent, inherited, controls);
@@ -400,11 +459,17 @@
public Collection<Group> findAssociatedGroups(Group group, String groupType,
boolean parent, boolean inherited) throws IdentityException
{
+ checkNotNullArgument(group, "Group");
+ checkNotNullArgument(groupType, "Group type");
+
return findAssociatedGroups(group, groupType, parent, inherited, null);
}
public Collection<Group> findAssociatedGroups(User identity, String groupType,
IdentitySearchControl[] controls) throws IdentityException
{
+ checkNotNullArgument(identity, "User");
+ checkNotNullArgument(groupType, "Group type");
+
List<Group> identities = new LinkedList<Group>();
IdentityObjectType iot = getIdentityObjectType(groupType);
@@ -424,6 +489,9 @@
public Collection<Group> findAssociatedGroups(String userName, String groupType,
IdentitySearchControl[] controls) throws IdentityException
{
+ checkNotNullArgument(userName, "User name");
+ checkNotNullArgument(groupType, "Group type");
+
User user = createUserFromId(userName);
return findAssociatedGroups(user, groupType, controls);
@@ -431,11 +499,16 @@
public Collection<Group> findAssociatedGroups(User identity, String groupType)
throws IdentityException
{
+ checkNotNullArgument(identity, "User");
+ checkNotNullArgument(groupType, "Group type");
+
return findAssociatedGroups(identity, groupType, null);
}
public Collection<Group> findAssociatedGroups(User identity,
IdentitySearchControl[] controls) throws IdentityException
{
+ checkNotNullArgument(identity, "User");
+
List<Group> identities = new LinkedList<Group>();
Collection<IdentityObject> ios =
getRepository().findIdentityObject(getInvocationContext(), createIdentityObject(identity),
MEMBER, false, convertSearchControls(controls));
@@ -450,6 +523,8 @@
public Collection<Group> findAssociatedGroups(String userName,
IdentitySearchControl[] controls) throws IdentityException
{
+ checkNotNullArgument(userName, "User name");
+
User user = createUserFromId(userName);
return findAssociatedGroups(user, controls);
@@ -457,11 +532,15 @@
public Collection<Group> findAssociatedGroups(User identity) throws
IdentityException
{
+ checkNotNullArgument(identity, "User");
+
return findAssociatedGroups(identity, new IdentitySearchControl[] {});
}
public Collection<User> findAssociatedUsers(Group group, boolean inherited,
IdentitySearchControl[] controls) throws IdentityException
{
+ checkNotNullArgument(group, "Group");
+
List<User> identities = new LinkedList<User>();
//TODO Handle inherited
@@ -487,6 +566,8 @@
public Collection<User> findAssociatedUsers(String groupId, boolean inherited,
IdentitySearchControl[] controls) throws IdentityException
{
+ checkNotNullArgument(groupId, "Group Id");
+
Group group = createGroupFromId(groupId);
return findAssociatedUsers(group, inherited, controls);
@@ -494,6 +575,8 @@
public Collection<User> findAssociatedUsers(Group group, boolean inherited)
throws IdentityException
{
+ checkNotNullArgument(group, "Group");
+
return findAssociatedUsers(group, inherited, null);
}
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RoleManagerImpl.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RoleManagerImpl.java 2009-03-18
20:27:31 UTC (rev 380)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RoleManagerImpl.java 2009-03-18
21:22:32 UTC (rev 381)
@@ -102,6 +102,9 @@
public RoleType createRoleType(String name) throws IdentityException
{
+ checkNotNullArgument(name, "RoleType name");
+ checkObjectName(name);
+
String roleType = null;
try
@@ -118,6 +121,8 @@
public void removeRoleType(String name) throws IdentityException
{
+ checkNotNullArgument(name, "RoleType name");
+
try
{
getRepository().removeRelationshipName(getInvocationContext(), name);
@@ -130,11 +135,15 @@
public void removeRoleType(RoleType roleType) throws IdentityException
{
+ checkNotNullArgument(roleType, "RoleType");
+
removeRoleType(roleType.getName());
}
public RoleType getRoleType(String name) throws IdentityException
{
+
+ checkNotNullArgument(name, "RoleType name");
try
{
Set<String> names =
getRepository().getRelationshipNames(getInvocationContext(), null);
@@ -153,6 +162,7 @@
public Collection<RoleType> findRoleTypes(IdentitySearchControl[] controls)
throws IdentityException
{
+
try
{
@@ -175,6 +185,10 @@
public Role createRole(RoleType roleType, User identity, Group group) throws
IdentityException
{
+ checkNotNullArgument(roleType, "RoleType");
+ checkNotNullArgument(identity, "User");
+ checkNotNullArgument(group, "Group");
+
//TODO: add createRoleType switch to the API
IdentityObjectRelationship rel =
getRepository().createRelationship(getInvocationContext(), createIdentityObject(identity),
createIdentityObject(group), ROLE, roleType.getName(), false);
@@ -186,6 +200,10 @@
public Role createRole(String roleTypeName, String userName, String groupId) throws
IdentityException
{
+ checkNotNullArgument(roleTypeName, "RoleType name");
+ checkNotNullArgument(userName, "User name");
+ checkNotNullArgument(groupId, "Group Id");
+
User user = createUserFromId(userName);
Group group = createGroupFromId(groupId);
@@ -194,11 +212,19 @@
public void removeRole(RoleType roleType, User identity, Group group) throws
IdentityException
{
+ checkNotNullArgument(roleType, "RoleType");
+ checkNotNullArgument(identity, "User");
+ checkNotNullArgument(group, "Group");
+
getRepository().removeRelationship(getInvocationContext(),
createIdentityObject(identity), createIdentityObject(group), ROLE, roleType.getName());
}
public void removeRole(String roleTypeName, String userName, String groupId) throws
IdentityException
{
+ checkNotNullArgument(roleTypeName, "RoleType name");
+ checkNotNullArgument(userName, "User name");
+ checkNotNullArgument(groupId, "Group Id");
+
User user = createUserFromId(userName);
Group group = createGroupFromId(groupId);
@@ -207,11 +233,17 @@
public void removeRole(Role role) throws IdentityException
{
+ checkNotNullArgument(role, "Role");
+
getRepository().removeRelationship(getInvocationContext(),
createIdentityObject(role.getIdentity()), createIdentityObject(role.getGroup()), ROLE,
role.getRoleType().getName());
}
public boolean hasRole(User identity, Group group, RoleType roleType) throws
IdentityException
{
+ checkNotNullArgument(roleType, "RoleType");
+ checkNotNullArgument(identity, "User");
+ checkNotNullArgument(group, "Group");
+
//TODO: does separate hasRelationship method in IdentityStore makes sense?
Set<IdentityObjectRelationship> rels =
getRepository().resolveRelationships(getInvocationContext(),
createIdentityObject(identity), createIdentityObject(group), ROLE);
@@ -229,6 +261,10 @@
public boolean hasRole(String userName, String groupId, String roleTypeName) throws
IdentityException
{
+ checkNotNullArgument(roleTypeName, "RoleType name");
+ checkNotNullArgument(userName, "User name");
+ checkNotNullArgument(groupId, "Group Id");
+
User user = createUserFromId(userName);
Group group = createGroupFromId(groupId);
@@ -237,11 +273,17 @@
public Collection<RoleType> findRoleTypes(User identity, Group group) throws
IdentityException
{
+
+ checkNotNullArgument(identity, "User");
+ checkNotNullArgument(group, "Group");
+
return findRoleTypes(identity, group, null);
}
public Collection<RoleType> findRoleTypes(User identity, Group group,
IdentitySearchControl[] controls) throws IdentityException
{
+ checkNotNullArgument(identity, "User");
+ checkNotNullArgument(group, "Group");
Set<IdentityObjectRelationship> rels =
getRepository().resolveRelationships(getInvocationContext(),
createIdentityObject(identity), createIdentityObject(group), ROLE);
Set<RoleType> types = new HashSet<RoleType>();
@@ -258,6 +300,9 @@
public Collection<RoleType> findRoleTypes(String userName, String groupId,
IdentitySearchControl[] controls) throws IdentityException
{
+ checkNotNullArgument(userName, "User name");
+ checkNotNullArgument(groupId, "Group Id");
+
User user = createUserFromId(userName);
Group group = createGroupFromId(groupId);
@@ -266,11 +311,15 @@
public Collection<RoleType> findUserRoleTypes(User identity) throws
IdentityException
{
+ checkNotNullArgument(identity, "User");
+
return findUserRoleTypes(identity, null);
}
public Collection<RoleType> findUserRoleTypes(User identity,
IdentitySearchControl[] controls) throws IdentityException
{
+ checkNotNullArgument(identity, "User");
+
Set<RoleType> types = new HashSet<RoleType>();
try
@@ -294,6 +343,8 @@
public Collection<RoleType> findUserRoleTypes(String userName,
IdentitySearchControl[] controls) throws IdentityException
{
+ checkNotNullArgument(userName, "User name");
+
User user = createUserFromId(userName);
return findUserRoleTypes(user, controls);
@@ -301,11 +352,15 @@
public Collection<RoleType> findGroupRoleTypes(Group group) throws
IdentityException
{
+ checkNotNullArgument(group, "Group");
+
return findGroupRoleTypes(group, null);
}
public Collection<RoleType> findGroupRoleTypes(String groupId,
IdentitySearchControl[] controls) throws IdentityException
{
+ checkNotNullArgument(groupId, "Group Id");
+
Group group = createGroupFromId(groupId);
return findGroupRoleTypes(group, controls);
@@ -313,6 +368,8 @@
public Collection<RoleType> findGroupRoleTypes(Group group,
IdentitySearchControl[] controls) throws IdentityException
{
+ checkNotNullArgument(group, "Group");
+
Set<RoleType> types = new HashSet<RoleType>();
try
@@ -336,6 +393,8 @@
public Collection<Group> findGroupsWithRelatedRole(User identity,
IdentitySearchControl[] controls) throws IdentityException
{
+ checkNotNullArgument(identity, "User");
+
List<Group> identities = new LinkedList<Group>();
@@ -354,6 +413,8 @@
public Collection<Group> findGroupsWithRelatedRole(String userName,
IdentitySearchControl[] controls) throws IdentityException
{
+ checkNotNullArgument(userName, "User name");
+
User user = createUserFromId(userName);
return findGroupsWithRelatedRole(user, controls);
@@ -361,6 +422,9 @@
public Collection<Group> findGroupsWithRelatedRole(User identity, String
groupType, IdentitySearchControl[] controls) throws IdentityException
{
+ checkNotNullArgument(identity, "User");
+ checkNotNullArgument(groupType, "Group type");
+
List<Group> identities = new LinkedList<Group>();
IdentityObjectType iot = getIdentityObjectType(groupType);
@@ -382,6 +446,10 @@
public Collection<Group> findGroupsWithRelatedRole(String userName, String
groupType, IdentitySearchControl[] controls) throws IdentityException
{
+ checkNotNullArgument(userName, "User name");
+ checkNotNullArgument(groupType, "Group type");
+
+
User user = createUserFromId(userName);
return findGroupsWithRelatedRole(user, groupType, controls);
@@ -389,6 +457,9 @@
public Collection<Role> findRoles(IdentityType identityType, RoleType roleType)
throws IdentityException
{
+ checkNotNullArgument(identityType, "IdentityType");
+ checkNotNullArgument(roleType, "RoleType");
+
Set<Role> roles = new HashSet<Role>();
Set<IdentityObjectRelationship> relationships = null;
@@ -418,6 +489,9 @@
public <T extends IdentityType> Collection<Role> findRoles(String id,
String roleTypeName) throws IdentityException
{
+ checkNotNullArgument(id, "Group id or User name");
+ checkNotNullArgument(roleTypeName, "RoleType name");
+
return findRoles(createIdentityTypeFromId(id), new SimpleRoleType(roleTypeName));
}
}
Modified:
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/PersistenceManagerTest.java
===================================================================
---
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/PersistenceManagerTest.java 2009-03-18
20:27:31 UTC (rev 380)
+++
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/PersistenceManagerTest.java 2009-03-18
21:22:32 UTC (rev 381)
@@ -31,6 +31,7 @@
import org.jboss.identity.idm.api.AttributeDescription;
import org.jboss.identity.idm.api.IdentitySearchControl;
import org.jboss.identity.idm.p3p.P3PConstants;
+import org.jboss.identity.idm.exception.IdentityException;
import java.util.Collection;
import java.util.Map;
@@ -86,6 +87,29 @@
session.getTransaction().start();
+ // Bad names
+
+ try
+ {
+ session.getPersistenceManager().createUser("lol/olo");
+ fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ // expected
+ }
+
+ try
+ {
+ session.getPersistenceManager().createGroup("/toto", ORGANIZATION);
+ fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ // expected
+ }
+
+
// Create / Remove
// Group
Modified:
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java
===================================================================
---
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java 2009-03-18
20:27:31 UTC (rev 380)
+++
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java 2009-03-18
21:22:32 UTC (rev 381)
@@ -195,7 +195,7 @@
* (such as a pseudonym)
* @return true (virtual identity)
*/
- boolean isVirtual(User user);
+// boolean isVirtual(User user);
}