Author: bdaw
Date: 2009-04-23 06:55:39 -0400 (Thu, 23 Apr 2009)
New Revision: 455
Added:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/types/SimpleIdentityObjectRelationship.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/types/SimpleIdentityObjectRelationshipType.java
Modified:
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RoleManager.java
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/exception/OperationNotSupportedException.java
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/store/FeaturesMetaData.java
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityStore.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AbstractManager.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RoleManagerImpl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheIdentityStoreWrapper.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectRelationship.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectRelationshipName.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/FallbackIdentityStoreRepository.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/WrapperIdentityStoreRepository.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/FeaturesMetaDataImpl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreImpl.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RoleManagerTest.java
Log:
role and roleType properties and few other improvements
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-04-23
03:48:49 UTC (rev 454)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AbstractManager.java 2009-04-23
10:55:39 UTC (rev 455)
@@ -28,13 +28,16 @@
import org.jboss.identity.idm.api.IdentityType;
import org.jboss.identity.idm.api.Attribute;
import org.jboss.identity.idm.api.IdentitySearchCriteria;
+import org.jboss.identity.idm.api.Role;
import org.jboss.identity.idm.spi.repository.IdentityStoreRepository;
import org.jboss.identity.idm.spi.store.IdentityStoreInvocationContext;
import org.jboss.identity.idm.spi.model.IdentityObject;
import org.jboss.identity.idm.spi.model.IdentityObjectType;
import org.jboss.identity.idm.spi.model.IdentityObjectAttribute;
+import org.jboss.identity.idm.spi.model.IdentityObjectRelationship;
import org.jboss.identity.idm.spi.search.IdentityObjectSearchCriteria;
import org.jboss.identity.idm.impl.types.SimpleIdentityObject;
+import org.jboss.identity.idm.impl.types.SimpleIdentityObjectRelationship;
import org.jboss.identity.idm.impl.api.session.context.IdentitySessionContext;
import org.jboss.identity.idm.impl.api.session.IdentitySessionImpl;
import org.jboss.identity.idm.impl.api.model.SimpleUser;
@@ -174,6 +177,8 @@
}
}
+
+
protected Group createGroupFromId(String id)
{
return new SimpleGroup(new GroupId(id));
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RoleManagerImpl.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RoleManagerImpl.java 2009-04-23
03:48:49 UTC (rev 454)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RoleManagerImpl.java 2009-04-23
10:55:39 UTC (rev 455)
@@ -41,12 +41,17 @@
import org.jboss.identity.idm.spi.store.IdentityObjectSearchCriteriaType;
import org.jboss.identity.idm.impl.api.model.SimpleRoleType;
import org.jboss.identity.idm.impl.api.model.SimpleRole;
+import org.jboss.identity.idm.impl.api.model.SimpleUser;
+import org.jboss.identity.idm.impl.api.model.SimpleGroup;
+import org.jboss.identity.idm.impl.types.SimpleIdentityObjectRelationship;
import java.util.Collection;
import java.util.Set;
import java.util.HashSet;
import java.util.List;
import java.util.LinkedList;
+import java.util.Map;
+import java.util.HashMap;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
@@ -92,6 +97,16 @@
};
}
+ protected IdentityObjectRelationship createIdentityObjectRelationship(Role role)
+ {
+ return new SimpleIdentityObjectRelationship(
+ createIdentityObject(role.getGroup()),
+ createIdentityObject(role.getIdentity()),
+ role.getRoleType().getName(),
+ ROLE
+ );
+ }
+
public RoleManagerFeaturesDescription getSupportedFeatures()
{
return featuresDescription;
@@ -268,6 +283,48 @@
return hasRole(user, group, new SimpleRoleType(roleTypeName));
}
+ public Role getRole(RoleType roleType, User user, Group group) throws
IdentityException
+ {
+ checkNotNullArgument(roleType, "RoleType");
+ checkNotNullArgument(user, "User");
+ checkNotNullArgument(group, "Group");
+
+ //TODO: does separate hasRelationship method in IdentityStore makes sense?
+
+ Set<IdentityObjectRelationship> rels =
getRepository().resolveRelationships(getInvocationContext(), createIdentityObject(group),
createIdentityObject(user), ROLE);
+
+ if (rels.size() == 0)
+ {
+ throw new IdentityException("No such role present");
+ }
+
+ if (rels.size() > 1)
+ {
+ throw new IdentityException("More than one role definition present -
illegal state!");
+ }
+
+ IdentityObjectRelationship relationship = rels.iterator().next();
+
+ return new SimpleRole(new SimpleRoleType(relationship.getType().getName()),
+ createUser(relationship.getFromIdentityObject()),
+ createGroup(relationship.getToIdentityObject()));
+ }
+
+ public Role getRole(String roleTypeName, String userId, String groupId) throws
IdentityException
+ {
+ checkNotNullArgument(roleTypeName, "RoleType name");
+ checkNotNullArgument(userId, "User id");
+ checkNotNullArgument(groupId, "Group Id");
+
+ // TODO: Check if relationship is present in the store
+
+ User user = createUserFromId(userId);
+ Group group = createGroupFromId(groupId);
+ RoleType roleType = new SimpleRoleType(roleTypeName);
+
+ return getRole(roleType, user, group);
+ }
+
public Collection<RoleType> findRoleTypes(User identity, Group group) throws
IdentityException
{
@@ -484,11 +541,122 @@
}
- public <T extends IdentityType> Collection<Role> findRoles(String id,
String roleTypeName) throws IdentityException
+ public 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));
}
+
+ public Map<String, String> getProperties(RoleType roleType) throws
IdentityException
+ {
+ checkNotNullArgument(roleType, "RoleType name");
+
+ return getRepository().getRelationshipNameProperties(getInvocationContext(),
roleType.getName());
+ }
+
+ public Map<String, String> getProperties(String roleTypeName) throws
IdentityException
+ {
+ checkNotNullArgument(roleTypeName, "RoleType name");
+
+ return getProperties(new SimpleRoleType(roleTypeName));
+ }
+
+ public Map<String, String> getProperties(Role role) throws IdentityException
+ {
+ checkNotNullArgument(role, "Role");
+
+ return getRepository().getRelationshipProperties(getInvocationContext(),
createIdentityObjectRelationship(role));
+ }
+
+ public void setProperty(Role role, String name, String value) throws
IdentityException
+ {
+ checkNotNullArgument(role, "Role");
+ checkNotNullArgument(name, "Property name");
+ checkNotNullArgument(value, "Property value");
+
+ Map<String, String> props = new HashMap<String, String>();
+ props.put(name, value);
+
+
+ getRepository().setRelationshipProperties(getInvocationContext(),
createIdentityObjectRelationship(role), props);
+ }
+
+ public void setProperty(RoleType roleType, String name, String value) throws
IdentityException
+ {
+ checkNotNullArgument(roleType, "RoleType");
+ checkNotNullArgument(name, "Property name");
+ checkNotNullArgument(value, "Property value");
+
+ Map<String, String> props = new HashMap<String, String>();
+ props.put(name, value);
+
+
+ getRepository().setRelationshipNameProperties(getInvocationContext(),
roleType.getName(), props);
+ }
+
+ public void setProperty(String roleTypeName, String name, String value) throws
IdentityException
+ {
+ checkNotNullArgument(roleTypeName, "RoleType name");
+ checkNotNullArgument(name, "Property name");
+ checkNotNullArgument(value, "Property value");
+
+ setProperty(new SimpleRoleType(roleTypeName), name, value);
+ }
+
+ public void setProperties(Role role, Map<String, String> properties) throws
IdentityException
+ {
+ checkNotNullArgument(role, "Role");
+ checkNotNullArgument(properties, "Properties");
+
+
+ getRepository().setRelationshipProperties(getInvocationContext(),
createIdentityObjectRelationship(role), properties);
+ }
+
+ public void setProperties(RoleType roleType, Map<String, String> properties)
throws IdentityException
+ {
+ checkNotNullArgument(roleType, "RoleType");
+ checkNotNullArgument(properties, "Properties");
+
+
+ getRepository().setRelationshipNameProperties(getInvocationContext(),
roleType.getName(), properties);
+ }
+
+ public void setProperties(String roleTypeName, Map<String, String> properties)
throws IdentityException
+ {
+ checkNotNullArgument(roleTypeName, "RoleType name");
+
+ setProperties(new SimpleRoleType(roleTypeName), properties);
+ }
+
+ public void removeProperty(Role role, String name) throws IdentityException
+ {
+ checkNotNullArgument(role, "Role");
+ checkNotNullArgument(name, "Property name");
+
+ Set<String> names = new HashSet<String>();
+ names.add(name);
+
+ getRepository().removeRelationshipProperties(getInvocationContext(),
createIdentityObjectRelationship(role), names);
+ }
+
+ public void removeProperty(RoleType roleType, String name) throws IdentityException
+ {
+ checkNotNullArgument(roleType, "RoleType");
+ checkNotNullArgument(name, "Property name");
+
+ Set<String> names = new HashSet<String>();
+ names.add(name);
+
+
+ getRepository().removeRelationshipNameProperties(getInvocationContext(),
roleType.getName(), names);
+ }
+
+ public void removeProperty(String roleTypeName, String name) throws IdentityException
+ {
+ checkNotNullArgument(roleTypeName, "RoleType name");
+
+ removeProperty(new SimpleRoleType(roleTypeName), name);
+ }
}
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheIdentityStoreWrapper.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheIdentityStoreWrapper.java 2009-04-23
03:48:49 UTC (rev 454)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheIdentityStoreWrapper.java 2009-04-23
10:55:39 UTC (rev 455)
@@ -376,8 +376,45 @@
return results;
}
-
+ public Map<String, String>
getRelationshipNameProperties(IdentityStoreInvocationContext ctx, String name) throws
IdentityException, OperationNotSupportedException
+ {
+ //TODO: apply caching
+ return identityStore.getRelationshipNameProperties(ctx, name);
+ }
+
+ public void setRelationshipNameProperties(IdentityStoreInvocationContext ctx, String
name, Map<String, String> properties) throws IdentityException,
OperationNotSupportedException
+ {
+ //TODO: apply caching
+ identityStore.setRelationshipNameProperties(ctx, name, properties);
+ }
+
+ public void removeRelationshipNameProperties(IdentityStoreInvocationContext ctx,
String name, Set<String> properties) throws IdentityException,
OperationNotSupportedException
+ {
+ //TODO: apply caching
+ identityStore.removeRelationshipNameProperties(ctx, name, properties);
+
+ }
+
+ public Map<String, String>
getRelationshipProperties(IdentityStoreInvocationContext ctx, IdentityObjectRelationship
relationship) throws IdentityException, OperationNotSupportedException
+ {
+ //TODO: apply caching
+ return identityStore.getRelationshipProperties(ctx, relationship);
+ }
+
+ public void setRelationshipProperties(IdentityStoreInvocationContext ctx,
IdentityObjectRelationship relationship, Map<String, String> properties) throws
IdentityException, OperationNotSupportedException
+ {
+ //TODO: apply caching
+ identityStore.setRelationshipProperties(ctx, relationship, properties);
+
+ }
+
+ public void removeRelationshipProperties(IdentityStoreInvocationContext ctx,
IdentityObjectRelationship relationship, Set<String> properties) throws
IdentityException, OperationNotSupportedException
+ {
+ //TODO: apply caching
+ identityStore.removeRelationshipProperties(ctx, relationship, properties);
+ }
+
public boolean validateCredential(IdentityStoreInvocationContext ctx,
IdentityObject identityObject,
IdentityObjectCredential credential) throws
IdentityException
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectRelationship.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectRelationship.java 2009-04-23
03:48:49 UTC (rev 454)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectRelationship.java 2009-04-23
10:55:39 UTC (rev 455)
@@ -32,12 +32,18 @@
import javax.persistence.JoinColumn;
import javax.persistence.UniqueConstraint;
import javax.persistence.FetchType;
+import javax.persistence.JoinTable;
+import javax.persistence.Column;
import org.jboss.identity.idm.spi.model.IdentityObjectRelationship;
import org.jboss.identity.idm.spi.model.IdentityObjectRelationshipType;
import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObject;
import
org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipType;
+import org.hibernate.annotations.CollectionOfElements;
+import java.util.Map;
+import java.util.HashMap;
+
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
* @version : 0.1 $
@@ -73,6 +79,11 @@
@JoinColumn(nullable = false, name="TO_IDENTITY")
private HibernateIdentityObject toIdentityObject;
+ @CollectionOfElements
+ @JoinTable(name = "jbid_io_rel_props", joinColumns = @JoinColumn(name =
"REALATIONSHIP_ID"))
+ @Column(name = "PROPERTY")
+ private Map<String, String> properties = new HashMap<String, String>();
+
public HibernateIdentityObjectRelationship()
{
}
@@ -149,4 +160,14 @@
{
this.name = name;
}
+
+ public Map<String, String> getProperties()
+ {
+ return properties;
+ }
+
+ public void setProperties(Map<String, String> properties)
+ {
+ this.properties = properties;
+ }
}
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectRelationshipName.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectRelationshipName.java 2009-04-23
03:48:49 UTC (rev 454)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectRelationshipName.java 2009-04-23
10:55:39 UTC (rev 455)
@@ -22,6 +22,8 @@
package org.jboss.identity.idm.impl.model.hibernate;
+import org.hibernate.annotations.CollectionOfElements;
+
import javax.persistence.Table;
import javax.persistence.Entity;
import javax.persistence.Column;
@@ -32,6 +34,9 @@
import javax.persistence.ManyToOne;
import javax.persistence.JoinColumn;
import javax.persistence.UniqueConstraint;
+import javax.persistence.JoinTable;
+import java.util.Map;
+import java.util.HashMap;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
@@ -83,6 +88,11 @@
@JoinColumn(nullable = false, name="REALM")
private HibernateRealm realm;
+ @CollectionOfElements
+ @JoinTable(name = "jbid_io_rel_name_props", joinColumns = @JoinColumn(name =
"REALATIONSHIP_NAME_ID"))
+ @Column(name = "PROPERTY")
+ private Map<String, String> properties = new HashMap<String, String>();
+
public HibernateIdentityObjectRelationshipName()
{
}
@@ -122,4 +132,14 @@
{
this.realm = realm;
}
+
+ public Map<String, String> getProperties()
+ {
+ return properties;
+ }
+
+ public void setProperties(Map<String, String> properties)
+ {
+ this.properties = properties;
+ }
}
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/FallbackIdentityStoreRepository.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/FallbackIdentityStoreRepository.java 2009-04-23
03:48:49 UTC (rev 454)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/FallbackIdentityStoreRepository.java 2009-04-23
10:55:39 UTC (rev 455)
@@ -147,6 +147,19 @@
return
defaultIdentityStore.getSupportedFeatures().isNamedRelationshipsSupported();
}
+ public boolean isRelationshipPropertiesSupported()
+ {
+ // If there is any IdentityStore that supports relationship properties...
+ for (IdentityStore identityStore : getIdentityStoreMappings().values())
+ {
+ if
(identityStore.getSupportedFeatures().isRelationshipPropertiesSupported())
+ {
+ return true;
+ }
+ }
+ return
defaultIdentityStore.getSupportedFeatures().isRelationshipPropertiesSupported();
+ }
+
public boolean isSearchCriteriaTypeSupported(IdentityObjectType
identityObjectType, IdentityObjectSearchCriteriaType storeSearchConstraint)
{
return
resolveIdentityStore(identityObjectType).getSupportedFeatures().isSearchCriteriaTypeSupported(identityObjectType,
storeSearchConstraint);
@@ -683,6 +696,101 @@
return defaultIdentityStore.getRelationshipNames(defaultCtx, identity, controls);
}
+ public Map<String, String>
getRelationshipNameProperties(IdentityStoreInvocationContext ctx, String name) throws
IdentityException, OperationNotSupportedException
+ {
+ Map<String, String> results = new HashMap<String, String>();
+
+ // For any IdentityStore that supports named relationships...
+ for (IdentityStore identityStore : configuredIdentityStores)
+ {
+ if (identityStore.getSupportedFeatures().isNamedRelationshipsSupported())
+ {
+ IdentityStoreInvocationContext storeCtx =
resolveInvocationContext(identityStore, ctx);
+
+ Map<String, String> props =
identityStore.getRelationshipNameProperties(storeCtx, name);
+ if (props != null && props.keySet().size() > 0)
+ {
+ results.putAll(props);
+ }
+
+ }
+ }
+
+ return results;
+ }
+
+ public void setRelationshipNameProperties(IdentityStoreInvocationContext ctx, String
name, Map<String, String> properties) throws IdentityException,
OperationNotSupportedException
+ {
+ // For any IdentityStore that supports named relationships...
+ for (IdentityStore identityStore : configuredIdentityStores)
+ {
+ if (identityStore.getSupportedFeatures().isNamedRelationshipsSupported())
+ {
+ IdentityStoreInvocationContext storeCtx =
resolveInvocationContext(identityStore, ctx);
+
+ identityStore.setRelationshipNameProperties(storeCtx, name, properties);
+
+ }
+ }
+ }
+
+ public void removeRelationshipNameProperties(IdentityStoreInvocationContext ctx,
String name, Set<String> properties) throws IdentityException,
OperationNotSupportedException
+ {
+ // For any IdentityStore that supports named relationships...
+ for (IdentityStore identityStore : configuredIdentityStores)
+ {
+ if (identityStore.getSupportedFeatures().isNamedRelationshipsSupported())
+ {
+ IdentityStoreInvocationContext storeCtx =
resolveInvocationContext(identityStore, ctx);
+
+ identityStore.removeRelationshipNameProperties(storeCtx, name, properties);
+
+ }
+ }
+ }
+
+ public Map<String, String>
getRelationshipProperties(IdentityStoreInvocationContext ctx, IdentityObjectRelationship
relationship) throws IdentityException, OperationNotSupportedException
+ {
+
+ IdentityStore fromStore =
resolveIdentityStore(relationship.getFromIdentityObject());
+ IdentityStore toStore = resolveIdentityStore(relationship.getToIdentityObject());
+
+ if (fromStore == toStore &&
toStore.getSupportedFeatures().isNamedRelationshipsSupported())
+ {
+ return fromStore.getRelationshipProperties(resolveInvocationContext(fromStore,
ctx), relationship);
+ }
+
+ return
defaultIdentityStore.getRelationshipProperties(resolveInvocationContext(defaultIdentityStore,
ctx), relationship);
+ }
+
+ public void setRelationshipProperties(IdentityStoreInvocationContext ctx,
IdentityObjectRelationship relationship, Map<String, String> properties) throws
IdentityException, OperationNotSupportedException
+ {
+ IdentityStore fromStore =
resolveIdentityStore(relationship.getFromIdentityObject());
+ IdentityStore toStore = resolveIdentityStore(relationship.getToIdentityObject());
+
+ if (fromStore == toStore &&
toStore.getSupportedFeatures().isNamedRelationshipsSupported())
+ {
+ fromStore.setRelationshipProperties(resolveInvocationContext(fromStore, ctx),
relationship, properties);
+ return;
+ }
+
+
defaultIdentityStore.setRelationshipProperties(resolveInvocationContext(defaultIdentityStore,
ctx), relationship, properties);
+ }
+
+ public void removeRelationshipProperties(IdentityStoreInvocationContext ctx,
IdentityObjectRelationship relationship, Set<String> properties) throws
IdentityException, OperationNotSupportedException
+ {
+ IdentityStore fromStore =
resolveIdentityStore(relationship.getFromIdentityObject());
+ IdentityStore toStore = resolveIdentityStore(relationship.getToIdentityObject());
+
+ if (fromStore == toStore &&
toStore.getSupportedFeatures().isNamedRelationshipsSupported())
+ {
+ fromStore.removeRelationshipProperties(resolveInvocationContext(fromStore, ctx),
relationship, properties);
+ return;
+ }
+
+
defaultIdentityStore.removeRelationshipProperties(resolveInvocationContext(defaultIdentityStore,
ctx), relationship, properties);
+ }
+
public boolean validateCredential(IdentityStoreInvocationContext ctx, IdentityObject
identityObject, IdentityObjectCredential credential) throws IdentityException
{
IdentityStore toStore = resolveIdentityStore(identityObject);
@@ -1016,4 +1124,4 @@
{
return allowNotDefinedAttributes;
}
-}
\ No newline at end of file
+}
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/WrapperIdentityStoreRepository.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/WrapperIdentityStoreRepository.java 2009-04-23
03:48:49 UTC (rev 454)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/WrapperIdentityStoreRepository.java 2009-04-23
10:55:39 UTC (rev 455)
@@ -249,6 +249,37 @@
return
defaultIdentityStore.getRelationshipNames(resolveIdentityStoreInvocationContext(ctx),
identity, controls);
}
+ public Map<String, String>
getRelationshipNameProperties(IdentityStoreInvocationContext ctx, String name) throws
IdentityException, OperationNotSupportedException
+ {
+ return
defaultIdentityStore.getRelationshipNameProperties(resolveAttributeStoreInvocationContext(ctx),
name);
+ }
+
+ public void setRelationshipNameProperties(IdentityStoreInvocationContext ctx, String
name, Map<String, String> properties) throws IdentityException,
OperationNotSupportedException
+ {
+
defaultIdentityStore.setRelationshipNameProperties(resolveIdentityStoreInvocationContext(ctx),
name, properties);
+
+ }
+
+ public void removeRelationshipNameProperties(IdentityStoreInvocationContext ctx,
String name, Set<String> properties) throws IdentityException,
OperationNotSupportedException
+ {
+
defaultIdentityStore.removeRelationshipNameProperties(resolveIdentityStoreInvocationContext(ctx),
name, properties);
+ }
+
+ public Map<String, String>
getRelationshipProperties(IdentityStoreInvocationContext ctx, IdentityObjectRelationship
relationship) throws IdentityException, OperationNotSupportedException
+ {
+ return
defaultIdentityStore.getRelationshipProperties(resolveIdentityStoreInvocationContext(ctx),
relationship);
+ }
+
+ public void setRelationshipProperties(IdentityStoreInvocationContext ctx,
IdentityObjectRelationship relationship, Map<String, String> properties) throws
IdentityException, OperationNotSupportedException
+ {
+
defaultIdentityStore.setRelationshipProperties(resolveIdentityStoreInvocationContext(ctx),
relationship, properties);
+ }
+
+ public void removeRelationshipProperties(IdentityStoreInvocationContext ctx,
IdentityObjectRelationship relationship, Set<String> properties) throws
IdentityException, OperationNotSupportedException
+ {
+
defaultIdentityStore.removeRelationshipProperties(resolveIdentityStoreInvocationContext(ctx),
relationship, properties);
+ }
+
public boolean validateCredential(IdentityStoreInvocationContext ctx,
IdentityObject identityObject,
IdentityObjectCredential credential) throws
IdentityException
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/FeaturesMetaDataImpl.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/FeaturesMetaDataImpl.java 2009-04-23
03:48:49 UTC (rev 454)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/FeaturesMetaDataImpl.java 2009-04-23
10:55:39 UTC (rev 455)
@@ -55,15 +55,20 @@
private final Set<String> readOnlyObjectTypes;
+ private final boolean relationshipPropertiesSupport;
+
// <Relationship Type, <From IdentityType, To IdentityType>>
private final Map<String, Map<String, Set<String>>>
supportedRelationshipMappings = new HashMap<String, Map<String,
Set<String>>>();
public FeaturesMetaDataImpl(IdentityStoreConfigurationMetaData configurationMD,
Set<IdentityObjectSearchCriteriaType>
supportedControls,
+ boolean relationshipPropertiesSupport,
boolean namedRelationshipsSupport,
Set<String> readOnlyObjectTypes)
{
+
+ this.relationshipPropertiesSupport = relationshipPropertiesSupport;
this.namedRelationshipsSupport = namedRelationshipsSupport;
this.readOnlyObjectTypes = readOnlyObjectTypes;
@@ -163,6 +168,11 @@
return namedRelationshipsSupport;
}
+ public boolean isRelationshipPropertiesSupported()
+ {
+ return relationshipPropertiesSupport;
+ }
+
public boolean isSearchCriteriaTypeSupported(IdentityObjectType identityObjectType,
IdentityObjectSearchCriteriaType storeSearchConstraint)
{
if (supportedSearchConstraintTypes.contains(storeSearchConstraint))
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java 2009-04-23
03:48:49 UTC (rev 454)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java 2009-04-23
10:55:39 UTC (rev 455)
@@ -179,7 +179,7 @@
id = configurationMD.getId();
- supportedFeatures = new FeaturesMetaDataImpl(configurationMD,
supportedIdentityObjectSearchControls, true, new HashSet<String>());
+ supportedFeatures = new FeaturesMetaDataImpl(configurationMD,
supportedIdentityObjectSearchControls, true, true, new HashSet<String>());
String populateMembershipTypes =
configurationMD.getOptionSingleValue(POPULATE_MEMBERSHIP_TYPES);
@@ -1237,6 +1237,241 @@
return getRelationshipNames(ctx, identity, null);
}
+ public Map<String, String>
getRelationshipNameProperties(IdentityStoreInvocationContext ctx, String name) throws
IdentityException, OperationNotSupportedException
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("name is null");
+ }
+
+ Session em = getHibernateSession(ctx);
+
+
+ try
+ {
+ HibernateIdentityObjectRelationshipName hiorn =
(HibernateIdentityObjectRelationshipName)em.createCriteria(HibernateIdentityObjectRelationshipName.class)
+ .add(Restrictions.eq("name",
name)).add(Restrictions.eq("realm", getRealm(em, ctx))).uniqueResult();
+
+ if (hiorn == null)
+ {
+ throw new IdentityException("Relationship name doesn't
exist");
+ }
+
+ return new HashMap<String, String>(hiorn.getProperties());
+
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Cannot get relationship name properties:
" + name, e);
+ }
+ }
+
+ public void setRelationshipNameProperties(IdentityStoreInvocationContext ctx, String
name, Map<String, String> properties) throws IdentityException,
OperationNotSupportedException
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("name is null");
+ }
+
+ Session em = getHibernateSession(ctx);
+
+
+ try
+ {
+ HibernateIdentityObjectRelationshipName hiorn =
(HibernateIdentityObjectRelationshipName)em.createCriteria(HibernateIdentityObjectRelationshipName.class)
+ .add(Restrictions.eq("name",
name)).add(Restrictions.eq("realm", getRealm(em, ctx))).uniqueResult();
+
+ if (hiorn == null)
+ {
+ throw new IdentityException("Relationship name doesn't
exist");
+ }
+
+ hiorn.getProperties().putAll(properties);
+
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Cannot set relationship name properties:
" + name, e);
+ }
+ }
+
+ public void removeRelationshipNameProperties(IdentityStoreInvocationContext ctx,
String name, Set<String> properties) throws IdentityException,
OperationNotSupportedException
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("name is null");
+ }
+
+ Session em = getHibernateSession(ctx);
+
+
+ try
+ {
+ HibernateIdentityObjectRelationshipName hiorn =
(HibernateIdentityObjectRelationshipName)em.createCriteria(HibernateIdentityObjectRelationshipName.class)
+ .add(Restrictions.eq("name",
name)).add(Restrictions.eq("realm", getRealm(em, ctx))).uniqueResult();
+
+ if (hiorn == null)
+ {
+ throw new IdentityException("Relationship name doesn't
exist");
+ }
+
+ for (String property : properties)
+ {
+ hiorn.getProperties().remove(property);
+ }
+
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Cannot remove relationship name properties:
" + name, e);
+ }
+ }
+
+ public Map<String, String>
getRelationshipProperties(IdentityStoreInvocationContext ctx, IdentityObjectRelationship
relationship) throws IdentityException, OperationNotSupportedException
+ {
+ HibernateIdentityObject fromIO = safeGet(ctx,
relationship.getFromIdentityObject());
+ HibernateIdentityObject toIO = safeGet(ctx, relationship.getToIdentityObject());
+ HibernateIdentityObjectRelationshipType type =
getHibernateIdentityObjectRelationshipType(ctx, relationship.getType());
+
+ Query query = null;
+
+ if (relationship.getName() == null)
+ {
+ query =
getHibernateSession(ctx).createQuery(QUERY_RELATIONSHIP_BY_FROM_TO_TYPE)
+ .setParameter("fromIO", fromIO)
+ .setParameter("toIO", toIO)
+ .setParameter("typeName", type.getName());
+ }
+ else
+ {
+ HibernateIdentityObjectRelationshipName relationshipName =
+ (HibernateIdentityObjectRelationshipName)getHibernateSession(ctx)
+
.createCriteria(HibernateIdentityObjectRelationshipName.class).add(Restrictions.eq("name",
relationship.getName()))
+ .uniqueResult();
+
+ if (relationshipName == null)
+ {
+ throw new IdentityException("Relationship name not present in the
store");
+ }
+
+ query =
getHibernateSession(ctx).createQuery(QUERY_RELATIONSHIP_BY_FROM_TO_TYPE_NAME)
+ .setParameter("fromIO", fromIO)
+ .setParameter("toIO", toIO)
+ .setParameter("typeName", type.getName())
+ .setParameter("name", relationship.getName());
+ }
+
+
+ try
+ {
+ HibernateIdentityObjectRelationship hibernateRelationship =
(HibernateIdentityObjectRelationship)query.uniqueResult();
+
+ return new HashMap<String,
String>(hibernateRelationship.getProperties());
+ }
+ catch (HibernateException e)
+ {
+ throw new IdentityException("Cannot obtain relationship properties: ",
e);
+ }
+ }
+
+ public void setRelationshipProperties(IdentityStoreInvocationContext ctx,
IdentityObjectRelationship relationship, Map<String, String> properties) throws
IdentityException, OperationNotSupportedException
+ {
+ HibernateIdentityObject fromIO = safeGet(ctx,
relationship.getFromIdentityObject());
+ HibernateIdentityObject toIO = safeGet(ctx, relationship.getToIdentityObject());
+ HibernateIdentityObjectRelationshipType type =
getHibernateIdentityObjectRelationshipType(ctx, relationship.getType());
+
+ Query query = null;
+
+ if (relationship.getName() == null)
+ {
+ query =
getHibernateSession(ctx).createQuery(QUERY_RELATIONSHIP_BY_FROM_TO_TYPE)
+ .setParameter("fromIO", fromIO)
+ .setParameter("toIO", toIO)
+ .setParameter("typeName", type.getName());
+ }
+ else
+ {
+ HibernateIdentityObjectRelationshipName relationshipName =
+ (HibernateIdentityObjectRelationshipName)getHibernateSession(ctx)
+
.createCriteria(HibernateIdentityObjectRelationshipName.class).add(Restrictions.eq("name",
relationship.getName()))
+ .uniqueResult();
+
+ if (relationshipName == null)
+ {
+ throw new IdentityException("Relationship name not present in the
store");
+ }
+
+ query =
getHibernateSession(ctx).createQuery(QUERY_RELATIONSHIP_BY_FROM_TO_TYPE_NAME)
+ .setParameter("fromIO", fromIO)
+ .setParameter("toIO", toIO)
+ .setParameter("typeName", type.getName())
+ .setParameter("name", relationship.getName());
+ }
+
+
+ try
+ {
+ HibernateIdentityObjectRelationship hibernateRelationship =
(HibernateIdentityObjectRelationship)query.uniqueResult();
+
+ hibernateRelationship.getProperties().putAll(properties);
+ }
+ catch (HibernateException e)
+ {
+ throw new IdentityException("Cannot update relationship properties: ",
e);
+ }
+ }
+
+ public void removeRelationshipProperties(IdentityStoreInvocationContext ctx,
IdentityObjectRelationship relationship, Set<String> properties) throws
IdentityException, OperationNotSupportedException
+ {
+ HibernateIdentityObject fromIO = safeGet(ctx,
relationship.getFromIdentityObject());
+ HibernateIdentityObject toIO = safeGet(ctx, relationship.getToIdentityObject());
+ HibernateIdentityObjectRelationshipType type =
getHibernateIdentityObjectRelationshipType(ctx, relationship.getType());
+
+ Query query = null;
+
+ if (relationship.getName() == null)
+ {
+ query =
getHibernateSession(ctx).createQuery(QUERY_RELATIONSHIP_BY_FROM_TO_TYPE)
+ .setParameter("fromIO", fromIO)
+ .setParameter("toIO", toIO)
+ .setParameter("typeName", type.getName());
+ }
+ else
+ {
+ HibernateIdentityObjectRelationshipName relationshipName =
+ (HibernateIdentityObjectRelationshipName)getHibernateSession(ctx)
+
.createCriteria(HibernateIdentityObjectRelationshipName.class).add(Restrictions.eq("name",
relationship.getName()))
+ .uniqueResult();
+
+ if (relationshipName == null)
+ {
+ throw new IdentityException("Relationship name not present in the
store");
+ }
+
+ query =
getHibernateSession(ctx).createQuery(QUERY_RELATIONSHIP_BY_FROM_TO_TYPE_NAME)
+ .setParameter("fromIO", fromIO)
+ .setParameter("toIO", toIO)
+ .setParameter("typeName", type.getName())
+ .setParameter("name", relationship.getName());
+ }
+
+
+ try
+ {
+ HibernateIdentityObjectRelationship hibernateRelationship =
(HibernateIdentityObjectRelationship)query.uniqueResult();
+
+ for (String property : properties)
+ {
+ hibernateRelationship.getProperties().remove(property);
+ }
+ }
+ catch (HibernateException e)
+ {
+ throw new IdentityException("Cannot update relationship properties: ",
e);
+ }
+ }
+
+
// Attribute store
public Set<String> getSupportedAttributeNames(IdentityStoreInvocationContext
ctx, IdentityObjectType identityType) throws IdentityException
@@ -1685,6 +1920,7 @@
}
}
+
public void updateCredential(IdentityStoreInvocationContext ctx, IdentityObject
identityObject, IdentityObjectCredential credential) throws IdentityException
{
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreImpl.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreImpl.java 2009-04-23
03:48:49 UTC (rev 454)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreImpl.java 2009-04-23
10:55:39 UTC (rev 455)
@@ -144,7 +144,7 @@
}
}
- supportedFeatures = new FeaturesMetaDataImpl(configurationMD,
supportedSearchConstraintTypes, false, readOnlyObjectTypes);
+ supportedFeatures = new FeaturesMetaDataImpl(configurationMD,
supportedSearchConstraintTypes, false, false, readOnlyObjectTypes);
// Attribute mappings - helper structures
@@ -1345,6 +1345,43 @@
throw new OperationNotSupportedException("Named relationships are not
supported by this implementation of LDAP IdentityStore");
}
+
+ public Map<String, String>
getRelationshipNameProperties(IdentityStoreInvocationContext ctx, String name) throws
IdentityException, OperationNotSupportedException
+ {
+ throw new OperationNotSupportedException("Named relationships are not
supported by this implementation of LDAP IdentityStore");
+
+ }
+
+ public void setRelationshipNameProperties(IdentityStoreInvocationContext ctx, String
name, Map<String, String> properties) throws IdentityException,
OperationNotSupportedException
+ {
+ throw new OperationNotSupportedException("Named relationships are not
supported by this implementation of LDAP IdentityStore");
+
+ }
+
+ public void removeRelationshipNameProperties(IdentityStoreInvocationContext ctx,
String name, Set<String> properties) throws IdentityException,
OperationNotSupportedException
+ {
+ throw new OperationNotSupportedException("Named relationships are not
supported by this implementation of LDAP IdentityStore");
+
+ }
+
+ public Map<String, String>
getRelationshipProperties(IdentityStoreInvocationContext ctx, IdentityObjectRelationship
relationship) throws IdentityException, OperationNotSupportedException
+ {
+ throw new OperationNotSupportedException("Relationship properties are not
supported by this implementation of LDAP IdentityStore");
+
+ }
+
+ public void setRelationshipProperties(IdentityStoreInvocationContext ctx,
IdentityObjectRelationship relationship, Map<String, String> properties) throws
IdentityException, OperationNotSupportedException
+ {
+ throw new OperationNotSupportedException("Relationship properties are not
supported by this implementation of LDAP IdentityStore");
+
+ }
+
+ public void removeRelationshipProperties(IdentityStoreInvocationContext ctx,
IdentityObjectRelationship relationship, Set<String> properties) throws
IdentityException, OperationNotSupportedException
+ {
+ throw new OperationNotSupportedException("Relationship properties are not
supported by this implementation of LDAP IdentityStore");
+
+ }
+
public boolean validateCredential(IdentityStoreInvocationContext ctx, IdentityObject
identityObject, IdentityObjectCredential credential) throws IdentityException
{
if (credential == null)
Added:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/types/SimpleIdentityObjectRelationship.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/types/SimpleIdentityObjectRelationship.java
(rev 0)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/types/SimpleIdentityObjectRelationship.java 2009-04-23
10:55:39 UTC (rev 455)
@@ -0,0 +1,70 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.impl.types;
+
+import org.jboss.identity.idm.spi.model.IdentityObjectRelationship;
+import org.jboss.identity.idm.spi.model.IdentityObject;
+import org.jboss.identity.idm.spi.model.IdentityObjectRelationshipType;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class SimpleIdentityObjectRelationship implements IdentityObjectRelationship
+{
+ private IdentityObject fromIdentityObject;
+
+ private IdentityObject toIdentityObject;
+
+ private String name;
+
+ private IdentityObjectRelationshipType type;
+
+ public SimpleIdentityObjectRelationship(IdentityObject fromIdentityObject,
IdentityObject toIdentityObject, String name, IdentityObjectRelationshipType type)
+ {
+ this.fromIdentityObject = fromIdentityObject;
+ this.toIdentityObject = toIdentityObject;
+ this.name = name;
+ this.type = type;
+ }
+
+ public IdentityObject getFromIdentityObject()
+ {
+ return fromIdentityObject;
+ }
+
+ public IdentityObject getToIdentityObject()
+ {
+ return toIdentityObject;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public IdentityObjectRelationshipType getType()
+ {
+ return type;
+ }
+}
Added:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/types/SimpleIdentityObjectRelationshipType.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/types/SimpleIdentityObjectRelationshipType.java
(rev 0)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/types/SimpleIdentityObjectRelationshipType.java 2009-04-23
10:55:39 UTC (rev 455)
@@ -0,0 +1,44 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.impl.types;
+
+import org.jboss.identity.idm.spi.model.IdentityObjectRelationshipType;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class SimpleIdentityObjectRelationshipType implements
IdentityObjectRelationshipType
+{
+ private String name;
+
+ public SimpleIdentityObjectRelationshipType(String name)
+ {
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+}
Modified:
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RoleManagerTest.java
===================================================================
---
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RoleManagerTest.java 2009-04-23
03:48:49 UTC (rev 454)
+++
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RoleManagerTest.java 2009-04-23
10:55:39 UTC (rev 455)
@@ -31,6 +31,11 @@
import junit.framework.Assert;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Set;
+import java.util.HashSet;
+
/**
*
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
@@ -118,12 +123,18 @@
assertEquals(4, session.getRoleManager().findRoleTypes(null).size());
+
+
+
// Create/remove and find roles
Role role1 = session.getRoleManager().createRole(rt1, user1, group1);
Role role2 = session.getRoleManager().createRole(rt1, user1, group2);
Role role3 = session.getRoleManager().createRole("rt2", user1.getId(),
group1.getId());
+
+
+
//
assertEquals(2, session.getRoleManager().findRoles(user1, rt1).size());
@@ -166,7 +177,60 @@
assertFalse(session.getRoleManager().hasRole(user1, group1, rt3));
assertFalse(session.getRoleManager().hasRole(user1, group4, rt3));
+ // Role properties
+ assertEquals(0, session.getRoleManager().getProperties(role1).keySet().size());
+ assertEquals(0, session.getRoleManager().getProperties(rt1).keySet().size());
+ assertEquals(0,
session.getRoleManager().getProperties(rt1.getName()).keySet().size());
+
+ session.getRoleManager().setProperty(role1, "roleProp1",
"val1");
+ session.getRoleManager().setProperty(role1, "roleProp1",
"val2");
+ session.getRoleManager().setProperty(role1, "roleProp2",
"val1");
+ session.getRoleManager().setProperty(rt1, "rtProp1", "val1");
+ session.getRoleManager().setProperty(rt1.getName(), "rtProp1",
"val2");
+ session.getRoleManager().setProperty(rt1, "rtProp2", "val1");
+ session.getRoleManager().setProperty(rt1, "rtProp3", "val1");
+
+ assertEquals(2, session.getRoleManager().getProperties(role1).keySet().size());
+ assertEquals(3, session.getRoleManager().getProperties(rt1).keySet().size());
+ assertEquals(3,
session.getRoleManager().getProperties(rt1.getName()).keySet().size());
+
+ assertEquals("val2",
session.getRoleManager().getProperties(role1).get("roleProp1"));
+ assertEquals("val1",
session.getRoleManager().getProperties(role1).get("roleProp2"));
+ assertEquals("val2",
session.getRoleManager().getProperties(rt1).get("rtProp1"));
+ assertEquals("val1",
session.getRoleManager().getProperties(rt1).get("rtProp2"));
+ assertEquals("val1",
session.getRoleManager().getProperties(rt1).get("rtProp3"));
+
+
+ Map<String, String> props = new HashMap<String, String>();
+ props.put("prop5", "val1");
+
+ session.getRoleManager().setProperties(role2, props);
+
+ assertEquals(1, session.getRoleManager().getProperties(role2).keySet().size());
+
+ assertEquals("val1",
session.getRoleManager().getProperties(role2).get("prop5"));
+
+
+ props.put("prop6", "val3");
+ session.getRoleManager().setProperties(rt2, props);
+ session.getRoleManager().setProperties(rt3.getName(), props);
+
+ assertEquals(2, session.getRoleManager().getProperties(rt2).keySet().size());
+
+ assertEquals("val3",
session.getRoleManager().getProperties(rt2).get("prop6"));
+ assertEquals("val3",
session.getRoleManager().getProperties(rt3).get("prop6"));
+
+
+ session.getRoleManager().removeProperty(role2, "prop5");
+ assertEquals(0, session.getRoleManager().getProperties(role2).keySet().size());
+
+ session.getRoleManager().removeProperty(rt2, "prop6");
+ assertEquals(1, session.getRoleManager().getProperties(rt2).keySet().size());
+ session.getRoleManager().removeProperty(rt2, "prop5");
+ assertEquals(0, session.getRoleManager().getProperties(rt2).keySet().size());
+
+
// Remove roles
session.getRoleManager().removeRole(rt1, user1, group1);
Modified: idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RoleManager.java
===================================================================
--- idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RoleManager.java 2009-04-23
03:48:49 UTC (rev 454)
+++ idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RoleManager.java 2009-04-23
10:55:39 UTC (rev 455)
@@ -25,6 +25,7 @@
import org.jboss.identity.idm.exception.IdentityException;
import java.util.Collection;
+import java.util.Map;
/**
* Management operations on Role objects. Role support is optional and depends on the
capabilities of the underlying
@@ -110,6 +111,26 @@
Role createRole(String roleTypeName, String userId, String groupId) throws
IdentityException;
/**
+ * Create role
+ * @param roleType
+ * @param user
+ * @param group
+ * @return
+ * @throws IdentityException
+ */
+ Role getRole(RoleType roleType, User user, Group group) throws IdentityException;
+
+ /**
+ * Create role
+ * @param roleTypeName
+ * @param userId
+ * @param groupId
+ * @return
+ * @throws IdentityException
+ */
+ Role getRole(String roleTypeName, String userId, String groupId) throws
IdentityException;
+
+ /**
* Remove Role
* @param roleType
* @param user
@@ -300,4 +321,94 @@
<T extends IdentityType> Collection<Role> findRoles(String id,
String roleTypeName) throws
IdentityException;
+ /**
+ *
+ * @param role
+ * @return
+ */
+ Map<String,String> getProperties(Role role) throws IdentityException;
+
+ /**
+ *
+ * @param roleType
+ * @return
+ */
+ Map<String,String> getProperties(RoleType roleType) throws IdentityException;
+
+ /**
+ *
+ * @param roleTypeName
+ * @return
+ */
+ Map<String,String> getProperties(String roleTypeName) throws IdentityException;
+
+ /**
+ *
+ * @param role
+ * @param name
+ * @param value
+ */
+ void setProperty(Role role, String name, String value) throws IdentityException;
+
+ /**
+ *
+ * @param roleType
+ * @param name
+ * @param value
+ */
+ void setProperty(RoleType roleType, String name, String value) throws
IdentityException;
+
+ /**
+ *
+ * @param roleTypeName
+ * @param name
+ * @param value
+ */
+ void setProperty(String roleTypeName, String name, String value) throws
IdentityException;
+
+ /**
+ *
+ * @param role
+ * @param properties
+ */
+ void setProperties(Role role, Map<String, String> properties) throws
IdentityException;
+
+ /**
+ *
+ * @param roleType
+ * @param properties
+ */
+ void setProperties(RoleType roleType, Map<String, String> properties) throws
IdentityException;
+
+ /**
+ *
+ * @param roleTypeName
+ * @param properties
+ */
+ void setProperties(String roleTypeName, Map<String, String> properties) throws
IdentityException;
+
+ /**
+ *
+ * @param role
+ * @param name
+ */
+ void removeProperty(Role role, String name) throws IdentityException;
+
+ /**
+ *
+ * @param roleType
+ * @param name
+ */
+ void removeProperty(RoleType roleType, String name) throws IdentityException;
+
+ /**
+ *
+ * @param roleTypeName
+ * @param name
+ */
+ void removeProperty(String roleTypeName, String name) throws IdentityException;
+
+
+
+
}
Modified:
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/exception/OperationNotSupportedException.java
===================================================================
---
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/exception/OperationNotSupportedException.java 2009-04-23
03:48:49 UTC (rev 454)
+++
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/exception/OperationNotSupportedException.java 2009-04-23
10:55:39 UTC (rev 455)
@@ -22,12 +22,14 @@
package org.jboss.identity.idm.spi.exception;
+import org.jboss.identity.idm.exception.IdentityException;
+
/**
* Identity operation not supported exception
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
* @version : 0.1 $
*/
-public class OperationNotSupportedException extends Exception
+public class OperationNotSupportedException extends IdentityException
{
private static final long serialVersionUID = 1L;
@@ -45,4 +47,4 @@
{
super(cause);
}
-}
\ No newline at end of file
+}
Modified:
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/store/FeaturesMetaData.java
===================================================================
---
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/store/FeaturesMetaData.java 2009-04-23
03:48:49 UTC (rev 454)
+++
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/store/FeaturesMetaData.java 2009-04-23
10:55:39 UTC (rev 455)
@@ -96,7 +96,13 @@
*/
boolean isNamedRelationshipsSupported();
+ /**
+ *
+ * @return
+ */
+ boolean isRelationshipPropertiesSupported();
+
/**
* @return Set of relationship type names supported in this store
*/
@@ -110,4 +116,4 @@
*/
boolean isCredentialSupported(IdentityObjectType identityObjectType,
IdentityObjectCredentialType credentialType);
-}
\ No newline at end of file
+}
Modified:
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityStore.java
===================================================================
---
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityStore.java 2009-04-23
03:48:49 UTC (rev 454)
+++
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityStore.java 2009-04-23
10:55:39 UTC (rev 455)
@@ -268,13 +268,79 @@
* @param name
* @return
*/
- String removeRelationshipName(IdentityStoreInvocationContext ctx, String name) throws
IdentityException, OperationNotSupportedException;
+ String removeRelationshipName(IdentityStoreInvocationContext ctx, String name)
+ throws IdentityException, OperationNotSupportedException;
+ /**
+ *
+ * @param ctx
+ * @param name
+ * @return
+ * @throws IdentityException
+ * @throws OperationNotSupportedException
+ */
+ Map<String, String> getRelationshipNameProperties(IdentityStoreInvocationContext
ctx, String name)
+ throws IdentityException, OperationNotSupportedException;
+ /**
+ *
+ * @param ctx
+ * @param name
+ * @param properties
+ * @throws IdentityException
+ * @throws OperationNotSupportedException
+ */
+ void setRelationshipNameProperties(IdentityStoreInvocationContext ctx, String name,
Map<String, String> properties)
+ throws IdentityException, OperationNotSupportedException;
/**
+ *
+ * @param ctx
+ * @param name
+ * @param properties
+ * @throws IdentityException
+ * @throws OperationNotSupportedException
+ */
+ void removeRelationshipNameProperties(IdentityStoreInvocationContext ctx, String name,
Set<String> properties)
+ throws IdentityException, OperationNotSupportedException;
+
+ /**
*
* @param ctx
+ * @param relationship
+ * @return
+ * @throws IdentityException
+ * @throws OperationNotSupportedException
+ */
+ Map<String, String> getRelationshipProperties(IdentityStoreInvocationContext
ctx, IdentityObjectRelationship relationship)
+ throws IdentityException, OperationNotSupportedException;
+
+ /**
+ *
+ * @param ctx
+ * @param relationship
+ * @param properties
+ * @throws IdentityException
+ * @throws OperationNotSupportedException
+ */
+ void setRelationshipProperties(IdentityStoreInvocationContext ctx,
IdentityObjectRelationship relationship, Map<String, String> properties)
+ throws IdentityException, OperationNotSupportedException;
+
+ /**
+ *
+ * @param ctx
+ * @param relationship
+ * @param properties
+ * @throws IdentityException
+ * @throws OperationNotSupportedException
+ */
+ void removeRelationshipProperties(IdentityStoreInvocationContext ctx,
IdentityObjectRelationship relationship, Set<String> properties)
+ throws IdentityException, OperationNotSupportedException;
+
+
+ /**
+ *
+ * @param ctx
* @param controls
* @return
* @throws IdentityException
@@ -319,4 +385,4 @@
*/
void updateCredential(IdentityStoreInvocationContext ctx, IdentityObject
identityObject, IdentityObjectCredential credential) throws IdentityException;
-}
\ No newline at end of file
+}