[jboss-identity-commits] JBoss Identity SVN: r212 - in trunk: identity-api/src/main/java/org/jboss/identity and 54 other directories.
jboss-identity-commits at lists.jboss.org
jboss-identity-commits at lists.jboss.org
Tue Jan 13 10:40:00 EST 2009
Author: bdaw
Date: 2009-01-13 10:39:59 -0500 (Tue, 13 Jan 2009)
New Revision: 212
Added:
trunk/identity-api/src/main/java/org/jboss/identity/idm/
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Attribute.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/AttributesManager.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Credential.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/CredentialType.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Group.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/IdentitySearchControl.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/IdentitySession.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/PersistenceManagerFeaturesDescription.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Realm.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/RelationshipManagerFeaturesDescription.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/RoleManager.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/RoleManagerFeaturesDescription.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/RoleType.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Transaction.java
trunk/identity-common/src/main/java/org/jboss/identity/idm/
trunk/identity-common/src/main/java/org/jboss/identity/idm/exception/
trunk/identity-common/src/main/java/org/jboss/identity/idm/p3p/
trunk/identity-impl/src/main/java/org/jboss/identity/idm/
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/AbstractCredential.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/BinaryCredential.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/IdentitySessionFactoryImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/PasswordCredential.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/SimpleAttribute.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/SimpleCredentialType.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/attribute/
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/model/
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/JAXB2IdentityConfiguration.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/metadata/IdentityObjectTypeMetaDataImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObject.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/ldap/LDAPIdentityObjectImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/ldap/LDAPIdentityObjectRelationshipImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/repository/AbstractIdentityStoreRepository.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/repository/FallbackIdentityStoreRepository.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/repository/RepositoryIdentityStoreSessionImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/FeaturesMetaDataImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreSessionImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityObjectTypeConfiguration.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreConfiguration.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreSessionImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/SimpleLDAPIdentityObjectTypeConfiguration.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/SimpleLDAPIdentityStoreConfiguration.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/types/SimpleIdentityObject.java
trunk/identity-impl/src/test/java/org/jboss/identity/idm/
trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/
trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTest.java
trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/store/CommonIdentityStoreTest.java
trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreTestCase.java
trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreTestCase.java
trunk/identity-impl/src/test/java/org/jboss/identity/idm/opends/
trunk/identity-impl/src/test/java/org/jboss/identity/idm/opends/OpenDSService.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityConfigurationMetaData.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityObjectAttributeMetaData.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityObjectTypeMetaData.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityRepositoryConfigurationMetaData.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityStoreConfigurationMetaData.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityStoreMappingMetaData.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/RealmConfigurationMetaData.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/RelationshipMetaData.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObject.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectAttribute.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectCredential.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectCredentialType.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectRelationship.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectRelationshipType.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/policy/IdentityTypePolicy.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/policy/PasswordExpirationPolicy.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/policy/RelationshipPolicy.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/store/AttributeStore.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/store/FeaturesMetaData.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityStoreSession.java
Removed:
trunk/identity-api/src/main/java/org/jboss/identity/api/
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Attribute.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/AttributesManager.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Credential.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/CredentialType.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Group.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/IdentitySearchControl.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/IdentitySession.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/PersistenceManagerFeaturesDescription.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Realm.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/RelationshipManagerFeaturesDescription.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/RoleManager.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/RoleManagerFeaturesDescription.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/RoleType.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Transaction.java
trunk/identity-common/src/main/java/org/jboss/identity/exception/
trunk/identity-common/src/main/java/org/jboss/identity/p3p/
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/AbstractCredential.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/AbstractManager.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/AttributesManagerImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/BinaryCredential.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/DirectIdentityObjectTypeMapperImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/EntityManagerWrapper.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/IdentityObjectAttributeMetaDataImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/IdentityObjectTypeMapper.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/IdentityObjectTypeMapperImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/IdentitySessionContext.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/IdentitySessionContextImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/IdentitySessionFactoryImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/IdentitySessionImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/IdentityStoreInvocationContextResolver.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/PasswordCredential.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/PersistenceManagerImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/RelationshipManagerImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/RoleHandler.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/RoleManagerImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/SessionWrapper.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/SimpleAttributeImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/SimpleCredentialTypeImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/SimpleGroupImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/SimpleGroupType.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/SimpleIdentityImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/SimpleRoleImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/SimpleRoleType.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/SimpleTransactionImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/JAXB2IdentityConfiguration.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/metadata/IdentityObjectTypeMetaDataImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObject.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/ldap/LDAPIdentityObjectImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/ldap/LDAPIdentityObjectRelationshipImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/repository/AbstractIdentityStoreRepository.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/repository/FallbackIdentityStoreRepository.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/repository/RepositoryIdentityStoreSessionImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/FeaturesMetaDataImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/FileBasedIdentityStore.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/filesystem/
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreInvocationContext.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreSessionImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityObjectTypeConfiguration.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreConfiguration.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreSessionImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/SimpleLDAPIdentityObjectTypeConfiguration.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/SimpleLDAPIdentityStoreConfiguration.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/types/SimpleIdentityObject.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/
trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTest.java
trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/store/CommonIdentityStoreTest.java
trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreTestCase.java
trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreTestCase.java
trunk/identity-impl/src/test/java/org/jboss/identity/idm/opends/OpenDSService.java
trunk/identity-impl/src/test/java/org/jboss/identity/impl/
trunk/identity-impl/src/test/java/org/jboss/identity/opends/
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/attribute/IdentityObjectAttributeMetaData.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/ConfigurationService.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityConfigurationMetaData.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityObjectTypeMetaData.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityRepositoryConfigurationMetaData.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityStoreConfigurationMetaData.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityStoreMappingMetaData.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/RealmConfigurationMetaData.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/RelationshipMetaData.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/credential/
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObject.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectAttribute.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectCredential.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectCredentialType.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectRelationship.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectRelationshipType.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/policy/IdentityTypePolicy.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/policy/PasswordExpirationPolicy.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/policy/RelationshipPolicy.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/store/AttributeStore.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/store/FeaturesMetaData.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityStoreContext.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityStoreSession.java
trunk/identity-spi/src/main/java/org/jboss/identity/spi/
Modified:
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/AttributeDescription.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/GroupType.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Identity.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/IdentitySessionFactory.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/IdentityType.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/RealmManager.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/RelationshipManager.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Role.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/event/IdentityEvent.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/event/IdentityEventBroadcaster.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/event/IdentityEventEmitter.java
trunk/identity-api/src/main/java/org/jboss/identity/idm/api/event/IdentityEventListener.java
trunk/identity-common/src/main/java/org/jboss/identity/idm/exception/FeatureNotSupportedException.java
trunk/identity-common/src/main/java/org/jboss/identity/idm/exception/IdentityException.java
trunk/identity-common/src/main/java/org/jboss/identity/idm/exception/PolicyValidationException.java
trunk/identity-common/src/main/java/org/jboss/identity/idm/p3p/P3PConstants.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/NotYetImplementedException.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/AttributeFilterSearchControl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/NameFilterSearchControl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/PageSearchControl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/SortByNameSearchControl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/attribute/IdentityObjectAttributeMetaDataImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleGroup.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleGroupType.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleIdentity.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleRole.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleRoleType.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/IdentitySessionImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/SimpleTransactionImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/context/IdentitySessionContext.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/context/IdentitySessionContextImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/context/IdentityStoreInvocationContextResolver.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AbstractManager.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AttributesManagerImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/managers/PersistenceManagerImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RoleManagerImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/mapper/DirectIdentityObjectTypeMapperImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/mapper/IdentityObjectTypeMapper.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/mapper/IdentityObjectTypeMapperImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/AttributeType.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/AttributesType.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/CredentialsType.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/ExternalConfigType.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/GroupTypeMappingType.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/IdentityObjectTypeType.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/IdentityObjectTypesType.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/IdentityStoreMappingType.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/IdentityStoreMappingsType.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/IdentityStoreType.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/IdentityStoresType.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/IdentityTypeMappingsType.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/JbossIdentityType.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/ObjectFactory.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/OptionType.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/OptionsType.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/RealmType.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/RealmsType.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/RelationshipType.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/RelationshipsType.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/RepositoriesType.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/RepositoryType.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/StoresType.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/SupportedIdentityObjectTypesType.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/SupportedRelationshipTypesType.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/package-info.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/metadata/IdentityConfigurationMetaDataImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/metadata/IdentityRepositoryConfigurationMetaDataImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/metadata/IdentityStoreConfigurationMetaDataImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/metadata/IdentityStoreMappingMetaDataImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/metadata/RealmConfigurationMetaDataImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/metadata/RelationshipMetaDataImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/fedid/UUIDPseudonymGenerator.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/helper/Tools.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectAttribute.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectBinaryAttribute.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectCredential.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectCredentialType.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectRelationship.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectRelationshipName.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectRelationshipType.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectTextAttribute.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectType.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateRealm.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/repository/WrapperIdentityStoreRepository.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/SimpleIdentityStoreInvocationContext.java
trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/types/SimpleIdentityObjectType.java
trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/HibernateTestSupport.java
trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/SimpleIdentityObjectRelationshipTypeImpl.java
trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/SimpleIdentityObjectTypeImpl.java
trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/api/APITestCase.java
trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/api/APITestContext.java
trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/api/GroupTypeEnum.java
trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/configuration/ConfigurationTestCase.java
trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/fedid/PseudonymGeneratorUnitTestCase.java
trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/store/IdentityStoreTestContext.java
trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/store/IdentityTypeEnum.java
trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/store/RelationshipTypeEnum.java
trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelTestCase.java
trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateTestBase.java
trunk/identity-impl/src/test/resources/META-INF/persistence.xml
trunk/identity-impl/src/test/resources/organization-test-config.xml
trunk/identity-impl/src/test/resources/store-test-config.xml
trunk/identity-impl/src/test/resources/test-config.xml
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/exception/IdentityConfigurationException.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/exception/IdentityTypeNotSupportedException.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/exception/OperationNotSupportedException.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/fedid/PseudonymGenerator.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectType.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/repository/IdentityStoreRepository.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/searchcontrol/IdentityObjectSearchControl.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityStore.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityStoreInvocationContext.java
trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityStoreSessionFactory.java
trunk/pom.xml
Log:
package change to org.jboss.identity.idm
Copied: trunk/identity-api/src/main/java/org/jboss/identity/idm/api (from rev 198, trunk/identity-api/src/main/java/org/jboss/identity/api)
Deleted: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Attribute.java
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/api/Attribute.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Attribute.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,42 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.api;
-
-import java.util.Collection;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public interface Attribute
-{
- String getName();
-
- Object getValue();
-
- void addValue(Object value);
-
- Collection getValues();
-
- int getSize();
-}
Copied: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Attribute.java (from rev 211, trunk/identity-api/src/main/java/org/jboss/identity/api/Attribute.java)
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Attribute.java (rev 0)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Attribute.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,60 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.api;
+
+import java.util.Collection;
+
+/**
+ * Abstract representation of attribute related to IdentityType object. Can have many values
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface Attribute
+{
+ /**
+ * @return attribute name
+ */
+ String getName();
+
+ /**
+ * @return attribute value. If attribute has many values it may be any one of them.
+ */
+ Object getValue();
+
+ /**
+ * Add attribute value. It will be appended.
+ * @param value
+ */
+ void addValue(Object value);
+
+ /**
+ * @return attribute values
+ */
+ Collection getValues();
+
+ /**
+ * @return number of attribute values
+ */
+ int getSize();
+}
Modified: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/AttributeDescription.java
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/api/AttributeDescription.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/AttributeDescription.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,7 +20,7 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.api;
+package org.jboss.identity.idm.api;
/**
* Information about attribute
Deleted: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/AttributesManager.java
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/api/AttributesManager.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/AttributesManager.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,188 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.api;
-
-import org.jboss.identity.exception.IdentityException;
-
-import java.util.Set;
-import java.util.Map;
-
-/**
- * All operations on attributes
- *
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public interface AttributesManager
-{
-
- /**
- * @return Session associated with this object instance
- */
- IdentitySession getIdentitySession();
-
- /**
- * Get AttributeDesciption object for single attribute supported with a given IdentityType
- *
- * @param identityType
- * @param name
- * @return
- */
- AttributeDescription getAttributeDescription(IdentityType identityType, String name);
-
- /**
- * Get AttributeDesciption object for all attributes supported with a given IdentityType
- *
- * @param identityType
- * @return
- */
- Map<String, AttributeDescription> getSupportedAttributesDescriptions(IdentityType identityType);
-
- /**
- * @param identityType
- * @return names of supported attributes
- * @throws org.jboss.identity.exception.IdentityException
- */
- Set<String> getSupportedAttributeNames(IdentityType identityType)
- throws IdentityException;
-
- /**
- * Get attributes for the given IdentityType
- *
- * @param identity
- * @return
- * @throws org.jboss.identity.exception.IdentityException
- */
- Map<String, Attribute> getAttributes(IdentityType identity) throws IdentityException;
-
- /**
- * Get attribute values for the given IdentityType
- *
- * @param identity
- * @param attributeName
- * @return
- * @throws org.jboss.identity.exception.IdentityException
- */
- Attribute getAttribute(IdentityType identity, String attributeName) throws IdentityException;
-
- /**
- * Update attributes with new values - previous values will be overwritten. All the other attributes are not changed -
- * method doesn't overwrite whole attribute set connected with a given IdentityType object.
- * @param identity
- * @param attributes
- * @throws org.jboss.identity.exception.IdentityException
- */
- void updateAttributes(IdentityType identity, Attribute[] attributes)
- throws IdentityException;
-
- /**
- * Add new attributes - if attribute with given name already exists the values
- * will be appended
- *
- * @param identity
- * @param attributes
- * @throws org.jboss.identity.exception.IdentityException
- */
- void addAttributes(IdentityType identity, Attribute[] attributes)
- throws IdentityException;
-
- /**
- * Add new attribute - if attribute with given name already exists the values
- * will be appended
- *
- * @param identity
- * @param attributeName
- * @param values
- * @throws org.jboss.identity.exception.IdentityException
- */
- void addAttribute(IdentityType identity, String attributeName, Object[] values)
- throws IdentityException;
-
- /**
- * Add new attribute - if attribute with given name already exists the values
- * will be appended
- *
- * @param identity
- * @param attributeName
- * @param value
- * @throws org.jboss.identity.exception.IdentityException
- */
- void addAttribute(IdentityType identity, String attributeName, Object value)
- throws IdentityException;
-
- /**
- * Remove attributes
- *
- * @param identity
- * @param attributeNames
- */
- void removeAttributes(IdentityType identity, String[] attributeNames)
- throws IdentityException;
-
- /**
- * @param identity
- * @return
- * @throws IdentityException
- */
- boolean hasPassword(Identity identity) throws IdentityException;
-
- /**
- *
- * @param identity
- * @param password
- * @return
- * @throws IdentityException
- */
- boolean validatePassword(Identity identity, String password) throws IdentityException;
-
- /**
- *
- * @param identity
- * @param password
- * @throws IdentityException
- */
- void updatePassword(Identity identity, String password) throws IdentityException;
-
- /**
- *
- * @param identity
- * @param credentialType
- */
- boolean hasCredential(Identity identity, CredentialType credentialType) throws IdentityException;
-
- /**
- *
- * @param identity
- * @param credentials
- * @return
- */
- boolean validateCredentials(Identity identity, Credential[] credentials) throws IdentityException;
-
- /**
- *
- * @param identity
- * @param credential
- */
- void updateCredential(Identity identity, Credential credential) throws IdentityException;
-
-}
Copied: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/AttributesManager.java (from rev 211, trunk/identity-api/src/main/java/org/jboss/identity/api/AttributesManager.java)
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/idm/api/AttributesManager.java (rev 0)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/AttributesManager.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,196 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.api;
+
+import org.jboss.identity.idm.exception.IdentityException;
+
+import java.util.Set;
+import java.util.Map;
+
+/**
+ * All operations on attributes
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface AttributesManager
+{
+
+ /**
+ * @return Session associated with this object instance
+ */
+ IdentitySession getIdentitySession();
+
+ /**
+ * Get AttributeDesciption object for single attribute supported with a given IdentityType
+ *
+ * @param identityType
+ * @param name
+ * @return
+ */
+ AttributeDescription getAttributeDescription(IdentityType identityType, String name);
+
+ /**
+ * Get AttributeDesciption object for all attributes supported with a given IdentityType
+ *
+ * @param identityType
+ * @return
+ */
+ Map<String, AttributeDescription> getSupportedAttributesDescriptions(IdentityType identityType);
+
+ /**
+ * @param identityType
+ * @return names of supported attributes
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ Set<String> getSupportedAttributeNames(IdentityType identityType)
+ throws IdentityException;
+
+ /**
+ * Get attributes for the given IdentityType
+ *
+ * @param identity
+ * @return
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ Map<String, Attribute> getAttributes(IdentityType identity) throws IdentityException;
+
+ /**
+ * Get attribute values for the given IdentityType
+ *
+ * @param identity
+ * @param attributeName
+ * @return
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ Attribute getAttribute(IdentityType identity, String attributeName) throws IdentityException;
+
+ /**
+ * Update attributes with new values - previous values will be overwritten. All the other attributes are not changed -
+ * method doesn't overwrite whole attribute set connected with a given IdentityType object.
+ *
+ * @param identity
+ * @param attributes
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ void updateAttributes(IdentityType identity, Attribute[] attributes)
+ throws IdentityException;
+
+ /**
+ * Add new attributes - if attribute with given name already exists the values
+ * will be appended
+ *
+ * @param identity
+ * @param attributes
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ void addAttributes(IdentityType identity, Attribute[] attributes)
+ throws IdentityException;
+
+ /**
+ * Add new attribute - if attribute with given name already exists the values
+ * will be appended
+ *
+ * @param identity
+ * @param attributeName
+ * @param values
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ void addAttribute(IdentityType identity, String attributeName, Object[] values)
+ throws IdentityException;
+
+ /**
+ * Add new attribute - if attribute with given name already exists the values
+ * will be appended
+ *
+ * @param identity
+ * @param attributeName
+ * @param value
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ void addAttribute(IdentityType identity, String attributeName, Object value)
+ throws IdentityException;
+
+ /**
+ * Remove attributes
+ *
+ * @param identity
+ * @param attributeNames
+ */
+ void removeAttributes(IdentityType identity, String[] attributeNames)
+ throws IdentityException;
+
+ /**
+ * Check if given identity can be protected with text password
+ *
+ * @param identity
+ * @return
+ * @throws IdentityException
+ */
+ boolean hasPassword(Identity identity) throws IdentityException;
+
+ /**
+ * Validate text password for a given identity
+ *
+ * @param identity
+ * @param password
+ * @return
+ * @throws IdentityException
+ */
+ boolean validatePassword(Identity identity, String password) throws IdentityException;
+
+ /**
+ * Update text password for a given identity
+ *
+ * @param identity
+ * @param password
+ * @throws IdentityException
+ */
+ void updatePassword(Identity identity, String password) throws IdentityException;
+
+ /**
+ * Check if identity can be protected with a given credential type
+ *
+ * @param identity
+ * @param credentialType
+ */
+ boolean hasCredential(Identity identity, CredentialType credentialType) throws IdentityException;
+
+ /**
+ * Validate credential for a given identity
+ *
+ * @param identity
+ * @param credentials
+ * @return
+ */
+ boolean validateCredentials(Identity identity, Credential[] credentials) throws IdentityException;
+
+ /**
+ * Update credential for a given identity
+ *
+ * @param identity
+ * @param credential
+ */
+ void updateCredential(Identity identity, Credential credential) throws IdentityException;
+
+}
Deleted: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Credential.java
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/api/Credential.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Credential.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,36 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.api;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public interface Credential
-{
- /**
- *
- * @return
- */
- CredentialType getType();
-}
Copied: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Credential.java (from rev 211, trunk/identity-api/src/main/java/org/jboss/identity/api/Credential.java)
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Credential.java (rev 0)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Credential.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,37 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.api;
+
+/**
+ * Credential object.
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface Credential
+{
+ /**
+ *@return type of Credential
+ */
+ CredentialType getType();
+}
Deleted: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/CredentialType.java
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/api/CredentialType.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/CredentialType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,36 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.api;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public interface CredentialType
-{
- /**
- *
- * @return
- */
- String getName();
-}
Copied: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/CredentialType.java (from rev 211, trunk/identity-api/src/main/java/org/jboss/identity/api/CredentialType.java)
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/idm/api/CredentialType.java (rev 0)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/CredentialType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,37 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.api;
+
+/**
+ * CredentialType defines type of Credential. Sample types can be binary certificate or text password
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface CredentialType
+{
+ /**
+ * @return name of CredentialType
+ */
+ String getName();
+}
Deleted: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Group.java
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/api/Group.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Group.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,42 +0,0 @@
-/*
- * 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;
-
-/**
- * Represents a Group
- *
- * @author Anil.Saldhana at redhat.com
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @since Jul 9, 2008
- */
-public interface Group extends IdentityType
-{
- /**
- * @return
- */
- GroupType getGroupType();
-
-
-}
\ No newline at end of file
Copied: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Group.java (from rev 211, trunk/identity-api/src/main/java/org/jboss/identity/api/Group.java)
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Group.java (rev 0)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Group.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,42 @@
+/*
+ * 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.idm.api;
+
+/**
+ * Represents a Group
+ *
+ * @author Anil.Saldhana at redhat.com
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @since Jul 9, 2008
+ */
+public interface Group extends IdentityType
+{
+ /**
+ * @return GroupType
+ */
+ GroupType getGroupType();
+
+
+}
\ No newline at end of file
Modified: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/GroupType.java
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/api/GroupType.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/GroupType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -19,7 +19,7 @@
* 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;
+package org.jboss.identity.idm.api;
/**
* Type of Group
Modified: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Identity.java
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/api/Identity.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Identity.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -19,7 +19,7 @@
* 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;
+package org.jboss.identity.idm.api;
/**
* Represents an Identity
Deleted: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/IdentitySearchControl.java
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/api/IdentitySearchControl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/IdentitySearchControl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,31 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.api;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public interface IdentitySearchControl
-{
-}
Copied: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/IdentitySearchControl.java (from rev 211, trunk/identity-api/src/main/java/org/jboss/identity/api/IdentitySearchControl.java)
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/idm/api/IdentitySearchControl.java (rev 0)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/IdentitySearchControl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,33 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.api;
+
+/**
+ * IdentitySearchControl enables to add additional constraints to the results of operations on identity objects
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface IdentitySearchControl
+{
+}
Deleted: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/IdentitySession.java
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/api/IdentitySession.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/IdentitySession.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,106 +0,0 @@
-/*
- * 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;
-
-
-import org.jboss.identity.exception.IdentityException;
-import org.jboss.identity.exception.FeatureNotSupportedException;
-
-/**
- * Expose all identity management operations within a given realm
- *
- * <p>An Identity Session</p>
- * @author boleslaw dot dawidowicz at redhat anotherdot com
- * @author Anil.Saldhana at redhat.com
- * @since Jul 10, 2008
- */
-public interface IdentitySession
-{
-
- /**
- * @return Name of the realm this session is connected to
- */
- String getRealmName();
-
- /**
- * Close this session
- * @throws org.jboss.identity.exception.IdentityException
- */
- void close() throws IdentityException;
-
- /**
- * Save all pending changes
- * @throws org.jboss.identity.exception.IdentityException
- */
- void save() throws IdentityException;
-
- /**
- * Clear this session
- * @throws org.jboss.identity.exception.IdentityException
- */
- void clear() throws IdentityException;
-
- /**
- * Check if this session is open
- * @return
- */
- boolean isOpen();
-
- //TODO: expose metadata describing capabilities of underlaying stores - or split it between managers
- //TODO: which groupType names are supported and etc.
-
- /**
- * @return
- * @throws IdentityException
- */
- Transaction beginTransaction() throws IdentityException;
-
- /**
- * Transaction instance assosiated with this session
- * @return
- */
- Transaction getTransaction() throws IdentityException;
-
- /**
- * PersistenceManager exposes management operations on Group and Identity objects
- * @return
- */
- PersistenceManager getPersistenceManager();
-
- /**
- * RelationshipManager enables to associate and disassociate Group and Identity objects
- * @return
- */
- RelationshipManager getRelationshipManager();
-
- /**
- * RoleManager exposes operation on Role objects. This is optional feature that may be not supported
- * @return
- * @throws FeatureNotSupportedException
- */
- AttributesManager getAttributesManager();
-
-
- //TODO: proper exception if roles are not supported
- RoleManager getRoleManager() throws FeatureNotSupportedException ;
-
-}
\ No newline at end of file
Copied: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/IdentitySession.java (from rev 211, trunk/identity-api/src/main/java/org/jboss/identity/api/IdentitySession.java)
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/idm/api/IdentitySession.java (rev 0)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/IdentitySession.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,107 @@
+/*
+ * 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.idm.api;
+
+
+import org.jboss.identity.idm.exception.IdentityException;
+import org.jboss.identity.idm.exception.FeatureNotSupportedException;
+
+/**
+ * Expose all identity management operations within a given realm
+ *
+ * <p>An Identity Session</p>
+ * @author boleslaw dot dawidowicz at redhat anotherdot com
+ * @author Anil.Saldhana at redhat.com
+ * @since Jul 10, 2008
+ */
+public interface IdentitySession
+{
+
+ /**
+ * @return Name of the realm this session is connected to
+ */
+ String getRealmName();
+
+ /**
+ * Close this session
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ void close() throws IdentityException;
+
+ /**
+ * Save all pending changes
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ void save() throws IdentityException;
+
+ /**
+ * Clear this session
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ void clear() throws IdentityException;
+
+ /**
+ * Check if this session is open
+ * @return
+ */
+ boolean isOpen();
+
+ /**
+ * @return
+ * @throws IdentityException
+ */
+ Transaction beginTransaction() throws IdentityException;
+
+ /**
+ * Transaction instance assosiated with this session
+ * @return
+ */
+ Transaction getTransaction() throws IdentityException;
+
+ /**
+ * PersistenceManager exposes management operations on Group and Identity objects
+ * @return
+ */
+ PersistenceManager getPersistenceManager();
+
+ /**
+ * RelationshipManager enables to associate and disassociate Group and Identity objects
+ * @return
+ */
+ RelationshipManager getRelationshipManager();
+
+ /**
+ * AttributesManager exposes operation related to Attribute objects. It enables to associate and disassociate Attribute
+ * with a given Group and Identity objects
+ * @return
+ * @throws FeatureNotSupportedException
+ */
+ AttributesManager getAttributesManager();
+
+ /**
+ * RoleManager exposes operation on Role objects. This is optional feature that may be not supported
+ * @return
+ * @throws FeatureNotSupportedException
+ */
+ RoleManager getRoleManager() throws FeatureNotSupportedException ;
+
+}
\ No newline at end of file
Modified: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/IdentitySessionFactory.java
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/api/IdentitySessionFactory.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/IdentitySessionFactory.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,7 +20,7 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.api;
+package org.jboss.identity.idm.api;
/**
* Creates IdentitySession objects for a given Realm.
Modified: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/IdentityType.java
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/api/IdentityType.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/IdentityType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,7 +20,7 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.api;
+package org.jboss.identity.idm.api;
/**
Deleted: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/api/PersistenceManager.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,205 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.api;
-
-import org.jboss.identity.exception.IdentityException;
-
-import java.util.Collection;
-import java.util.Map;
-
-/**
- * Exposes all management operations on Group and Identity objects.
- *
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public interface PersistenceManager
-{
-
- /**
- * @return Session associated with this object instance
- */
- IdentitySession getIdentitySession();
-
-
- /**
- * @return
- */
- PersistenceManagerFeaturesDescription getFeaturesDescription();
-
-
- // Create
-
- /**
- * <p>Create an identity in the realm</p>
- * @param identityName
- * @throws IdentityException
- * @return
- */
- Identity createIdentity(String identityName) throws IdentityException;
-
- /**
- * <p>Create a group of a particular type</p>
- * @param groupName
- * @param groupType
- * @return
- */
- Group createGroup(String groupName, GroupType groupType)
- throws IdentityException;
-
- // Remove
-
- /**
- * Remove given identity
- *
- * @param identity
- * @param force - if true all present relationships will be removed, if false any present relationship will cause
- * removal to fail
- * @throws org.jboss.identity.exception.IdentityException
- */
- void removeIdentity(Identity identity, boolean force) throws IdentityException;
-
- /**
- * Remove given group
- *
- * @param group
- * @param force - if true all present relationships will be removed, if false any present relationship will cause
- * removal to fail
- * @throws org.jboss.identity.exception.IdentityException
- */
- void removeGroup(Group group, boolean force) throws IdentityException;
-
- // Search
-
- /**
- * @return a number of stored identities
- * @throws org.jboss.identity.exception.IdentityException
- */
- int getIdentityCount()
- throws IdentityException;
-
- /**
- * @param groupType
- * @return a number of stored groups with a given type
- * @throws org.jboss.identity.exception.IdentityException
- */
- int getGroupTypeCount(GroupType groupType)
- throws IdentityException;
-
- /**
- * Find identity with a given name
- *
- * @param name
- * @return
- * @throws org.jboss.identity.exception.IdentityException
- */
- Identity findIdentity(String name) throws IdentityException;
-
- /**
- * Find identity with a given id
- *
- * @param id
- * @return
- * @throws org.jboss.identity.exception.IdentityException
- */
- Identity findIdentityById(String id) throws IdentityException;
-
-
- //Collection<Identity> findIdentity(String filterName, int offset, int limit,
-// boolean orderedByName,
-// boolean ascending) throws IdentityException;
-
-// Collection<Identity> findIdentity(String filterName, Map<String, String[]> attributes,
-// int offset, int limit,
-// boolean orderedByName, boolean ascending) throws IdentityException;
-
-
- /**
- *
- * @param controls
- * @return
- * @throws IdentityException
- */
- Collection<Identity> findIdentity(IdentitySearchControl[] controls) throws IdentityException;
-
- // Search Groups
-
- /**
- * Find group with a given name and type
- *
- * @param name
- * @param groupType
- * @return
- * @throws org.jboss.identity.exception.IdentityException
- */
- Group findGroup(String name, GroupType groupType) throws IdentityException;
-
- /**
- * Find group with a given id
- *
- * @param id
- * @return
- * @throws org.jboss.identity.exception.IdentityException
- */
- Group findGroupById(String id) throws IdentityException;
-
-
- /**
- *
- * @param groupType
- * @param controls
- * @return
- * @throws IdentityException
- */
- Collection<Group> findGroup(GroupType groupType, IdentitySearchControl[] controls) throws IdentityException;
-
- /**
- *
- * @param groupType
- * @return
- * @throws IdentityException
- */
- Collection<Group> findGroup(GroupType groupType) throws IdentityException;
-
-
-// Collection<Group> findGroup(GroupType groupType, String filterName,
-// int offset, int limit,
-// boolean orderedByName,
-// boolean ascending) throws IdentityException;
-
-// Collection<Group> findGroup(GroupType groupType, Map<String, String[]> attributes,
-// int offset, int limit,
-// boolean orderedByName, boolean ascending) throws IdentityException;
-
- /**
- * Whether Identity is a virtual
- * (such as a pseudonym)
- * @return true (virtual identity)
- */
- boolean isVirtual(Identity identity);
-
-
-
-
-
-}
Copied: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java (from rev 211, trunk/identity-api/src/main/java/org/jboss/identity/api/PersistenceManager.java)
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java (rev 0)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,185 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.api;
+
+import org.jboss.identity.idm.exception.IdentityException;
+
+import java.util.Collection;
+
+/**
+ * Exposes all management operations on Group and Identity objects.
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface PersistenceManager
+{
+
+ /**
+ * @return Session associated with this object instance
+ */
+ IdentitySession getIdentitySession();
+
+
+ /**
+ * @return object describing supported features
+ */
+ PersistenceManagerFeaturesDescription getFeaturesDescription();
+
+
+ // Create
+
+ /**
+ * <p>Create an identity in the realm</p>
+ * @param identityName
+ * @throws IdentityException
+ * @return
+ */
+ Identity createIdentity(String identityName) throws IdentityException;
+
+ /**
+ * <p>Create a group of a particular type</p>
+ * @param groupName
+ * @param groupType
+ * @return
+ */
+ Group createGroup(String groupName, GroupType groupType)
+ throws IdentityException;
+
+ // Remove
+
+ /**
+ * Remove given identity
+ *
+ * @param identity
+ * @param force - if true all present relationships will be removed, if false any present relationship will cause
+ * removal to fail
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ void removeIdentity(Identity identity, boolean force) throws IdentityException;
+
+ /**
+ * Remove given group
+ *
+ * @param group
+ * @param force - if true all present relationships will be removed, if false any present relationship will cause
+ * removal to fail
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ void removeGroup(Group group, boolean force) throws IdentityException;
+
+ // Search
+
+ /**
+ * @return a number of stored identities
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ int getIdentityCount()
+ throws IdentityException;
+
+ /**
+ * @param groupType
+ * @return a number of stored groups with a given type
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ int getGroupTypeCount(GroupType groupType)
+ throws IdentityException;
+
+ /**
+ * Find identity with a given name
+ *
+ * @param name
+ * @return
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ Identity findIdentity(String name) throws IdentityException;
+
+ /**
+ * Find identity with a given id
+ *
+ * @param id
+ * @return
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ Identity findIdentityById(String id) throws IdentityException;
+
+ /**
+ *
+ * @param controls
+ * @return
+ * @throws IdentityException
+ */
+ Collection<Identity> findIdentity(IdentitySearchControl[] controls) throws IdentityException;
+
+ // Search Groups
+
+ /**
+ * Find group with a given name and type
+ *
+ * @param name
+ * @param groupType
+ * @return
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ Group findGroup(String name, GroupType groupType) throws IdentityException;
+
+ /**
+ * Find group with a given id
+ *
+ * @param id
+ * @return
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ Group findGroupById(String id) throws IdentityException;
+
+
+ /**
+ *
+ * @param groupType
+ * @param controls
+ * @return
+ * @throws IdentityException
+ */
+ Collection<Group> findGroup(GroupType groupType, IdentitySearchControl[] controls) throws IdentityException;
+
+ /**
+ *
+ * @param groupType
+ * @return
+ * @throws IdentityException
+ */
+ Collection<Group> findGroup(GroupType groupType) throws IdentityException;
+
+
+ /**
+ * Whether Identity is a virtual
+ * (such as a pseudonym)
+ * @return true (virtual identity)
+ */
+ boolean isVirtual(Identity identity);
+
+
+
+
+
+}
Deleted: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/PersistenceManagerFeaturesDescription.java
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/api/PersistenceManagerFeaturesDescription.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/PersistenceManagerFeaturesDescription.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,63 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.api;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public interface PersistenceManagerFeaturesDescription
-{
-
- /**
- * @return
- */
- boolean isIdentitiesCreationSupported();
-
- /**
- * @return
- */
- boolean isGroupsCreationSupported();
-
- /**
- * @return
- */
- boolean isIdentitiesSortedSearchSupported();
-
- /**
- * @param groupType
- * @return
- */
- boolean isGroupsSortedSearchSupported(GroupType groupType);
-
- /**
- * @return
- */
- boolean isIdentitiesPaginatedSearchSupported();
-
- /**
- * @param groupType
- * @return
- */
- boolean isGroupsPaginatedSearchSupported(GroupType groupType);
-}
Copied: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/PersistenceManagerFeaturesDescription.java (from rev 211, trunk/identity-api/src/main/java/org/jboss/identity/api/PersistenceManagerFeaturesDescription.java)
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/idm/api/PersistenceManagerFeaturesDescription.java (rev 0)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/PersistenceManagerFeaturesDescription.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,71 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.api;
+
+/**
+ * Describes capabilities of PersistenceManager
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface PersistenceManagerFeaturesDescription
+{
+
+ /**
+ * Check if Identity objects can be created
+ * @return
+ */
+ boolean isIdentitiesCreationSupported();
+
+ /**
+ * Check if Group objects can be created
+ * @return
+ */
+ boolean isGroupsCreationSupported();
+
+ /**
+ * Check if IdentitySearchControl for sorted results can be used in Identity object queries
+ * @return
+ */
+ boolean isIdentitiesSortedSearchSupported();
+
+ /**
+ * Check if IdentitySearchControl for sorted results can be used in Group object queries
+ * @param groupType
+ * @return
+ */
+ boolean isGroupsSortedSearchSupported(GroupType groupType);
+
+ /**
+ * Check if IdentitySearchControl for paged results can be used in Identity object queries
+ * @return
+ */
+ boolean isIdentitiesPaginatedSearchSupported();
+
+ /**
+ * Check if IdentitySearchControl for sorted results can be used in Group object queries
+ * @param groupType
+ * @return
+ */
+ boolean isGroupsPaginatedSearchSupported(GroupType groupType);
+}
Deleted: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Realm.java
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/api/Realm.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Realm.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,36 +0,0 @@
-/*
- * 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;
-
-/**
- * <p>The <b>realm</b> contain configuration of a set of identity data providers</p>
- * @author Anil.Saldhana at redhat.com
- * @since Jul 9, 2008
- */
-public interface Realm
-{
-
- /**
- * @return name
- */
- String getName();
-}
\ No newline at end of file
Copied: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Realm.java (from rev 211, trunk/identity-api/src/main/java/org/jboss/identity/api/Realm.java)
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Realm.java (rev 0)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Realm.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,37 @@
+/*
+ * 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.idm.api;
+
+/**
+ * <p>The <b>realm</b> contain configuration of a set of identity data providers</p>
+ *
+ * @author Anil.Saldhana at redhat.com
+ * @since Jul 9, 2008
+ */
+public interface Realm
+{
+
+ /**
+ * @return name
+ */
+ String getName();
+}
\ No newline at end of file
Modified: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/RealmManager.java
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/api/RealmManager.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/RealmManager.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,9 +20,9 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.api;
+package org.jboss.identity.idm.api;
-import org.jboss.identity.exception.IdentityException;
+import org.jboss.identity.idm.exception.IdentityException;
import java.io.InputStream;
Modified: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/RelationshipManager.java
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/api/RelationshipManager.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/RelationshipManager.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,9 +20,9 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.api;
+package org.jboss.identity.idm.api;
-import org.jboss.identity.exception.IdentityException;
+import org.jboss.identity.idm.exception.IdentityException;
import java.util.Collection;
@@ -51,7 +51,7 @@
* <p>Associate groups</p>
* @param parents
* @param members
- * @throws org.jboss.identity.exception.IdentityException
+ * @throws org.jboss.identity.idm.exception.IdentityException
*/
void associateGroups(Collection<Group> parents, Collection<Group> members)
throws IdentityException;
@@ -60,7 +60,7 @@
* <p>Associate groups</p>
* @param parent
* @param member
- * @throws org.jboss.identity.exception.IdentityException
+ * @throws org.jboss.identity.idm.exception.IdentityException
*/
void associateGroups(Group parent, Group member)
throws IdentityException;
@@ -69,7 +69,7 @@
* <p>Associate identities to groups</p>
* @param parents
* @param members
- * @throws org.jboss.identity.exception.IdentityException
+ * @throws org.jboss.identity.idm.exception.IdentityException
*/
void associateIdentities(Collection<Group> parents, Collection<Identity> members)
throws IdentityException;
@@ -78,7 +78,7 @@
* <p>Associate identities to groups</p>
* @param parents
* @param members
- * @throws org.jboss.identity.exception.IdentityException
+ * @throws org.jboss.identity.idm.exception.IdentityException
*/
void associateIdentities(Group parents, Identity members)
throws IdentityException;
@@ -87,7 +87,7 @@
* <p>Disassociate groups</p>
* @param parents
* @param members
- * @throws org.jboss.identity.exception.IdentityException
+ * @throws org.jboss.identity.idm.exception.IdentityException
*/
void disassociateGroups(Collection<Group> parents, Collection<Group> members)
throws IdentityException;
@@ -96,7 +96,7 @@
* <p>Disassociate identities from groups</p>
* @param parents
* @param members
- * @throws org.jboss.identity.exception.IdentityException
+ * @throws org.jboss.identity.idm.exception.IdentityException
*/
void disassociateIdentities(Collection<Group> parents, Collection<Identity> members)
throws IdentityException;
@@ -106,7 +106,7 @@
* @param parents
* @param members
* @return
- * @throws org.jboss.identity.exception.IdentityException
+ * @throws org.jboss.identity.idm.exception.IdentityException
*/
<G extends IdentityType, I extends IdentityType> boolean isAssociated(Collection<G> parents, Collection<I> members)
throws IdentityException;
@@ -116,7 +116,7 @@
* @param parent
* @param member
* @return
- * @throws org.jboss.identity.exception.IdentityException
+ * @throws org.jboss.identity.idm.exception.IdentityException
*/
<G extends IdentityType, I extends IdentityType> boolean isAssociated(G parent, I member)
throws IdentityException;
@@ -137,7 +137,7 @@
* @param inherited if true also identities from subgroubs will be retreived. Matters only when parent is set to true.
* Default is false
* @return
- * @throws org.jboss.identity.exception.IdentityException
+ * @throws org.jboss.identity.idm.exception.IdentityException
*/
Collection<Group> findAssociatedGroups(Group group,
GroupType groupType,
@@ -158,7 +158,7 @@
* @param inherited if true also identities from subgroubs will be retreived. Matters only when parent is set to true.
* Default is false
* @return
- * @throws org.jboss.identity.exception.IdentityException
+ * @throws org.jboss.identity.idm.exception.IdentityException
*/
Collection<Group> findAssociatedGroups(Group group,
GroupType groupType,
@@ -175,7 +175,7 @@
* @param identity child identity
* @param groupType can be null
* @return
- * @throws org.jboss.identity.exception.IdentityException
+ * @throws org.jboss.identity.idm.exception.IdentityException
*/
Collection<Group> findAssociatedGroups(Identity identity,
GroupType groupType) throws IdentityException;
@@ -189,7 +189,7 @@
* @param identity child identity
* @param groupType can be null
* @return
- * @throws org.jboss.identity.exception.IdentityException
+ * @throws org.jboss.identity.idm.exception.IdentityException
*/
Collection<Group> findAssociatedGroups(Identity identity,
GroupType groupType,
@@ -203,7 +203,7 @@
*
* @param identity child identity
* @return
- * @throws org.jboss.identity.exception.IdentityException
+ * @throws org.jboss.identity.idm.exception.IdentityException
*/
Collection<Group> findAssociatedGroups(Identity identity,
IdentitySearchControl[] controls) throws IdentityException;
@@ -216,7 +216,7 @@
*
* @param identity child identity
* @return
- * @throws org.jboss.identity.exception.IdentityException
+ * @throws org.jboss.identity.idm.exception.IdentityException
*/
Collection<Group> findAssociatedGroups(Identity identity) throws IdentityException;
@@ -229,7 +229,7 @@
* @param group parent group
* @param inherited if true also identities from subgroubs will be retrieved. Default is false
* @return
- * @throws org.jboss.identity.exception.IdentityException
+ * @throws org.jboss.identity.idm.exception.IdentityException
*/
Collection<Identity> findAssociatedIdentities(Group group,
boolean inherited) throws IdentityException;
@@ -243,7 +243,7 @@
* @param group parent group
* @param inherited if true also identities from subgroubs will be retrieved. Default is false
* @return
- * @throws org.jboss.identity.exception.IdentityException
+ * @throws org.jboss.identity.idm.exception.IdentityException
*/
Collection<Identity> findAssociatedIdentities(Group group,
boolean inherited,
Deleted: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/RelationshipManagerFeaturesDescription.java
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/api/RelationshipManagerFeaturesDescription.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/RelationshipManagerFeaturesDescription.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,69 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.api;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public interface RelationshipManagerFeaturesDescription
-{
-
- /**
- * @param fromGroupType
- * @return
- */
- boolean isIdentityAssociationSupported(GroupType fromGroupType);
-
- /**
- * @param fromGroupType
- * @param toGroupType
- * @return
- */
- boolean isGroupAssociationSupported(GroupType fromGroupType, GroupType toGroupType);
-
- /**
- * @return
- */
- boolean isIdentitiesSortedSearchSupported();
-
- /**
- * @param groupType
- * @return
- */
- boolean isGroupsSortedSearchSupported(GroupType groupType);
-
- /**
- * @return
- */
- boolean isIdentitiesPaginatedSearchSupported();
-
- /**
- * @param groupType
- * @return
- */
- boolean isGroupsPaginatedSearchSupported(GroupType groupType);
-
-
-
-}
Copied: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/RelationshipManagerFeaturesDescription.java (from rev 211, trunk/identity-api/src/main/java/org/jboss/identity/api/RelationshipManagerFeaturesDescription.java)
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/idm/api/RelationshipManagerFeaturesDescription.java (rev 0)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/RelationshipManagerFeaturesDescription.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,73 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.api;
+
+/**
+ * Describes capabilities of RelationshipManager
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface RelationshipManagerFeaturesDescription
+{
+
+ /**
+ * Can Identity objects have role association with a given GroupType
+ * @param fromGroupType
+ * @return
+ */
+ boolean isIdentityAssociationSupported(GroupType fromGroupType);
+
+ /**
+ * Can given group types have role association
+ * @param fromGroupType
+ * @param toGroupType
+ * @return
+ */
+ boolean isGroupAssociationSupported(GroupType fromGroupType, GroupType toGroupType);
+
+ /**
+ * @return
+ */
+ boolean isIdentitiesSortedSearchSupported();
+
+ /**
+ * @param groupType
+ * @return
+ */
+ boolean isGroupsSortedSearchSupported(GroupType groupType);
+
+ /**
+ * @return
+ */
+ boolean isIdentitiesPaginatedSearchSupported();
+
+ /**
+ * @param groupType
+ * @return
+ */
+ boolean isGroupsPaginatedSearchSupported(GroupType groupType);
+
+
+
+}
Modified: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Role.java
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/api/Role.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Role.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -19,7 +19,7 @@
* 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;
+package org.jboss.identity.idm.api;
/**
Deleted: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/RoleManager.java
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/api/RoleManager.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/RoleManager.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,203 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.api;
-
-import org.jboss.identity.exception.IdentityException;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.List;
-
-/**
- * Management operations on Role objects. Role support is optional and depends on the capabilities of the underlying
- * configured identity stores capabilities.
- *
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public interface RoleManager
-{
-
- /**
- * @return Session associated with this object instance
- */
- IdentitySession getIdentitySession();
-
- /**
- * @return
- */
- RoleManagerFeaturesDescription getSupportedFeatures();
-
- // RoleType
-
- /**
- * Create RoleType
- * @param name
- * @return
- * @throws IdentityException
- */
- RoleType createRoleType(String name) throws IdentityException;
-
- /**
- * Remove RoleType
- * @param name
- * @throws IdentityException
- */
- void removeRoleType(String name) throws IdentityException;
-
- /**
- * Remove RoleType
- * @param roleType
- * @throws IdentityException
- */
- void removeRoleType(RoleType roleType) throws IdentityException;
-
- /**
- * Get RoleType
- * @param name
- * @return
- * @throws IdentityException
- */
- RoleType getRoleType(String name) throws IdentityException;
-
- /**
- * Find all RoleType objects stored
- * @return
- * @throws IdentityException
- */
- Collection<RoleType> findRoleTypes(IdentitySearchControl[] controls) throws IdentityException;
-
-
- // Role
-
-
- /**
- * Create role
- * @param roleType
- * @param identity
- * @param group
- * @return
- * @throws IdentityException
- */
- Role createRole(RoleType roleType, Identity identity, Group group) throws IdentityException;
-
- /**
- * Remove Role
- * @param roleType
- * @param identity
- * @param group
- * @throws IdentityException
- */
- void removeRole(RoleType roleType, Identity identity, Group group) throws IdentityException;
-
- /**
- * Remove Role
- * @param role
- * @throws IdentityException
- */
- void removeRole(Role role) throws IdentityException;
-
- /**
- * Check if Role is present
- * @param identity
- * @param group
- * @param roleType
- * @return
- * @throws IdentityException
- */
- boolean hasRole(Identity identity, Group group, RoleType roleType) throws IdentityException;
-
- /**
- * Find RoleType objects for roles associated with a given Identity and Group
- * @param identity
- * @param group
- * @return
- * @throws IdentityException
- */
- Collection<RoleType> findRoleTypes(Identity identity, Group group,
- IdentitySearchControl[] controls) throws IdentityException;
-
- /**
- * Find RoleType objects for roles associated with a given Identity and Group
- * @param identity
- * @param group
- * @return
- * @throws IdentityException
- */
- Collection<RoleType> findRoleTypes(Identity identity, Group group) throws IdentityException;
-
- /**
- * Find RoleType objects for roles associated with a given Identity
- * @param identity
- * @return
- * @throws IdentityException
- */
- Collection<RoleType> findIdentityRoleTypes(Identity identity) throws IdentityException;
-
- /**
- * Find RoleType objects for roles associated with a given Identity
- * @param identity
- * @return
- * @throws IdentityException
- */
- Collection<RoleType> findIdentityRoleTypes(Identity identity, IdentitySearchControl[] controls) throws IdentityException;
-
- /**
- * Find RoleType objects for roles associated with a given Group
- * @param group
- * @return
- * @throws IdentityException
- */
- Collection<RoleType> findGroupRoleTypes(Group group) throws IdentityException;
-
- /**
- * Find RoleType objects for roles associated with a given Group
- * @param group
- * @return
- * @throws IdentityException
- */
- Collection<RoleType> findGroupRoleTypes(Group group,
- IdentitySearchControl[] controls) throws IdentityException;
-
- /**
- * Find Role objects with a given RoleType associated with a given IdentityType
- * @param identityType
- * @param roleType
- * @return
- * @throws IdentityException
- */
- <T extends IdentityType> Collection<Role> findRoles(T identityType,
- RoleType roleType) throws IdentityException;
-
- /**
- * Find Role objects with a given RoleType associated with a given IdentityType
- * @param identityType
- * @param roleType
- * @return
- * @throws IdentityException
- */
- <T extends IdentityType> Collection<Role> findRoles(T identityType,
- RoleType roleType,
- IdentitySearchControl[] controls) throws IdentityException;
-
-}
Copied: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/RoleManager.java (from rev 211, trunk/identity-api/src/main/java/org/jboss/identity/api/RoleManager.java)
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/idm/api/RoleManager.java (rev 0)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/RoleManager.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,199 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.api;
+
+import org.jboss.identity.idm.exception.IdentityException;
+
+import java.util.Collection;
+
+/**
+ * Management operations on Role objects. Role support is optional and depends on the capabilities of the underlying
+ * configured identity stores capabilities.
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface RoleManager
+{
+
+ /**
+ * @return Session associated with this object instance
+ */
+ IdentitySession getIdentitySession();
+
+ /**
+ * @return
+ */
+ RoleManagerFeaturesDescription getSupportedFeatures();
+
+ // RoleType
+
+ /**
+ * Create RoleType
+ * @param name
+ * @return
+ * @throws IdentityException
+ */
+ RoleType createRoleType(String name) throws IdentityException;
+
+ /**
+ * Remove RoleType
+ * @param name
+ * @throws IdentityException
+ */
+ void removeRoleType(String name) throws IdentityException;
+
+ /**
+ * Remove RoleType
+ * @param roleType
+ * @throws IdentityException
+ */
+ void removeRoleType(RoleType roleType) throws IdentityException;
+
+ /**
+ * Get RoleType
+ * @param name
+ * @return
+ * @throws IdentityException
+ */
+ RoleType getRoleType(String name) throws IdentityException;
+
+ /**
+ * Find all RoleType objects stored
+ * @return
+ * @throws IdentityException
+ */
+ Collection<RoleType> findRoleTypes(IdentitySearchControl[] controls) throws IdentityException;
+
+
+ // Role
+ /**
+ * Create role
+ * @param roleType
+ * @param identity
+ * @param group
+ * @return
+ * @throws IdentityException
+ */
+ Role createRole(RoleType roleType, Identity identity, Group group) throws IdentityException;
+
+ /**
+ * Remove Role
+ * @param roleType
+ * @param identity
+ * @param group
+ * @throws IdentityException
+ */
+ void removeRole(RoleType roleType, Identity identity, Group group) throws IdentityException;
+
+ /**
+ * Remove Role
+ * @param role
+ * @throws IdentityException
+ */
+ void removeRole(Role role) throws IdentityException;
+
+ /**
+ * Check if Role is present
+ * @param identity
+ * @param group
+ * @param roleType
+ * @return
+ * @throws IdentityException
+ */
+ boolean hasRole(Identity identity, Group group, RoleType roleType) throws IdentityException;
+
+ /**
+ * Find RoleType objects for roles associated with a given Identity and Group
+ * @param identity
+ * @param group
+ * @return
+ * @throws IdentityException
+ */
+ Collection<RoleType> findRoleTypes(Identity identity, Group group,
+ IdentitySearchControl[] controls) throws IdentityException;
+
+ /**
+ * Find RoleType objects for roles associated with a given Identity and Group
+ * @param identity
+ * @param group
+ * @return
+ * @throws IdentityException
+ */
+ Collection<RoleType> findRoleTypes(Identity identity, Group group) throws IdentityException;
+
+ /**
+ * Find RoleType objects for roles associated with a given Identity
+ * @param identity
+ * @return
+ * @throws IdentityException
+ */
+ Collection<RoleType> findIdentityRoleTypes(Identity identity) throws IdentityException;
+
+ /**
+ * Find RoleType objects for roles associated with a given Identity
+ * @param identity
+ * @return
+ * @throws IdentityException
+ */
+ Collection<RoleType> findIdentityRoleTypes(Identity identity, IdentitySearchControl[] controls) throws IdentityException;
+
+ /**
+ * Find RoleType objects for roles associated with a given Group
+ * @param group
+ * @return
+ * @throws IdentityException
+ */
+ Collection<RoleType> findGroupRoleTypes(Group group) throws IdentityException;
+
+ /**
+ * Find RoleType objects for roles associated with a given Group
+ * @param group
+ * @return
+ * @throws IdentityException
+ */
+ Collection<RoleType> findGroupRoleTypes(Group group,
+ IdentitySearchControl[] controls) throws IdentityException;
+
+ /**
+ * Find Role objects with a given RoleType associated with a given IdentityType
+ * @param identityType
+ * @param roleType
+ * @return
+ * @throws IdentityException
+ */
+ <T extends IdentityType> Collection<Role> findRoles(T identityType,
+ RoleType roleType) throws IdentityException;
+
+ /**
+ * Find Role objects with a given RoleType associated with a given IdentityType
+ * @param identityType
+ * @param roleType
+ * @return
+ * @throws IdentityException
+ */
+ <T extends IdentityType> Collection<Role> findRoles(T identityType,
+ RoleType roleType,
+ IdentitySearchControl[] controls) throws IdentityException;
+
+}
Deleted: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/RoleManagerFeaturesDescription.java
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/api/RoleManagerFeaturesDescription.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/RoleManagerFeaturesDescription.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,62 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.api;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public interface RoleManagerFeaturesDescription
-{
- /**
- * @return
- */
- boolean isRoleTypeCreationSupported();
-
- /**
- * @return
- */
- boolean isRoleTypeRemovalSupported();
-
- /**
- * @return
- */
- boolean isRoleSortedSearchSupported();
-
- /**
- * @param groupType
- * @return
- */
- boolean isRoleTypeSortedSearchSupported(GroupType groupType);
-
- /**
- * @return
- */
- boolean isRolePaginatedSearchSupported();
-
- /**
- * @param groupType
- * @return
- */
- boolean isRoleTypePaginatedSearchSupported(GroupType groupType);
-}
Copied: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/RoleManagerFeaturesDescription.java (from rev 211, trunk/identity-api/src/main/java/org/jboss/identity/api/RoleManagerFeaturesDescription.java)
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/idm/api/RoleManagerFeaturesDescription.java (rev 0)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/RoleManagerFeaturesDescription.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,67 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.api;
+
+/**
+ * Describes capabilities of RoleManager
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface RoleManagerFeaturesDescription
+{
+ /**
+ * Can RoleType object be created
+ * @return
+ */
+ boolean isRoleTypeCreationSupported();
+
+ /**
+ * Can RoleType objects be removed
+ *
+ * @return
+ */
+ boolean isRoleTypeRemovalSupported();
+
+ /**
+ * @return
+ */
+ boolean isRoleSortedSearchSupported();
+
+ /**
+ * @param groupType
+ * @return
+ */
+ boolean isRoleTypeSortedSearchSupported(GroupType groupType);
+
+ /**
+ * @return
+ */
+ boolean isRolePaginatedSearchSupported();
+
+ /**
+ * @param groupType
+ * @return
+ */
+ boolean isRoleTypePaginatedSearchSupported(GroupType groupType);
+}
Deleted: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/RoleType.java
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/api/RoleType.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/RoleType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,39 +0,0 @@
-/*
- * 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;
-
-
-/**
- * Type of Role
- * @author Anil.Saldhana at redhat.com
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @since Jun 30, 2008
- */
-public interface RoleType
-{
-
- /**
- * @return role type name
- */
- String getName();
-
-}
\ No newline at end of file
Copied: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/RoleType.java (from rev 211, trunk/identity-api/src/main/java/org/jboss/identity/api/RoleType.java)
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/idm/api/RoleType.java (rev 0)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/RoleType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,40 @@
+/*
+ * 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.idm.api;
+
+
+/**
+ * Type of Role
+ *
+ * @author Anil.Saldhana at redhat.com
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @since Jun 30, 2008
+ */
+public interface RoleType
+{
+
+ /**
+ * @return role type name
+ */
+ String getName();
+
+}
\ No newline at end of file
Deleted: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Transaction.java
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/api/Transaction.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Transaction.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,53 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.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();
-
-}
\ No newline at end of file
Copied: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Transaction.java (from rev 211, trunk/identity-api/src/main/java/org/jboss/identity/api/Transaction.java)
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Transaction.java (rev 0)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/Transaction.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,55 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.api;
+
+/**
+ * Transaction
+ *
+ * @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();
+
+}
\ No newline at end of file
Modified: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/event/IdentityEvent.java
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/api/event/IdentityEvent.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/event/IdentityEvent.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,7 +20,7 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.api.event;
+package org.jboss.identity.idm.api.event;
/**
* @author boleslaw dot dawidowicz at redhat anotherdot com
Modified: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/event/IdentityEventBroadcaster.java
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/api/event/IdentityEventBroadcaster.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/event/IdentityEventBroadcaster.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,9 +20,9 @@
* 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.event;
+package org.jboss.identity.idm.api.event;
-import org.jboss.identity.api.event.IdentityEvent;
+import org.jboss.identity.idm.api.event.IdentityEvent;
/**
* Interface that allow event firing.
Modified: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/event/IdentityEventEmitter.java
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/api/event/IdentityEventEmitter.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/event/IdentityEventEmitter.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,9 +20,9 @@
* 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.event;
+package org.jboss.identity.idm.api.event;
-import org.jboss.identity.api.event.IdentityEventListener;
+import org.jboss.identity.idm.api.event.IdentityEventListener;
/**
* Interface that allows registration management of identity event listeners.
Modified: trunk/identity-api/src/main/java/org/jboss/identity/idm/api/event/IdentityEventListener.java
===================================================================
--- trunk/identity-api/src/main/java/org/jboss/identity/api/event/IdentityEventListener.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-api/src/main/java/org/jboss/identity/idm/api/event/IdentityEventListener.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,9 +20,9 @@
* 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.event;
+package org.jboss.identity.idm.api.event;
-import org.jboss.identity.api.event.IdentityEvent;
+import org.jboss.identity.idm.api.event.IdentityEvent;
/**
* An event listener.
Copied: trunk/identity-common/src/main/java/org/jboss/identity/idm/exception (from rev 198, trunk/identity-common/src/main/java/org/jboss/identity/exception)
Modified: trunk/identity-common/src/main/java/org/jboss/identity/idm/exception/FeatureNotSupportedException.java
===================================================================
--- trunk/identity-common/src/main/java/org/jboss/identity/exception/FeatureNotSupportedException.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-common/src/main/java/org/jboss/identity/idm/exception/FeatureNotSupportedException.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,7 +20,7 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.exception;
+package org.jboss.identity.idm.exception;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Modified: trunk/identity-common/src/main/java/org/jboss/identity/idm/exception/IdentityException.java
===================================================================
--- trunk/identity-common/src/main/java/org/jboss/identity/exception/IdentityException.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-common/src/main/java/org/jboss/identity/idm/exception/IdentityException.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -19,7 +19,7 @@
* 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.exception;
+package org.jboss.identity.idm.exception;
import java.security.GeneralSecurityException;
Modified: trunk/identity-common/src/main/java/org/jboss/identity/idm/exception/PolicyValidationException.java
===================================================================
--- trunk/identity-common/src/main/java/org/jboss/identity/exception/PolicyValidationException.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-common/src/main/java/org/jboss/identity/idm/exception/PolicyValidationException.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -19,7 +19,7 @@
* 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.exception;
+package org.jboss.identity.idm.exception;
import java.security.GeneralSecurityException;
Copied: trunk/identity-common/src/main/java/org/jboss/identity/idm/p3p (from rev 198, trunk/identity-common/src/main/java/org/jboss/identity/p3p)
Modified: trunk/identity-common/src/main/java/org/jboss/identity/idm/p3p/P3PConstants.java
===================================================================
--- trunk/identity-common/src/main/java/org/jboss/identity/p3p/P3PConstants.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-common/src/main/java/org/jboss/identity/idm/p3p/P3PConstants.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,7 +20,7 @@
* 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.p3p;
+package org.jboss.identity.idm.p3p;
/**
* Class taken from JBoss Portal common module.
Copied: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl (from rev 198, trunk/identity-impl/src/main/java/org/jboss/identity/impl)
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/NotYetImplementedException.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/NotYetImplementedException.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/NotYetImplementedException.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,7 +20,7 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl;
+package org.jboss.identity.idm.impl;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/AbstractCredential.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/AbstractCredential.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/AbstractCredential.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,53 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.api;
-
-import org.jboss.identity.spi.model.IdentityObjectCredential;
-import org.jboss.identity.api.Credential;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public abstract class AbstractCredential implements Credential, IdentityObjectCredential
-{
- private final SimpleCredentialTypeImpl type;
-
- public AbstractCredential(SimpleCredentialTypeImpl type)
- {
- if (type == null)
- {
- throw new IllegalArgumentException("type is null");
- }
-
-
-
-
- this.type = type;
- }
-
- public SimpleCredentialTypeImpl getType()
- {
- return type;
- }
-}
Copied: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/AbstractCredential.java (from rev 211, trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/AbstractCredential.java)
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/AbstractCredential.java (rev 0)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/AbstractCredential.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -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.idm.impl.api;
+
+import org.jboss.identity.idm.spi.model.IdentityObjectCredential;
+import org.jboss.identity.idm.api.Credential;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public abstract class AbstractCredential implements Credential, IdentityObjectCredential
+{
+ private final SimpleCredentialType type;
+
+ public AbstractCredential(SimpleCredentialType type)
+ {
+ if (type == null)
+ {
+ throw new IllegalArgumentException("type is null");
+ }
+
+
+
+
+ this.type = type;
+ }
+
+ public SimpleCredentialType getType()
+ {
+ return type;
+ }
+}
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/AbstractManager.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/AbstractManager.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/AbstractManager.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,205 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.api;
-
-import org.jboss.identity.api.IdentitySession;
-import org.jboss.identity.api.Identity;
-import org.jboss.identity.api.Group;
-import org.jboss.identity.api.GroupType;
-import org.jboss.identity.api.IdentityType;
-import org.jboss.identity.api.IdentitySearchControl;
-import org.jboss.identity.api.Attribute;
-import org.jboss.identity.spi.repository.IdentityStoreRepository;
-import org.jboss.identity.spi.store.IdentityStoreInvocationContext;
-import org.jboss.identity.spi.searchcontrol.IdentityObjectSearchControl;
-import org.jboss.identity.spi.model.IdentityObject;
-import org.jboss.identity.spi.model.IdentityObjectType;
-import org.jboss.identity.spi.model.IdentityObjectAttribute;
-import org.jboss.identity.impl.types.SimpleIdentityObject;
-
-import java.util.List;
-import java.util.LinkedList;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public abstract class AbstractManager
-{
- protected final IdentitySession identitySession;
-
- protected AbstractManager(IdentitySession session)
- {
- this.identitySession = session;
- }
-
- public IdentitySession getIdentitySession()
- {
- return identitySession;
- }
-
- protected IdentitySessionContext getSessionContext()
- {
- if (identitySession instanceof IdentitySessionImpl)
- {
- return ((IdentitySessionImpl)identitySession).getSessionContext();
- }
- return null;
- }
-
- protected IdentityStoreRepository getRepository()
- {
- return getSessionContext().getIdentityStoreRepository();
- }
-
- protected IdentityStoreInvocationContext getInvocationContext()
- {
- return getSessionContext().resolveStoreInvocationContext();
- }
-
- protected Identity createIdentity(IdentityObject identityObject)
- {
- return new SimpleIdentityImpl(identityObject.getName(), identityObject.getId());
- }
-
- protected Group createGroup(IdentityObject identityObject)
- {
- GroupType groupType = getSessionContext().getIdentityObjectTypeMapper().getGroupType(identityObject.getIdentityType());
- return new SimpleGroupImpl(identityObject.getName(), identityObject.getId(), groupType);
- }
-
- protected IdentityObject createIdentityObject(Identity identity)
- {
- IdentityObjectType iot = getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType();
-
- return new SimpleIdentityObject(identity.getName(), identity.getId(), iot);
- }
-
- protected IdentityObject createIdentityObject(Group group)
- {
- IdentityObjectType iot = getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType(group.getGroupType());
-
- return new SimpleIdentityObject(group.getName(), group.getId(), iot);
- }
-
- protected IdentityObject createIdentityObject(IdentityType identityType)
- {
- if (identityType instanceof Identity)
- {
- return createIdentityObject((Identity)identityType);
- }
- else if (identityType instanceof Group)
- {
- return createIdentityObject((Group)identityType);
- }
-
- throw new IllegalStateException("Not supported IdentityType extension: " + identityType.getClass());
-
- }
-
- protected IdentityObjectSearchControl[] convertSearchControls(IdentitySearchControl[] controls)
- {
- if (controls == null)
- {
- return null;
- }
-
- //TODO: simples check
- List<IdentityObjectSearchControl> result = new LinkedList<IdentityObjectSearchControl>();
-
- for (IdentitySearchControl control : controls)
- {
- if (control instanceof IdentityObjectSearchControl)
- {
- result.add((IdentityObjectSearchControl)control);
- }
- }
-
- if (result.size() == 0)
- {
- return null;
- }
-
- return result.toArray(new IdentityObjectSearchControl[result.size()]);
-
- }
-
- protected IdentityObjectType getIdentityObjectType()
- {
- return getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType();
- }
-
- protected IdentityObjectType getIdentityObjectType(GroupType groupType)
- {
- return getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType(groupType);
- }
-
- protected IdentityObjectAttribute[] convertAttributes(Attribute[] attributes)
- {
- IdentityObjectAttribute[] convertedAttributes = new IdentityObjectAttribute[attributes.length];
-
- for (int i = 0; i < attributes.length; i++)
- {
- convertedAttributes[i] = convertAttribute(attributes[i]);
- }
- return convertedAttributes;
- }
-
- protected Attribute[] convertAttributes(IdentityObjectAttribute[] attributes)
- {
- Attribute[] convertedAttributes = new Attribute[attributes.length];
-
- for (int i = 0; i < attributes.length; i++)
- {
- convertedAttributes[i] = convertAttribute(attributes[i]);
- }
- return convertedAttributes;
- }
-
- protected Attribute convertAttribute(IdentityObjectAttribute attribute)
- {
- if (attribute instanceof Attribute)
- {
- return (Attribute)attribute;
- }
- else
- {
- return new SimpleAttributeImpl(attribute);
- }
- }
-
- protected IdentityObjectAttribute convertAttribute(Attribute attribute)
- {
- if (attribute instanceof IdentityObjectAttribute)
- {
- return (IdentityObjectAttribute)attribute;
- }
- else
- {
- return new SimpleAttributeImpl(attribute);
- }
- }
-
-
-
-}
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/AttributeFilterSearchControl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/AttributeFilterSearchControl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/AttributeFilterSearchControl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,10 +20,10 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.api;
+package org.jboss.identity.idm.impl.api;
-import org.jboss.identity.api.IdentitySearchControl;
-import org.jboss.identity.spi.searchcontrol.IdentityObjectSearchControl;
+import org.jboss.identity.idm.api.IdentitySearchControl;
+import org.jboss.identity.idm.spi.searchcontrol.IdentityObjectSearchControl;
import java.util.Map;
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/AttributesManagerImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/AttributesManagerImpl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/AttributesManagerImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,216 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.api;
-
-import org.jboss.identity.api.IdentitySession;
-import org.jboss.identity.api.AttributesManager;
-import org.jboss.identity.api.IdentityType;
-import org.jboss.identity.api.Identity;
-import org.jboss.identity.api.AttributeDescription;
-import org.jboss.identity.api.CredentialType;
-import org.jboss.identity.api.Credential;
-import org.jboss.identity.api.Attribute;
-import org.jboss.identity.exception.IdentityException;
-import org.jboss.identity.spi.model.IdentityObjectCredential;
-import org.jboss.identity.spi.model.IdentityObjectAttribute;
-import org.jboss.identity.spi.attribute.IdentityObjectAttributeMetaData;
-import org.jboss.identity.impl.NotYetImplementedException;
-
-import java.util.Set;
-import java.util.Map;
-import java.util.HashMap;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class AttributesManagerImpl extends AbstractManager implements AttributesManager
-{
-
- public AttributesManagerImpl(IdentitySession session)
- {
- super(session);
- }
-
- public AttributeDescription getAttributeDescription(IdentityType identityType, String name)
- {
-
- Map<String, IdentityObjectAttributeMetaData> mdMap =
- getRepository().getAttributesMetaData(getInvocationContext(), createIdentityObject(identityType).getIdentityType());
-
- if (mdMap != null && mdMap.containsKey(name))
- {
- IdentityObjectAttributeMetaData attributeMD = mdMap.get(name);
- if (attributeMD instanceof AttributeDescription)
- {
- return (AttributeDescription)attributeMD;
- }
- else
- {
- return new IdentityObjectAttributeMetaDataImpl(attributeMD);
- }
- }
-
- return null;
-
- }
-
- public Map<String, AttributeDescription> getSupportedAttributesDescriptions(IdentityType identityType)
- {
-
- Map<String, IdentityObjectAttributeMetaData> mdMap =
- getRepository().getAttributesMetaData(getInvocationContext(), createIdentityObject(identityType).getIdentityType());
-
- Map<String, AttributeDescription> descriptionMap = new HashMap<String, AttributeDescription>();
-
- if (mdMap != null)
- {
- for (IdentityObjectAttributeMetaData attributeMD : mdMap.values())
- {
- if (attributeMD instanceof AttributeDescription)
- {
- descriptionMap.put(attributeMD.getName(), (AttributeDescription)attributeMD);
- }
- else
- {
- descriptionMap.put(attributeMD.getName(), new IdentityObjectAttributeMetaDataImpl(attributeMD));
- }
- }
- }
-
- return descriptionMap;
- }
-
- public Set<String> getSupportedAttributeNames(IdentityType identityType) throws IdentityException
- {
- return getRepository().getSupportedAttributeNames(getInvocationContext(), createIdentityObject(identityType).getIdentityType());
- }
-
- public Map<String, Attribute> getAttributes(IdentityType identity) throws IdentityException
- {
- Map<String, IdentityObjectAttribute> map = getRepository().getAttributes(getInvocationContext(), createIdentityObject(identity));
-
- Map<String, Attribute> newMap = new HashMap<String, Attribute>();
-
- for (Map.Entry<String, IdentityObjectAttribute> entry : map.entrySet())
- {
- newMap.put(entry.getKey(), convertAttribute(entry.getValue()));
- }
- return newMap;
- }
-
- public void updateAttributes(IdentityType identity, Attribute[] attributes) throws IdentityException
- {
- getRepository().updateAttributes(getInvocationContext(), createIdentityObject(identity), convertAttributes(attributes));
-
- }
-
- public Attribute getAttribute(IdentityType identity, String attributeName) throws IdentityException
- {
- return getAttributes(identity).get(attributeName);
- }
-
- public void addAttribute(IdentityType identity, String attributeName, Object[] values) throws IdentityException
- {
- Attribute[] attrs = new Attribute[]{new SimpleAttributeImpl(attributeName, values)};
-
- addAttributes(identity, attrs);
-
- }
-
- public void addAttribute(IdentityType identity, String attributeName, Object value) throws IdentityException
- {
- Attribute[] attrs = new Attribute[]{new SimpleAttributeImpl(attributeName, value)};
-
-
- addAttributes(identity, attrs);
-
- }
-
- public void addAttributes(IdentityType identity, Attribute[] attributes) throws IdentityException
- {
- getRepository().addAttributes(getInvocationContext(), createIdentityObject(identity), convertAttributes(attributes));
- }
-
- public void removeAttributes(IdentityType identity, String[] attributeNames) throws IdentityException
- {
- getRepository().removeAttributes(getInvocationContext(), createIdentityObject(identity), attributeNames);
- }
-
- public boolean hasPassword(Identity identity) throws IdentityException
- {
- return getRepository().getSupportedFeatures().isCredentialSupported(createIdentityObject(identity).getIdentityType(), PasswordCredential.TYPE);
- }
-
- public boolean validatePassword(Identity identity, String password) throws IdentityException
- {
- return getRepository().validateCredential(getInvocationContext(), createIdentityObject(identity), new PasswordCredential(password));
- }
-
- public void updatePassword(Identity identity, String password) throws IdentityException
- {
- getRepository().updateCredential(getInvocationContext(), createIdentityObject(identity), new PasswordCredential(password));
- }
-
- public boolean hasCredential(Identity identity, CredentialType credentialType) throws IdentityException
- {
- return getRepository().getSupportedFeatures().isCredentialSupported(createIdentityObject(identity).getIdentityType(), new SimpleCredentialTypeImpl(credentialType.getName()));
- }
-
- public boolean validateCredentials(Identity identity, Credential[] credentials) throws IdentityException
- {
-
- for (Credential credential : credentials)
- {
- IdentityObjectCredential ioc = null;
-
- //Handle only those credentials that implement SPI
-
- if (!(credential instanceof IdentityObjectCredential))
- {
- throw new IdentityException("Unsupported Credential implementation: " + credential.getClass());
- }
-
- // All credentials must pass
-
- if (!getRepository().validateCredential(getInvocationContext(), createIdentityObject(identity), ioc))
- {
- return false;
- }
- }
-
- return true;
- }
-
- public void updateCredential(Identity identity, Credential credential) throws IdentityException
- {
- if (credential instanceof IdentityObjectCredential)
- {
- getRepository().updateCredential(getInvocationContext(), createIdentityObject(identity), (IdentityObjectCredential)credential);
- }
- else
- {
- throw new IdentityException("Unsupported Credential implementation: " + credential.getClass());
- }
- }
-}
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/BinaryCredential.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/BinaryCredential.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/BinaryCredential.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,50 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.api;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class BinaryCredential extends AbstractCredential
-{
- private final byte[] value;
-
- public static final SimpleCredentialTypeImpl TYPE = new SimpleCredentialTypeImpl("BINARY");
-
- public BinaryCredential(byte[] value)
- {
- super(TYPE);
- this.value = value;
- }
-
- public byte[] getValue()
- {
- return value;
- }
-
- public Object getEncodedValue()
- {
- return null;
- }
-}
\ No newline at end of file
Copied: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/BinaryCredential.java (from rev 211, trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/BinaryCredential.java)
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/BinaryCredential.java (rev 0)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/BinaryCredential.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,50 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.impl.api;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class BinaryCredential extends AbstractCredential
+{
+ private final byte[] value;
+
+ public static final SimpleCredentialType TYPE = new SimpleCredentialType("BINARY");
+
+ public BinaryCredential(byte[] value)
+ {
+ super(TYPE);
+ this.value = value;
+ }
+
+ public byte[] getValue()
+ {
+ return value;
+ }
+
+ public Object getEncodedValue()
+ {
+ return null;
+ }
+}
\ No newline at end of file
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/DirectIdentityObjectTypeMapperImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/DirectIdentityObjectTypeMapperImpl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/DirectIdentityObjectTypeMapperImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,101 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.api;
-
-import org.jboss.identity.spi.model.IdentityObjectType;
-import org.jboss.identity.impl.types.SimpleIdentityObjectType;
-import org.jboss.identity.api.GroupType;
-
-import java.util.Map;
-import java.util.Collections;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class DirectIdentityObjectTypeMapperImpl implements IdentityObjectTypeMapper
-{
-
- private final String identityTypeName;
-
- public DirectIdentityObjectTypeMapperImpl(String identityTypeName)
- {
- this.identityTypeName = identityTypeName;
- }
-
- public IdentityObjectType getIdentityObjectType()
- {
- return new SimpleIdentityObjectType(identityTypeName);
- }
-
- public IdentityObjectType getIdentityObjectType(GroupType groupType)
- {
- if (groupType == null)
- {
- throw new IllegalArgumentException("groupType is null");
- }
-
- return new SimpleIdentityObjectType(groupType.getName());
- }
-
- public GroupType getGroupType(IdentityObjectType identityObjectType)
- {
- if (identityObjectType == null)
- {
- throw new IllegalArgumentException("identityObjectType is null");
- }
-
- return new SimpleGroupType(identityObjectType.getName());
-
- }
-
- public boolean isGroupType(IdentityObjectType identityObjectType)
- {
- if (identityObjectType == null)
- {
- throw new IllegalArgumentException("identityObjectType is null");
- }
-
- if (isIdentity(identityObjectType))
- {
- return false;
- }
-
- return true;
- }
-
-
- public boolean isIdentity(IdentityObjectType identityObjectType)
- {
- if (identityObjectType == null)
- {
- throw new IllegalArgumentException("identityObjectType is null");
- }
-
- if (identityObjectType.getName().equals(identityTypeName))
- {
- return true;
- }
- return false;
- }
-}
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/EntityManagerWrapper.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/EntityManagerWrapper.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/EntityManagerWrapper.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,86 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.api;
-
-import org.jboss.identity.exception.IdentityException;
-
-import javax.persistence.EntityManager;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class EntityManagerWrapper implements SessionWrapper
-{
- private final EntityManager em;
-
- public EntityManagerWrapper(EntityManager entityManager)
- {
- this.em = entityManager;
- }
-
- public void close() throws IdentityException
- {
- em.close();
- }
-
- public void save() throws IdentityException
- {
- em.flush();
- }
-
- public void clear() throws IdentityException
- {
- em.clear();
- }
-
- public boolean isOpen()
- {
- return em.isOpen();
- }
-
- public boolean isTransactionSupported()
- {
- return true;
- }
-
- public void startTransaction()
- {
- em.getTransaction().begin();
- }
-
- public void commitTransaction()
- {
- em.getTransaction().commit();
- }
-
- public void rollbackTransaction()
- {
- em.getTransaction().rollback();
- }
-
- public boolean isTransactionActive()
- {
- return em.getTransaction().isActive();
- }
-}
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/IdentityObjectAttributeMetaDataImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/IdentityObjectAttributeMetaDataImpl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/IdentityObjectAttributeMetaDataImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,96 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.api;
-
-import org.jboss.identity.spi.attribute.IdentityObjectAttributeMetaData;
-import org.jboss.identity.api.AttributeDescription;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class IdentityObjectAttributeMetaDataImpl implements IdentityObjectAttributeMetaData, AttributeDescription
-{
-
- private final String name;
-
- private final String storeMapping;
-
- private final String type;
-
- private final boolean readonly;
-
- private final boolean multivalued;
-
- private final boolean required;
-
- public IdentityObjectAttributeMetaDataImpl(String name, String storeMapping, String type, boolean readonly, boolean multivalued, boolean required)
- {
- this.name = name;
- this.storeMapping = storeMapping;
- this.type = type;
- this.readonly = readonly;
- this.multivalued = multivalued;
- this.required = required;
- }
-
- public IdentityObjectAttributeMetaDataImpl(IdentityObjectAttributeMetaData attributeMD)
- {
- this.name = attributeMD.getName();
- this.type = attributeMD.getType();
- this.readonly = attributeMD.isReadonly();
- this.multivalued = attributeMD.isMultivalued();
- this.required = attributeMD.isRequired();
- this.storeMapping = attributeMD.getStoreMapping();
- }
-
- public String getName()
- {
- return name;
- }
-
- public String getStoreMapping()
- {
- return storeMapping;
- }
-
- public String getType()
- {
- return type;
- }
-
- public boolean isReadonly()
- {
- return readonly;
- }
-
- public boolean isMultivalued()
- {
- return multivalued;
- }
-
- public boolean isRequired()
- {
- return required;
- }
-}
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/IdentityObjectTypeMapper.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/IdentityObjectTypeMapper.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/IdentityObjectTypeMapper.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,51 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.api;
-
-import org.jboss.identity.spi.model.IdentityObject;
-import org.jboss.identity.spi.model.IdentityObjectType;
-import org.jboss.identity.api.Identity;
-import org.jboss.identity.api.GroupType;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public interface IdentityObjectTypeMapper
-{
-
- IdentityObjectType getIdentityObjectType();
-
-
- IdentityObjectType getIdentityObjectType(GroupType groupType);
-
-
- GroupType getGroupType(IdentityObjectType identityObjectType);
-
-
- boolean isGroupType(IdentityObjectType identityObjectType);
-
-
- boolean isIdentity(IdentityObjectType identityObjectType);
-
-}
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/IdentityObjectTypeMapperImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/IdentityObjectTypeMapperImpl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/IdentityObjectTypeMapperImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,128 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.api;
-
-import org.jboss.identity.spi.model.IdentityObjectType;
-import org.jboss.identity.api.Identity;
-import org.jboss.identity.api.GroupType;
-import org.jboss.identity.impl.types.SimpleIdentityObjectType;
-
-import java.util.Map;
-import java.util.Collections;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class IdentityObjectTypeMapperImpl implements IdentityObjectTypeMapper
-{
-
- /**
- * IdentityObjectType --> GroupType
- */
- private final Map<String, String> groupTypeMap;
-
- private final String identityTypeName;
-
- public IdentityObjectTypeMapperImpl(Map<String, String> map, String identityTypeName)
- {
- groupTypeMap = Collections.unmodifiableMap(map);
- this.identityTypeName = identityTypeName;
- }
-
- public IdentityObjectType getIdentityObjectType()
- {
- return new SimpleIdentityObjectType(identityTypeName);
- }
-
- public IdentityObjectType getIdentityObjectType(GroupType groupType)
- {
- if (groupType == null)
- {
- throw new IllegalArgumentException("groupType is null");
- }
-
- for (Map.Entry<String, String> entry : groupTypeMap.entrySet())
- {
- if (entry.getValue().equals(groupType.getName()))
- {
- return new SimpleIdentityObjectType(entry.getKey());
- }
- }
-
- return null;
- }
-
- public GroupType getGroupType(IdentityObjectType identityObjectType)
- {
- if (identityObjectType == null)
- {
- throw new IllegalArgumentException("identityObjectType is null");
- }
-
- String name = groupTypeMap.get(identityObjectType.getName());
-
- if (name != null)
- {
- return new SimpleGroupType(name);
- }
-
- return null;
-
- }
-
- public boolean isGroupType(IdentityObjectType identityObjectType)
- {
- if (identityObjectType == null)
- {
- throw new IllegalArgumentException("identityObjectType is null");
- }
-
- if (isIdentity(identityObjectType))
- {
- return false;
- }
-
- if (groupTypeMap.containsKey(identityObjectType.getName()))
- {
- return true;
- }
-
- return false;
- }
-
-
- public boolean isIdentity(IdentityObjectType identityObjectType)
- {
- if (identityObjectType == null)
- {
- throw new IllegalArgumentException("identityObjectType is null");
- }
-
- if (identityObjectType.getName().equals(identityTypeName))
- {
- return true;
- }
- return false;
- }
-}
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/IdentitySessionContext.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/IdentitySessionContext.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/IdentitySessionContext.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,41 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.api;
-
-import org.jboss.identity.spi.repository.IdentityStoreRepository;
-import org.jboss.identity.spi.store.IdentityStoreInvocationContext;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public interface IdentitySessionContext
-{
-
- IdentityStoreRepository getIdentityStoreRepository();
-
- IdentityObjectTypeMapper getIdentityObjectTypeMapper();
-
- IdentityStoreInvocationContext resolveStoreInvocationContext();
-
-}
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/IdentitySessionContextImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/IdentitySessionContextImpl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/IdentitySessionContextImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,62 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.api;
-
-import org.jboss.identity.spi.repository.IdentityStoreRepository;
-import org.jboss.identity.spi.store.IdentityStoreInvocationContext;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class IdentitySessionContextImpl implements IdentitySessionContext
-{
- private final IdentityStoreRepository identityStoreRepository;
-
- private final IdentityObjectTypeMapper identityObjectTypeMapper;
-
- private final IdentityStoreInvocationContextResolver contextResolver;
-
-
- public IdentitySessionContextImpl(IdentityStoreRepository identityStoreRepository, IdentityObjectTypeMapper identityObjectTypeMapper, IdentityStoreInvocationContextResolver contextResolver)
- {
- this.identityStoreRepository = identityStoreRepository;
- this.identityObjectTypeMapper = identityObjectTypeMapper;
- this.contextResolver = contextResolver;
- }
-
- public IdentityStoreRepository getIdentityStoreRepository()
- {
- return identityStoreRepository;
- }
-
- public IdentityObjectTypeMapper getIdentityObjectTypeMapper()
- {
- return identityObjectTypeMapper;
- }
-
- public IdentityStoreInvocationContext resolveStoreInvocationContext()
- {
- return contextResolver.resolveInvocationContext();
- }
-}
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/IdentitySessionFactoryImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/IdentitySessionFactoryImpl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/IdentitySessionFactoryImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,173 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.api;
-
-import org.jboss.identity.api.IdentitySessionFactory;
-import org.jboss.identity.api.IdentitySession;
-import org.jboss.identity.spi.configuration.metadata.IdentityConfigurationMetaData;
-import org.jboss.identity.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
-import org.jboss.identity.spi.configuration.metadata.IdentityRepositoryConfigurationMetaData;
-import org.jboss.identity.spi.configuration.metadata.RealmConfigurationMetaData;
-import org.jboss.identity.spi.store.IdentityStore;
-import org.jboss.identity.spi.store.AttributeStore;
-import org.jboss.identity.spi.repository.IdentityStoreRepository;
-import org.jboss.identity.impl.configuration.jaxb2.JAXB2IdentityConfiguration;
-import org.jboss.identity.exception.IdentityException;
-
-import java.util.Map;
-import java.util.HashMap;
-import java.io.File;
-import java.lang.reflect.Constructor;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class IdentitySessionFactoryImpl implements IdentitySessionFactory
-{
-
- private final Map<String, IdentitySession> realmMap;
-
- public IdentitySessionFactoryImpl(Map<String, IdentitySession> realmMap)
- {
- this.realmMap = realmMap;
- }
-
- public IdentitySessionFactoryImpl(IdentityConfigurationMetaData configMD) throws Exception
- {
- realmMap = createSessionMap(configMD);
- }
-
- public IdentitySessionFactoryImpl(File configFile) throws Exception
- {
- IdentityConfigurationMetaData configMD = JAXB2IdentityConfiguration.createConfigurationMetaData(configFile);
-
- realmMap = createSessionMap(configMD);
-
- }
-
- private Map<String, IdentitySession> createSessionMap(IdentityConfigurationMetaData configMD) throws Exception
- {
- //TODO: some validation, sanity checks and error reporting
-
- // IdentityStore
-
- Map<String, IdentityStore> bootstrappedIdentityStores = new HashMap<String, IdentityStore>();
- Map<String, AttributeStore> bootstrappedAttributeStores = new HashMap<String, AttributeStore>();
-
- for (IdentityStoreConfigurationMetaData metaData : configMD.getIdentityStores())
- {
- Class storeClass = null;
- try
- {
- storeClass = Class.forName(metaData.getClassName());
- }
- catch (ClassNotFoundException e)
- {
- throw new IdentityException("Cannot instantiate identity store:" + metaData.getClassName(), e);
- }
- Class partypes[] = new Class[1];
- partypes[0] = String.class;
-
- Constructor ct = storeClass.getConstructor(partypes);
- Object argList[] = new Object[1];
- argList[0] = metaData.getId();
-
- IdentityStore store = (IdentityStore)ct.newInstance(argList);
-
- store.bootstrap(metaData);
-
- bootstrappedIdentityStores.put(store.getId(), store);
- bootstrappedAttributeStores.put(store.getId(), store);
- }
-
- // IdentityRepository
-
- Map<String, IdentityStoreRepository> bootstrappedRepositories = new HashMap<String, IdentityStoreRepository>();
-
- for (IdentityRepositoryConfigurationMetaData metaData : configMD.getRepositories())
- {
- Class repoClass = null;
- try
- {
- repoClass = Class.forName(metaData.getClassName());
- }
- catch (ClassNotFoundException e)
- {
- throw new IdentityException("Cannot instantiate identity store:" + metaData.getClassName(), e);
- }
- Class partypes[] = new Class[1];
- partypes[0] = String.class;
-
- Constructor ct = repoClass.getConstructor(partypes);
- Object argList[] = new Object[1];
- argList[0] = metaData.getId();
-
- IdentityStoreRepository repo = (IdentityStoreRepository)ct.newInstance(argList);
-
- repo.bootstrap(metaData, bootstrappedIdentityStores, bootstrappedAttributeStores);
-
- bootstrappedRepositories.put(repo.getId(), repo);
- }
-
- // Realms
-
- Map<String, IdentitySession> sessionMap = new HashMap<String, IdentitySession>();
-
- for (RealmConfigurationMetaData metaData : configMD.getRealms())
- {
- String realmName = metaData.getId();
-
- IdentityStoreRepository repo = bootstrappedRepositories.get(metaData.getIdentityRepositoryIdRef());
-
- //TODO: for now we just use direct type mapper and ignore group type mappings config
- IdentityObjectTypeMapper mapper = new DirectIdentityObjectTypeMapperImpl(metaData.getIdentityMapping());
-
- IdentitySession session = new IdentitySessionImpl(realmName, repo, mapper);
-
- sessionMap.put(realmName, session);
- }
-
- return sessionMap;
- }
-
- public void close()
- {
-
- }
-
- public boolean isClosed()
- {
- return false;
- }
-
- public IdentitySession createIdentitySession(String realmName)
- {
- return realmMap.get(realmName);
- }
-
- public IdentitySession getCurrentIdentitySession(String realmName)
- {
- return realmMap.get(realmName);
- }
-}
Copied: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/IdentitySessionFactoryImpl.java (from rev 211, trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/IdentitySessionFactoryImpl.java)
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/IdentitySessionFactoryImpl.java (rev 0)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/IdentitySessionFactoryImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,176 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.impl.api;
+
+import org.jboss.identity.idm.api.IdentitySessionFactory;
+import org.jboss.identity.idm.api.IdentitySession;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityRepositoryConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.RealmConfigurationMetaData;
+import org.jboss.identity.idm.spi.store.IdentityStore;
+import org.jboss.identity.idm.spi.store.AttributeStore;
+import org.jboss.identity.idm.spi.repository.IdentityStoreRepository;
+import org.jboss.identity.idm.impl.configuration.jaxb2.JAXB2IdentityConfiguration;
+import org.jboss.identity.idm.impl.api.session.IdentitySessionImpl;
+import org.jboss.identity.idm.impl.api.session.mapper.DirectIdentityObjectTypeMapperImpl;
+import org.jboss.identity.idm.impl.api.session.mapper.IdentityObjectTypeMapper;
+import org.jboss.identity.idm.exception.IdentityException;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.io.File;
+import java.lang.reflect.Constructor;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class IdentitySessionFactoryImpl implements IdentitySessionFactory
+{
+
+ private final Map<String, IdentitySession> realmMap;
+
+ public IdentitySessionFactoryImpl(Map<String, IdentitySession> realmMap)
+ {
+ this.realmMap = realmMap;
+ }
+
+ public IdentitySessionFactoryImpl(IdentityConfigurationMetaData configMD) throws Exception
+ {
+ realmMap = createSessionMap(configMD);
+ }
+
+ public IdentitySessionFactoryImpl(File configFile) throws Exception
+ {
+ IdentityConfigurationMetaData configMD = JAXB2IdentityConfiguration.createConfigurationMetaData(configFile);
+
+ realmMap = createSessionMap(configMD);
+
+ }
+
+ private Map<String, IdentitySession> createSessionMap(IdentityConfigurationMetaData configMD) throws Exception
+ {
+ //TODO: some validation, sanity checks and error reporting
+
+ // IdentityStore
+
+ Map<String, IdentityStore> bootstrappedIdentityStores = new HashMap<String, IdentityStore>();
+ Map<String, AttributeStore> bootstrappedAttributeStores = new HashMap<String, AttributeStore>();
+
+ for (IdentityStoreConfigurationMetaData metaData : configMD.getIdentityStores())
+ {
+ Class storeClass = null;
+ try
+ {
+ storeClass = Class.forName(metaData.getClassName());
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new IdentityException("Cannot instantiate identity store:" + metaData.getClassName(), e);
+ }
+ Class partypes[] = new Class[1];
+ partypes[0] = String.class;
+
+ Constructor ct = storeClass.getConstructor(partypes);
+ Object argList[] = new Object[1];
+ argList[0] = metaData.getId();
+
+ IdentityStore store = (IdentityStore)ct.newInstance(argList);
+
+ store.bootstrap(metaData);
+
+ bootstrappedIdentityStores.put(store.getId(), store);
+ bootstrappedAttributeStores.put(store.getId(), store);
+ }
+
+ // IdentityRepository
+
+ Map<String, IdentityStoreRepository> bootstrappedRepositories = new HashMap<String, IdentityStoreRepository>();
+
+ for (IdentityRepositoryConfigurationMetaData metaData : configMD.getRepositories())
+ {
+ Class repoClass = null;
+ try
+ {
+ repoClass = Class.forName(metaData.getClassName());
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new IdentityException("Cannot instantiate identity store:" + metaData.getClassName(), e);
+ }
+ Class partypes[] = new Class[1];
+ partypes[0] = String.class;
+
+ Constructor ct = repoClass.getConstructor(partypes);
+ Object argList[] = new Object[1];
+ argList[0] = metaData.getId();
+
+ IdentityStoreRepository repo = (IdentityStoreRepository)ct.newInstance(argList);
+
+ repo.bootstrap(metaData, bootstrappedIdentityStores, bootstrappedAttributeStores);
+
+ bootstrappedRepositories.put(repo.getId(), repo);
+ }
+
+ // Realms
+
+ Map<String, IdentitySession> sessionMap = new HashMap<String, IdentitySession>();
+
+ for (RealmConfigurationMetaData metaData : configMD.getRealms())
+ {
+ String realmName = metaData.getId();
+
+ IdentityStoreRepository repo = bootstrappedRepositories.get(metaData.getIdentityRepositoryIdRef());
+
+ //TODO: for now we just use direct type mapper and ignore group type mappings config
+ IdentityObjectTypeMapper mapper = new DirectIdentityObjectTypeMapperImpl(metaData.getIdentityMapping());
+
+ IdentitySession session = new IdentitySessionImpl(realmName, repo, mapper);
+
+ sessionMap.put(realmName, session);
+ }
+
+ return sessionMap;
+ }
+
+ public void close()
+ {
+
+ }
+
+ public boolean isClosed()
+ {
+ return false;
+ }
+
+ public IdentitySession createIdentitySession(String realmName)
+ {
+ return realmMap.get(realmName);
+ }
+
+ public IdentitySession getCurrentIdentitySession(String realmName)
+ {
+ return realmMap.get(realmName);
+ }
+}
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/IdentitySessionImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/IdentitySessionImpl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/IdentitySessionImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,149 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.api;
-
-import org.jboss.identity.api.IdentitySession;
-import org.jboss.identity.api.Transaction;
-import org.jboss.identity.api.PersistenceManager;
-import org.jboss.identity.api.RelationshipManager;
-import org.jboss.identity.api.AttributesManager;
-import org.jboss.identity.api.RoleManager;
-import org.jboss.identity.exception.IdentityException;
-import org.jboss.identity.spi.store.IdentityStoreSession;
-import org.jboss.identity.spi.store.IdentityStoreInvocationContext;
-import org.jboss.identity.spi.repository.IdentityStoreRepository;
-import org.jboss.identity.impl.store.SimpleIdentityStoreInvocationContext;
-
-import java.util.Set;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class IdentitySessionImpl implements IdentitySession
-{
- private final String realmName;
-
- private final IdentitySessionContext sessionContext;
-
- private final PersistenceManager persistenceManager;
-
- private final RelationshipManager relationshipManager;
-
- private final AttributesManager profileManager;
-
- private final RoleManager roleManager;
-
- public IdentitySessionContext getSessionContext()
- {
- return sessionContext;
- }
-
- public IdentitySessionImpl(String realmName,
- IdentityStoreRepository repository,
- IdentityObjectTypeMapper typeMapper) throws IdentityException
- {
- this.realmName = realmName;
-
- IdentityStoreSession storeSession = repository.createIdentityStoreSession();
- final IdentityStoreInvocationContext invocationCtx = new SimpleIdentityStoreInvocationContext(storeSession, realmName);
-
- IdentityStoreInvocationContextResolver resolver = new IdentityStoreInvocationContextResolver()
- {
- public IdentityStoreInvocationContext resolveInvocationContext()
- {
- return invocationCtx;
- }
- };
-
- sessionContext = new IdentitySessionContextImpl(repository, typeMapper, resolver);
-
- this.persistenceManager = new PersistenceManagerImpl(this);
- this.relationshipManager = new RelationshipManagerImpl(this);
- this.profileManager = new AttributesManagerImpl(this);
- this.roleManager = new RoleManagerImpl(this);
-
- }
-
-
-
-
-
- public String getRealmName()
- {
- return realmName;
- }
-
- public void close() throws IdentityException
- {
- sessionContext.resolveStoreInvocationContext().getIdentityStoreSession().close();
- }
-
- public void save() throws IdentityException
- {
- sessionContext.resolveStoreInvocationContext().getIdentityStoreSession().save();
- }
-
- public void clear() throws IdentityException
- {
- sessionContext.resolveStoreInvocationContext().getIdentityStoreSession().clear();
- }
-
- public boolean isOpen()
- {
-
- return sessionContext.resolveStoreInvocationContext().getIdentityStoreSession().isOpen();
- }
-
- public Transaction beginTransaction()
- {
- return new SimpleTransactionImpl(sessionContext.resolveStoreInvocationContext().getIdentityStoreSession());
- }
-
- public Transaction getTransaction()
- {
- return new SimpleTransactionImpl(sessionContext.resolveStoreInvocationContext().getIdentityStoreSession());
- }
-
- public PersistenceManager getPersistenceManager()
- {
- return persistenceManager;
- }
-
- public RelationshipManager getRelationshipManager()
- {
- return relationshipManager;
- }
-
- public AttributesManager getAttributesManager()
- {
- return profileManager;
- }
-
- //TODO: proper exception if roles are not supported
-
- public RoleManager getRoleManager()
- {
- return roleManager;
- }
-}
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/IdentityStoreInvocationContextResolver.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/IdentityStoreInvocationContextResolver.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/IdentityStoreInvocationContextResolver.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,36 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.api;
-
-import org.jboss.identity.spi.store.IdentityStoreInvocationContext;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public interface IdentityStoreInvocationContextResolver
-{
-
- IdentityStoreInvocationContext resolveInvocationContext();
-
-}
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/NameFilterSearchControl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/NameFilterSearchControl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/NameFilterSearchControl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,10 +20,10 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.api;
+package org.jboss.identity.idm.impl.api;
-import org.jboss.identity.api.IdentitySearchControl;
-import org.jboss.identity.spi.searchcontrol.IdentityObjectSearchControl;
+import org.jboss.identity.idm.api.IdentitySearchControl;
+import org.jboss.identity.idm.spi.searchcontrol.IdentityObjectSearchControl;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/PageSearchControl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/PageSearchControl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/PageSearchControl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,10 +20,10 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.api;
+package org.jboss.identity.idm.impl.api;
-import org.jboss.identity.api.IdentitySearchControl;
-import org.jboss.identity.spi.searchcontrol.IdentityObjectSearchControl;
+import org.jboss.identity.idm.api.IdentitySearchControl;
+import org.jboss.identity.idm.spi.searchcontrol.IdentityObjectSearchControl;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/PasswordCredential.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/PasswordCredential.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/PasswordCredential.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,122 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.api;
-
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class PasswordCredential extends AbstractCredential
-{
- private final String value;
-
- public static final SimpleCredentialTypeImpl TYPE = new SimpleCredentialTypeImpl("PASSWORD");
-
- public PasswordCredential(String value)
- {
- super(TYPE);
- this.value = value;
- }
-
- public String getValue()
- {
- return value;
- }
-
- public Object getEncodedValue()
- {
- if (value != null)
- {
- return md5AsHexString(getValue());
- }
- return null;
- }
-
- /**
- * Computes an md5 hash of a string.
- *
- * @param text the hashed string
- * @return the string hash
- * @throws NullPointerException if text is null
- */
- public static byte[] md5(String text)
- {
- // arguments check
- if (text == null)
- {
- throw new NullPointerException("null text");
- }
-
- try
- {
- MessageDigest md = MessageDigest.getInstance("MD5");
- md.update(text.getBytes());
- return md.digest();
- }
- catch (NoSuchAlgorithmException e)
- {
-
- throw new RuntimeException("Cannot find MD5 algorithm");
- }
- }
-
- /**
- * Computes an md5 hash and returns the result as a string in hexadecimal format.
- *
- * @param text the hashed string
- * @return the string hash
- * @throws NullPointerException if text is null
- */
- public static String md5AsHexString(String text)
- {
- return toHexString(md5(text));
- }
-
-/**
- * Returns a string in the hexadecimal format.
- *
- * @param bytes the converted bytes
- * @return the hexadecimal string representing the bytes data
- * @throws IllegalArgumentException if the byte array is null
- */
- public static String toHexString(byte[] bytes)
- {
- if (bytes == null)
- {
- throw new IllegalArgumentException("byte array must not be null");
- }
- StringBuffer hex = new StringBuffer(bytes.length * 2);
- for (int i = 0; i < bytes.length; i++)
- {
- hex.append(Character.forDigit((bytes[i] & 0XF0) >> 4, 16));
- hex.append(Character.forDigit((bytes[i] & 0X0F), 16));
- }
- return hex.toString();
- }
-
-
-
-}
Copied: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/PasswordCredential.java (from rev 211, trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/PasswordCredential.java)
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/PasswordCredential.java (rev 0)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/PasswordCredential.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,122 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.impl.api;
+
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class PasswordCredential extends AbstractCredential
+{
+ private final String value;
+
+ public static final SimpleCredentialType TYPE = new SimpleCredentialType("PASSWORD");
+
+ public PasswordCredential(String value)
+ {
+ super(TYPE);
+ this.value = value;
+ }
+
+ public String getValue()
+ {
+ return value;
+ }
+
+ public Object getEncodedValue()
+ {
+ if (value != null)
+ {
+ return md5AsHexString(getValue());
+ }
+ return null;
+ }
+
+ /**
+ * Computes an md5 hash of a string.
+ *
+ * @param text the hashed string
+ * @return the string hash
+ * @throws NullPointerException if text is null
+ */
+ public static byte[] md5(String text)
+ {
+ // arguments check
+ if (text == null)
+ {
+ throw new NullPointerException("null text");
+ }
+
+ try
+ {
+ MessageDigest md = MessageDigest.getInstance("MD5");
+ md.update(text.getBytes());
+ return md.digest();
+ }
+ catch (NoSuchAlgorithmException e)
+ {
+
+ throw new RuntimeException("Cannot find MD5 algorithm");
+ }
+ }
+
+ /**
+ * Computes an md5 hash and returns the result as a string in hexadecimal format.
+ *
+ * @param text the hashed string
+ * @return the string hash
+ * @throws NullPointerException if text is null
+ */
+ public static String md5AsHexString(String text)
+ {
+ return toHexString(md5(text));
+ }
+
+/**
+ * Returns a string in the hexadecimal format.
+ *
+ * @param bytes the converted bytes
+ * @return the hexadecimal string representing the bytes data
+ * @throws IllegalArgumentException if the byte array is null
+ */
+ public static String toHexString(byte[] bytes)
+ {
+ if (bytes == null)
+ {
+ throw new IllegalArgumentException("byte array must not be null");
+ }
+ StringBuffer hex = new StringBuffer(bytes.length * 2);
+ for (int i = 0; i < bytes.length; i++)
+ {
+ hex.append(Character.forDigit((bytes[i] & 0XF0) >> 4, 16));
+ hex.append(Character.forDigit((bytes[i] & 0X0F), 16));
+ }
+ return hex.toString();
+ }
+
+
+
+}
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/PersistenceManagerImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/PersistenceManagerImpl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/PersistenceManagerImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,169 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.api;
-
-import org.jboss.identity.api.PersistenceManager;
-import org.jboss.identity.api.Identity;
-import org.jboss.identity.api.Group;
-import org.jboss.identity.api.GroupType;
-import org.jboss.identity.api.IdentityType;
-import org.jboss.identity.api.IdentitySession;
-import org.jboss.identity.api.PersistenceManagerFeaturesDescription;
-import org.jboss.identity.api.IdentitySearchControl;
-import org.jboss.identity.exception.IdentityException;
-import org.jboss.identity.spi.model.IdentityObjectType;
-import org.jboss.identity.spi.model.IdentityObject;
-import org.jboss.identity.impl.types.SimpleIdentityObject;
-import org.jboss.identity.impl.NotYetImplementedException;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.List;
-import java.util.LinkedList;
-import java.util.Iterator;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class PersistenceManagerImpl extends AbstractManager implements PersistenceManager
-{
-
- public PersistenceManagerImpl(IdentitySession session)
- {
- super(session);
- }
-
- public PersistenceManagerFeaturesDescription getFeaturesDescription()
- {
- return null;
- }
-
- public Identity createIdentity(String identityName) throws IdentityException
- {
- IdentityObjectType iot = getIdentityObjectType();
-
- IdentityObject identityObject = getRepository().createIdentityObject(getInvocationContext(), identityName, iot);
-
- return createIdentity(identityObject);
- }
-
- public Group createGroup(String groupName, GroupType groupType) throws IdentityException
- {
- IdentityObjectType iot = getIdentityObjectType(groupType);
-
- IdentityObject identityObject = getRepository().createIdentityObject(getInvocationContext(), groupName, iot);
-
- return createGroup(identityObject);
- }
-
- public void removeIdentity(Identity identity, boolean force) throws IdentityException
- {
- IdentityObjectType iot = getIdentityObjectType();
-
- getRepository().removeIdentityObject(getInvocationContext(), createIdentityObject(identity));
-
- }
-
- public void removeGroup(Group group, boolean force) throws IdentityException
- {
- //TODO: force
-
- getRepository().removeIdentityObject(getInvocationContext(), createIdentityObject(group));
- }
-
- public int getIdentityCount() throws IdentityException
- {
- IdentityObjectType iot = getIdentityObjectType();
-
- return getRepository().getIdentityObjectsCount(getInvocationContext(), iot);
- }
-
- public int getGroupTypeCount(GroupType groupType) throws IdentityException
- {
- IdentityObjectType iot = getIdentityObjectType(groupType);
-
- return getRepository().getIdentityObjectsCount(getInvocationContext(), iot);
- }
-
- public Identity findIdentity(String name) throws IdentityException
- {
- return createIdentity(getRepository().findIdentityObject(getInvocationContext(), name, getIdentityObjectType()));
- }
-
- public Identity findIdentityById(String id) throws IdentityException
- {
- return createIdentity(getRepository().findIdentityObject(getInvocationContext(), id));
- }
-
- public Collection<Identity> findIdentity(IdentitySearchControl[] controls) throws IdentityException
- {
-
-
- Collection<IdentityObject> ios = getRepository().findIdentityObject(getInvocationContext(), getIdentityObjectType(), convertSearchControls(controls));
- List<Identity> identities = new LinkedList<Identity>();
-
- for (Iterator<IdentityObject> iterator = ios.iterator(); iterator.hasNext();)
- {
- IdentityObject identityObject = iterator.next();
- identities.add(createIdentity(identityObject));
- }
-
- return identities;
- }
-
- public Group findGroup(String name, GroupType groupType) throws IdentityException
- {
- return createGroup(getRepository().findIdentityObject(getInvocationContext(), name, getIdentityObjectType(groupType)));
- }
-
- public Group findGroupById(String id) throws IdentityException
- {
- return createGroup(getRepository().findIdentityObject(getInvocationContext(), id));
- }
-
- public Collection<Group> findGroup(GroupType groupType, IdentitySearchControl[] controls) throws IdentityException
- {
- Collection<IdentityObject> ios = getRepository().findIdentityObject(getInvocationContext(), getIdentityObjectType(groupType), convertSearchControls(controls));
- List<Group> groups = new LinkedList<Group>();
-
- for (Iterator<IdentityObject> iterator = ios.iterator(); iterator.hasNext();)
- {
- IdentityObject identityObject = iterator.next();
- groups.add(createGroup(identityObject));
- }
-
- return groups;
- }
-
- public Collection<Group> findGroup(GroupType groupType) throws IdentityException
- {
- return findGroup(groupType, null);
- }
-
- public boolean isVirtual(Identity identity)
- {
- //TODO:NYI
- throw new NotYetImplementedException("Postponed");
- }
-}
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/RelationshipManagerImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/RelationshipManagerImpl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/RelationshipManagerImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,269 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.api;
-
-import org.jboss.identity.api.RelationshipManager;
-import org.jboss.identity.api.IdentitySession;
-import org.jboss.identity.api.Group;
-import org.jboss.identity.api.Identity;
-import org.jboss.identity.api.IdentityType;
-import org.jboss.identity.api.GroupType;
-import org.jboss.identity.api.RelationshipManagerFeaturesDescription;
-import org.jboss.identity.api.IdentitySearchControl;
-import org.jboss.identity.exception.IdentityException;
-import org.jboss.identity.spi.model.IdentityObjectRelationshipType;
-import org.jboss.identity.spi.model.IdentityObjectRelationship;
-import org.jboss.identity.spi.model.IdentityObject;
-import org.jboss.identity.spi.model.IdentityObjectType;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.LinkedList;
-import java.util.Set;
-import java.util.HashSet;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class RelationshipManagerImpl extends AbstractManager implements RelationshipManager
-{
-
- public static final IdentityObjectRelationshipType MEMBER = new IdentityObjectRelationshipType()
- {
- public String getName()
- {
- return "JBOSS_IDENTITY_MEMBERSHIP";
- }
- };
-
- public RelationshipManagerImpl(IdentitySession session)
- {
- super(session);
- }
-
- public RelationshipManagerFeaturesDescription getFeaturesDescription()
- {
- return null;
- }
-
- public void associateGroups(Collection<Group> parents, Collection<Group> members) throws IdentityException
- {
- for (Iterator<Group> parentsIterator = parents.iterator(); parentsIterator.hasNext();)
- {
- Group parent = parentsIterator.next();
-
- for (Iterator<Group> membersIterator = members.iterator(); membersIterator.hasNext();)
- {
- Group member = membersIterator.next();
-
- associateGroups(parent, member);
- }
- }
- }
-
- public void associateGroups(Group parent, Group member) throws IdentityException
- {
- getRepository().createRelationship(getInvocationContext(), createIdentityObject(parent), createIdentityObject(member), MEMBER, null, true);
- }
-
- public void associateIdentities(Collection<Group> parents, Collection<Identity> members) throws IdentityException
- {
- for (Iterator<Group> parentsIterator = parents.iterator(); parentsIterator.hasNext();)
- {
- Group parent = parentsIterator.next();
-
- for (Iterator<Identity> membersIterator = members.iterator(); membersIterator.hasNext();)
- {
- Identity member = membersIterator.next();
-
- associateIdentities(parent, member);
- }
- }
- }
-
- public void associateIdentities(Group parent, Identity member) throws IdentityException
- {
- getRepository().createRelationship(getInvocationContext(), createIdentityObject(parent), createIdentityObject(member), MEMBER, null, true);
- }
-
- public void disassociateGroups(Collection<Group> parents, Collection<Group> members) throws IdentityException
- {
- for (Iterator<Group> parentsIterator = parents.iterator(); parentsIterator.hasNext();)
- {
- Group parent = parentsIterator.next();
-
- for (Iterator<Group> membersIterator = members.iterator(); membersIterator.hasNext();)
- {
- Group member = membersIterator.next();
-
- getRepository().removeRelationship(getInvocationContext(), createIdentityObject(parent), createIdentityObject(member), MEMBER, null);
- }
- }
- }
-
- public void disassociateIdentities(Collection<Group> parents, Collection<Identity> members) throws IdentityException
- {
- for (Iterator<Group> parentsIterator = parents.iterator(); parentsIterator.hasNext();)
- {
- Group parent = parentsIterator.next();
-
- for (Iterator<Identity> membersIterator = members.iterator(); membersIterator.hasNext();)
- {
- Identity member = membersIterator.next();
-
- getRepository().removeRelationship(getInvocationContext(), createIdentityObject(parent), createIdentityObject(member), MEMBER, null);
- }
- }
-
- }
-
- public <G extends IdentityType, I extends IdentityType> boolean isAssociated(Collection<G> parents, Collection<I> members) throws IdentityException
- {
- //TODO: maybe IdentityStore should have isRelationshipPresent method to improve this?
-
- for (Iterator<G> parentsIterator = parents.iterator(); parentsIterator.hasNext();)
- {
- IdentityType parent = parentsIterator.next();
-
- for (Iterator<I> membersIterator = members.iterator(); membersIterator.hasNext();)
- {
- IdentityType member = membersIterator.next();
-
- Collection<IdentityObjectRelationship> relationships = getRepository().resolveRelationships(getInvocationContext(), createIdentityObject(parent), createIdentityObject(member), MEMBER);
-
- if (relationships.size() == 0)
- {
- return false;
- }
- }
- }
-
- return true;
- }
-
- public <G extends IdentityType, I extends IdentityType> boolean isAssociated(G parent, I member) throws IdentityException
- {
- Set<G> parents = new HashSet<G>();
- parents.add(parent);
- Set<I> members = new HashSet<I>();
- members.add(member);
-
- return isAssociated(parents, members);
- }
-
- public Collection<Group> findAssociatedGroups(Group group, GroupType groupType, boolean parent, boolean inherited, IdentitySearchControl[] controls) throws IdentityException
- {
-
- List<Group> identities = new LinkedList<Group>();
-
- IdentityObjectType iot = getIdentityObjectType(groupType);
-
- //TODO Handle inherited
-
- Collection<IdentityObject> ios = getRepository().findIdentityObject(getInvocationContext(), createIdentityObject(group), MEMBER, parent, convertSearchControls(controls));
-
- for (IdentityObject io : ios)
- {
- if (io.getIdentityType().getName().equals(iot.getName()))
- {
- identities.add(createGroup(io));
- }
- }
-
- return identities;
-
- }
-
- public Collection<Group> findAssociatedGroups(Group group, GroupType groupType, boolean parent, boolean inherited) throws IdentityException
- {
- return findAssociatedGroups(group, groupType, parent, inherited, null);
- }
-
- public Collection<Group> findAssociatedGroups(Identity identity, GroupType groupType, IdentitySearchControl[] controls) throws IdentityException
- {
- List<Group> identities = new LinkedList<Group>();
-
- IdentityObjectType iot = getIdentityObjectType(groupType);
-
- Collection<IdentityObject> ios = getRepository().findIdentityObject(getInvocationContext(), createIdentityObject(identity), MEMBER, false, convertSearchControls(controls));
-
- for (IdentityObject io : ios)
- {
- if (io.getIdentityType().getName().equals(iot.getName()))
- {
- identities.add(createGroup(io));
- }
- }
-
- return identities;
- }
-
- public Collection<Group> findAssociatedGroups(Identity identity, GroupType groupType) throws IdentityException
- {
- return findAssociatedGroups(identity, groupType, null);
- }
-
- public Collection<Group> findAssociatedGroups(Identity identity, IdentitySearchControl[] controls) throws IdentityException
- {
- List<Group> identities = new LinkedList<Group>();
-
- Collection<IdentityObject> ios = getRepository().findIdentityObject(getInvocationContext(), createIdentityObject(identity), MEMBER, false, convertSearchControls(controls));
-
- for (IdentityObject io : ios)
- {
- identities.add(createGroup(io));
- }
-
- return identities;
- }
-
- public Collection<Group> findAssociatedGroups(Identity identity) throws IdentityException
- {
- return findAssociatedGroups(identity, new IdentitySearchControl[] {});
- }
-
- public Collection<Identity> findAssociatedIdentities(Group group, boolean inherited, IdentitySearchControl[] controls) throws IdentityException
- {
- List<Identity> identities = new LinkedList<Identity>();
-
- //TODO Handle inherited
-
- Collection<IdentityObject> ios = getRepository().findIdentityObject(getInvocationContext(), createIdentityObject(group), MEMBER, true, convertSearchControls(controls));
-
- //TODO: filter out groups....
-
- for (IdentityObject io : ios)
- {
- identities.add(createIdentity(io));
- }
-
- return identities;
- }
-
- public Collection<Identity> findAssociatedIdentities(Group group, boolean inherited) throws IdentityException
- {
- return findAssociatedIdentities(group, inherited, null);
- }
-}
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/RoleHandler.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/RoleHandler.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/RoleHandler.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,50 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.api;
-
-import org.jboss.identity.spi.model.IdentityObjectRelationship;
-import org.jboss.identity.spi.model.IdentityObjectRelationshipType;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class RoleHandler
-{
-
- boolean isNamedRole(IdentityObjectRelationshipType rt)
- {
- return false;
- }
-
- IdentityObjectRelationshipType createRelationshipType(String roleName)
- {
- return null;
- }
-
- String resolveRoleName(IdentityObjectRelationshipType rt)
- {
- return null;
- }
-
-}
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/RoleManagerImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/RoleManagerImpl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/RoleManagerImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,286 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.api;
-
-import org.jboss.identity.api.RoleManager;
-import org.jboss.identity.api.IdentitySession;
-import org.jboss.identity.api.RoleType;
-import org.jboss.identity.api.Role;
-import org.jboss.identity.api.Identity;
-import org.jboss.identity.api.Group;
-import org.jboss.identity.api.IdentityType;
-import org.jboss.identity.api.RoleManagerFeaturesDescription;
-import org.jboss.identity.api.IdentitySearchControl;
-import org.jboss.identity.exception.IdentityException;
-import org.jboss.identity.spi.model.IdentityObjectRelationshipType;
-import org.jboss.identity.spi.model.IdentityObjectRelationship;
-import org.jboss.identity.spi.model.IdentityObject;
-import org.jboss.identity.spi.exception.OperationNotSupportedException;
-
-import java.util.Collection;
-import java.util.Set;
-import java.util.HashSet;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class RoleManagerImpl extends AbstractManager implements RoleManager
-{
- public static final IdentityObjectRelationshipType ROLE = new IdentityObjectRelationshipType()
- {
- public String getName()
- {
- return "JBOSS_IDENTITY_ROLE";
- }
- };
-
- public RoleManagerImpl(IdentitySession session)
- {
- super(session);
- }
-
- public RoleManagerFeaturesDescription getSupportedFeatures()
- {
- return null;
- }
-
- public RoleType createRoleType(String name) throws IdentityException
- {
- String roleType = null;
-
- try
- {
- roleType = getRepository().createRelationshipName(getInvocationContext(), name);
- }
- catch (OperationNotSupportedException e)
- {
- throw new IdentityException("Role management not supported");
- }
-
- return new SimpleRoleType(roleType);
- }
-
- public void removeRoleType(String name) throws IdentityException
- {
- try
- {
- getRepository().removeRelationshipName(getInvocationContext(), name);
- }
- catch (OperationNotSupportedException e)
- {
- throw new IdentityException("Role management not supported");
- }
- }
-
- public void removeRoleType(RoleType roleType) throws IdentityException
- {
- removeRoleType(roleType.getName());
- }
-
- public RoleType getRoleType(String name) throws IdentityException
- {
- try
- {
- Set<String> names = getRepository().getRelationshipNames(getInvocationContext(), null);
- if (names.contains(name))
- {
- return new SimpleRoleType(name);
- }
- }
- catch (OperationNotSupportedException e)
- {
- throw new IdentityException("Role management not supported");
- }
-
- return null;
- }
-
- public Collection<RoleType> findRoleTypes(IdentitySearchControl[] controls) throws IdentityException
- {
-
- try
- {
- Set<String> names = getRepository().getRelationshipNames(getInvocationContext(), convertSearchControls(controls));
- Set<RoleType> types = new HashSet<RoleType>();
-
- for (String name : names)
- {
- types.add(new SimpleRoleType(name));
- }
-
- return types;
- }
- catch (OperationNotSupportedException e)
- {
- throw new IdentityException("Role management not supported");
- }
-
- }
-
- public Role createRole(RoleType roleType, Identity identity, Group group) throws IdentityException
- {
- //TODO: add createRoleType switch to the API
-
- IdentityObjectRelationship rel = getRepository().createRelationship(getInvocationContext(), createIdentityObject(identity), createIdentityObject(group), ROLE, roleType.getName(), false);
-
- //TODO: null id - IdentityObjectRelationship doesn't have id
- return new SimpleRoleImpl(new SimpleRoleType(rel.getName()), createIdentity(rel.getFromIdentityObject()), createGroup(rel.getToIdentityObject()));
-
- }
-
- public void removeRole(RoleType roleType, Identity identity, Group group) throws IdentityException
- {
- getRepository().removeRelationship(getInvocationContext(), createIdentityObject(identity), createIdentityObject(group), ROLE, roleType.getName());
- }
-
- public void removeRole(Role role) throws IdentityException
- {
- getRepository().removeRelationship(getInvocationContext(), createIdentityObject(role.getIdentity()), createIdentityObject(role.getGroup()), ROLE, role.getRoleType().getName());
- }
-
- public boolean hasRole(Identity identity, Group group, RoleType roleType) throws IdentityException
- {
- //TODO: does separate hasRelationship method in IdentityStore makes sense?
-
- Set<IdentityObjectRelationship> rels = getRepository().resolveRelationships(getInvocationContext(), createIdentityObject(identity), createIdentityObject(group), ROLE);
-
- for (IdentityObjectRelationship rel : rels)
- {
- if (rel.getType().getName().equals(ROLE.getName()) && rel.getName() != null && rel.getName().equals(roleType.getName()))
- {
- return true;
- }
- }
-
- return false;
- }
-
- public Collection<RoleType> findRoleTypes(Identity identity, Group group) throws IdentityException
- {
- return findRoleTypes(identity, group, null);
- }
-
- public Collection<RoleType> findRoleTypes(Identity identity, Group group, IdentitySearchControl[] controls) throws IdentityException
- {
-
- Set<IdentityObjectRelationship> rels = getRepository().resolveRelationships(getInvocationContext(), createIdentityObject(identity), createIdentityObject(group), ROLE);
- Set<RoleType> types = new HashSet<RoleType>();
-
- for (IdentityObjectRelationship rel : rels)
- {
- types.add(new SimpleRoleType(rel.getName()));
- }
-
- return types;
-
-
- }
-
- public Collection<RoleType> findIdentityRoleTypes(Identity identity) throws IdentityException
- {
- return findIdentityRoleTypes(identity, null);
- }
-
- public Collection<RoleType> findIdentityRoleTypes(Identity identity, IdentitySearchControl[] controls) throws IdentityException
- {
- Set<RoleType> types = new HashSet<RoleType>();
-
- try
- {
- Collection<String> names = getRepository().getRelationshipNames(getInvocationContext(), createIdentityObject(identity), convertSearchControls(controls));
-
- for (String name : names)
- {
- types.add(new SimpleRoleType(name));
- }
-
- return types;
-
- }
- catch (OperationNotSupportedException e)
- {
- throw new IdentityException("Role management not supported", e);
- }
-
- }
-
- public Collection<RoleType> findGroupRoleTypes(Group group) throws IdentityException
- {
- return findGroupRoleTypes(group, null);
- }
-
- public Collection<RoleType> findGroupRoleTypes(Group group, IdentitySearchControl[] controls) throws IdentityException
- {
- Set<RoleType> types = new HashSet<RoleType>();
-
- try
- {
- Collection<String> names = getRepository().getRelationshipNames(getInvocationContext(), createIdentityObject(group), convertSearchControls(controls));
-
- for (String name : names)
- {
- types.add(new SimpleRoleType(name));
- }
-
- return types;
-
- }
- catch (OperationNotSupportedException e)
- {
- throw new IdentityException("Role management not supported");
- }
-
- }
-
- public <T extends IdentityType> Collection<Role> findRoles(T identityType, RoleType roleType) throws IdentityException
- {
- return findRoles(identityType, roleType, null);
- }
-
- public <T extends IdentityType> Collection<Role> findRoles(T identityType, RoleType roleType, IdentitySearchControl[] controls) throws IdentityException
- {
- Set<Role> roles = new HashSet<Role>();
-
- Set<IdentityObjectRelationship> relationships = null;
-
- // If Identity then search for parent relationships
- if (identityType instanceof Identity)
- {
- relationships = getRepository().resolveRelationships(getInvocationContext(), createIdentityObject(identityType), ROLE, true, true, null);
- }
- // If Group then search for child relationships
- else
- {
- relationships = getRepository().resolveRelationships(getInvocationContext(), createIdentityObject(identityType), ROLE, false, true, null);
- }
-
- for (IdentityObjectRelationship relationship : relationships)
- {
- roles.add(new SimpleRoleImpl(new SimpleRoleType(relationship.getName()), createIdentity(relationship.getFromIdentityObject()), createGroup(relationship.getToIdentityObject())));
- }
-
- return roles;
-
- }
-}
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/SessionWrapper.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SessionWrapper.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/SessionWrapper.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,83 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.api;
-
-import org.jboss.identity.exception.IdentityException;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public interface SessionWrapper
-{
-
- /**
- * Close this session
- * @throws org.jboss.identity.exception.IdentityException
- */
- void close() throws IdentityException;
-
- /**
- * Save all pending changes
- * @throws org.jboss.identity.exception.IdentityException
- */
- void save() throws IdentityException;
-
- /**
- * Clear this session
- * @throws org.jboss.identity.exception.IdentityException
- */
- void clear() throws IdentityException;
-
- /**
- * Check if this session is open
- * @return
- */
- boolean isOpen();
-
-
- boolean isTransactionSupported();
-
- /**
- * Begin new transaction
- */
- void startTransaction();
-
- /**
- * Commit transaction - flush associated session
- */
- void commitTransaction();
-
- /**
- * Rollback transaction
- */
- void rollbackTransaction();
-
- /**
- *
- * @return
- */
- boolean isTransactionActive();
-
-
-}
Copied: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/SimpleAttribute.java (from rev 211, trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SimpleAttribute.java)
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/SimpleAttribute.java (rev 0)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/SimpleAttribute.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,107 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.impl.api;
+
+import org.jboss.identity.idm.spi.model.IdentityObjectAttribute;
+import org.jboss.identity.idm.api.Attribute;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.LinkedList;
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class SimpleAttribute implements IdentityObjectAttribute, Attribute
+{
+
+ private final String name;
+
+ private final List<Object> values = new LinkedList<Object>();
+
+ public SimpleAttribute(String name)
+ {
+ this.name = name;
+ }
+
+ public SimpleAttribute(String name, Object[] values)
+ {
+ this.name = name;
+ for (Object value : values)
+ {
+ this.values.add(value);
+ }
+ }
+
+ public SimpleAttribute(String name, Object value)
+ {
+ this.name = name;
+ this.values.add(value);
+ }
+
+ public SimpleAttribute(Attribute attribute)
+ {
+ this.name = attribute.getName();
+ this.values.addAll(attribute.getValues());
+ }
+
+ public SimpleAttribute(IdentityObjectAttribute attribute)
+ {
+ this.name = attribute.getName();
+ this.values.addAll(attribute.getValues());
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public Collection getValues()
+ {
+ return Collections.unmodifiableList(values);
+ }
+
+ public Object getValue()
+ {
+ if (values.size() > 0)
+ {
+ return values.iterator().next();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public int getSize()
+ {
+ return values.size();
+ }
+
+ public void addValue(Object value)
+ {
+ values.add(value);
+ }
+}
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/SimpleAttributeImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SimpleAttributeImpl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/SimpleAttributeImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,108 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.api;
-
-import org.jboss.identity.spi.model.IdentityObjectAttribute;
-import org.jboss.identity.api.Attribute;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.LinkedList;
-import java.util.Set;
-import java.util.Collections;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class SimpleAttributeImpl implements IdentityObjectAttribute, Attribute
-{
-
- private final String name;
-
- private final List<Object> values = new LinkedList<Object>();
-
- public SimpleAttributeImpl(String name)
- {
- this.name = name;
- }
-
- public SimpleAttributeImpl(String name, Object[] values)
- {
- this.name = name;
- for (Object value : values)
- {
- this.values.add(value);
- }
- }
-
- public SimpleAttributeImpl(String name, Object value)
- {
- this.name = name;
- this.values.add(value);
- }
-
- public SimpleAttributeImpl(Attribute attribute)
- {
- this.name = attribute.getName();
- this.values.addAll(attribute.getValues());
- }
-
- public SimpleAttributeImpl(IdentityObjectAttribute attribute)
- {
- this.name = attribute.getName();
- this.values.addAll(attribute.getValues());
- }
-
- public String getName()
- {
- return name;
- }
-
- public Collection getValues()
- {
- return Collections.unmodifiableList(values);
- }
-
- public Object getValue()
- {
- if (values.size() > 0)
- {
- return values.iterator().next();
- }
- else
- {
- return null;
- }
- }
-
- public int getSize()
- {
- return values.size();
- }
-
- public void addValue(Object value)
- {
- values.add(value);
- }
-}
Copied: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/SimpleCredentialType.java (from rev 211, trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SimpleCredentialType.java)
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/SimpleCredentialType.java (rev 0)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/SimpleCredentialType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,46 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.impl.api;
+
+import org.jboss.identity.idm.api.CredentialType;
+import org.jboss.identity.idm.spi.model.IdentityObjectCredentialType;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class SimpleCredentialType implements CredentialType, IdentityObjectCredentialType
+{
+ private final String name;
+
+ public SimpleCredentialType(String name)
+ {
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+}
+
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/SimpleCredentialTypeImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SimpleCredentialTypeImpl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/SimpleCredentialTypeImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,46 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.api;
-
-import org.jboss.identity.api.CredentialType;
-import org.jboss.identity.spi.model.IdentityObjectCredentialType;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class SimpleCredentialTypeImpl implements CredentialType, IdentityObjectCredentialType
-{
- private final String name;
-
- public SimpleCredentialTypeImpl(String name)
- {
- this.name = name;
- }
-
- public String getName()
- {
- return name;
- }
-}
-
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/SimpleGroupImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SimpleGroupImpl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/SimpleGroupImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,100 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.api;
-
-import org.jboss.identity.api.Group;
-import org.jboss.identity.api.GroupType;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class SimpleGroupImpl implements Group
-{
- private final String name;
-
- private final String id;
-
- private final GroupType groupType;
-
- public SimpleGroupImpl(String name, String id, GroupType groupType)
- {
- this.name = name;
- this.id = id;
- this.groupType = groupType;
- }
-
- public String getName()
- {
- return name;
- }
-
- public GroupType getGroupType()
- {
- return groupType;
- }
-
- public String getId()
- {
- return id;
- }
-
- public String getDescription()
- {
- return null;
- }
-
- public boolean equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
- if (o == null || getClass() != o.getClass())
- {
- return false;
- }
-
- SimpleGroupImpl that = (SimpleGroupImpl)o;
-
- if (groupType != null ? !groupType.equals(that.groupType) : that.groupType != null)
- {
- return false;
- }
- if (name != null ? !name.equals(that.name) : that.name != null)
- {
- return false;
- }
-
- return true;
- }
-
- public int hashCode()
- {
- int result;
- result = (name != null ? name.hashCode() : 0);
- result = 31 * result + (id != null ? id.hashCode() : 0);
- result = 31 * result + (groupType != null ? groupType.hashCode() : 0);
- return result;
- }
-}
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/SimpleGroupType.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SimpleGroupType.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/SimpleGroupType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,71 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.api;
-
-import org.jboss.identity.api.GroupType;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class SimpleGroupType implements GroupType
-{
-
- private final String name;
-
- public SimpleGroupType(String name)
- {
- this.name = name;
- }
-
- public String getName()
- {
- return name;
- }
-
- public boolean equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
- if (o == null || getClass() != o.getClass())
- {
- return false;
- }
-
- SimpleGroupType that = (SimpleGroupType)o;
-
- if (name != null ? !name.equals(that.name) : that.name != null)
- {
- return false;
- }
-
- return true;
- }
-
- public int hashCode()
- {
- return (name != null ? name.hashCode() : 0);
- }
-}
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/SimpleIdentityImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SimpleIdentityImpl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/SimpleIdentityImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,92 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.api;
-
-import org.jboss.identity.api.Identity;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class SimpleIdentityImpl implements Identity
-{
- private final String name;
-
- private final String id;
-
-
- public SimpleIdentityImpl(String name, String id)
- {
- this.name = name;
- this.id = id;
- }
-
- public String getName()
- {
- return name;
- }
-
- public boolean isVirtual()
- {
- return false;
- }
-
- public String getId()
- {
- return id;
- }
-
- public String getDescription()
- {
- return null;
- }
-
- public boolean equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
- if (o == null || getClass() != o.getClass())
- {
- return false;
- }
-
- SimpleIdentityImpl that = (SimpleIdentityImpl)o;
-
- if (name != null ? !name.equals(that.name) : that.name != null)
- {
- return false;
- }
-
- return true;
- }
-
- public int hashCode()
- {
- int result;
- result = (name != null ? name.hashCode() : 0);
- result = 31 * result + (id != null ? id.hashCode() : 0);
- return result;
- }
-}
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/SimpleRoleImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SimpleRoleImpl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/SimpleRoleImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,68 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.api;
-
-import org.jboss.identity.api.Role;
-import org.jboss.identity.api.RoleType;
-import org.jboss.identity.api.Identity;
-import org.jboss.identity.api.Group;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class SimpleRoleImpl implements Role
-{
- private final RoleType type;
-
- private final Identity identity;
-
- private final Group group;
-
- public SimpleRoleImpl(RoleType type, Identity identity, Group group)
- {
- this.type = type;
- this.identity = identity;
- this.group = group;
- }
-
- public Identity getIdentity()
- {
- return identity;
- }
-
- public Group getGroup()
- {
- return group;
- }
-
- public String getDescription()
- {
- return null;
- }
-
- public RoleType getRoleType()
- {
- return type;
- }
-}
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/SimpleRoleType.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SimpleRoleType.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/SimpleRoleType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,74 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.api;
-
-import org.jboss.identity.api.RoleType;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class SimpleRoleType implements RoleType
-{
- private final String name;
-
- public SimpleRoleType(String name)
- {
- if (name == null)
- {
- throw new IllegalArgumentException("name cannot be null");
- }
- this.name = name;
- }
-
- public String getName()
- {
- return name;
- }
-
- public boolean equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
- if (o == null || getClass() != o.getClass())
- {
- return false;
- }
-
- SimpleRoleType that = (SimpleRoleType)o;
-
- if (name != null ? !name.equals(that.name) : that.name != null)
- {
- return false;
- }
-
- return true;
- }
-
- public int hashCode()
- {
- return (name != null ? name.hashCode() : 0);
- }
-}
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/SimpleTransactionImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SimpleTransactionImpl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/SimpleTransactionImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,65 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.api;
-
-import org.jboss.identity.api.Transaction;
-import org.jboss.identity.spi.store.IdentityStoreSession;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class SimpleTransactionImpl implements Transaction
-{
- private final IdentityStoreSession sessionWrapper;
-
- public SimpleTransactionImpl(IdentityStoreSession sessionWrapper)
- {
- this.sessionWrapper = sessionWrapper;
- }
-
- public void start()
- {
- sessionWrapper.startTransaction();
- }
-
- public void commit()
- {
-
- sessionWrapper.commitTransaction();
-
- }
-
- public void rollback()
- {
-
- sessionWrapper.rollbackTransaction();
-
- }
-
- public boolean isActive()
- {
-
- return sessionWrapper.isTransactionActive();
- }
-}
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/SortByNameSearchControl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SortByNameSearchControl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/SortByNameSearchControl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,10 +20,10 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.api;
+package org.jboss.identity.idm.impl.api;
-import org.jboss.identity.spi.searchcontrol.IdentityObjectSearchControl;
-import org.jboss.identity.api.IdentitySearchControl;
+import org.jboss.identity.idm.spi.searchcontrol.IdentityObjectSearchControl;
+import org.jboss.identity.idm.api.IdentitySearchControl;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Copied: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/attribute (from rev 211, trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/attribute)
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/attribute/IdentityObjectAttributeMetaDataImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/attribute/IdentityObjectAttributeMetaDataImpl.java 2009-01-13 15:18:42 UTC (rev 211)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/attribute/IdentityObjectAttributeMetaDataImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,10 +20,10 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.api.attribute;
+package org.jboss.identity.idm.impl.api.attribute;
-import org.jboss.identity.spi.configuration.metadata.IdentityObjectAttributeMetaData;
-import org.jboss.identity.api.AttributeDescription;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityObjectAttributeMetaData;
+import org.jboss.identity.idm.api.AttributeDescription;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Copied: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/model (from rev 211, trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/model)
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleGroup.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/model/SimpleGroup.java 2009-01-13 15:18:42 UTC (rev 211)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleGroup.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,10 +20,10 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.api.model;
+package org.jboss.identity.idm.impl.api.model;
-import org.jboss.identity.api.Group;
-import org.jboss.identity.api.GroupType;
+import org.jboss.identity.idm.api.Group;
+import org.jboss.identity.idm.api.GroupType;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleGroupType.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/model/SimpleGroupType.java 2009-01-13 15:18:42 UTC (rev 211)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleGroupType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,9 +20,9 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.api.model;
+package org.jboss.identity.idm.impl.api.model;
-import org.jboss.identity.api.GroupType;
+import org.jboss.identity.idm.api.GroupType;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleIdentity.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/model/SimpleIdentity.java 2009-01-13 15:18:42 UTC (rev 211)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleIdentity.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,9 +20,9 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.api.model;
+package org.jboss.identity.idm.impl.api.model;
-import org.jboss.identity.api.Identity;
+import org.jboss.identity.idm.api.Identity;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleRole.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/model/SimpleRole.java 2009-01-13 15:18:42 UTC (rev 211)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleRole.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,12 +20,12 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.api.model;
+package org.jboss.identity.idm.impl.api.model;
-import org.jboss.identity.api.Role;
-import org.jboss.identity.api.RoleType;
-import org.jboss.identity.api.Identity;
-import org.jboss.identity.api.Group;
+import org.jboss.identity.idm.api.Role;
+import org.jboss.identity.idm.api.RoleType;
+import org.jboss.identity.idm.api.Identity;
+import org.jboss.identity.idm.api.Group;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleRoleType.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/model/SimpleRoleType.java 2009-01-13 15:18:42 UTC (rev 211)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/model/SimpleRoleType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,9 +20,9 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.api.model;
+package org.jboss.identity.idm.impl.api.model;
-import org.jboss.identity.api.RoleType;
+import org.jboss.identity.idm.api.RoleType;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Copied: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session (from rev 211, trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/session)
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/IdentitySessionImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/session/IdentitySessionImpl.java 2009-01-13 15:18:42 UTC (rev 211)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/IdentitySessionImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,28 +20,28 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.api.session;
+package org.jboss.identity.idm.impl.api.session;
-import org.jboss.identity.api.IdentitySession;
-import org.jboss.identity.api.Transaction;
-import org.jboss.identity.api.PersistenceManager;
-import org.jboss.identity.api.RelationshipManager;
-import org.jboss.identity.api.AttributesManager;
-import org.jboss.identity.api.RoleManager;
-import org.jboss.identity.exception.IdentityException;
-import org.jboss.identity.spi.store.IdentityStoreSession;
-import org.jboss.identity.spi.store.IdentityStoreInvocationContext;
-import org.jboss.identity.spi.repository.IdentityStoreRepository;
-import org.jboss.identity.impl.store.SimpleIdentityStoreInvocationContext;
-import org.jboss.identity.impl.api.session.context.IdentitySessionContext;
-import org.jboss.identity.impl.api.session.context.IdentitySessionContextImpl;
-import org.jboss.identity.impl.api.session.context.IdentityStoreInvocationContextResolver;
-import org.jboss.identity.impl.api.session.mapper.IdentityObjectTypeMapper;
-import org.jboss.identity.impl.api.session.managers.PersistenceManagerImpl;
-import org.jboss.identity.impl.api.session.managers.RelationshipManagerImpl;
-import org.jboss.identity.impl.api.session.managers.AttributesManagerImpl;
-import org.jboss.identity.impl.api.session.managers.RoleManagerImpl;
-import org.jboss.identity.impl.api.session.SimpleTransactionImpl;
+import org.jboss.identity.idm.api.IdentitySession;
+import org.jboss.identity.idm.api.Transaction;
+import org.jboss.identity.idm.api.PersistenceManager;
+import org.jboss.identity.idm.api.RelationshipManager;
+import org.jboss.identity.idm.api.AttributesManager;
+import org.jboss.identity.idm.api.RoleManager;
+import org.jboss.identity.idm.exception.IdentityException;
+import org.jboss.identity.idm.spi.store.IdentityStoreSession;
+import org.jboss.identity.idm.spi.store.IdentityStoreInvocationContext;
+import org.jboss.identity.idm.spi.repository.IdentityStoreRepository;
+import org.jboss.identity.idm.impl.store.SimpleIdentityStoreInvocationContext;
+import org.jboss.identity.idm.impl.api.session.context.IdentitySessionContext;
+import org.jboss.identity.idm.impl.api.session.context.IdentitySessionContextImpl;
+import org.jboss.identity.idm.impl.api.session.context.IdentityStoreInvocationContextResolver;
+import org.jboss.identity.idm.impl.api.session.mapper.IdentityObjectTypeMapper;
+import org.jboss.identity.idm.impl.api.session.managers.PersistenceManagerImpl;
+import org.jboss.identity.idm.impl.api.session.managers.RelationshipManagerImpl;
+import org.jboss.identity.idm.impl.api.session.managers.AttributesManagerImpl;
+import org.jboss.identity.idm.impl.api.session.managers.RoleManagerImpl;
+import org.jboss.identity.idm.impl.api.session.SimpleTransactionImpl;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/SimpleTransactionImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/session/SimpleTransactionImpl.java 2009-01-13 15:18:42 UTC (rev 211)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/SimpleTransactionImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,10 +20,10 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.api.session;
+package org.jboss.identity.idm.impl.api.session;
-import org.jboss.identity.api.Transaction;
-import org.jboss.identity.spi.store.IdentityStoreSession;
+import org.jboss.identity.idm.api.Transaction;
+import org.jboss.identity.idm.spi.store.IdentityStoreSession;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/context/IdentitySessionContext.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/session/context/IdentitySessionContext.java 2009-01-13 15:18:42 UTC (rev 211)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/context/IdentitySessionContext.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,11 +20,11 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.api.session.context;
+package org.jboss.identity.idm.impl.api.session.context;
-import org.jboss.identity.spi.repository.IdentityStoreRepository;
-import org.jboss.identity.spi.store.IdentityStoreInvocationContext;
-import org.jboss.identity.impl.api.session.mapper.IdentityObjectTypeMapper;
+import org.jboss.identity.idm.spi.repository.IdentityStoreRepository;
+import org.jboss.identity.idm.spi.store.IdentityStoreInvocationContext;
+import org.jboss.identity.idm.impl.api.session.mapper.IdentityObjectTypeMapper;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/context/IdentitySessionContextImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/session/context/IdentitySessionContextImpl.java 2009-01-13 15:18:42 UTC (rev 211)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/context/IdentitySessionContextImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,13 +20,13 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.api.session.context;
+package org.jboss.identity.idm.impl.api.session.context;
-import org.jboss.identity.spi.repository.IdentityStoreRepository;
-import org.jboss.identity.spi.store.IdentityStoreInvocationContext;
-import org.jboss.identity.impl.api.session.context.IdentitySessionContext;
-import org.jboss.identity.impl.api.session.mapper.IdentityObjectTypeMapper;
-import org.jboss.identity.impl.api.session.context.IdentityStoreInvocationContextResolver;
+import org.jboss.identity.idm.spi.repository.IdentityStoreRepository;
+import org.jboss.identity.idm.spi.store.IdentityStoreInvocationContext;
+import org.jboss.identity.idm.impl.api.session.context.IdentitySessionContext;
+import org.jboss.identity.idm.impl.api.session.mapper.IdentityObjectTypeMapper;
+import org.jboss.identity.idm.impl.api.session.context.IdentityStoreInvocationContextResolver;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/context/IdentityStoreInvocationContextResolver.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/session/context/IdentityStoreInvocationContextResolver.java 2009-01-13 15:18:42 UTC (rev 211)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/context/IdentityStoreInvocationContextResolver.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,9 +20,9 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.api.session.context;
+package org.jboss.identity.idm.impl.api.session.context;
-import org.jboss.identity.spi.store.IdentityStoreInvocationContext;
+import org.jboss.identity.idm.spi.store.IdentityStoreInvocationContext;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AbstractManager.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/session/managers/AbstractManager.java 2009-01-13 15:18:42 UTC (rev 211)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AbstractManager.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,27 +20,27 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.api.session.managers;
+package org.jboss.identity.idm.impl.api.session.managers;
-import org.jboss.identity.api.IdentitySession;
-import org.jboss.identity.api.Identity;
-import org.jboss.identity.api.Group;
-import org.jboss.identity.api.GroupType;
-import org.jboss.identity.api.IdentityType;
-import org.jboss.identity.api.IdentitySearchControl;
-import org.jboss.identity.api.Attribute;
-import org.jboss.identity.spi.repository.IdentityStoreRepository;
-import org.jboss.identity.spi.store.IdentityStoreInvocationContext;
-import org.jboss.identity.spi.searchcontrol.IdentityObjectSearchControl;
-import org.jboss.identity.spi.model.IdentityObject;
-import org.jboss.identity.spi.model.IdentityObjectType;
-import org.jboss.identity.spi.model.IdentityObjectAttribute;
-import org.jboss.identity.impl.types.SimpleIdentityObject;
-import org.jboss.identity.impl.api.session.context.IdentitySessionContext;
-import org.jboss.identity.impl.api.session.IdentitySessionImpl;
-import org.jboss.identity.impl.api.model.SimpleIdentity;
-import org.jboss.identity.impl.api.model.SimpleGroup;
-import org.jboss.identity.impl.api.SimpleAttribute;
+import org.jboss.identity.idm.api.IdentitySession;
+import org.jboss.identity.idm.api.Identity;
+import org.jboss.identity.idm.api.Group;
+import org.jboss.identity.idm.api.GroupType;
+import org.jboss.identity.idm.api.IdentityType;
+import org.jboss.identity.idm.api.IdentitySearchControl;
+import org.jboss.identity.idm.api.Attribute;
+import org.jboss.identity.idm.spi.repository.IdentityStoreRepository;
+import org.jboss.identity.idm.spi.store.IdentityStoreInvocationContext;
+import org.jboss.identity.idm.spi.searchcontrol.IdentityObjectSearchControl;
+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.impl.types.SimpleIdentityObject;
+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.SimpleIdentity;
+import org.jboss.identity.idm.impl.api.model.SimpleGroup;
+import org.jboss.identity.idm.impl.api.SimpleAttribute;
import java.util.List;
import java.util.LinkedList;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AttributesManagerImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/session/managers/AttributesManagerImpl.java 2009-01-13 15:18:42 UTC (rev 211)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AttributesManagerImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,25 +20,25 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.api.session.managers;
+package org.jboss.identity.idm.impl.api.session.managers;
-import org.jboss.identity.api.IdentitySession;
-import org.jboss.identity.api.AttributesManager;
-import org.jboss.identity.api.IdentityType;
-import org.jboss.identity.api.Identity;
-import org.jboss.identity.api.AttributeDescription;
-import org.jboss.identity.api.CredentialType;
-import org.jboss.identity.api.Credential;
-import org.jboss.identity.api.Attribute;
-import org.jboss.identity.exception.IdentityException;
-import org.jboss.identity.spi.model.IdentityObjectCredential;
-import org.jboss.identity.spi.model.IdentityObjectAttribute;
-import org.jboss.identity.spi.configuration.metadata.IdentityObjectAttributeMetaData;
-import org.jboss.identity.impl.api.session.managers.AbstractManager;
-import org.jboss.identity.impl.api.attribute.IdentityObjectAttributeMetaDataImpl;
-import org.jboss.identity.impl.api.SimpleAttribute;
-import org.jboss.identity.impl.api.PasswordCredential;
-import org.jboss.identity.impl.api.SimpleCredentialType;
+import org.jboss.identity.idm.api.IdentitySession;
+import org.jboss.identity.idm.api.AttributesManager;
+import org.jboss.identity.idm.api.IdentityType;
+import org.jboss.identity.idm.api.Identity;
+import org.jboss.identity.idm.api.AttributeDescription;
+import org.jboss.identity.idm.api.CredentialType;
+import org.jboss.identity.idm.api.Credential;
+import org.jboss.identity.idm.api.Attribute;
+import org.jboss.identity.idm.exception.IdentityException;
+import org.jboss.identity.idm.spi.model.IdentityObjectCredential;
+import org.jboss.identity.idm.spi.model.IdentityObjectAttribute;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityObjectAttributeMetaData;
+import org.jboss.identity.idm.impl.api.session.managers.AbstractManager;
+import org.jboss.identity.idm.impl.api.attribute.IdentityObjectAttributeMetaDataImpl;
+import org.jboss.identity.idm.impl.api.SimpleAttribute;
+import org.jboss.identity.idm.impl.api.PasswordCredential;
+import org.jboss.identity.idm.impl.api.SimpleCredentialType;
import java.util.Set;
import java.util.Map;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/managers/PersistenceManagerImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/session/managers/PersistenceManagerImpl.java 2009-01-13 15:18:42 UTC (rev 211)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/managers/PersistenceManagerImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,20 +20,20 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.api.session.managers;
+package org.jboss.identity.idm.impl.api.session.managers;
-import org.jboss.identity.api.PersistenceManager;
-import org.jboss.identity.api.Identity;
-import org.jboss.identity.api.Group;
-import org.jboss.identity.api.GroupType;
-import org.jboss.identity.api.IdentitySession;
-import org.jboss.identity.api.PersistenceManagerFeaturesDescription;
-import org.jboss.identity.api.IdentitySearchControl;
-import org.jboss.identity.exception.IdentityException;
-import org.jboss.identity.spi.model.IdentityObjectType;
-import org.jboss.identity.spi.model.IdentityObject;
-import org.jboss.identity.impl.NotYetImplementedException;
-import org.jboss.identity.impl.api.session.managers.AbstractManager;
+import org.jboss.identity.idm.api.PersistenceManager;
+import org.jboss.identity.idm.api.Identity;
+import org.jboss.identity.idm.api.Group;
+import org.jboss.identity.idm.api.GroupType;
+import org.jboss.identity.idm.api.IdentitySession;
+import org.jboss.identity.idm.api.PersistenceManagerFeaturesDescription;
+import org.jboss.identity.idm.api.IdentitySearchControl;
+import org.jboss.identity.idm.exception.IdentityException;
+import org.jboss.identity.idm.spi.model.IdentityObjectType;
+import org.jboss.identity.idm.spi.model.IdentityObject;
+import org.jboss.identity.idm.impl.NotYetImplementedException;
+import org.jboss.identity.idm.impl.api.session.managers.AbstractManager;
import java.util.Collection;
import java.util.List;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/session/managers/RelationshipManagerImpl.java 2009-01-13 15:18:42 UTC (rev 211)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,23 +20,23 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.api.session.managers;
+package org.jboss.identity.idm.impl.api.session.managers;
-import org.jboss.identity.api.RelationshipManager;
-import org.jboss.identity.api.IdentitySession;
-import org.jboss.identity.api.Group;
-import org.jboss.identity.api.Identity;
-import org.jboss.identity.api.IdentityType;
-import org.jboss.identity.api.GroupType;
-import org.jboss.identity.api.RelationshipManagerFeaturesDescription;
-import org.jboss.identity.api.IdentitySearchControl;
-import org.jboss.identity.exception.IdentityException;
-import org.jboss.identity.spi.model.IdentityObjectRelationshipType;
-import org.jboss.identity.spi.model.IdentityObjectRelationship;
-import org.jboss.identity.spi.model.IdentityObject;
-import org.jboss.identity.spi.model.IdentityObjectType;
-import org.jboss.identity.impl.NotYetImplementedException;
-import org.jboss.identity.impl.api.session.managers.AbstractManager;
+import org.jboss.identity.idm.api.RelationshipManager;
+import org.jboss.identity.idm.api.IdentitySession;
+import org.jboss.identity.idm.api.Group;
+import org.jboss.identity.idm.api.Identity;
+import org.jboss.identity.idm.api.IdentityType;
+import org.jboss.identity.idm.api.GroupType;
+import org.jboss.identity.idm.api.RelationshipManagerFeaturesDescription;
+import org.jboss.identity.idm.api.IdentitySearchControl;
+import org.jboss.identity.idm.exception.IdentityException;
+import org.jboss.identity.idm.spi.model.IdentityObjectRelationshipType;
+import org.jboss.identity.idm.spi.model.IdentityObjectRelationship;
+import org.jboss.identity.idm.spi.model.IdentityObject;
+import org.jboss.identity.idm.spi.model.IdentityObjectType;
+import org.jboss.identity.idm.impl.NotYetImplementedException;
+import org.jboss.identity.idm.impl.api.session.managers.AbstractManager;
import java.util.Collection;
import java.util.Iterator;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RoleManagerImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/session/managers/RoleManagerImpl.java 2009-01-13 15:18:42 UTC (rev 211)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RoleManagerImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,25 +20,25 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.api.session.managers;
+package org.jboss.identity.idm.impl.api.session.managers;
-import org.jboss.identity.api.RoleManager;
-import org.jboss.identity.api.IdentitySession;
-import org.jboss.identity.api.RoleType;
-import org.jboss.identity.api.Role;
-import org.jboss.identity.api.Identity;
-import org.jboss.identity.api.Group;
-import org.jboss.identity.api.IdentityType;
-import org.jboss.identity.api.RoleManagerFeaturesDescription;
-import org.jboss.identity.api.IdentitySearchControl;
-import org.jboss.identity.exception.IdentityException;
-import org.jboss.identity.spi.model.IdentityObjectRelationshipType;
-import org.jboss.identity.spi.model.IdentityObjectRelationship;
-import org.jboss.identity.spi.exception.OperationNotSupportedException;
-import org.jboss.identity.impl.NotYetImplementedException;
-import org.jboss.identity.impl.api.session.managers.AbstractManager;
-import org.jboss.identity.impl.api.model.SimpleRoleType;
-import org.jboss.identity.impl.api.model.SimpleRole;
+import org.jboss.identity.idm.api.RoleManager;
+import org.jboss.identity.idm.api.IdentitySession;
+import org.jboss.identity.idm.api.RoleType;
+import org.jboss.identity.idm.api.Role;
+import org.jboss.identity.idm.api.Identity;
+import org.jboss.identity.idm.api.Group;
+import org.jboss.identity.idm.api.IdentityType;
+import org.jboss.identity.idm.api.RoleManagerFeaturesDescription;
+import org.jboss.identity.idm.api.IdentitySearchControl;
+import org.jboss.identity.idm.exception.IdentityException;
+import org.jboss.identity.idm.spi.model.IdentityObjectRelationshipType;
+import org.jboss.identity.idm.spi.model.IdentityObjectRelationship;
+import org.jboss.identity.idm.spi.exception.OperationNotSupportedException;
+import org.jboss.identity.idm.impl.NotYetImplementedException;
+import org.jboss.identity.idm.impl.api.session.managers.AbstractManager;
+import org.jboss.identity.idm.impl.api.model.SimpleRoleType;
+import org.jboss.identity.idm.impl.api.model.SimpleRole;
import java.util.Collection;
import java.util.Set;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/mapper/DirectIdentityObjectTypeMapperImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/session/mapper/DirectIdentityObjectTypeMapperImpl.java 2009-01-13 15:18:42 UTC (rev 211)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/mapper/DirectIdentityObjectTypeMapperImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,13 +20,13 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.api.session.mapper;
+package org.jboss.identity.idm.impl.api.session.mapper;
-import org.jboss.identity.spi.model.IdentityObjectType;
-import org.jboss.identity.impl.types.SimpleIdentityObjectType;
-import org.jboss.identity.impl.api.session.mapper.IdentityObjectTypeMapper;
-import org.jboss.identity.impl.api.model.SimpleGroupType;
-import org.jboss.identity.api.GroupType;
+import org.jboss.identity.idm.spi.model.IdentityObjectType;
+import org.jboss.identity.idm.impl.types.SimpleIdentityObjectType;
+import org.jboss.identity.idm.impl.api.session.mapper.IdentityObjectTypeMapper;
+import org.jboss.identity.idm.impl.api.model.SimpleGroupType;
+import org.jboss.identity.idm.api.GroupType;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/mapper/IdentityObjectTypeMapper.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/session/mapper/IdentityObjectTypeMapper.java 2009-01-13 15:18:42 UTC (rev 211)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/mapper/IdentityObjectTypeMapper.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,12 +20,10 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.api.session.mapper;
+package org.jboss.identity.idm.impl.api.session.mapper;
-import org.jboss.identity.spi.model.IdentityObject;
-import org.jboss.identity.spi.model.IdentityObjectType;
-import org.jboss.identity.api.Identity;
-import org.jboss.identity.api.GroupType;
+import org.jboss.identity.idm.spi.model.IdentityObjectType;
+import org.jboss.identity.idm.api.GroupType;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/mapper/IdentityObjectTypeMapperImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/session/mapper/IdentityObjectTypeMapperImpl.java 2009-01-13 15:18:42 UTC (rev 211)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/api/session/mapper/IdentityObjectTypeMapperImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,13 +20,13 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.api.session.mapper;
+package org.jboss.identity.idm.impl.api.session.mapper;
-import org.jboss.identity.spi.model.IdentityObjectType;
-import org.jboss.identity.api.GroupType;
-import org.jboss.identity.impl.types.SimpleIdentityObjectType;
-import org.jboss.identity.impl.api.session.mapper.IdentityObjectTypeMapper;
-import org.jboss.identity.impl.api.model.SimpleGroupType;
+import org.jboss.identity.idm.spi.model.IdentityObjectType;
+import org.jboss.identity.idm.api.GroupType;
+import org.jboss.identity.idm.impl.types.SimpleIdentityObjectType;
+import org.jboss.identity.idm.impl.api.session.mapper.IdentityObjectTypeMapper;
+import org.jboss.identity.idm.impl.api.model.SimpleGroupType;
import java.util.Map;
import java.util.Collections;
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/JAXB2IdentityConfiguration.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/JAXB2IdentityConfiguration.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/JAXB2IdentityConfiguration.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,347 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.configuration.jaxb2;
-
-import org.jboss.identity.impl.configuration.metadata.IdentityConfigurationMetaDataImpl;
-import org.jboss.identity.impl.configuration.metadata.IdentityObjectTypeMetaDataImpl;
-import org.jboss.identity.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
-import org.jboss.identity.spi.configuration.metadata.IdentityRepositoryConfigurationMetaData;
-import org.jboss.identity.spi.configuration.metadata.RealmConfigurationMetaData;
-import org.jboss.identity.impl.configuration.metadata.RealmConfigurationMetaDataImpl;
-import org.jboss.identity.impl.configuration.metadata.IdentityRepositoryConfigurationMetaDataImpl;
-import org.jboss.identity.impl.configuration.metadata.IdentityStoreConfigurationMetaDataImpl;
-import org.jboss.identity.impl.configuration.metadata.IdentityStoreMappingMetaDataImpl;
-import org.jboss.identity.impl.configuration.metadata.RelationshipMetaDataImpl;
-import org.jboss.identity.spi.configuration.metadata.IdentityStoreMappingMetaData;
-import org.jboss.identity.spi.configuration.metadata.IdentityConfigurationMetaData;
-import org.jboss.identity.spi.configuration.metadata.RelationshipMetaData;
-import org.jboss.identity.spi.exception.IdentityConfigurationException;
-import org.jboss.identity.spi.attribute.IdentityObjectAttributeMetaData;
-import org.jboss.identity.impl.api.IdentityObjectAttributeMetaDataImpl;
-import org.jboss.identity.impl.configuration.jaxb2.generated.JbossIdentityType;
-import org.jboss.identity.impl.configuration.jaxb2.generated.IdentityStoreType;
-import org.jboss.identity.impl.configuration.jaxb2.generated.RepositoryType;
-import org.jboss.identity.impl.configuration.jaxb2.generated.RealmType;
-import org.jboss.identity.impl.configuration.jaxb2.generated.GroupTypeMappingType;
-import org.jboss.identity.impl.configuration.jaxb2.generated.OptionType;
-import org.jboss.identity.impl.configuration.jaxb2.generated.OptionsType;
-import org.jboss.identity.impl.configuration.jaxb2.generated.IdentityStoreMappingType;
-import org.jboss.identity.impl.configuration.jaxb2.generated.IdentityObjectTypeType;
-import org.jboss.identity.impl.configuration.jaxb2.generated.AttributeType;
-import org.jboss.identity.impl.configuration.jaxb2.generated.RelationshipType;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import java.io.File;
-import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.LinkedList;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public abstract class JAXB2IdentityConfiguration
-{
-
- //TODO: check if configuration is consistent. Part of constraints should be checked by schema. Test cases needed :)
-
-
- public static IdentityConfigurationMetaData createConfigurationMetaData(File xmlConfig) throws IdentityConfigurationException
- {
-
- if (xmlConfig == null || !xmlConfig.exists())
- {
- throw new IllegalArgumentException("File does not exist");
- }
-
- JAXBElement<JbossIdentityType> jiElement = null;
-
- Object o = null;
- try
- {
- JAXBContext jaxbContext = JAXBContext.newInstance("org.jboss.identity.impl.configuration.jaxb2.generated");
- Unmarshaller unMarshaller = jaxbContext.createUnmarshaller();
-
- jiElement = (JAXBElement<JbossIdentityType>)unMarshaller.unmarshal(xmlConfig);
- }
- catch (JAXBException e)
- {
- throw new IdentityConfigurationException("Cannot unmarshal xml configuration: ", e);
- }
-
- JbossIdentityType identityConfig = jiElement.getValue();
-
- IdentityConfigurationMetaDataImpl configurationMD = new IdentityConfigurationMetaDataImpl();
-
- if (identityConfig.getStores() != null &&
- identityConfig.getStores().getIdentityStores() != null &&
- identityConfig.getStores().getIdentityStores().getIdentityStore() != null)
- {
-
- for (IdentityStoreType identityStoreType : identityConfig.getStores().getIdentityStores().getIdentityStore())
- {
- configurationMD.getIdentityStores().add(createIdentityStoreConfigurationMetaData(identityStoreType));
- }
- }
-
- if (identityConfig.getRepositories() != null &&
- identityConfig.getRepositories().getRepository() != null)
- {
-
- for (RepositoryType repositoryType : identityConfig.getRepositories().getRepository())
- {
- configurationMD.getRepositories().add(createIdentityRepositoryConfigurationMetaData(repositoryType));
- }
- }
-
- if (identityConfig.getRealms() != null &&
- identityConfig.getRealms().getRealm() != null)
- {
- for (RealmType realmType : identityConfig.getRealms().getRealm())
- {
- configurationMD.getRealms().add(createRealmConfigurationMetaData(realmType));
- }
- }
-
- return configurationMD;
-
- }
-
- private static RealmConfigurationMetaData createRealmConfigurationMetaData(RealmType realmType)
- {
- RealmConfigurationMetaDataImpl realmMD = new RealmConfigurationMetaDataImpl();
-
- realmMD.setId(realmType.getId());
- if (realmType.getIdentityTypeMappings() != null)
- {
- realmMD.setIdentityMapping(realmType.getIdentityTypeMappings().getIdentityMapping());
- }
- realmMD.setIdentityRepositoryIdRef(realmType.getRepositoryIdRef());
-
- Map<String, String> groupMappings = new HashMap<String, String>();
-
- if (realmType.getIdentityTypeMappings() != null
- && realmType.getIdentityTypeMappings().getGroupTypeMapping() != null)
- {
- for (GroupTypeMappingType groupTypeMappingType : realmType.getIdentityTypeMappings().getGroupTypeMapping())
- {
- groupMappings.put(groupTypeMappingType.getGroupTypeName(), groupTypeMappingType.getIdentityObjectTypeName());
- }
- }
-
- realmMD.setGroupTypeMappings(groupMappings);
-
- realmMD.setOptions(createOptions(realmType.getOptions()));
-
-
- return realmMD;
- }
-
-
- private static IdentityRepositoryConfigurationMetaData createIdentityRepositoryConfigurationMetaData(RepositoryType repositoryType)
- {
- IdentityRepositoryConfigurationMetaDataImpl repoMD = new IdentityRepositoryConfigurationMetaDataImpl();
-
- repoMD.setId(repositoryType.getId());
- repoMD.setClassName(repositoryType.getClazz());
- if (repositoryType.getExternalConfig() != null)
- {
- repoMD.setExternalConfig(repositoryType.getExternalConfig().getValue());
- }
- repoMD.setDefaultAttributeStroeId(repositoryType.getDefaultAttributeStoreId());
- repoMD.setDefaultIdentityStoreId(repositoryType.getDefaultIdentityStoreId());
-
- List<IdentityStoreMappingMetaData> storeMappings = new LinkedList<IdentityStoreMappingMetaData>();
-
- if (repositoryType.getIdentityStoreMappings() != null &&
- repositoryType.getIdentityStoreMappings().getIdentityStoreMapping() != null)
- {
-
- for (IdentityStoreMappingType identityStoreMappingType : repositoryType.getIdentityStoreMappings().getIdentityStoreMapping())
- {
- IdentityStoreMappingMetaDataImpl mapping = new IdentityStoreMappingMetaDataImpl();
-
- mapping.setIdentityStoreId(identityStoreMappingType.getIdentityStoreId());
- mapping.setIdentityObjectTypeMappings(identityStoreMappingType.getIdentityObjectTypes().getIdentityObjectType());
- mapping.setOptions(createOptions(identityStoreMappingType.getOptions()));
-
- storeMappings.add(mapping);
- }
- }
-
- repoMD.setIdentityStoreToIdentityObjectTypeMappings(storeMappings);
-
- repoMD.setOptions(createOptions(repositoryType.getOptions()));
-
-
- return repoMD;
- }
-
- private static IdentityStoreConfigurationMetaData createIdentityStoreConfigurationMetaData(IdentityStoreType identityStoreType)
- {
- IdentityStoreConfigurationMetaDataImpl storeMD = new IdentityStoreConfigurationMetaDataImpl();
-
- storeMD.setId(identityStoreType.getId());
- storeMD.setClassName(identityStoreType.getClazz());
-
- if (identityStoreType.getExternalConfig() != null)
- {
- storeMD.setExternalConfig(identityStoreType.getExternalConfig().getValue());
- }
-
- storeMD.setSupportedRelationshipTypes(identityStoreType.getSupportedRelationshipTypes().getRelationshipType());
-
- if (identityStoreType.getSupportedIdentityObjectTypes() != null &&
- identityStoreType.getSupportedIdentityObjectTypes().getIdentityObjectType() != null)
-
- {
-
- for (IdentityObjectTypeType identityObjectTypeType : identityStoreType.getSupportedIdentityObjectTypes().getIdentityObjectType())
- {
- IdentityObjectTypeMetaDataImpl identityObjectTypeMD = new IdentityObjectTypeMetaDataImpl();
-
- identityObjectTypeMD.setName(identityObjectTypeType.getName());
-
-
- // Attributes
-
- List<IdentityObjectAttributeMetaData> attributes = new LinkedList<IdentityObjectAttributeMetaData>();
-
- if (identityObjectTypeType.getAttributes() != null &&
- identityObjectTypeType.getAttributes().getAttribute() != null)
- {
-
- for (AttributeType attributeType : identityObjectTypeType.getAttributes().getAttribute())
- {
-
- String readOnly = attributeType.getIsReadOnly();
- String multivalued = attributeType.getIsMultivalued();
- String required = attributeType.getIsRequired();
-
- IdentityObjectAttributeMetaDataImpl attributeMD = new IdentityObjectAttributeMetaDataImpl(
- attributeType.getName(),
- attributeType.getMapping(),
- attributeType.getType(),
- (readOnly != null && readOnly.equalsIgnoreCase("true")),
- (multivalued != null && multivalued.equalsIgnoreCase("true")),
- (required != null && required.equalsIgnoreCase("true"))
- );
-
- attributes.add(attributeMD);
- }
- }
-
- identityObjectTypeMD.setAttributes(attributes);
-
- // Credentials
-
- List<String> credentials = new LinkedList<String>();
-
- if (identityObjectTypeType.getCredentials() != null &&
- identityObjectTypeType.getCredentials().getCredentialType() != null)
- {
- for (String credentialType : identityObjectTypeType.getCredentials().getCredentialType())
- {
- credentials.add(credentialType);
- }
- }
-
- identityObjectTypeMD.setCredentials(credentials);
-
- // Relationships
-
- List<RelationshipMetaData> relationships = new LinkedList<RelationshipMetaData>();
-
- if (identityObjectTypeType.getRelationships() != null &&
- identityObjectTypeType.getRelationships().getRelationship() != null)
- {
- for (RelationshipType relationshipType : identityObjectTypeType.getRelationships().getRelationship())
- {
- RelationshipMetaDataImpl relMD = new RelationshipMetaDataImpl();
- relMD.setIdentityObjectTypeRef(relationshipType.getIdentityObjectTypeRef());
- relMD.setRelationshipTypeRef(relationshipType.getRelationshipTypeRef());
- relationships.add(relMD);
- }
- }
-
- identityObjectTypeMD.setRelationships(relationships);
-
- // Options
-
- Map<String, List<String>> options = new HashMap<String, List<String>>();
-
- if (identityObjectTypeType.getOptions() != null &&
- identityObjectTypeType.getOptions().getOption() != null)
- {
-
- for (OptionType optionType : identityObjectTypeType.getOptions().getOption())
- {
- options.put(optionType.getName(), optionType.getValue());
- }
- }
-
- identityObjectTypeMD.setOptions(options);
-
- storeMD.getSupportedIdentityTypes().add(identityObjectTypeMD);
- }
- }
-
-
- Map<String, List<String>> options = new HashMap<String, List<String>>();
-
- if (identityStoreType.getOptions() != null &&
- identityStoreType.getOptions().getOption() != null)
- {
-
- for (OptionType optionType : identityStoreType.getOptions().getOption())
- {
- options.put(optionType.getName(), optionType.getValue());
- }
- }
-
- storeMD.setOptions(options);
-
- return storeMD;
- }
-
- private static Map<String, List<String>> createOptions(OptionsType optionsType)
- {
- Map<String, List<String>> options = new HashMap<String, List<String>>();
-
- if (optionsType != null &&
- optionsType.getOption() != null)
- {
- for (OptionType optionType : optionsType.getOption())
- {
- options.put(optionType.getName(), optionType.getValue());
- }
- }
-
- return options;
- }
-
-}
Copied: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/JAXB2IdentityConfiguration.java (from rev 211, trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/JAXB2IdentityConfiguration.java)
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/JAXB2IdentityConfiguration.java (rev 0)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/JAXB2IdentityConfiguration.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,347 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.impl.configuration.jaxb2;
+
+import org.jboss.identity.idm.impl.configuration.metadata.IdentityConfigurationMetaDataImpl;
+import org.jboss.identity.idm.impl.configuration.metadata.IdentityObjectTypeMetaDataImpl;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityRepositoryConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.RealmConfigurationMetaData;
+import org.jboss.identity.idm.impl.configuration.metadata.RealmConfigurationMetaDataImpl;
+import org.jboss.identity.idm.impl.configuration.metadata.IdentityRepositoryConfigurationMetaDataImpl;
+import org.jboss.identity.idm.impl.configuration.metadata.IdentityStoreConfigurationMetaDataImpl;
+import org.jboss.identity.idm.impl.configuration.metadata.IdentityStoreMappingMetaDataImpl;
+import org.jboss.identity.idm.impl.configuration.metadata.RelationshipMetaDataImpl;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreMappingMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.RelationshipMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityObjectAttributeMetaData;
+import org.jboss.identity.idm.spi.exception.IdentityConfigurationException;
+import org.jboss.identity.idm.impl.api.attribute.IdentityObjectAttributeMetaDataImpl;
+import org.jboss.identity.idm.impl.configuration.jaxb2.generated.JbossIdentityType;
+import org.jboss.identity.idm.impl.configuration.jaxb2.generated.IdentityStoreType;
+import org.jboss.identity.idm.impl.configuration.jaxb2.generated.RepositoryType;
+import org.jboss.identity.idm.impl.configuration.jaxb2.generated.RealmType;
+import org.jboss.identity.idm.impl.configuration.jaxb2.generated.GroupTypeMappingType;
+import org.jboss.identity.idm.impl.configuration.jaxb2.generated.OptionType;
+import org.jboss.identity.idm.impl.configuration.jaxb2.generated.OptionsType;
+import org.jboss.identity.idm.impl.configuration.jaxb2.generated.IdentityStoreMappingType;
+import org.jboss.identity.idm.impl.configuration.jaxb2.generated.IdentityObjectTypeType;
+import org.jboss.identity.idm.impl.configuration.jaxb2.generated.AttributeType;
+import org.jboss.identity.idm.impl.configuration.jaxb2.generated.RelationshipType;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import java.io.File;
+import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.LinkedList;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public abstract class JAXB2IdentityConfiguration
+{
+
+ //TODO: check if configuration is consistent. Part of constraints should be checked by schema. Test cases needed :)
+
+
+ public static IdentityConfigurationMetaData createConfigurationMetaData(File xmlConfig) throws IdentityConfigurationException
+ {
+
+ if (xmlConfig == null || !xmlConfig.exists())
+ {
+ throw new IllegalArgumentException("File does not exist");
+ }
+
+ JAXBElement<JbossIdentityType> jiElement = null;
+
+ Object o = null;
+ try
+ {
+ JAXBContext jaxbContext = JAXBContext.newInstance("org.jboss.identity.idm.impl.configuration.jaxb2.generated");
+ Unmarshaller unMarshaller = jaxbContext.createUnmarshaller();
+
+ jiElement = (JAXBElement<JbossIdentityType>)unMarshaller.unmarshal(xmlConfig);
+ }
+ catch (JAXBException e)
+ {
+ throw new IdentityConfigurationException("Cannot unmarshal xml configuration: ", e);
+ }
+
+ JbossIdentityType identityConfig = jiElement.getValue();
+
+ IdentityConfigurationMetaDataImpl configurationMD = new IdentityConfigurationMetaDataImpl();
+
+ if (identityConfig.getStores() != null &&
+ identityConfig.getStores().getIdentityStores() != null &&
+ identityConfig.getStores().getIdentityStores().getIdentityStore() != null)
+ {
+
+ for (IdentityStoreType identityStoreType : identityConfig.getStores().getIdentityStores().getIdentityStore())
+ {
+ configurationMD.getIdentityStores().add(createIdentityStoreConfigurationMetaData(identityStoreType));
+ }
+ }
+
+ if (identityConfig.getRepositories() != null &&
+ identityConfig.getRepositories().getRepository() != null)
+ {
+
+ for (RepositoryType repositoryType : identityConfig.getRepositories().getRepository())
+ {
+ configurationMD.getRepositories().add(createIdentityRepositoryConfigurationMetaData(repositoryType));
+ }
+ }
+
+ if (identityConfig.getRealms() != null &&
+ identityConfig.getRealms().getRealm() != null)
+ {
+ for (RealmType realmType : identityConfig.getRealms().getRealm())
+ {
+ configurationMD.getRealms().add(createRealmConfigurationMetaData(realmType));
+ }
+ }
+
+ return configurationMD;
+
+ }
+
+ private static RealmConfigurationMetaData createRealmConfigurationMetaData(RealmType realmType)
+ {
+ RealmConfigurationMetaDataImpl realmMD = new RealmConfigurationMetaDataImpl();
+
+ realmMD.setId(realmType.getId());
+ if (realmType.getIdentityTypeMappings() != null)
+ {
+ realmMD.setIdentityMapping(realmType.getIdentityTypeMappings().getIdentityMapping());
+ }
+ realmMD.setIdentityRepositoryIdRef(realmType.getRepositoryIdRef());
+
+ Map<String, String> groupMappings = new HashMap<String, String>();
+
+ if (realmType.getIdentityTypeMappings() != null
+ && realmType.getIdentityTypeMappings().getGroupTypeMapping() != null)
+ {
+ for (GroupTypeMappingType groupTypeMappingType : realmType.getIdentityTypeMappings().getGroupTypeMapping())
+ {
+ groupMappings.put(groupTypeMappingType.getGroupTypeName(), groupTypeMappingType.getIdentityObjectTypeName());
+ }
+ }
+
+ realmMD.setGroupTypeMappings(groupMappings);
+
+ realmMD.setOptions(createOptions(realmType.getOptions()));
+
+
+ return realmMD;
+ }
+
+
+ private static IdentityRepositoryConfigurationMetaData createIdentityRepositoryConfigurationMetaData(RepositoryType repositoryType)
+ {
+ IdentityRepositoryConfigurationMetaDataImpl repoMD = new IdentityRepositoryConfigurationMetaDataImpl();
+
+ repoMD.setId(repositoryType.getId());
+ repoMD.setClassName(repositoryType.getClazz());
+ if (repositoryType.getExternalConfig() != null)
+ {
+ repoMD.setExternalConfig(repositoryType.getExternalConfig().getValue());
+ }
+ repoMD.setDefaultAttributeStroeId(repositoryType.getDefaultAttributeStoreId());
+ repoMD.setDefaultIdentityStoreId(repositoryType.getDefaultIdentityStoreId());
+
+ List<IdentityStoreMappingMetaData> storeMappings = new LinkedList<IdentityStoreMappingMetaData>();
+
+ if (repositoryType.getIdentityStoreMappings() != null &&
+ repositoryType.getIdentityStoreMappings().getIdentityStoreMapping() != null)
+ {
+
+ for (IdentityStoreMappingType identityStoreMappingType : repositoryType.getIdentityStoreMappings().getIdentityStoreMapping())
+ {
+ IdentityStoreMappingMetaDataImpl mapping = new IdentityStoreMappingMetaDataImpl();
+
+ mapping.setIdentityStoreId(identityStoreMappingType.getIdentityStoreId());
+ mapping.setIdentityObjectTypeMappings(identityStoreMappingType.getIdentityObjectTypes().getIdentityObjectType());
+ mapping.setOptions(createOptions(identityStoreMappingType.getOptions()));
+
+ storeMappings.add(mapping);
+ }
+ }
+
+ repoMD.setIdentityStoreToIdentityObjectTypeMappings(storeMappings);
+
+ repoMD.setOptions(createOptions(repositoryType.getOptions()));
+
+
+ return repoMD;
+ }
+
+ private static IdentityStoreConfigurationMetaData createIdentityStoreConfigurationMetaData(IdentityStoreType identityStoreType)
+ {
+ IdentityStoreConfigurationMetaDataImpl storeMD = new IdentityStoreConfigurationMetaDataImpl();
+
+ storeMD.setId(identityStoreType.getId());
+ storeMD.setClassName(identityStoreType.getClazz());
+
+ if (identityStoreType.getExternalConfig() != null)
+ {
+ storeMD.setExternalConfig(identityStoreType.getExternalConfig().getValue());
+ }
+
+ storeMD.setSupportedRelationshipTypes(identityStoreType.getSupportedRelationshipTypes().getRelationshipType());
+
+ if (identityStoreType.getSupportedIdentityObjectTypes() != null &&
+ identityStoreType.getSupportedIdentityObjectTypes().getIdentityObjectType() != null)
+
+ {
+
+ for (IdentityObjectTypeType identityObjectTypeType : identityStoreType.getSupportedIdentityObjectTypes().getIdentityObjectType())
+ {
+ IdentityObjectTypeMetaDataImpl identityObjectTypeMD = new IdentityObjectTypeMetaDataImpl();
+
+ identityObjectTypeMD.setName(identityObjectTypeType.getName());
+
+
+ // Attributes
+
+ List<IdentityObjectAttributeMetaData> attributes = new LinkedList<IdentityObjectAttributeMetaData>();
+
+ if (identityObjectTypeType.getAttributes() != null &&
+ identityObjectTypeType.getAttributes().getAttribute() != null)
+ {
+
+ for (AttributeType attributeType : identityObjectTypeType.getAttributes().getAttribute())
+ {
+
+ String readOnly = attributeType.getIsReadOnly();
+ String multivalued = attributeType.getIsMultivalued();
+ String required = attributeType.getIsRequired();
+
+ IdentityObjectAttributeMetaDataImpl attributeMD = new IdentityObjectAttributeMetaDataImpl(
+ attributeType.getName(),
+ attributeType.getMapping(),
+ attributeType.getType(),
+ (readOnly != null && readOnly.equalsIgnoreCase("true")),
+ (multivalued != null && multivalued.equalsIgnoreCase("true")),
+ (required != null && required.equalsIgnoreCase("true"))
+ );
+
+ attributes.add(attributeMD);
+ }
+ }
+
+ identityObjectTypeMD.setAttributes(attributes);
+
+ // Credentials
+
+ List<String> credentials = new LinkedList<String>();
+
+ if (identityObjectTypeType.getCredentials() != null &&
+ identityObjectTypeType.getCredentials().getCredentialType() != null)
+ {
+ for (String credentialType : identityObjectTypeType.getCredentials().getCredentialType())
+ {
+ credentials.add(credentialType);
+ }
+ }
+
+ identityObjectTypeMD.setCredentials(credentials);
+
+ // Relationships
+
+ List<RelationshipMetaData> relationships = new LinkedList<RelationshipMetaData>();
+
+ if (identityObjectTypeType.getRelationships() != null &&
+ identityObjectTypeType.getRelationships().getRelationship() != null)
+ {
+ for (RelationshipType relationshipType : identityObjectTypeType.getRelationships().getRelationship())
+ {
+ RelationshipMetaDataImpl relMD = new RelationshipMetaDataImpl();
+ relMD.setIdentityObjectTypeRef(relationshipType.getIdentityObjectTypeRef());
+ relMD.setRelationshipTypeRef(relationshipType.getRelationshipTypeRef());
+ relationships.add(relMD);
+ }
+ }
+
+ identityObjectTypeMD.setRelationships(relationships);
+
+ // Options
+
+ Map<String, List<String>> options = new HashMap<String, List<String>>();
+
+ if (identityObjectTypeType.getOptions() != null &&
+ identityObjectTypeType.getOptions().getOption() != null)
+ {
+
+ for (OptionType optionType : identityObjectTypeType.getOptions().getOption())
+ {
+ options.put(optionType.getName(), optionType.getValue());
+ }
+ }
+
+ identityObjectTypeMD.setOptions(options);
+
+ storeMD.getSupportedIdentityTypes().add(identityObjectTypeMD);
+ }
+ }
+
+
+ Map<String, List<String>> options = new HashMap<String, List<String>>();
+
+ if (identityStoreType.getOptions() != null &&
+ identityStoreType.getOptions().getOption() != null)
+ {
+
+ for (OptionType optionType : identityStoreType.getOptions().getOption())
+ {
+ options.put(optionType.getName(), optionType.getValue());
+ }
+ }
+
+ storeMD.setOptions(options);
+
+ return storeMD;
+ }
+
+ private static Map<String, List<String>> createOptions(OptionsType optionsType)
+ {
+ Map<String, List<String>> options = new HashMap<String, List<String>>();
+
+ if (optionsType != null &&
+ optionsType.getOption() != null)
+ {
+ for (OptionType optionType : optionsType.getOption())
+ {
+ options.put(optionType.getName(), optionType.getValue());
+ }
+ }
+
+ return options;
+ }
+
+}
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/AttributeType.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/AttributeType.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/AttributeType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -6,7 +6,7 @@
//
-package org.jboss.identity.impl.configuration.jaxb2.generated;
+package org.jboss.identity.idm.impl.configuration.jaxb2.generated;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/AttributesType.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/AttributesType.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/AttributesType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -6,7 +6,7 @@
//
-package org.jboss.identity.impl.configuration.jaxb2.generated;
+package org.jboss.identity.idm.impl.configuration.jaxb2.generated;
import java.util.ArrayList;
import java.util.List;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/CredentialsType.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/CredentialsType.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/CredentialsType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -6,7 +6,7 @@
//
-package org.jboss.identity.impl.configuration.jaxb2.generated;
+package org.jboss.identity.idm.impl.configuration.jaxb2.generated;
import java.util.ArrayList;
import java.util.List;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/ExternalConfigType.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/ExternalConfigType.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/ExternalConfigType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -6,7 +6,7 @@
//
-package org.jboss.identity.impl.configuration.jaxb2.generated;
+package org.jboss.identity.idm.impl.configuration.jaxb2.generated;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/GroupTypeMappingType.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/GroupTypeMappingType.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/GroupTypeMappingType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -6,7 +6,7 @@
//
-package org.jboss.identity.impl.configuration.jaxb2.generated;
+package org.jboss.identity.idm.impl.configuration.jaxb2.generated;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/IdentityObjectTypeType.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/IdentityObjectTypeType.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/IdentityObjectTypeType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -6,7 +6,7 @@
//
-package org.jboss.identity.impl.configuration.jaxb2.generated;
+package org.jboss.identity.idm.impl.configuration.jaxb2.generated;
import java.util.ArrayList;
import java.util.List;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/IdentityObjectTypesType.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/IdentityObjectTypesType.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/IdentityObjectTypesType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -6,7 +6,7 @@
//
-package org.jboss.identity.impl.configuration.jaxb2.generated;
+package org.jboss.identity.idm.impl.configuration.jaxb2.generated;
import java.util.ArrayList;
import java.util.List;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/IdentityStoreMappingType.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/IdentityStoreMappingType.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/IdentityStoreMappingType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -6,7 +6,7 @@
//
-package org.jboss.identity.impl.configuration.jaxb2.generated;
+package org.jboss.identity.idm.impl.configuration.jaxb2.generated;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/IdentityStoreMappingsType.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/IdentityStoreMappingsType.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/IdentityStoreMappingsType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -6,7 +6,7 @@
//
-package org.jboss.identity.impl.configuration.jaxb2.generated;
+package org.jboss.identity.idm.impl.configuration.jaxb2.generated;
import java.util.ArrayList;
import java.util.List;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/IdentityStoreType.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/IdentityStoreType.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/IdentityStoreType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -6,7 +6,7 @@
//
-package org.jboss.identity.impl.configuration.jaxb2.generated;
+package org.jboss.identity.idm.impl.configuration.jaxb2.generated;
import java.util.ArrayList;
import java.util.List;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/IdentityStoresType.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/IdentityStoresType.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/IdentityStoresType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -6,7 +6,7 @@
//
-package org.jboss.identity.impl.configuration.jaxb2.generated;
+package org.jboss.identity.idm.impl.configuration.jaxb2.generated;
import java.util.ArrayList;
import java.util.List;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/IdentityTypeMappingsType.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/IdentityTypeMappingsType.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/IdentityTypeMappingsType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -6,7 +6,7 @@
//
-package org.jboss.identity.impl.configuration.jaxb2.generated;
+package org.jboss.identity.idm.impl.configuration.jaxb2.generated;
import java.util.ArrayList;
import java.util.List;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/JbossIdentityType.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/JbossIdentityType.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/JbossIdentityType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -6,7 +6,7 @@
//
-package org.jboss.identity.impl.configuration.jaxb2.generated;
+package org.jboss.identity.idm.impl.configuration.jaxb2.generated;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/ObjectFactory.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/ObjectFactory.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/ObjectFactory.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -6,7 +6,7 @@
//
-package org.jboss.identity.impl.configuration.jaxb2.generated;
+package org.jboss.identity.idm.impl.configuration.jaxb2.generated;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlElementDecl;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/OptionType.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/OptionType.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/OptionType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -6,7 +6,7 @@
//
-package org.jboss.identity.impl.configuration.jaxb2.generated;
+package org.jboss.identity.idm.impl.configuration.jaxb2.generated;
import java.util.ArrayList;
import java.util.List;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/OptionsType.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/OptionsType.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/OptionsType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -6,7 +6,7 @@
//
-package org.jboss.identity.impl.configuration.jaxb2.generated;
+package org.jboss.identity.idm.impl.configuration.jaxb2.generated;
import java.util.ArrayList;
import java.util.List;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/RealmType.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/RealmType.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/RealmType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -6,7 +6,7 @@
//
-package org.jboss.identity.impl.configuration.jaxb2.generated;
+package org.jboss.identity.idm.impl.configuration.jaxb2.generated;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/RealmsType.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/RealmsType.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/RealmsType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -6,7 +6,7 @@
//
-package org.jboss.identity.impl.configuration.jaxb2.generated;
+package org.jboss.identity.idm.impl.configuration.jaxb2.generated;
import java.util.ArrayList;
import java.util.List;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/RelationshipType.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/RelationshipType.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/RelationshipType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -6,7 +6,7 @@
//
-package org.jboss.identity.impl.configuration.jaxb2.generated;
+package org.jboss.identity.idm.impl.configuration.jaxb2.generated;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/RelationshipsType.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/RelationshipsType.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/RelationshipsType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -6,7 +6,7 @@
//
-package org.jboss.identity.impl.configuration.jaxb2.generated;
+package org.jboss.identity.idm.impl.configuration.jaxb2.generated;
import java.util.ArrayList;
import java.util.List;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/RepositoriesType.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/RepositoriesType.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/RepositoriesType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -6,7 +6,7 @@
//
-package org.jboss.identity.impl.configuration.jaxb2.generated;
+package org.jboss.identity.idm.impl.configuration.jaxb2.generated;
import java.util.ArrayList;
import java.util.List;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/RepositoryType.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/RepositoryType.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/RepositoryType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -6,7 +6,7 @@
//
-package org.jboss.identity.impl.configuration.jaxb2.generated;
+package org.jboss.identity.idm.impl.configuration.jaxb2.generated;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/StoresType.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/StoresType.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/StoresType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -6,7 +6,7 @@
//
-package org.jboss.identity.impl.configuration.jaxb2.generated;
+package org.jboss.identity.idm.impl.configuration.jaxb2.generated;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/SupportedIdentityObjectTypesType.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/SupportedIdentityObjectTypesType.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/SupportedIdentityObjectTypesType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -6,7 +6,7 @@
//
-package org.jboss.identity.impl.configuration.jaxb2.generated;
+package org.jboss.identity.idm.impl.configuration.jaxb2.generated;
import java.util.ArrayList;
import java.util.List;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/SupportedRelationshipTypesType.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/SupportedRelationshipTypesType.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/SupportedRelationshipTypesType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -6,7 +6,7 @@
//
-package org.jboss.identity.impl.configuration.jaxb2.generated;
+package org.jboss.identity.idm.impl.configuration.jaxb2.generated;
import java.util.ArrayList;
import java.util.List;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/package-info.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/package-info.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/jaxb2/generated/package-info.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -6,4 +6,4 @@
//
@javax.xml.bind.annotation.XmlSchema(namespace = "urn:jboss:identity:config:v0_1", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
-package org.jboss.identity.impl.configuration.jaxb2.generated;
+package org.jboss.identity.idm.impl.configuration.jaxb2.generated;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/metadata/IdentityConfigurationMetaDataImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/metadata/IdentityConfigurationMetaDataImpl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/metadata/IdentityConfigurationMetaDataImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,12 +20,12 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.configuration.metadata;
+package org.jboss.identity.idm.impl.configuration.metadata;
-import org.jboss.identity.spi.configuration.metadata.IdentityConfigurationMetaData;
-import org.jboss.identity.spi.configuration.metadata.IdentityRepositoryConfigurationMetaData;
-import org.jboss.identity.spi.configuration.metadata.RealmConfigurationMetaData;
-import org.jboss.identity.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityRepositoryConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.RealmConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
import java.util.List;
import java.util.Map;
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/metadata/IdentityObjectTypeMetaDataImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/metadata/IdentityObjectTypeMetaDataImpl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/metadata/IdentityObjectTypeMetaDataImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,124 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.configuration.metadata;
-
-import org.jboss.identity.spi.attribute.IdentityObjectAttributeMetaData;
-import org.jboss.identity.spi.configuration.metadata.IdentityObjectTypeMetaData;
-import org.jboss.identity.spi.configuration.metadata.RelationshipMetaData;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class IdentityObjectTypeMetaDataImpl implements IdentityObjectTypeMetaData
-{
-
- private String name;
-
- private List<RelationshipMetaData> relationships;
-
- private List<IdentityObjectAttributeMetaData> attributes;
-
- private Map<String, List<String>> options;
-
- private List<String> credentials;
-
- public IdentityObjectTypeMetaDataImpl()
- {
- }
-
- public String getName()
- {
- return name;
- }
-
- public void setName(String name)
- {
- this.name = name;
- }
-
- public List<RelationshipMetaData> getRelationships()
- {
- return relationships;
- }
-
- public void setRelationships(List<RelationshipMetaData> relationships)
- {
- this.relationships = relationships;
- }
-
- public List<IdentityObjectAttributeMetaData> getAttributes()
- {
- return attributes;
- }
-
- public void setAttributes(List<IdentityObjectAttributeMetaData> attributes)
- {
- this.attributes = attributes;
- }
-
- public List<String> getCredentials()
- {
- return credentials;
- }
-
- public void setCredentials(List<String> credentials)
- {
- this.credentials = credentials;
- }
-
- public Map<String, List<String>> getOptions()
- {
- return options;
- }
-
- public void setOptions(Map<String, List<String>> options)
- {
- this.options = options;
- }
-
- public List<String> getOption(String optionName)
- {
- if (options != null )
- {
- return options.get(optionName);
- }
-
- return null;
- }
-
- public String getOptionSingleValue(String optionName)
- {
- List<String> values = getOption(optionName);
-
- if (values != null && values.size() > 0)
- {
- return values.get(0);
- }
-
- return null;
- }
-}
Copied: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/metadata/IdentityObjectTypeMetaDataImpl.java (from rev 211, trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/metadata/IdentityObjectTypeMetaDataImpl.java)
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/metadata/IdentityObjectTypeMetaDataImpl.java (rev 0)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/metadata/IdentityObjectTypeMetaDataImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,124 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.impl.configuration.metadata;
+
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityObjectAttributeMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityObjectTypeMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.RelationshipMetaData;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class IdentityObjectTypeMetaDataImpl implements IdentityObjectTypeMetaData
+{
+
+ private String name;
+
+ private List<RelationshipMetaData> relationships;
+
+ private List<IdentityObjectAttributeMetaData> attributes;
+
+ private Map<String, List<String>> options;
+
+ private List<String> credentials;
+
+ public IdentityObjectTypeMetaDataImpl()
+ {
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public List<RelationshipMetaData> getRelationships()
+ {
+ return relationships;
+ }
+
+ public void setRelationships(List<RelationshipMetaData> relationships)
+ {
+ this.relationships = relationships;
+ }
+
+ public List<IdentityObjectAttributeMetaData> getAttributes()
+ {
+ return attributes;
+ }
+
+ public void setAttributes(List<IdentityObjectAttributeMetaData> attributes)
+ {
+ this.attributes = attributes;
+ }
+
+ public List<String> getCredentials()
+ {
+ return credentials;
+ }
+
+ public void setCredentials(List<String> credentials)
+ {
+ this.credentials = credentials;
+ }
+
+ public Map<String, List<String>> getOptions()
+ {
+ return options;
+ }
+
+ public void setOptions(Map<String, List<String>> options)
+ {
+ this.options = options;
+ }
+
+ public List<String> getOption(String optionName)
+ {
+ if (options != null )
+ {
+ return options.get(optionName);
+ }
+
+ return null;
+ }
+
+ public String getOptionSingleValue(String optionName)
+ {
+ List<String> values = getOption(optionName);
+
+ if (values != null && values.size() > 0)
+ {
+ return values.get(0);
+ }
+
+ return null;
+ }
+}
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/metadata/IdentityRepositoryConfigurationMetaDataImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/metadata/IdentityRepositoryConfigurationMetaDataImpl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/metadata/IdentityRepositoryConfigurationMetaDataImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,10 +20,10 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.configuration.metadata;
+package org.jboss.identity.idm.impl.configuration.metadata;
-import org.jboss.identity.spi.configuration.metadata.IdentityRepositoryConfigurationMetaData;
-import org.jboss.identity.spi.configuration.metadata.IdentityStoreMappingMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityRepositoryConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreMappingMetaData;
import java.util.List;
import java.util.Map;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/metadata/IdentityStoreConfigurationMetaDataImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/metadata/IdentityStoreConfigurationMetaDataImpl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/metadata/IdentityStoreConfigurationMetaDataImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,10 +20,10 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.configuration.metadata;
+package org.jboss.identity.idm.impl.configuration.metadata;
-import org.jboss.identity.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
-import org.jboss.identity.spi.configuration.metadata.IdentityObjectTypeMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityObjectTypeMetaData;
import java.util.List;
import java.util.Map;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/metadata/IdentityStoreMappingMetaDataImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/metadata/IdentityStoreMappingMetaDataImpl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/metadata/IdentityStoreMappingMetaDataImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,9 +20,9 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.configuration.metadata;
+package org.jboss.identity.idm.impl.configuration.metadata;
-import org.jboss.identity.spi.configuration.metadata.IdentityStoreMappingMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreMappingMetaData;
import java.util.List;
import java.util.Map;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/metadata/RealmConfigurationMetaDataImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/metadata/RealmConfigurationMetaDataImpl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/metadata/RealmConfigurationMetaDataImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,9 +20,9 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.configuration.metadata;
+package org.jboss.identity.idm.impl.configuration.metadata;
-import org.jboss.identity.spi.configuration.metadata.RealmConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.RealmConfigurationMetaData;
import java.util.Map;
import java.util.List;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/metadata/RelationshipMetaDataImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/metadata/RelationshipMetaDataImpl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/configuration/metadata/RelationshipMetaDataImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,9 +20,9 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.configuration.metadata;
+package org.jboss.identity.idm.impl.configuration.metadata;
-import org.jboss.identity.spi.configuration.metadata.RelationshipMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.RelationshipMetaData;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/fedid/UUIDPseudonymGenerator.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/fedid/UUIDPseudonymGenerator.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/fedid/UUIDPseudonymGenerator.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -19,9 +19,9 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.fedid;
+package org.jboss.identity.idm.impl.fedid;
-import org.jboss.identity.spi.fedid.PseudonymGenerator;
+import org.jboss.identity.idm.spi.fedid.PseudonymGenerator;
/**
* Pseudonym generator that is
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/helper/Tools.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/helper/Tools.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/helper/Tools.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,7 +20,7 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.helper;
+package org.jboss.identity.idm.impl.helper;
import java.util.List;
import java.util.Enumeration;
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObject.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateIdentityObject.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObject.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,365 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.model.hibernate;
-
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.HashMap;
-import java.util.Collections;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Collection;
-
-import javax.persistence.Column;
-import javax.persistence.CascadeType;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.ManyToOne;
-import javax.persistence.OneToMany;
-import javax.persistence.Table;
-import javax.persistence.FetchType;
-import javax.persistence.UniqueConstraint;
-import javax.persistence.JoinColumn;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.JoinTable;
-
-import org.jboss.identity.exception.PolicyValidationException;
-import org.jboss.identity.exception.IdentityException;
-import org.jboss.identity.spi.model.IdentityObject;
-import org.jboss.identity.spi.model.IdentityObjectCredentialType;
-import org.jboss.identity.spi.model.IdentityObjectAttribute;
-import org.jboss.identity.spi.attribute.IdentityObjectAttributeMetaData;
-import org.hibernate.annotations.Cascade;
-import org.hibernate.annotations.CollectionOfElements;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
- at NamedQueries({
- @NamedQuery(
- name = "findIdentityObjectByNameAndType",
- query = "select o from HibernateIdentityObject o where o.realm like :realm and o.name like :name and o.identityType.name like :typeName"
- ),
- @NamedQuery(
- name = "findIdentityObjectsByType",
- query = "select o from HibernateIdentityObject o where o.name like :nameFilter and o.realm like :realm and o.identityType.name like :typeName"
- ),
- @NamedQuery(
- name = "findIdentityObjectsByTypeOrderedByNameAsc",
- query = "select o from HibernateIdentityObject o where o.name like :nameFilter and o.realm like :realm and o.identityType.name like :typeName " +
- "order by o.name asc"
- ),
- @NamedQuery(
- name = "findIdentityObjectsByTypeOrderedByNameDesc",
- query = "select o from HibernateIdentityObject o where o.name like :nameFilter and o.realm like :realm and o.identityType.name like :typeName " +
- "order by o.name desc"
- ),
- @NamedQuery(
- name = "countIdentityObjectsByType",
- query = "select count(o.id) from HibernateIdentityObject o where o.realm like :realm and o.identityType.name like :typeName"
- )
- })
- at Entity
- at Table(name = "identity_obj", uniqueConstraints = {@UniqueConstraint(columnNames = {"NAME", "IDENTITY_TYPE", "REALM"})})
-public class HibernateIdentityObject implements IdentityObject
-{
- @Id
- @GeneratedValue
- private Long id;
-
- @Column(name = "NAME", nullable = false)
- private String name;
-
- @ManyToOne(fetch = FetchType.EAGER)
- @JoinColumn(name = "IDENTITY_TYPE", nullable = false)
- private HibernateIdentityObjectType identityType;
-
- @OneToMany(mappedBy = "fromIdentityObject")
- private Set<HibernateIdentityObjectRelationship> fromRelationships = new HashSet<HibernateIdentityObjectRelationship>();
-
- @OneToMany(mappedBy = "toIdentityObject")
- private Set<HibernateIdentityObjectRelationship> toRelationships = new HashSet<HibernateIdentityObjectRelationship>();
-
- @OneToMany(fetch = FetchType.EAGER, cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE},
- mappedBy = "identityObject")
- @org.hibernate.annotations.Cascade(
- value = org.hibernate.annotations.CascadeType.DELETE_ORPHAN
- )
- private Set<HibernateIdentityObjectAttribute> attributes = new HashSet<HibernateIdentityObjectAttribute>();
-
- @CollectionOfElements
- @JoinTable(name = "identity_obj_properties", joinColumns = @JoinColumn(name = "IDENTITY_OBJ_ID"))
- @Column(name = "PROPERTY")
- private Map<String, String> properties = new HashMap<String, String>();
-
- @OneToMany(fetch = FetchType.EAGER, cascade = {CascadeType.ALL})
- @Cascade(value = org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
- private Map<String, HibernateIdentityObjectCredential> credentials = new HashMap<String, HibernateIdentityObjectCredential>();
-
- @ManyToOne(fetch = FetchType.EAGER)
- @JoinColumn(nullable = false, unique = false, name="REALM")
- private HibernateRealm realm;
-
- public HibernateIdentityObject()
- {
- }
-
- public HibernateIdentityObject(String name, HibernateIdentityObjectType identityType, HibernateRealm realm)
- {
- this.name = name;
- this.identityType = identityType;
- this.realm = realm;
- }
-
- public String getId()
- {
- return id.toString();
- }
-
- public void setId(String id)
- {
- this.id = Long.valueOf(id);
- }
-
- public String getName()
- {
- return name;
- }
-
- public void setName(String name)
- {
- this.name = name;
- }
-
- public HibernateIdentityObjectType getIdentityType()
- {
- return identityType;
- }
-
- public void setIdentityType(HibernateIdentityObjectType identityType)
- {
- this.identityType = identityType;
- }
-
- public String getFQDN()
- {
- return null;
- }
-
- public Set<HibernateIdentityObjectAttribute> getAttributes()
- {
- return attributes;
- }
-
- public void setAttributes(Set<HibernateIdentityObjectAttribute> attributes)
- {
- this.attributes = attributes;
- }
-
-// public Collection getAttribute(String name)
-// {
-// for (HibernateIdentityObjectAttribute attribute : attributes)
-// {
-// if (attribute.getName().equals(name))
-// {
-// return Collections.unmodifiableCollection(attribute.getValues());
-// }
-// }
-//
-//
-// return new HashSet<String>();
-// }
-//
- public Map<String, Collection> getAttributesAsMap()
- {
- Map<String, Collection> map = new HashMap<String, Collection>();
-
- for (HibernateIdentityObjectAttribute attribute : attributes)
- {
- Collection values = attribute.getValues();
- map.put(attribute.getName(), values);
- }
-
- return Collections.unmodifiableMap(map);
- }
-//
- public void addTextAttribute(String name, String[] values)
- {
- attributes.add(new HibernateIdentityObjectTextAttribute(this, name, values));
- }
-
-
- //
-// public void updateAttribute(String name, IdentityObjectAttribute attribute, IdentityObjectAttributeMetaData md)
-// throws IdentityException
-// {
-//
-// }
-//
-// public void addAttributeValues(String name, String[] values) throws IdentityException
-// {
-//
-// for (HibernateIdentityObjectAttribute attribute : attributes)
-// {
-// if (attribute.getName().equals(name))
-// {
-// Set<String> mergedValues = new HashSet<String>(attribute.getValues());
-// List<String> list = Arrays.asList(values);
-// mergedValues.addAll(new HashSet<String>(list));
-// attribute.setValues(mergedValues);
-//
-// return;
-// }
-// }
-//
-// addAttribute(name, values);
-// }
-//
-// public void updateAttributes(Map<String, Set<String>> values)
-// {
-// Set<HibernateIdentityObjectAttribute> newAttrs= new HashSet<HibernateIdentityObjectAttribute>();
-//
-// for (String name : values.keySet())
-// {
-// newAttrs.add(new HibernateIdentityObjectAttribute(this, name, new HashSet<String>(values.get(name))));
-// }
-//
-// attributes = newAttrs;
-// }
-
-
-
- public void removeAttribute(String name)
- {
- HibernateIdentityObjectAttribute attributeToRemove = null;
-
- for (HibernateIdentityObjectAttribute attribute : attributes)
- {
- if (attribute.getName().equals(name))
- {
- attributeToRemove = attribute;
- break;
- }
- }
-
- if (attributeToRemove != null)
- {
- attributes.remove(attributeToRemove);
- }
- }
-
- public Set<HibernateIdentityObjectRelationship> getFromRelationships()
- {
- return fromRelationships;
- }
-
- public void setFromRelationships(Set<HibernateIdentityObjectRelationship> fromRelationships)
- {
- this.fromRelationships = fromRelationships;
- }
-
- public void addFromRelationship(HibernateIdentityObjectRelationship fromRelationship)
- {
- fromRelationship.setFromIdentityObject(this);
- fromRelationships.add(fromRelationship);
- }
-
- public Set<HibernateIdentityObjectRelationship> getToRelationships()
- {
- return toRelationships;
- }
-
- public void setToRelationships(Set<HibernateIdentityObjectRelationship> toRelationships)
- {
- this.toRelationships = toRelationships;
- }
-
- public void addToRelationship(HibernateIdentityObjectRelationship toRelationship)
- {
- toRelationship.setToIdentityObject(this);
- fromRelationships.add(toRelationship);
- }
-
- public HibernateRealm getRealm()
- {
- return realm;
- }
-
- public void setRealm(HibernateRealm realm)
- {
- this.realm = realm;
- }
-
- public Map<String, HibernateIdentityObjectCredential> getCredentials()
- {
- return credentials;
- }
-
- public void setCredentials(Map<String, HibernateIdentityObjectCredential> credentials)
- {
- this.credentials = credentials;
- }
-
- public void addCredential(HibernateIdentityObjectCredential credential)
- {
- credential.setIdentityObject(this);
- credentials.put(credential.getType().getName(), credential);
- }
-
- public boolean hasCredentials()
- {
- if (credentials != null && credentials.size() > 0)
- {
- return true;
- }
- return false;
- }
-
- public boolean hasCredential(IdentityObjectCredentialType type)
- {
- if (credentials != null && credentials.keySet().contains(type.getName()))
- {
- return true;
- }
- return false;
- }
-
- public Map<String, String> getProperties()
- {
- return properties;
- }
-
- public void setProperties(Map<String, String> properties)
- {
- this.properties = properties;
- }
-
- public void validatePolicy() throws PolicyValidationException
- {
-
- }
-}
Copied: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObject.java (from rev 211, trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateIdentityObject.java)
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObject.java (rev 0)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObject.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,305 @@
+/*
+* 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.model.hibernate;
+
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.HashMap;
+import java.util.Collections;
+import java.util.Collection;
+
+import javax.persistence.Column;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import javax.persistence.FetchType;
+import javax.persistence.UniqueConstraint;
+import javax.persistence.JoinColumn;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.JoinTable;
+
+import org.jboss.identity.idm.exception.PolicyValidationException;
+import org.jboss.identity.idm.spi.model.IdentityObject;
+import org.jboss.identity.idm.spi.model.IdentityObjectCredentialType;
+import org.hibernate.annotations.Cascade;
+import org.hibernate.annotations.CollectionOfElements;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+ at NamedQueries({
+ @NamedQuery(
+ name = "findIdentityObjectByNameAndType",
+ query = "select o from HibernateIdentityObject o where o.realm like :realm and o.name like :name and o.identityType.name like :typeName"
+ ),
+ @NamedQuery(
+ name = "findIdentityObjectsByType",
+ query = "select o from HibernateIdentityObject o where o.name like :nameFilter and o.realm like :realm and o.identityType.name like :typeName"
+ ),
+ @NamedQuery(
+ name = "findIdentityObjectsByTypeOrderedByNameAsc",
+ query = "select o from HibernateIdentityObject o where o.name like :nameFilter and o.realm like :realm and o.identityType.name like :typeName " +
+ "order by o.name asc"
+ ),
+ @NamedQuery(
+ name = "findIdentityObjectsByTypeOrderedByNameDesc",
+ query = "select o from HibernateIdentityObject o where o.name like :nameFilter and o.realm like :realm and o.identityType.name like :typeName " +
+ "order by o.name desc"
+ ),
+ @NamedQuery(
+ name = "countIdentityObjectsByType",
+ query = "select count(o.id) from HibernateIdentityObject o where o.realm like :realm and o.identityType.name like :typeName"
+ )
+ })
+ at Entity
+ at Table(name = "identity_obj", uniqueConstraints = {@UniqueConstraint(columnNames = {"NAME", "IDENTITY_TYPE", "REALM"})})
+public class HibernateIdentityObject implements IdentityObject
+{
+ @Id
+ @GeneratedValue
+ private Long id;
+
+ @Column(name = "NAME", nullable = false)
+ private String name;
+
+ @ManyToOne(fetch = FetchType.EAGER)
+ @JoinColumn(name = "IDENTITY_TYPE", nullable = false)
+ private HibernateIdentityObjectType identityType;
+
+ @OneToMany(mappedBy = "fromIdentityObject")
+ private Set<HibernateIdentityObjectRelationship> fromRelationships = new HashSet<HibernateIdentityObjectRelationship>();
+
+ @OneToMany(mappedBy = "toIdentityObject")
+ private Set<HibernateIdentityObjectRelationship> toRelationships = new HashSet<HibernateIdentityObjectRelationship>();
+
+ @OneToMany(fetch = FetchType.EAGER, cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE},
+ mappedBy = "identityObject")
+ @org.hibernate.annotations.Cascade(
+ value = org.hibernate.annotations.CascadeType.DELETE_ORPHAN
+ )
+ private Set<HibernateIdentityObjectAttribute> attributes = new HashSet<HibernateIdentityObjectAttribute>();
+
+ @CollectionOfElements
+ @JoinTable(name = "identity_obj_properties", joinColumns = @JoinColumn(name = "IDENTITY_OBJ_ID"))
+ @Column(name = "PROPERTY")
+ private Map<String, String> properties = new HashMap<String, String>();
+
+ @OneToMany(fetch = FetchType.EAGER, cascade = {CascadeType.ALL})
+ @Cascade(value = org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
+ private Map<String, HibernateIdentityObjectCredential> credentials = new HashMap<String, HibernateIdentityObjectCredential>();
+
+ @ManyToOne(fetch = FetchType.EAGER)
+ @JoinColumn(nullable = false, unique = false, name="REALM")
+ private HibernateRealm realm;
+
+ public HibernateIdentityObject()
+ {
+ }
+
+ public HibernateIdentityObject(String name, HibernateIdentityObjectType identityType, HibernateRealm realm)
+ {
+ this.name = name;
+ this.identityType = identityType;
+ this.realm = realm;
+ }
+
+ public String getId()
+ {
+ return id.toString();
+ }
+
+ public void setId(String id)
+ {
+ this.id = Long.valueOf(id);
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public HibernateIdentityObjectType getIdentityType()
+ {
+ return identityType;
+ }
+
+ public void setIdentityType(HibernateIdentityObjectType identityType)
+ {
+ this.identityType = identityType;
+ }
+
+ public String getFQDN()
+ {
+ return null;
+ }
+
+ public Set<HibernateIdentityObjectAttribute> getAttributes()
+ {
+ return attributes;
+ }
+
+ public void setAttributes(Set<HibernateIdentityObjectAttribute> attributes)
+ {
+ this.attributes = attributes;
+ }
+
+ public Map<String, Collection> getAttributesAsMap()
+ {
+ Map<String, Collection> map = new HashMap<String, Collection>();
+
+ for (HibernateIdentityObjectAttribute attribute : attributes)
+ {
+ Collection values = attribute.getValues();
+ map.put(attribute.getName(), values);
+ }
+
+ return Collections.unmodifiableMap(map);
+ }
+
+ public void addTextAttribute(String name, String[] values)
+ {
+ attributes.add(new HibernateIdentityObjectTextAttribute(this, name, values));
+ }
+
+ public void removeAttribute(String name)
+ {
+ HibernateIdentityObjectAttribute attributeToRemove = null;
+
+ for (HibernateIdentityObjectAttribute attribute : attributes)
+ {
+ if (attribute.getName().equals(name))
+ {
+ attributeToRemove = attribute;
+ break;
+ }
+ }
+
+ if (attributeToRemove != null)
+ {
+ attributes.remove(attributeToRemove);
+ }
+ }
+
+ public Set<HibernateIdentityObjectRelationship> getFromRelationships()
+ {
+ return fromRelationships;
+ }
+
+ public void setFromRelationships(Set<HibernateIdentityObjectRelationship> fromRelationships)
+ {
+ this.fromRelationships = fromRelationships;
+ }
+
+ public void addFromRelationship(HibernateIdentityObjectRelationship fromRelationship)
+ {
+ fromRelationship.setFromIdentityObject(this);
+ fromRelationships.add(fromRelationship);
+ }
+
+ public Set<HibernateIdentityObjectRelationship> getToRelationships()
+ {
+ return toRelationships;
+ }
+
+ public void setToRelationships(Set<HibernateIdentityObjectRelationship> toRelationships)
+ {
+ this.toRelationships = toRelationships;
+ }
+
+ public void addToRelationship(HibernateIdentityObjectRelationship toRelationship)
+ {
+ toRelationship.setToIdentityObject(this);
+ fromRelationships.add(toRelationship);
+ }
+
+ public HibernateRealm getRealm()
+ {
+ return realm;
+ }
+
+ public void setRealm(HibernateRealm realm)
+ {
+ this.realm = realm;
+ }
+
+ public Map<String, HibernateIdentityObjectCredential> getCredentials()
+ {
+ return credentials;
+ }
+
+ public void setCredentials(Map<String, HibernateIdentityObjectCredential> credentials)
+ {
+ this.credentials = credentials;
+ }
+
+ public void addCredential(HibernateIdentityObjectCredential credential)
+ {
+ credential.setIdentityObject(this);
+ credentials.put(credential.getType().getName(), credential);
+ }
+
+ public boolean hasCredentials()
+ {
+ if (credentials != null && credentials.size() > 0)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ public boolean hasCredential(IdentityObjectCredentialType type)
+ {
+ if (credentials != null && credentials.keySet().contains(type.getName()))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ public Map<String, String> getProperties()
+ {
+ return properties;
+ }
+
+ public void setProperties(Map<String, String> properties)
+ {
+ this.properties = properties;
+ }
+
+ public void validatePolicy() throws PolicyValidationException
+ {
+
+ }
+}
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectAttribute.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateIdentityObjectAttribute.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectAttribute.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,17 +20,14 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.model.hibernate;
+package org.jboss.identity.idm.impl.model.hibernate;
-import org.hibernate.annotations.CollectionOfElements;
-import org.jboss.identity.spi.model.IdentityObjectAttribute;
+import org.jboss.identity.idm.spi.model.IdentityObjectAttribute;
import javax.persistence.Entity;
import javax.persistence.Table;
-import javax.persistence.OneToMany;
import javax.persistence.Id;
import javax.persistence.GeneratedValue;
-import javax.persistence.Embedded;
import javax.persistence.Column;
import javax.persistence.ManyToOne;
import javax.persistence.JoinColumn;
@@ -38,9 +35,6 @@
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import java.util.Set;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Arrays;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectBinaryAttribute.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateIdentityObjectBinaryAttribute.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectBinaryAttribute.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,7 +20,7 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.model.hibernate;
+package org.jboss.identity.idm.impl.model.hibernate;
import org.hibernate.annotations.CollectionOfElements;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectCredential.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateIdentityObjectCredential.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectCredential.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,9 +20,9 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.model.hibernate;
+package org.jboss.identity.idm.impl.model.hibernate;
-import org.jboss.identity.spi.model.IdentityObjectCredential;
+import org.jboss.identity.idm.spi.model.IdentityObjectCredential;
import org.hibernate.annotations.CollectionOfElements;
import javax.persistence.Entity;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectCredentialType.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateIdentityObjectCredentialType.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectCredentialType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,9 +20,9 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.model.hibernate;
+package org.jboss.identity.idm.impl.model.hibernate;
-import org.jboss.identity.spi.model.IdentityObjectCredentialType;
+import org.jboss.identity.idm.spi.model.IdentityObjectCredentialType;
import javax.persistence.Entity;
import javax.persistence.Table;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectRelationship.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateIdentityObjectRelationship.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectRelationship.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,7 +20,7 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.model.hibernate;
+package org.jboss.identity.idm.impl.model.hibernate;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -31,14 +31,12 @@
import javax.persistence.NamedQuery;
import javax.persistence.JoinColumn;
import javax.persistence.UniqueConstraint;
-import javax.persistence.Column;
import javax.persistence.FetchType;
-import org.jboss.identity.spi.model.IdentityObjectRelationship;
-import org.jboss.identity.spi.model.IdentityObjectRelationshipType;
-import org.jboss.identity.impl.model.hibernate.HibernateIdentityObject;
-import org.jboss.identity.impl.model.hibernate.HibernateIdentityObjectRelationshipType;
-import org.hibernate.annotations.Fetch;
+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;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectRelationshipName.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateIdentityObjectRelationshipName.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectRelationshipName.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,7 +20,7 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.model.hibernate;
+package org.jboss.identity.idm.impl.model.hibernate;
import javax.persistence.Table;
import javax.persistence.Entity;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectRelationshipType.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateIdentityObjectRelationshipType.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectRelationshipType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,7 +20,7 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.model.hibernate;
+package org.jboss.identity.idm.impl.model.hibernate;
import javax.persistence.Column;
import javax.persistence.Entity;
@@ -29,10 +29,8 @@
import javax.persistence.Table;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
-import javax.persistence.ManyToOne;
-import javax.persistence.JoinColumn;
-import org.jboss.identity.spi.model.IdentityObjectRelationshipType;
+import org.jboss.identity.idm.spi.model.IdentityObjectRelationshipType;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectTextAttribute.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateIdentityObjectTextAttribute.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectTextAttribute.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,7 +20,7 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.model.hibernate;
+package org.jboss.identity.idm.impl.model.hibernate;
import org.hibernate.annotations.CollectionOfElements;
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectType.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateIdentityObjectType.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateIdentityObjectType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,7 +20,7 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.model.hibernate;
+package org.jboss.identity.idm.impl.model.hibernate;
import javax.persistence.Column;
import javax.persistence.Entity;
@@ -30,7 +30,7 @@
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
-import org.jboss.identity.spi.model.IdentityObjectType;
+import org.jboss.identity.idm.spi.model.IdentityObjectType;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateRealm.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateRealm.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/hibernate/HibernateRealm.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,7 +20,7 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.model.hibernate;
+package org.jboss.identity.idm.impl.model.hibernate;
import org.hibernate.annotations.CollectionOfElements;
@@ -30,20 +30,12 @@
import javax.persistence.Id;
import javax.persistence.GeneratedValue;
import javax.persistence.Column;
-import javax.persistence.OneToMany;
-import javax.persistence.FetchType;
-import javax.persistence.CascadeType;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.JoinTable;
import javax.persistence.JoinColumn;
import java.util.Map;
import java.util.HashMap;
-import java.util.Set;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Arrays;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/ldap/LDAPIdentityObjectImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/ldap/LDAPIdentityObjectImpl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/ldap/LDAPIdentityObjectImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,85 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.model.ldap;
-
-import org.jboss.identity.spi.model.IdentityObject;
-import org.jboss.identity.spi.model.IdentityObjectType;
-import org.jboss.identity.exception.PolicyValidationException;
-
-import java.util.Set;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class LDAPIdentityObjectImpl implements IdentityObject
-{
- private String dn;
-
- private String id;
-
- private IdentityObjectType type;
-
- public LDAPIdentityObjectImpl(String dn, String id, IdentityObjectType type)
- {
- this.dn = dn;
- this.id = id;
- this.type = type;
- }
-
- public String getId()
- {
- return dn;
- }
-
- public String getDn()
- {
- return dn;
- }
-
- public String getFQDN()
- {
- return null;
- }
-
- public String getName()
- {
- return id;
- }
-
- public IdentityObjectType getIdentityType()
- {
- return type;
- }
-
- public Map<String, Set<String>> getAttributes()
- {
- return null;
- }
-
- public void validatePolicy() throws PolicyValidationException
- {
-
- }
-}
Copied: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/ldap/LDAPIdentityObjectImpl.java (from rev 211, trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/ldap/LDAPIdentityObjectImpl.java)
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/ldap/LDAPIdentityObjectImpl.java (rev 0)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/ldap/LDAPIdentityObjectImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,80 @@
+/*
+* 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.model.ldap;
+
+import org.jboss.identity.idm.spi.model.IdentityObject;
+import org.jboss.identity.idm.spi.model.IdentityObjectType;
+import org.jboss.identity.idm.exception.PolicyValidationException;
+
+import java.util.Set;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class LDAPIdentityObjectImpl implements IdentityObject
+{
+ private String dn;
+
+ private String id;
+
+ private IdentityObjectType type;
+
+ public LDAPIdentityObjectImpl(String dn, String id, IdentityObjectType type)
+ {
+ this.dn = dn;
+ this.id = id;
+ this.type = type;
+ }
+
+ public String getId()
+ {
+ return dn;
+ }
+
+ public String getDn()
+ {
+ return dn;
+ }
+
+ public String getName()
+ {
+ return id;
+ }
+
+ public IdentityObjectType getIdentityType()
+ {
+ return type;
+ }
+
+ public Map<String, Set<String>> getAttributes()
+ {
+ return null;
+ }
+
+ public void validatePolicy() throws PolicyValidationException
+ {
+
+ }
+}
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/ldap/LDAPIdentityObjectRelationshipImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/ldap/LDAPIdentityObjectRelationshipImpl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/ldap/LDAPIdentityObjectRelationshipImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,79 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.model.ldap;
-
-import org.jboss.identity.spi.model.IdentityObjectRelationship;
-import org.jboss.identity.spi.model.IdentityObjectRelationshipType;
-import org.jboss.identity.spi.model.IdentityObject;
-import org.jboss.identity.spi.model.IdentityObjectType;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class LDAPIdentityObjectRelationshipImpl implements IdentityObjectRelationship
-{
-
- private final String name;
-
- private final IdentityObject from;
-
- private final IdentityObject to;
-
- //TODO:
- //private final IdentityObjectType type;
-
- public LDAPIdentityObjectRelationshipImpl(String name, IdentityObject from, IdentityObject to)
- {
- this.name = name;
- this.from = from;
- this.to = to;
- }
-
- public String getName()
- {
- return name;
- }
-
- public IdentityObjectRelationshipType getType()
- {
- //TODO
- return new IdentityObjectRelationshipType()
- {
- public String getName()
- {
- return "";
- }
- };
- }
-
- public IdentityObject getFromIdentityObject()
- {
- return from;
- }
-
- public IdentityObject getToIdentityObject()
- {
- return to;
- }
-}
Copied: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/ldap/LDAPIdentityObjectRelationshipImpl.java (from rev 211, trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/ldap/LDAPIdentityObjectRelationshipImpl.java)
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/ldap/LDAPIdentityObjectRelationshipImpl.java (rev 0)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/model/ldap/LDAPIdentityObjectRelationshipImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,78 @@
+/*
+* 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.model.ldap;
+
+import org.jboss.identity.idm.spi.model.IdentityObjectRelationship;
+import org.jboss.identity.idm.spi.model.IdentityObjectRelationshipType;
+import org.jboss.identity.idm.spi.model.IdentityObject;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class LDAPIdentityObjectRelationshipImpl implements IdentityObjectRelationship
+{
+
+ private final String name;
+
+ private final IdentityObject from;
+
+ private final IdentityObject to;
+
+ //TODO:
+ //private final IdentityObjectType type;
+
+ public LDAPIdentityObjectRelationshipImpl(String name, IdentityObject from, IdentityObject to)
+ {
+ this.name = name;
+ this.from = from;
+ this.to = to;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public IdentityObjectRelationshipType getType()
+ {
+ //TODO: for now just hardcoded value
+ return new IdentityObjectRelationshipType()
+ {
+ public String getName()
+ {
+ return "JBOSS_IDENTITY_MEMBERSHIP";
+ }
+ };
+ }
+
+ public IdentityObject getFromIdentityObject()
+ {
+ return from;
+ }
+
+ public IdentityObject getToIdentityObject()
+ {
+ return to;
+ }
+}
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/repository/AbstractIdentityStoreRepository.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/repository/AbstractIdentityStoreRepository.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/repository/AbstractIdentityStoreRepository.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,126 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.repository;
-
-import org.jboss.identity.spi.repository.IdentityStoreRepository;
-import org.jboss.identity.spi.store.IdentityStore;
-import org.jboss.identity.spi.store.AttributeStore;
-import org.jboss.identity.spi.store.IdentityStoreInvocationContext;
-import org.jboss.identity.spi.model.IdentityObjectType;
-import org.jboss.identity.spi.model.IdentityObject;
-import org.jboss.identity.spi.configuration.metadata.IdentityRepositoryConfigurationMetaData;
-import org.jboss.identity.spi.configuration.metadata.IdentityStoreMappingMetaData;
-import org.jboss.identity.exception.IdentityException;
-
-import java.util.Set;
-import java.util.Map;
-import java.util.HashSet;
-import java.util.List;
-import java.util.HashMap;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public abstract class AbstractIdentityStoreRepository implements IdentityStoreRepository
-{
-
- protected Map<String, IdentityStore> identityStoreMappings = new HashMap<String, IdentityStore>();
-
- protected Map<String, AttributeStore> attributeStoreMappings = new HashMap<String, AttributeStore>();
-
- public void bootstrap(IdentityRepositoryConfigurationMetaData configurationMD,
- Map<String, IdentityStore> bootstrappedIdentityStores,
- Map<String, AttributeStore> bootstrappedAttributeStores) throws IdentityException
- {
-
- for (IdentityStoreMappingMetaData identityStoreMappingMetaData : configurationMD.getIdentityStoreToIdentityObjectTypeMappings())
- {
- String storeId = identityStoreMappingMetaData.getIdentityStoreId();
- List<String> identityObjectTypeMappings = identityStoreMappingMetaData.getIdentityObjectTypeMappings();
-
- IdentityStore store = bootstrappedIdentityStores.get(storeId);
-
- if (store == null)
- {
- throw new IdentityException("Mapped IdentityStore not available: " + storeId);
- }
-
- for (String mapping : identityObjectTypeMappings)
- {
- identityStoreMappings.put(mapping, store);
- attributeStoreMappings.put(mapping, store);
- }
-
- }
-
- }
-
- public Set<IdentityStore> getConfiguredIdentityStores()
- {
- return new HashSet<IdentityStore>(identityStoreMappings.values());
- }
-
- public Set<AttributeStore> getConfiguredAttributeStores()
- {
- return new HashSet<AttributeStore>(attributeStoreMappings.values());
- }
-
- public Map<String, IdentityStore> getIdentityStoreMappings()
- {
- return identityStoreMappings;
- }
-
- public Map<String, AttributeStore> getAttributeStoreMappings()
- {
- return attributeStoreMappings;
- }
-
- public IdentityStore getIdentityStore(IdentityObjectType identityObjectType)
- {
- return identityStoreMappings.get(identityObjectType.getName());
- }
-
- public AttributeStore getAttributeStore(IdentityObjectType identityObjectType)
- {
- return attributeStoreMappings.get(identityObjectType.getName());
- }
-
- protected boolean hasIdentityObject(IdentityStoreInvocationContext ctx, IdentityStore is, IdentityObject io) throws IdentityException
- {
- try
- {
- if (is.findIdentityObject(ctx, io.getName(), io.getIdentityType()) != null)
- {
- return true;
- }
- }
- catch (IdentityException e)
- {
- //store may throw exception if there is no identity so do nothing
- //TODO: this behaviour sucks...
-
- }
- return false;
- }
-}
Copied: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/repository/AbstractIdentityStoreRepository.java (from rev 211, trunk/identity-impl/src/main/java/org/jboss/identity/impl/repository/AbstractIdentityStoreRepository.java)
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/repository/AbstractIdentityStoreRepository.java (rev 0)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/repository/AbstractIdentityStoreRepository.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,126 @@
+/*
+* 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.repository;
+
+import org.jboss.identity.idm.spi.repository.IdentityStoreRepository;
+import org.jboss.identity.idm.spi.store.IdentityStore;
+import org.jboss.identity.idm.spi.store.AttributeStore;
+import org.jboss.identity.idm.spi.store.IdentityStoreInvocationContext;
+import org.jboss.identity.idm.spi.model.IdentityObjectType;
+import org.jboss.identity.idm.spi.model.IdentityObject;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityRepositoryConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreMappingMetaData;
+import org.jboss.identity.idm.exception.IdentityException;
+
+import java.util.Set;
+import java.util.Map;
+import java.util.HashSet;
+import java.util.List;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public abstract class AbstractIdentityStoreRepository implements IdentityStoreRepository
+{
+
+ protected Map<String, IdentityStore> identityStoreMappings = new HashMap<String, IdentityStore>();
+
+ protected Map<String, AttributeStore> attributeStoreMappings = new HashMap<String, AttributeStore>();
+
+ public void bootstrap(IdentityRepositoryConfigurationMetaData configurationMD,
+ Map<String, IdentityStore> bootstrappedIdentityStores,
+ Map<String, AttributeStore> bootstrappedAttributeStores) throws IdentityException
+ {
+
+ for (IdentityStoreMappingMetaData identityStoreMappingMetaData : configurationMD.getIdentityStoreToIdentityObjectTypeMappings())
+ {
+ String storeId = identityStoreMappingMetaData.getIdentityStoreId();
+ List<String> identityObjectTypeMappings = identityStoreMappingMetaData.getIdentityObjectTypeMappings();
+
+ IdentityStore store = bootstrappedIdentityStores.get(storeId);
+
+ if (store == null)
+ {
+ throw new IdentityException("Mapped IdentityStore not available: " + storeId);
+ }
+
+ for (String mapping : identityObjectTypeMappings)
+ {
+ identityStoreMappings.put(mapping, store);
+ attributeStoreMappings.put(mapping, store);
+ }
+
+ }
+
+ }
+
+ public Set<IdentityStore> getConfiguredIdentityStores()
+ {
+ return new HashSet<IdentityStore>(identityStoreMappings.values());
+ }
+
+ public Set<AttributeStore> getConfiguredAttributeStores()
+ {
+ return new HashSet<AttributeStore>(attributeStoreMappings.values());
+ }
+
+ public Map<String, IdentityStore> getIdentityStoreMappings()
+ {
+ return identityStoreMappings;
+ }
+
+ public Map<String, AttributeStore> getAttributeStoreMappings()
+ {
+ return attributeStoreMappings;
+ }
+
+ public IdentityStore getIdentityStore(IdentityObjectType identityObjectType)
+ {
+ return identityStoreMappings.get(identityObjectType.getName());
+ }
+
+ public AttributeStore getAttributeStore(IdentityObjectType identityObjectType)
+ {
+ return attributeStoreMappings.get(identityObjectType.getName());
+ }
+
+ protected boolean hasIdentityObject(IdentityStoreInvocationContext ctx, IdentityStore is, IdentityObject io) throws IdentityException
+ {
+ try
+ {
+ if (is.findIdentityObject(ctx, io.getName(), io.getIdentityType()) != null)
+ {
+ return true;
+ }
+ }
+ catch (IdentityException e)
+ {
+ //store may throw exception if there is no identity so do nothing
+ //TODO: should have isIdentityPresent method
+
+ }
+ return false;
+ }
+}
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/repository/FallbackIdentityStoreRepository.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/repository/FallbackIdentityStoreRepository.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/repository/FallbackIdentityStoreRepository.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,999 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.repository;
-
-import org.jboss.identity.spi.store.IdentityStore;
-import org.jboss.identity.spi.store.AttributeStore;
-import org.jboss.identity.spi.store.FeaturesMetaData;
-import org.jboss.identity.spi.store.IdentityStoreInvocationContext;
-import org.jboss.identity.spi.store.IdentityStoreSession;
-import org.jboss.identity.spi.searchcontrol.IdentityObjectSearchControl;
-import org.jboss.identity.spi.model.IdentityObject;
-import org.jboss.identity.spi.model.IdentityObjectType;
-import org.jboss.identity.spi.model.IdentityObjectRelationshipType;
-import org.jboss.identity.spi.model.IdentityObjectRelationship;
-import org.jboss.identity.spi.exception.OperationNotSupportedException;
-import org.jboss.identity.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
-import org.jboss.identity.spi.configuration.metadata.IdentityRepositoryConfigurationMetaData;
-import org.jboss.identity.spi.model.IdentityObjectCredential;
-import org.jboss.identity.spi.model.IdentityObjectCredentialType;
-import org.jboss.identity.spi.model.IdentityObjectAttribute;
-import org.jboss.identity.spi.attribute.IdentityObjectAttributeMetaData;
-import org.jboss.identity.exception.IdentityException;
-import org.jboss.identity.impl.store.SimpleIdentityStoreInvocationContext;
-import org.jboss.identity.impl.api.PageSearchControl;
-import org.jboss.identity.impl.api.SortByNameSearchControl;
-
-import java.util.Map;
-import java.util.Collection;
-import java.util.Set;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.LinkedList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Arrays;
-import java.util.ArrayList;
-
-/**
- * <p>In FallbackIdentityStoreRepository one IdentityStore plays the role of default store. Any operation that cannot be
- * handled with other IdentityObjectType/IdentityStore mappings will fallback to such IdentityStore. The most common example
- * is RDBMS + LDAP configuration. LDAP has limmited schema for possible profile attributes so for LDAP entries part of
- * profile can be stored in RDBMS by syncing entries into default store.</p>
- * <p>For any relationship that is not supported in other stores, or between entries persisted in two different stores,
- * proper IdentityObjects will be synced to default store and if possible, such relationship will be created. </p>
- *
- *
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class FallbackIdentityStoreRepository extends AbstractIdentityStoreRepository
-{
- //TODO: - relationships in default store - after resolving relationships for synced IOs those IOs need to be retreived from proper stores once again
- //TODO: if they don't exist such relationship + synced identities need to be cleanedup from default store
- //TODO: - filter out controls based on features MD before passing
- //TODO: - configuration option to store not mapped attributes in default store
- //TODO: - configuration option to fallback named relationships to default store when not supported in mapped one
-
- private final String id;
-
- private IdentityStore defaultIdentityStore;
-
- private AttributeStore defaultAttributeStore;
-
- //TODO: rewrite this to other config object?
- private IdentityRepositoryConfigurationMetaData configurationMD;
-
- public static final String ALLOW_NOT_DEFINED_ATTRIBUTES = "allowNotDefinedAttributes";
-
- private FeaturesMetaData featuresMetaData;
-
- private boolean allowNotDefinedAttributes = false;
-
- private final Set<IdentityStore> configuredIdentityStores = new HashSet<IdentityStore>();
-
- public FallbackIdentityStoreRepository(String id)
- {
- this.id = id;
- }
-
- public void bootstrap(IdentityRepositoryConfigurationMetaData configurationMD,
- Map<String, IdentityStore> bootstrappedIdentityStores,
- Map<String, AttributeStore> bootstrappedAttributeStores) throws IdentityException
- {
- super.bootstrap(configurationMD, bootstrappedIdentityStores, bootstrappedAttributeStores);
-
- // Helper collection to keep all identity stores in use
-
- if (getIdentityStoreMappings().size() > 0)
- {
- configuredIdentityStores.addAll(getIdentityStoreMappings().values());
- }
-
-
-
- this.configurationMD = configurationMD;
-
- String asId = configurationMD.getDefaultAttributeStroeId();
- String isId = configurationMD.getDefaultIdentityStoreId();
-
- if (asId != null && bootstrappedAttributeStores.keySet().contains(asId))
- {
- defaultAttributeStore = bootstrappedAttributeStores.get(asId);
- }
-
- if (isId != null && bootstrappedIdentityStores.keySet().contains(isId))
- {
- defaultIdentityStore = bootstrappedIdentityStores.get(isId);
-
- if (!getIdentityStoreMappings().keySet().contains(defaultIdentityStore.getId()))
- {
- configuredIdentityStores.add(defaultIdentityStore);
- }
-
- }
-
- String allowNotDefineAttributes = configurationMD.getOptionSingleValue(ALLOW_NOT_DEFINED_ATTRIBUTES);
-
- if (allowNotDefineAttributes != null && allowNotDefineAttributes.equalsIgnoreCase("true"))
- {
- this.allowNotDefinedAttributes = true;
- }
-
- // A wrapper around all stores features meta data
- featuresMetaData = new FeaturesMetaData()
- {
-
- public boolean isNamedRelationshipsSupported()
- {
- // If there is any IdentityStore that supports named relationships...
- for (IdentityStore identityStore : getIdentityStoreMappings().values())
- {
- if (identityStore.getSupportedFeatures().isNamedRelationshipsSupported())
- {
- return true;
- }
- }
- return defaultIdentityStore.getSupportedFeatures().isNamedRelationshipsSupported();
- }
-
- public boolean isControlSupported(IdentityObjectType identityObjectType, IdentityObjectSearchControl control)
- {
- return resolveIdentityStore(identityObjectType).getSupportedFeatures().isControlSupported(identityObjectType, control);
- }
-
- public boolean isControlSupported(IdentityObjectType identityObjectType, Class controlClazz)
- {
- return resolveIdentityStore(identityObjectType).getSupportedFeatures().isControlSupported(identityObjectType, controlClazz);
- }
-
- public Set<String> getSupportedIdentityObjectTypes()
- {
- Set<String> supportedIOTs = new HashSet<String>();
-
- for (IdentityStore identityStore : getIdentityStoreMappings().values())
- {
- supportedIOTs.addAll(identityStore.getSupportedFeatures().getSupportedIdentityObjectTypes());
- }
- supportedIOTs.addAll(defaultIdentityStore.getSupportedFeatures().getSupportedRelationshipTypes());
-
- return supportedIOTs;
- }
-
- public boolean isIdentityObjectTypeSupported(IdentityObjectType identityObjectType)
- {
- return resolveIdentityStore(identityObjectType).getSupportedFeatures().isIdentityObjectTypeSupported(identityObjectType);
- }
-
- public boolean isRelationshipTypeSupported(IdentityObjectType fromType, IdentityObjectType toType, IdentityObjectRelationshipType relationshipType) throws IdentityException
- {
- IdentityStore fromStore = resolveIdentityStore(fromType);
-
- IdentityStore toStore = resolveIdentityStore(toType);
-
- if (fromStore == toStore)
- {
- return fromStore.getSupportedFeatures().isRelationshipTypeSupported(fromType, toType, relationshipType);
- }
- else
- {
- return defaultIdentityStore.getSupportedFeatures().isRelationshipTypeSupported(fromType, toType, relationshipType);
- }
-
- }
-
- public Set<String> getSupportedRelationshipTypes()
- {
- Set<String> supportedRelTypes = new HashSet<String>();
-
- for (IdentityStore identityStore : getIdentityStoreMappings().values())
- {
- supportedRelTypes.addAll(identityStore.getSupportedFeatures().getSupportedRelationshipTypes());
- }
- supportedRelTypes.addAll(defaultIdentityStore.getSupportedFeatures().getSupportedRelationshipTypes());
-
- return supportedRelTypes;
- }
-
- public boolean isCredentialSupported(IdentityObjectType identityObjectType, IdentityObjectCredentialType credentialType)
- {
- return resolveIdentityStore(identityObjectType).getSupportedFeatures().isCredentialSupported(identityObjectType, credentialType);
- }
- };
-
- }
-
- public void bootstrap(IdentityStoreConfigurationMetaData configurationMD) throws IdentityException
- {
- // Nothing
- }
-
- public IdentityStoreSession createIdentityStoreSession() throws IdentityException
- {
- Map<String, IdentityStoreSession> sessions = new HashMap<String, IdentityStoreSession>();
-
- for (IdentityStore identityStore : identityStoreMappings.values())
- {
- sessions.put(identityStore.getId(), identityStore.createIdentityStoreSession());
- }
-
- for (AttributeStore attributeStore : attributeStoreMappings.values())
- {
- if (!sessions.containsKey(attributeStore.getId()))
- {
- sessions.put(attributeStore.getId(), attributeStore.createIdentityStoreSession());
- }
- }
-
- if (!sessions.containsKey(defaultAttributeStore.getId()))
- {
- sessions.put(defaultAttributeStore.getId(), defaultAttributeStore.createIdentityStoreSession());
- }
-
- if (!sessions.containsKey(defaultIdentityStore.getId()))
- {
- sessions.put(defaultIdentityStore.getId(), defaultIdentityStore.createIdentityStoreSession());
- }
-
- return new RepositoryIdentityStoreSessionImpl(sessions);
- }
-
- public String getId()
- {
- return id;
- }
-
- public FeaturesMetaData getSupportedFeatures()
- {
- return featuresMetaData;
- }
-
- IdentityStore resolveIdentityStore(IdentityObject io)
- {
- return resolveIdentityStore(io.getIdentityType());
- }
-
- IdentityStore resolveIdentityStore(IdentityObjectType iot)
- {
- IdentityStore ids = getIdentityStore(iot);
- if (ids == null)
- {
- ids = defaultIdentityStore;
- }
- return ids;
- }
-
- AttributeStore resolveAttributeStore(IdentityObjectType iot)
- {
- AttributeStore ads = getAttributeStore(iot);
- if (ads == null)
- {
- ads = defaultIdentityStore;
- }
- return ads;
- }
-
- IdentityStoreInvocationContext resolveInvocationContext(IdentityStore targetStore, IdentityStoreInvocationContext invocationCtx)
- {
- return resolveInvocationContext(targetStore.getId(), invocationCtx);
-
- }
-
- IdentityStoreInvocationContext resolveInvocationContext(AttributeStore targetStore, IdentityStoreInvocationContext invocationCtx)
- {
- return resolveInvocationContext(targetStore.getId(), invocationCtx);
-
- }
-
- IdentityStoreInvocationContext resolveInvocationContext(String id, IdentityStoreInvocationContext invocationCtx)
- {
- RepositoryIdentityStoreSessionImpl repoSession = (RepositoryIdentityStoreSessionImpl)invocationCtx.getIdentityStoreSession();
- IdentityStoreSession targetSession = repoSession.getIdentityStoreSession(id);
-
- return new SimpleIdentityStoreInvocationContext(targetSession, invocationCtx.getRealmId());
-
- }
-
- public IdentityObject createIdentityObject(IdentityStoreInvocationContext invocationCtx, String name, IdentityObjectType identityObjectType) throws IdentityException
- {
- IdentityStore targetStore = resolveIdentityStore(identityObjectType);
- IdentityStoreInvocationContext targetCtx = resolveInvocationContext(targetStore, invocationCtx);
- return targetStore.createIdentityObject(targetCtx, name, identityObjectType);
- }
-
- public IdentityObject createIdentityObject(IdentityStoreInvocationContext invocationCtx, String name, IdentityObjectType identityObjectType, Map<String, String[]> attributes) throws IdentityException
- {
- IdentityStore targetStore = resolveIdentityStore(identityObjectType);
- IdentityStoreInvocationContext targetCtx = resolveInvocationContext(targetStore, invocationCtx);
- return targetStore.createIdentityObject(targetCtx, name, identityObjectType, attributes);
- }
-
- public void removeIdentityObject(IdentityStoreInvocationContext invocationCtx, IdentityObject identity) throws IdentityException
- {
- IdentityStore targetStore = resolveIdentityStore(identity);
- IdentityStoreInvocationContext targetCtx = resolveInvocationContext(targetStore, invocationCtx);
-
- targetStore.removeIdentityObject(targetCtx, identity);
- }
-
- public int getIdentityObjectsCount(IdentityStoreInvocationContext invocationCtx, IdentityObjectType identityType) throws IdentityException
- {
- IdentityStore targetStore = resolveIdentityStore(identityType);
- IdentityStoreInvocationContext targetCtx = resolveInvocationContext(targetStore, invocationCtx);
-
- return targetStore.getIdentityObjectsCount(targetCtx, identityType);
- }
-
- public IdentityObject findIdentityObject(IdentityStoreInvocationContext invocationContext, String name, IdentityObjectType identityObjectType) throws IdentityException
- {
- IdentityStore targetStore = resolveIdentityStore(identityObjectType);
- IdentityStoreInvocationContext targetCtx = resolveInvocationContext(targetStore, invocationContext);
-
- return targetStore.findIdentityObject(targetCtx, name, identityObjectType);
- }
-
- public IdentityObject findIdentityObject(IdentityStoreInvocationContext invocationContext, String id) throws IdentityException
- {
- //TODO: information about the store mapping should be encoded in type as now its like random guess...
-
- for (IdentityStore identityStore : getIdentityStoreMappings().values())
- {
- IdentityStoreInvocationContext targetCtx = resolveInvocationContext(identityStore, invocationContext);
-
- IdentityObject io = identityStore.findIdentityObject(targetCtx, id);
- if (io != null)
- {
- return io;
- }
- }
-
- return defaultIdentityStore.findIdentityObject(invocationContext, id);
- }
-
- public Collection<IdentityObject> findIdentityObject(IdentityStoreInvocationContext invocationCtx, IdentityObjectType identityType, IdentityObjectSearchControl[] controls) throws IdentityException
- {
- IdentityStore targetStore = resolveIdentityStore(identityType);
- IdentityStoreInvocationContext targetCtx = resolveInvocationContext(targetStore, invocationCtx);
-
- return targetStore.findIdentityObject(targetCtx, identityType, controls);
- }
-
- public Collection<IdentityObject> findIdentityObject(IdentityStoreInvocationContext invocationCxt,
- IdentityObject identity,
- IdentityObjectRelationshipType relationshipType,
- boolean parent,
- IdentityObjectSearchControl[] controls) throws IdentityException
- {
- // Check in the mapped store and merge with default
-
- IdentityStore mappedStore = resolveIdentityStore(identity);
-
- IdentityStoreInvocationContext mappedCtx = resolveInvocationContext(mappedStore, invocationCxt);
-
- IdentityStoreInvocationContext defaultCtx = resolveInvocationContext(defaultIdentityStore, invocationCxt);
-
-
- if (mappedStore == defaultIdentityStore)
- {
- return defaultIdentityStore.findIdentityObject(defaultCtx, identity, relationshipType, parent, controls);
- }
-
- Collection<IdentityObject> results = mappedStore.findIdentityObject(mappedCtx, identity, relationshipType, parent, controls);
-
- Collection<IdentityObject> objects = defaultIdentityStore.findIdentityObject(defaultCtx, identity, relationshipType, parent, controls);
-
- PageSearchControl pageSearchControl = null;
- SortByNameSearchControl sortSearchControl = null;
-
- if (controls != null)
- {
- for (IdentityObjectSearchControl control : controls)
- {
- if (control instanceof PageSearchControl)
- {
- pageSearchControl = (PageSearchControl)control;
- }
- else if (control instanceof SortByNameSearchControl)
- {
- sortSearchControl = (SortByNameSearchControl)control;
- }
- }
- }
-
-
- // If default store contain related relationships merge and sort/page once more
- if (objects != null && objects.size() != 0)
- {
- results.addAll(objects);
-
- //TODO: hardcoded List
- if (pageSearchControl != null && results instanceof List)
- {
- results = cutPageFromResults((List<IdentityObject>)results, pageSearchControl);
- }
-
- //TODO: hardcoded List
- if (sortSearchControl != null && results instanceof List)
- {
- sortByName((List<IdentityObject>)results, sortSearchControl.isAscending());
- }
- }
-
- return results;
-
- }
-
- public IdentityObjectRelationship createRelationship(IdentityStoreInvocationContext invocationCxt, IdentityObject fromIdentity, IdentityObject toIdentity, IdentityObjectRelationshipType relationshipType, String relationshipName, boolean createNames) throws IdentityException
- {
- IdentityStore fromStore = resolveIdentityStore(fromIdentity);
-
- IdentityStore toStore = resolveIdentityStore(toIdentity);
-
- IdentityStoreInvocationContext toTargetCtx = resolveInvocationContext(toStore, invocationCxt);
-
- IdentityStoreInvocationContext defaultTargetCtx = resolveInvocationContext(defaultIdentityStore, invocationCxt);
-
- if (fromStore == toStore)
- {
- // If relationship is named and target store doesn't support named relationships it need to be put in default store anyway
- if (relationshipName == null ||
- (relationshipName != null && fromStore.getSupportedFeatures().isNamedRelationshipsSupported()))
- {
- return fromStore.createRelationship(toTargetCtx, fromIdentity, toIdentity, relationshipType, relationshipName, createNames);
- }
- }
-
- if (!hasIdentityObject(defaultTargetCtx, defaultIdentityStore, fromIdentity))
- {
- defaultIdentityStore.createIdentityObject(defaultTargetCtx, fromIdentity.getName(), fromIdentity.getIdentityType());
- }
-
- if (!hasIdentityObject(defaultTargetCtx, defaultIdentityStore, toIdentity))
- {
- defaultIdentityStore.createIdentityObject(defaultTargetCtx, toIdentity.getName(), toIdentity.getIdentityType());
- }
-
- return defaultIdentityStore.createRelationship(defaultTargetCtx, fromIdentity, toIdentity, relationshipType, relationshipName, createNames);
- }
-
- public void removeRelationship(IdentityStoreInvocationContext invocationCxt, IdentityObject fromIdentity, IdentityObject toIdentity, IdentityObjectRelationshipType relationshipType, String relationshipName) throws IdentityException
- {
- IdentityStore fromStore = resolveIdentityStore(fromIdentity);
-
- IdentityStore toStore = resolveIdentityStore(toIdentity);
-
- IdentityStoreInvocationContext toTargetCtx = resolveInvocationContext(toStore, invocationCxt);
-
- IdentityStoreInvocationContext defaultTargetCtx = resolveInvocationContext(defaultIdentityStore, invocationCxt);
-
- if (fromStore == toStore)
- {
- if (relationshipName == null ||
- (relationshipName != null && fromStore.getSupportedFeatures().isNamedRelationshipsSupported()))
- {
- fromStore.removeRelationship(toTargetCtx, fromIdentity, toIdentity, relationshipType, relationshipName);
- return;
- }
- }
-
- if (!hasIdentityObject(defaultTargetCtx, defaultIdentityStore, fromIdentity))
- {
- defaultIdentityStore.createIdentityObject(defaultTargetCtx, fromIdentity.getName(), fromIdentity.getIdentityType());
- }
-
- if (!hasIdentityObject(defaultTargetCtx, defaultIdentityStore, toIdentity))
- {
- defaultIdentityStore.createIdentityObject(defaultTargetCtx, toIdentity.getName(), toIdentity.getIdentityType());
- }
-
- defaultIdentityStore.removeRelationship(defaultTargetCtx, fromIdentity, toIdentity, relationshipType, relationshipName);
- }
-
- public void removeRelationships(IdentityStoreInvocationContext invocationCtx, IdentityObject identity1, IdentityObject identity2, boolean named) throws IdentityException
- {
- IdentityStore fromStore = resolveIdentityStore(identity1);
-
- IdentityStore toStore = resolveIdentityStore(identity2);
-
- IdentityStoreInvocationContext toTargetCtx = resolveInvocationContext(toStore, invocationCtx);
-
- IdentityStoreInvocationContext defaultTargetCtx = resolveInvocationContext(defaultIdentityStore, invocationCtx);
-
-
- if (fromStore == toStore)
- {
- fromStore.removeRelationships(toTargetCtx, identity1, identity2, named);
- return;
- }
-
- if (!hasIdentityObject(defaultTargetCtx, defaultIdentityStore, identity1))
- {
- defaultIdentityStore.createIdentityObject(defaultTargetCtx, identity1.getName(), identity1.getIdentityType());
- }
-
- if (!hasIdentityObject(defaultTargetCtx, defaultIdentityStore, identity2))
- {
- defaultIdentityStore.createIdentityObject(defaultTargetCtx, identity2.getName(), identity2.getIdentityType());
- }
-
- defaultIdentityStore.removeRelationships(defaultTargetCtx, identity1, identity2, named);
- }
-
- public Set<IdentityObjectRelationship> resolveRelationships(IdentityStoreInvocationContext invocationCxt,
- IdentityObject fromIdentity,
- IdentityObject toIdentity,
- IdentityObjectRelationshipType relationshipType) throws IdentityException
- {
-
- IdentityStore fromStore = resolveIdentityStore(fromIdentity);
-
- IdentityStore toStore = resolveIdentityStore(toIdentity);
-
- IdentityStoreInvocationContext toTargetCtx = resolveInvocationContext(toStore, invocationCxt);
-
- IdentityStoreInvocationContext defaultTargetCtx = resolveInvocationContext(defaultIdentityStore, invocationCxt);
-
- if (fromStore == toStore)
- {
- return fromStore.resolveRelationships(toTargetCtx, fromIdentity, toIdentity, relationshipType);
-
- }
-
- if (!hasIdentityObject(defaultTargetCtx, defaultIdentityStore, fromIdentity))
- {
- defaultIdentityStore.createIdentityObject(defaultTargetCtx, fromIdentity.getName(), fromIdentity.getIdentityType());
- }
-
- if (!hasIdentityObject(defaultTargetCtx, defaultIdentityStore, toIdentity))
- {
- defaultIdentityStore.createIdentityObject(defaultTargetCtx, toIdentity.getName(), toIdentity.getIdentityType());
- }
-
- return defaultIdentityStore.resolveRelationships(defaultTargetCtx, fromIdentity, toIdentity, relationshipType);
- }
-
- public Set<IdentityObjectRelationship> resolveRelationships(IdentityStoreInvocationContext ctx, IdentityObject identity, IdentityObjectRelationshipType relationshipType, boolean parent, boolean named, String name) throws IdentityException
- {
- IdentityStore store = resolveIdentityStore(identity);
-
- Set<IdentityObjectRelationship> relationships = new HashSet<IdentityObjectRelationship>();
-
- // For any IdentityStore that supports named relationships...
- for (IdentityStore identityStore : configuredIdentityStores)
- {
- if (!identityStore.getSupportedFeatures().getSupportedRelationshipTypes().contains(relationshipType.getName()))
- {
- continue;
- }
-
- if (!named || (named && identityStore.getSupportedFeatures().isNamedRelationshipsSupported()))
- {
- IdentityStoreInvocationContext storeCtx = resolveInvocationContext(identityStore, ctx);
- relationships.addAll(identityStore.resolveRelationships(storeCtx, identity, relationshipType, parent, named, name));
- }
- }
-
- return relationships;
- }
-
- public String createRelationshipName(IdentityStoreInvocationContext ctx, String name) throws IdentityException, OperationNotSupportedException
- {
- // For any IdentityStore that supports named relationships...
- for (IdentityStore identityStore : configuredIdentityStores)
- {
- if (identityStore.getSupportedFeatures().isNamedRelationshipsSupported())
- {
- IdentityStoreInvocationContext storeCtx = resolveInvocationContext(identityStore, ctx);
- identityStore.createRelationshipName(storeCtx, name);
-
- }
- }
-
- return name;
- }
-
- public String removeRelationshipName(IdentityStoreInvocationContext ctx, String name) throws IdentityException, OperationNotSupportedException
- {
-
- // For any IdentityStore that supports named relationships...
- for (IdentityStore identityStore : configuredIdentityStores)
- {
- if (identityStore.getSupportedFeatures().isNamedRelationshipsSupported())
- {
- IdentityStoreInvocationContext storeCtx = resolveInvocationContext(identityStore, ctx);
- identityStore.removeRelationshipName(storeCtx, name);
-
- }
- }
-
- return name;
- }
-
- public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx, IdentityObjectSearchControl[] controls) throws IdentityException, OperationNotSupportedException
- {
- Set<String> results = new HashSet<String>();
-
- // For any IdentityStore that supports named relationships...
- for (IdentityStore identityStore : configuredIdentityStores)
- {
- if (identityStore.getSupportedFeatures().isNamedRelationshipsSupported())
- {
- IdentityStoreInvocationContext storeCtx = resolveInvocationContext(identityStore, ctx);
- results.addAll(identityStore.getRelationshipNames(storeCtx, controls));
-
- }
- }
-
- return results;
- }
-
- public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx, IdentityObject identity, IdentityObjectSearchControl[] controls) throws IdentityException, OperationNotSupportedException
- {
-
- IdentityStore toStore = resolveIdentityStore(identity);
- IdentityStoreInvocationContext targetCtx = resolveInvocationContext(toStore, ctx);
-
- if (toStore.getSupportedFeatures().isNamedRelationshipsSupported())
- {
- return toStore.getRelationshipNames(targetCtx, identity, controls);
- }
- IdentityStoreInvocationContext defaultCtx = resolveInvocationContext(defaultIdentityStore, ctx);
-
- return defaultIdentityStore.getRelationshipNames(defaultCtx, identity, controls);
- }
-
- public boolean validateCredential(IdentityStoreInvocationContext ctx, IdentityObject identityObject, IdentityObjectCredential credential) throws IdentityException
- {
- IdentityStore toStore = resolveIdentityStore(identityObject);
- IdentityStoreInvocationContext targetCtx = resolveInvocationContext(toStore, ctx);
-
- return toStore.validateCredential(targetCtx, identityObject, credential);
- }
-
- public void updateCredential(IdentityStoreInvocationContext ctx, IdentityObject identityObject, IdentityObjectCredential credential) throws IdentityException
- {
- IdentityStore toStore = resolveIdentityStore(identityObject);
- IdentityStoreInvocationContext targetCtx = resolveInvocationContext(toStore, ctx);
-
- toStore.updateCredential(targetCtx, identityObject, credential);
- }
-
-
- public Set<String> getSupportedAttributeNames(IdentityStoreInvocationContext invocationContext, IdentityObjectType identityType) throws IdentityException
- {
- Set<String> results;
-
- IdentityStore toStore = resolveIdentityStore(identityType);
- IdentityStoreInvocationContext targetCtx = resolveInvocationContext(toStore, invocationContext);
-
- results = toStore.getSupportedAttributeNames(targetCtx, identityType);
-
- if (toStore != defaultAttributeStore)
- {
- IdentityStoreInvocationContext defaultCtx = resolveInvocationContext(defaultAttributeStore, invocationContext);
-
- results.addAll(defaultAttributeStore.getSupportedAttributeNames(defaultCtx, identityType));
- }
-
- return results;
- }
-
- public Map<String, IdentityObjectAttributeMetaData> getAttributesMetaData(IdentityStoreInvocationContext invocationContext,
- IdentityObjectType identityObjectType)
- {
-
- IdentityStore targetStore = resolveIdentityStore(identityObjectType);
- IdentityStoreInvocationContext targetCtx = resolveInvocationContext(targetStore, invocationContext);
-
- Map<String, IdentityObjectAttributeMetaData> mdMap = new HashMap<String, IdentityObjectAttributeMetaData>();
- mdMap.putAll(targetStore.getAttributesMetaData(targetCtx, identityObjectType));
-
- if (targetStore != defaultAttributeStore)
- {
- IdentityStoreInvocationContext defaultCtx = resolveInvocationContext(defaultAttributeStore, invocationContext);
-
- Map<String, IdentityObjectAttributeMetaData> defaultMDMap = defaultAttributeStore.getAttributesMetaData(defaultCtx, identityObjectType);
-
-
- // put all missing attribute MD from default store
- if (defaultMDMap != null)
- {
- for (Map.Entry<String, IdentityObjectAttributeMetaData> entry : defaultMDMap.entrySet())
- {
- if (!mdMap.containsKey(entry.getKey()))
- {
- mdMap.put(entry.getKey(), entry.getValue());
- }
- }
- }
- }
-
- return mdMap;
- }
-
- public IdentityObjectAttribute getAttribute(IdentityStoreInvocationContext invocationContext, IdentityObject identity, String name) throws IdentityException
- {
- IdentityObjectAttribute result;
-
- IdentityStore toStore = resolveIdentityStore(identity);
- IdentityStoreInvocationContext targetCtx = resolveInvocationContext(toStore, invocationContext);
-
- result = toStore.getAttribute(targetCtx, identity, name);
-
- if (result == null && toStore != defaultAttributeStore)
- {
- IdentityStoreInvocationContext defaultCtx = resolveInvocationContext(defaultAttributeStore, invocationContext);
-
- result = defaultAttributeStore.getAttribute(defaultCtx, identity, name);
- }
-
- return result;
- }
-
- public Map<String, IdentityObjectAttribute> getAttributes(IdentityStoreInvocationContext invocationContext, IdentityObject identity) throws IdentityException
- {
- Map<String, IdentityObjectAttribute> results;
-
- IdentityStore toStore = resolveIdentityStore(identity);
- IdentityStoreInvocationContext targetCtx = resolveInvocationContext(toStore, invocationContext);
-
- results = toStore.getAttributes(targetCtx, identity);
-
- if (toStore != defaultAttributeStore)
- {
- IdentityStoreInvocationContext defaultCtx = resolveInvocationContext(defaultAttributeStore, invocationContext);
-
- Map<String, IdentityObjectAttribute> defaultAttrs = defaultAttributeStore.getAttributes(defaultCtx, identity);
-
- // Add only those attributes which are missing - don't overwrite or merge existing values
- for (Map.Entry<String, IdentityObjectAttribute> entry : defaultAttrs.entrySet())
- {
- if (!results.keySet().contains(entry.getKey()))
- {
- results.put(entry.getKey(), entry.getValue());
- }
- }
- }
-
- return results;
- }
-
- public void updateAttributes(IdentityStoreInvocationContext invocationCtx, IdentityObject identity, IdentityObjectAttribute[] attributes) throws IdentityException
- {
- ArrayList<IdentityObjectAttribute> filteredAttrs = new ArrayList<IdentityObjectAttribute>();
- ArrayList<IdentityObjectAttribute> leftAttrs = new ArrayList<IdentityObjectAttribute>();
-
- IdentityObjectAttribute[] attributesToAdd = null;
-
- IdentityStore toStore = resolveIdentityStore(identity);
- IdentityStoreInvocationContext targetCtx = resolveInvocationContext(toStore, invocationCtx);
-
- // Put supported attrs to the main store
- if (toStore != defaultAttributeStore)
- {
- Set<String> supportedAttrs = toStore.getSupportedAttributeNames(targetCtx, identity.getIdentityType());
-
- // Filter out supported and not supported attributes
- for (IdentityObjectAttribute entry : attributes)
- {
- if (supportedAttrs.contains(entry.getName()))
- {
- filteredAttrs.add(entry);
- }
- else
- {
- leftAttrs.add(entry);
- }
- }
-
- toStore.updateAttributes(targetCtx, identity, filteredAttrs.toArray(new IdentityObjectAttribute[filteredAttrs.size()]));
-
- attributesToAdd = leftAttrs.toArray(new IdentityObjectAttribute[leftAttrs.size()]);
-
- }
- else
- {
- attributesToAdd = attributes;
- }
-
- IdentityStoreInvocationContext defaultCtx = resolveInvocationContext(defaultAttributeStore, invocationCtx);
-
- if (isAllowNotDefinedAttributes())
- {
- defaultAttributeStore.updateAttributes(defaultCtx, identity, attributesToAdd);
- }
- else
- {
- Set<String> supportedAttrs = defaultAttributeStore.getSupportedAttributeNames(defaultCtx, identity.getIdentityType());
- for (IdentityObjectAttribute entry : leftAttrs)
- {
- if (!supportedAttrs.contains(entry.getName()))
- {
- throw new IdentityException("Cannot update not defined attribute. Use '"
- + ALLOW_NOT_DEFINED_ATTRIBUTES + "' option to pass such attributes to default IdentityStore anyway." +
- "Attribute name: " + entry.getName());
- }
- }
- defaultAttributeStore.updateAttributes(defaultCtx, identity, attributesToAdd);
- }
-
- }
-
- public void addAttributes(IdentityStoreInvocationContext invocationCtx, IdentityObject identity, IdentityObjectAttribute[] attributes) throws IdentityException
- {
-
- ArrayList<IdentityObjectAttribute> filteredAttrs = new ArrayList<IdentityObjectAttribute>();
- ArrayList<IdentityObjectAttribute> leftAttrs = new ArrayList<IdentityObjectAttribute>();
- IdentityObjectAttribute[] attributesToAdd = null;
-
- IdentityStore toStore = resolveIdentityStore(identity);
- IdentityStoreInvocationContext targetCtx = resolveInvocationContext(toStore, invocationCtx);
-
- // Put supported attrs to the main store
- if (toStore != defaultAttributeStore)
- {
- Set<String> supportedAttrs = toStore.getSupportedAttributeNames(targetCtx, identity.getIdentityType());
-
- // Filter out supported and not supported attributes
- for (IdentityObjectAttribute entry : attributes)
- {
- if (supportedAttrs.contains(entry.getName()))
- {
- filteredAttrs.add(entry);
- }
- else
- {
- leftAttrs.add(entry);
- }
- }
-
- toStore.addAttributes(targetCtx, identity, filteredAttrs.toArray(new IdentityObjectAttribute[filteredAttrs.size()]));
-
- attributesToAdd = leftAttrs.toArray(new IdentityObjectAttribute[leftAttrs.size()]);
-
-
- }
- else
- {
- attributesToAdd = attributes;
- }
-
- IdentityStoreInvocationContext defaultCtx = resolveInvocationContext(defaultAttributeStore, invocationCtx);
-
- if (isAllowNotDefinedAttributes())
- {
- defaultAttributeStore.addAttributes(defaultCtx, identity, attributesToAdd);
- }
- else
- {
- Set<String> supportedAttrs = defaultAttributeStore.getSupportedAttributeNames(defaultCtx, identity.getIdentityType());
- for (IdentityObjectAttribute entry : attributesToAdd)
- {
- // if we hit some unsupported attribute at this stage that we cannot store...
- if (!supportedAttrs.contains(entry.getName()))
- {
- throw new IdentityException("Cannot add not defined attribute. Use '"
- + ALLOW_NOT_DEFINED_ATTRIBUTES + "' option to pass such attributes to default IdentityStore anyway." +
- "Attribute name: " + entry.getName());
- }
-
- }
- defaultAttributeStore.addAttributes(defaultCtx, identity, attributesToAdd);
- }
-
- }
-
- public void removeAttributes(IdentityStoreInvocationContext invocationCtx, IdentityObject identity, String[] attributes) throws IdentityException
- {
- List<String> filteredAttrs = new LinkedList<String>();
- List<String> leftAttrs = new LinkedList<String>();
-
- IdentityStore toStore = resolveIdentityStore(identity);
- IdentityStoreInvocationContext targetCtx = resolveInvocationContext(toStore, invocationCtx);
-
- // Put supported attrs to the main store
- if (toStore != defaultAttributeStore)
- {
- Set<String> supportedAttrs = toStore.getSupportedAttributeNames(targetCtx, identity.getIdentityType());
-
- // Filter out supported and not supported attributes
- for (String name : attributes)
- {
- if (supportedAttrs.contains(name))
- {
- filteredAttrs.add(name);
- }
- else
- {
- leftAttrs.add(name);
- }
- }
-
- toStore.removeAttributes(targetCtx, identity, filteredAttrs.toArray(new String[filteredAttrs.size()]));
-
-
- }
- else
- {
- leftAttrs = Arrays.asList(attributes);
- }
-
- IdentityStoreInvocationContext defaultCtx = resolveInvocationContext(defaultAttributeStore, invocationCtx);
-
- if (isAllowNotDefinedAttributes())
- {
- defaultAttributeStore.removeAttributes(defaultCtx, identity, leftAttrs.toArray(new String[leftAttrs.size()]));
- }
- else
- {
- Set<String> supportedAttrs = defaultAttributeStore.getSupportedAttributeNames(defaultCtx, identity.getIdentityType());
- for (String name : leftAttrs)
- {
- if (!supportedAttrs.contains(name))
- {
- throw new IdentityException("Cannot remove not defined attribute. Use '"
- + ALLOW_NOT_DEFINED_ATTRIBUTES + "' option to pass such attributes to default IdentityStore anyway." +
- "Attribute name: " + name);
- }
- }
- defaultAttributeStore.removeAttributes(defaultCtx, identity, leftAttrs.toArray(new String[leftAttrs.size()]));
- }
- }
-
- private void sortByName(List<IdentityObject> objects, final boolean ascending)
- {
- Collections.sort(objects, new Comparator<IdentityObject>(){
- public int compare(IdentityObject o1, IdentityObject o2)
- {
- if (ascending)
- {
- return o1.getName().compareTo(o2.getName());
- }
- else
- {
- return o2.getName().compareTo(o1.getName());
- }
- }
- });
- }
-
- //TODO: other way?
- private List<IdentityObject> cutPageFromResults(List<IdentityObject> objects, PageSearchControl pageControl)
- {
- List<IdentityObject> results = new LinkedList<IdentityObject>();
- for (int i = pageControl.getOffset(); i < pageControl.getOffset() + pageControl.getLimit(); i++)
- {
- if (i < objects.size())
- {
- results.add(objects.get(i));
- }
- }
- return results;
- }
-
- public boolean isAllowNotDefinedAttributes()
- {
- return allowNotDefinedAttributes;
- }
-}
\ No newline at end of file
Copied: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/repository/FallbackIdentityStoreRepository.java (from rev 211, trunk/identity-impl/src/main/java/org/jboss/identity/impl/repository/FallbackIdentityStoreRepository.java)
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/repository/FallbackIdentityStoreRepository.java (rev 0)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/repository/FallbackIdentityStoreRepository.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,1011 @@
+/*
+* 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.repository;
+
+import org.jboss.identity.idm.spi.store.IdentityStore;
+import org.jboss.identity.idm.spi.store.AttributeStore;
+import org.jboss.identity.idm.spi.store.FeaturesMetaData;
+import org.jboss.identity.idm.spi.store.IdentityStoreInvocationContext;
+import org.jboss.identity.idm.spi.store.IdentityStoreSession;
+import org.jboss.identity.idm.spi.searchcontrol.IdentityObjectSearchControl;
+import org.jboss.identity.idm.spi.model.IdentityObject;
+import org.jboss.identity.idm.spi.model.IdentityObjectType;
+import org.jboss.identity.idm.spi.model.IdentityObjectRelationshipType;
+import org.jboss.identity.idm.spi.model.IdentityObjectRelationship;
+import org.jboss.identity.idm.spi.exception.OperationNotSupportedException;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityRepositoryConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityObjectAttributeMetaData;
+import org.jboss.identity.idm.spi.model.IdentityObjectCredential;
+import org.jboss.identity.idm.spi.model.IdentityObjectCredentialType;
+import org.jboss.identity.idm.spi.model.IdentityObjectAttribute;
+import org.jboss.identity.idm.exception.IdentityException;
+import org.jboss.identity.idm.impl.store.SimpleIdentityStoreInvocationContext;
+import org.jboss.identity.idm.impl.api.PageSearchControl;
+import org.jboss.identity.idm.impl.api.SortByNameSearchControl;
+
+import java.util.Map;
+import java.util.Collection;
+import java.util.Set;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.LinkedList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Arrays;
+import java.util.ArrayList;
+
+/**
+ * <p>In FallbackIdentityStoreRepository one IdentityStore plays the role of default store. Any operation that cannot be
+ * handled with other IdentityObjectType/IdentityStore mappings will fallback to such IdentityStore. The most common example
+ * is RDBMS + LDAP configuration. LDAP has limmited schema for possible profile attributes so for LDAP entries part of
+ * profile can be stored in RDBMS by syncing entries into default store.</p>
+ * <p>For any relationship that is not supported in other stores, or between entries persisted in two different stores,
+ * proper IdentityObjects will be synced to default store and if possible, such relationship will be created. </p>
+ *
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class FallbackIdentityStoreRepository extends AbstractIdentityStoreRepository
+{
+ //TODO: -
+ //TODO: - filter out controls based on features MD before passing
+ //TODO: - configuration option to store not mapped attributes in default store
+ //TODO: - configuration option to fallback named relationships to default store when not supported in mapped one
+
+ private final String id;
+
+ private IdentityStore defaultIdentityStore;
+
+ private AttributeStore defaultAttributeStore;
+
+ //TODO: rewrite this to other config object?
+ private IdentityRepositoryConfigurationMetaData configurationMD;
+
+ public static final String ALLOW_NOT_DEFINED_ATTRIBUTES = "allowNotDefinedAttributes";
+
+ private FeaturesMetaData featuresMetaData;
+
+ private boolean allowNotDefinedAttributes = false;
+
+ private final Set<IdentityStore> configuredIdentityStores = new HashSet<IdentityStore>();
+
+ public FallbackIdentityStoreRepository(String id)
+ {
+ this.id = id;
+ }
+
+ public void bootstrap(IdentityRepositoryConfigurationMetaData configurationMD,
+ Map<String, IdentityStore> bootstrappedIdentityStores,
+ Map<String, AttributeStore> bootstrappedAttributeStores) throws IdentityException
+ {
+ super.bootstrap(configurationMD, bootstrappedIdentityStores, bootstrappedAttributeStores);
+
+ // Helper collection to keep all identity stores in use
+
+ if (getIdentityStoreMappings().size() > 0)
+ {
+ configuredIdentityStores.addAll(getIdentityStoreMappings().values());
+ }
+
+
+
+ this.configurationMD = configurationMD;
+
+ String asId = configurationMD.getDefaultAttributeStroeId();
+ String isId = configurationMD.getDefaultIdentityStoreId();
+
+ if (asId != null && bootstrappedAttributeStores.keySet().contains(asId))
+ {
+ defaultAttributeStore = bootstrappedAttributeStores.get(asId);
+ }
+
+ if (isId != null && bootstrappedIdentityStores.keySet().contains(isId))
+ {
+ defaultIdentityStore = bootstrappedIdentityStores.get(isId);
+
+ if (!getIdentityStoreMappings().keySet().contains(defaultIdentityStore.getId()))
+ {
+ configuredIdentityStores.add(defaultIdentityStore);
+ }
+
+ }
+
+ String allowNotDefineAttributes = configurationMD.getOptionSingleValue(ALLOW_NOT_DEFINED_ATTRIBUTES);
+
+ if (allowNotDefineAttributes != null && allowNotDefineAttributes.equalsIgnoreCase("true"))
+ {
+ this.allowNotDefinedAttributes = true;
+ }
+
+ // A wrapper around all stores features meta data
+ featuresMetaData = new FeaturesMetaData()
+ {
+
+ public boolean isNamedRelationshipsSupported()
+ {
+ // If there is any IdentityStore that supports named relationships...
+ for (IdentityStore identityStore : getIdentityStoreMappings().values())
+ {
+ if (identityStore.getSupportedFeatures().isNamedRelationshipsSupported())
+ {
+ return true;
+ }
+ }
+ return defaultIdentityStore.getSupportedFeatures().isNamedRelationshipsSupported();
+ }
+
+ public boolean isControlSupported(IdentityObjectType identityObjectType, IdentityObjectSearchControl control)
+ {
+ return resolveIdentityStore(identityObjectType).getSupportedFeatures().isControlSupported(identityObjectType, control);
+ }
+
+ public boolean isControlSupported(IdentityObjectType identityObjectType, Class controlClazz)
+ {
+ return resolveIdentityStore(identityObjectType).getSupportedFeatures().isControlSupported(identityObjectType, controlClazz);
+ }
+
+ public Set<String> getSupportedIdentityObjectTypes()
+ {
+ Set<String> supportedIOTs = new HashSet<String>();
+
+ for (IdentityStore identityStore : getIdentityStoreMappings().values())
+ {
+ supportedIOTs.addAll(identityStore.getSupportedFeatures().getSupportedIdentityObjectTypes());
+ }
+ supportedIOTs.addAll(defaultIdentityStore.getSupportedFeatures().getSupportedRelationshipTypes());
+
+ return supportedIOTs;
+ }
+
+ public boolean isIdentityObjectTypeSupported(IdentityObjectType identityObjectType)
+ {
+ return resolveIdentityStore(identityObjectType).getSupportedFeatures().isIdentityObjectTypeSupported(identityObjectType);
+ }
+
+ public boolean isRelationshipTypeSupported(IdentityObjectType fromType, IdentityObjectType toType, IdentityObjectRelationshipType relationshipType) throws IdentityException
+ {
+ IdentityStore fromStore = resolveIdentityStore(fromType);
+
+ IdentityStore toStore = resolveIdentityStore(toType);
+
+ if (fromStore == toStore)
+ {
+ return fromStore.getSupportedFeatures().isRelationshipTypeSupported(fromType, toType, relationshipType);
+ }
+ else
+ {
+ return defaultIdentityStore.getSupportedFeatures().isRelationshipTypeSupported(fromType, toType, relationshipType);
+ }
+
+ }
+
+ public Set<String> getSupportedRelationshipTypes()
+ {
+ Set<String> supportedRelTypes = new HashSet<String>();
+
+ for (IdentityStore identityStore : getIdentityStoreMappings().values())
+ {
+ supportedRelTypes.addAll(identityStore.getSupportedFeatures().getSupportedRelationshipTypes());
+ }
+ supportedRelTypes.addAll(defaultIdentityStore.getSupportedFeatures().getSupportedRelationshipTypes());
+
+ return supportedRelTypes;
+ }
+
+ public boolean isCredentialSupported(IdentityObjectType identityObjectType, IdentityObjectCredentialType credentialType)
+ {
+ return resolveIdentityStore(identityObjectType).getSupportedFeatures().isCredentialSupported(identityObjectType, credentialType);
+ }
+ };
+
+ }
+
+ public void bootstrap(IdentityStoreConfigurationMetaData configurationMD) throws IdentityException
+ {
+ // Nothing
+ }
+
+ public IdentityStoreSession createIdentityStoreSession() throws IdentityException
+ {
+ Map<String, IdentityStoreSession> sessions = new HashMap<String, IdentityStoreSession>();
+
+ for (IdentityStore identityStore : identityStoreMappings.values())
+ {
+ sessions.put(identityStore.getId(), identityStore.createIdentityStoreSession());
+ }
+
+ for (AttributeStore attributeStore : attributeStoreMappings.values())
+ {
+ if (!sessions.containsKey(attributeStore.getId()))
+ {
+ sessions.put(attributeStore.getId(), attributeStore.createIdentityStoreSession());
+ }
+ }
+
+ if (!sessions.containsKey(defaultAttributeStore.getId()))
+ {
+ sessions.put(defaultAttributeStore.getId(), defaultAttributeStore.createIdentityStoreSession());
+ }
+
+ if (!sessions.containsKey(defaultIdentityStore.getId()))
+ {
+ sessions.put(defaultIdentityStore.getId(), defaultIdentityStore.createIdentityStoreSession());
+ }
+
+ return new RepositoryIdentityStoreSessionImpl(sessions);
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public FeaturesMetaData getSupportedFeatures()
+ {
+ return featuresMetaData;
+ }
+
+ IdentityStore resolveIdentityStore(IdentityObject io)
+ {
+ return resolveIdentityStore(io.getIdentityType());
+ }
+
+ IdentityStore resolveIdentityStore(IdentityObjectType iot)
+ {
+ IdentityStore ids = getIdentityStore(iot);
+ if (ids == null)
+ {
+ ids = defaultIdentityStore;
+ }
+ return ids;
+ }
+
+ AttributeStore resolveAttributeStore(IdentityObjectType iot)
+ {
+ AttributeStore ads = getAttributeStore(iot);
+ if (ads == null)
+ {
+ ads = defaultIdentityStore;
+ }
+ return ads;
+ }
+
+ IdentityStoreInvocationContext resolveInvocationContext(IdentityStore targetStore, IdentityStoreInvocationContext invocationCtx)
+ {
+ return resolveInvocationContext(targetStore.getId(), invocationCtx);
+
+ }
+
+ IdentityStoreInvocationContext resolveInvocationContext(AttributeStore targetStore, IdentityStoreInvocationContext invocationCtx)
+ {
+ return resolveInvocationContext(targetStore.getId(), invocationCtx);
+
+ }
+
+ IdentityStoreInvocationContext resolveInvocationContext(String id, IdentityStoreInvocationContext invocationCtx)
+ {
+ RepositoryIdentityStoreSessionImpl repoSession = (RepositoryIdentityStoreSessionImpl)invocationCtx.getIdentityStoreSession();
+ IdentityStoreSession targetSession = repoSession.getIdentityStoreSession(id);
+
+ return new SimpleIdentityStoreInvocationContext(targetSession, invocationCtx.getRealmId());
+
+ }
+
+ public IdentityObject createIdentityObject(IdentityStoreInvocationContext invocationCtx, String name, IdentityObjectType identityObjectType) throws IdentityException
+ {
+ IdentityStore targetStore = resolveIdentityStore(identityObjectType);
+ IdentityStoreInvocationContext targetCtx = resolveInvocationContext(targetStore, invocationCtx);
+ return targetStore.createIdentityObject(targetCtx, name, identityObjectType);
+ }
+
+ public IdentityObject createIdentityObject(IdentityStoreInvocationContext invocationCtx, String name, IdentityObjectType identityObjectType, Map<String, String[]> attributes) throws IdentityException
+ {
+ IdentityStore targetStore = resolveIdentityStore(identityObjectType);
+ IdentityStoreInvocationContext targetCtx = resolveInvocationContext(targetStore, invocationCtx);
+ return targetStore.createIdentityObject(targetCtx, name, identityObjectType, attributes);
+ }
+
+ public void removeIdentityObject(IdentityStoreInvocationContext invocationCtx, IdentityObject identity) throws IdentityException
+ {
+ IdentityStore targetStore = resolveIdentityStore(identity);
+ IdentityStoreInvocationContext targetCtx = resolveInvocationContext(targetStore, invocationCtx);
+
+ targetStore.removeIdentityObject(targetCtx, identity);
+ }
+
+ public int getIdentityObjectsCount(IdentityStoreInvocationContext invocationCtx, IdentityObjectType identityType) throws IdentityException
+ {
+ IdentityStore targetStore = resolveIdentityStore(identityType);
+ IdentityStoreInvocationContext targetCtx = resolveInvocationContext(targetStore, invocationCtx);
+
+ return targetStore.getIdentityObjectsCount(targetCtx, identityType);
+ }
+
+ public IdentityObject findIdentityObject(IdentityStoreInvocationContext invocationContext, String name, IdentityObjectType identityObjectType) throws IdentityException
+ {
+ IdentityStore targetStore = resolveIdentityStore(identityObjectType);
+ IdentityStoreInvocationContext targetCtx = resolveInvocationContext(targetStore, invocationContext);
+
+ return targetStore.findIdentityObject(targetCtx, name, identityObjectType);
+ }
+
+ public IdentityObject findIdentityObject(IdentityStoreInvocationContext invocationContext, String id) throws IdentityException
+ {
+ //TODO: information about the store mapping should be encoded in id as now its like random guess and this kills performance ...
+
+ for (IdentityStore identityStore : getIdentityStoreMappings().values())
+ {
+ IdentityStoreInvocationContext targetCtx = resolveInvocationContext(identityStore, invocationContext);
+
+ IdentityObject io = identityStore.findIdentityObject(targetCtx, id);
+ if (io != null)
+ {
+ return io;
+ }
+ }
+
+ return defaultIdentityStore.findIdentityObject(invocationContext, id);
+ }
+
+ public Collection<IdentityObject> findIdentityObject(IdentityStoreInvocationContext invocationCtx, IdentityObjectType identityType, IdentityObjectSearchControl[] controls) throws IdentityException
+ {
+ IdentityStore targetStore = resolveIdentityStore(identityType);
+ IdentityStoreInvocationContext targetCtx = resolveInvocationContext(targetStore, invocationCtx);
+
+ return targetStore.findIdentityObject(targetCtx, identityType, controls);
+ }
+
+ public Collection<IdentityObject> findIdentityObject(IdentityStoreInvocationContext invocationCxt,
+ IdentityObject identity,
+ IdentityObjectRelationshipType relationshipType,
+ boolean parent,
+ IdentityObjectSearchControl[] controls) throws IdentityException
+ {
+ // Check in the mapped store and merge with default
+
+ IdentityStore mappedStore = resolveIdentityStore(identity);
+
+ IdentityStoreInvocationContext mappedCtx = resolveInvocationContext(mappedStore, invocationCxt);
+
+ IdentityStoreInvocationContext defaultCtx = resolveInvocationContext(defaultIdentityStore, invocationCxt);
+
+
+ if (mappedStore == defaultIdentityStore)
+ {
+ return defaultIdentityStore.findIdentityObject(defaultCtx, identity, relationshipType, parent, controls);
+ }
+
+ Collection<IdentityObject> results = mappedStore.findIdentityObject(mappedCtx, identity, relationshipType, parent, controls);
+
+ IdentityObject defaultStoreIdentityObject = null;
+
+ try
+ {
+ defaultStoreIdentityObject = defaultIdentityStore.findIdentityObject(defaultCtx, identity.getName(), identity.getIdentityType());
+ }
+ catch (IdentityException e)
+ {
+ return results;
+ }
+
+ if (defaultStoreIdentityObject != null)
+ {
+ Collection<IdentityObject> objects = defaultIdentityStore.findIdentityObject(defaultCtx, identity, relationshipType, parent, controls);
+
+ PageSearchControl pageSearchControl = null;
+ SortByNameSearchControl sortSearchControl = null;
+
+ if (controls != null)
+ {
+ for (IdentityObjectSearchControl control : controls)
+ {
+ if (control instanceof PageSearchControl)
+ {
+ pageSearchControl = (PageSearchControl)control;
+ }
+ else if (control instanceof SortByNameSearchControl)
+ {
+ sortSearchControl = (SortByNameSearchControl)control;
+ }
+ }
+ }
+
+
+ // If default store contain related relationships merge and sort/page once more
+ if (objects != null && objects.size() != 0)
+ {
+ results.addAll(objects);
+
+ //TODO: hardcoded List
+ if (pageSearchControl != null && results instanceof List)
+ {
+ results = cutPageFromResults((List<IdentityObject>)results, pageSearchControl);
+ }
+
+ //TODO: hardcoded List
+ if (sortSearchControl != null && results instanceof List)
+ {
+ sortByName((List<IdentityObject>)results, sortSearchControl.isAscending());
+ }
+ }
+ }
+ return results;
+
+ }
+
+ public IdentityObjectRelationship createRelationship(IdentityStoreInvocationContext invocationCxt, IdentityObject fromIdentity, IdentityObject toIdentity, IdentityObjectRelationshipType relationshipType, String relationshipName, boolean createNames) throws IdentityException
+ {
+ IdentityStore fromStore = resolveIdentityStore(fromIdentity);
+
+ IdentityStore toStore = resolveIdentityStore(toIdentity);
+
+ IdentityStoreInvocationContext toTargetCtx = resolveInvocationContext(toStore, invocationCxt);
+
+ IdentityStoreInvocationContext defaultTargetCtx = resolveInvocationContext(defaultIdentityStore, invocationCxt);
+
+ if (fromStore == toStore)
+ {
+ // If relationship is named and target store doesn't support named relationships it need to be put in default store anyway
+ if (relationshipName == null ||
+ (relationshipName != null && fromStore.getSupportedFeatures().isNamedRelationshipsSupported()))
+ {
+ return fromStore.createRelationship(toTargetCtx, fromIdentity, toIdentity, relationshipType, relationshipName, createNames);
+ }
+ }
+
+ if (!hasIdentityObject(defaultTargetCtx, defaultIdentityStore, fromIdentity))
+ {
+ defaultIdentityStore.createIdentityObject(defaultTargetCtx, fromIdentity.getName(), fromIdentity.getIdentityType());
+ }
+
+ if (!hasIdentityObject(defaultTargetCtx, defaultIdentityStore, toIdentity))
+ {
+ defaultIdentityStore.createIdentityObject(defaultTargetCtx, toIdentity.getName(), toIdentity.getIdentityType());
+ }
+
+ return defaultIdentityStore.createRelationship(defaultTargetCtx, fromIdentity, toIdentity, relationshipType, relationshipName, createNames);
+ }
+
+ public void removeRelationship(IdentityStoreInvocationContext invocationCxt, IdentityObject fromIdentity, IdentityObject toIdentity, IdentityObjectRelationshipType relationshipType, String relationshipName) throws IdentityException
+ {
+ IdentityStore fromStore = resolveIdentityStore(fromIdentity);
+
+ IdentityStore toStore = resolveIdentityStore(toIdentity);
+
+ IdentityStoreInvocationContext toTargetCtx = resolveInvocationContext(toStore, invocationCxt);
+
+ IdentityStoreInvocationContext defaultTargetCtx = resolveInvocationContext(defaultIdentityStore, invocationCxt);
+
+ if (fromStore == toStore)
+ {
+ if (relationshipName == null ||
+ (relationshipName != null && fromStore.getSupportedFeatures().isNamedRelationshipsSupported()))
+ {
+ fromStore.removeRelationship(toTargetCtx, fromIdentity, toIdentity, relationshipType, relationshipName);
+ return;
+ }
+ }
+
+ if (!hasIdentityObject(defaultTargetCtx, defaultIdentityStore, fromIdentity))
+ {
+ defaultIdentityStore.createIdentityObject(defaultTargetCtx, fromIdentity.getName(), fromIdentity.getIdentityType());
+ }
+
+ if (!hasIdentityObject(defaultTargetCtx, defaultIdentityStore, toIdentity))
+ {
+ defaultIdentityStore.createIdentityObject(defaultTargetCtx, toIdentity.getName(), toIdentity.getIdentityType());
+ }
+
+ defaultIdentityStore.removeRelationship(defaultTargetCtx, fromIdentity, toIdentity, relationshipType, relationshipName);
+ }
+
+ public void removeRelationships(IdentityStoreInvocationContext invocationCtx, IdentityObject identity1, IdentityObject identity2, boolean named) throws IdentityException
+ {
+ IdentityStore fromStore = resolveIdentityStore(identity1);
+
+ IdentityStore toStore = resolveIdentityStore(identity2);
+
+ IdentityStoreInvocationContext toTargetCtx = resolveInvocationContext(toStore, invocationCtx);
+
+ IdentityStoreInvocationContext defaultTargetCtx = resolveInvocationContext(defaultIdentityStore, invocationCtx);
+
+
+ if (fromStore == toStore)
+ {
+ fromStore.removeRelationships(toTargetCtx, identity1, identity2, named);
+ return;
+ }
+
+ if (!hasIdentityObject(defaultTargetCtx, defaultIdentityStore, identity1))
+ {
+ defaultIdentityStore.createIdentityObject(defaultTargetCtx, identity1.getName(), identity1.getIdentityType());
+ }
+
+ if (!hasIdentityObject(defaultTargetCtx, defaultIdentityStore, identity2))
+ {
+ defaultIdentityStore.createIdentityObject(defaultTargetCtx, identity2.getName(), identity2.getIdentityType());
+ }
+
+ defaultIdentityStore.removeRelationships(defaultTargetCtx, identity1, identity2, named);
+ }
+
+ public Set<IdentityObjectRelationship> resolveRelationships(IdentityStoreInvocationContext invocationCxt,
+ IdentityObject fromIdentity,
+ IdentityObject toIdentity,
+ IdentityObjectRelationshipType relationshipType) throws IdentityException
+ {
+
+ IdentityStore fromStore = resolveIdentityStore(fromIdentity);
+
+ IdentityStore toStore = resolveIdentityStore(toIdentity);
+
+ IdentityStoreInvocationContext toTargetCtx = resolveInvocationContext(toStore, invocationCxt);
+
+ IdentityStoreInvocationContext defaultTargetCtx = resolveInvocationContext(defaultIdentityStore, invocationCxt);
+
+ if (fromStore == toStore)
+ {
+ return fromStore.resolveRelationships(toTargetCtx, fromIdentity, toIdentity, relationshipType);
+
+ }
+
+ if (!hasIdentityObject(defaultTargetCtx, defaultIdentityStore, fromIdentity))
+ {
+ defaultIdentityStore.createIdentityObject(defaultTargetCtx, fromIdentity.getName(), fromIdentity.getIdentityType());
+ }
+
+ if (!hasIdentityObject(defaultTargetCtx, defaultIdentityStore, toIdentity))
+ {
+ defaultIdentityStore.createIdentityObject(defaultTargetCtx, toIdentity.getName(), toIdentity.getIdentityType());
+ }
+
+ return defaultIdentityStore.resolveRelationships(defaultTargetCtx, fromIdentity, toIdentity, relationshipType);
+ }
+
+ public Set<IdentityObjectRelationship> resolveRelationships(IdentityStoreInvocationContext ctx, IdentityObject identity, IdentityObjectRelationshipType relationshipType, boolean parent, boolean named, String name) throws IdentityException
+ {
+ IdentityStore store = resolveIdentityStore(identity);
+
+ Set<IdentityObjectRelationship> relationships = new HashSet<IdentityObjectRelationship>();
+
+ // For any IdentityStore that supports named relationships...
+ for (IdentityStore identityStore : configuredIdentityStores)
+ {
+ if (!identityStore.getSupportedFeatures().getSupportedRelationshipTypes().contains(relationshipType.getName()))
+ {
+ continue;
+ }
+
+ if (!named || (named && identityStore.getSupportedFeatures().isNamedRelationshipsSupported()))
+ {
+ IdentityStoreInvocationContext storeCtx = resolveInvocationContext(identityStore, ctx);
+ relationships.addAll(identityStore.resolveRelationships(storeCtx, identity, relationshipType, parent, named, name));
+ }
+ }
+
+ return relationships;
+ }
+
+ public String createRelationshipName(IdentityStoreInvocationContext ctx, String name) throws IdentityException, OperationNotSupportedException
+ {
+ // For any IdentityStore that supports named relationships...
+ for (IdentityStore identityStore : configuredIdentityStores)
+ {
+ if (identityStore.getSupportedFeatures().isNamedRelationshipsSupported())
+ {
+ IdentityStoreInvocationContext storeCtx = resolveInvocationContext(identityStore, ctx);
+ identityStore.createRelationshipName(storeCtx, name);
+
+ }
+ }
+
+ return name;
+ }
+
+ public String removeRelationshipName(IdentityStoreInvocationContext ctx, String name) throws IdentityException, OperationNotSupportedException
+ {
+
+ // For any IdentityStore that supports named relationships...
+ for (IdentityStore identityStore : configuredIdentityStores)
+ {
+ if (identityStore.getSupportedFeatures().isNamedRelationshipsSupported())
+ {
+ IdentityStoreInvocationContext storeCtx = resolveInvocationContext(identityStore, ctx);
+ identityStore.removeRelationshipName(storeCtx, name);
+
+ }
+ }
+
+ return name;
+ }
+
+ public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx, IdentityObjectSearchControl[] controls) throws IdentityException, OperationNotSupportedException
+ {
+ Set<String> results = new HashSet<String>();
+
+ // For any IdentityStore that supports named relationships...
+ for (IdentityStore identityStore : configuredIdentityStores)
+ {
+ if (identityStore.getSupportedFeatures().isNamedRelationshipsSupported())
+ {
+ IdentityStoreInvocationContext storeCtx = resolveInvocationContext(identityStore, ctx);
+ results.addAll(identityStore.getRelationshipNames(storeCtx, controls));
+
+ }
+ }
+
+ return results;
+ }
+
+ public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx, IdentityObject identity, IdentityObjectSearchControl[] controls) throws IdentityException, OperationNotSupportedException
+ {
+
+ IdentityStore toStore = resolveIdentityStore(identity);
+ IdentityStoreInvocationContext targetCtx = resolveInvocationContext(toStore, ctx);
+
+ if (toStore.getSupportedFeatures().isNamedRelationshipsSupported())
+ {
+ return toStore.getRelationshipNames(targetCtx, identity, controls);
+ }
+ IdentityStoreInvocationContext defaultCtx = resolveInvocationContext(defaultIdentityStore, ctx);
+
+ return defaultIdentityStore.getRelationshipNames(defaultCtx, identity, controls);
+ }
+
+ public boolean validateCredential(IdentityStoreInvocationContext ctx, IdentityObject identityObject, IdentityObjectCredential credential) throws IdentityException
+ {
+ IdentityStore toStore = resolveIdentityStore(identityObject);
+ IdentityStoreInvocationContext targetCtx = resolveInvocationContext(toStore, ctx);
+
+ return toStore.validateCredential(targetCtx, identityObject, credential);
+ }
+
+ public void updateCredential(IdentityStoreInvocationContext ctx, IdentityObject identityObject, IdentityObjectCredential credential) throws IdentityException
+ {
+ IdentityStore toStore = resolveIdentityStore(identityObject);
+ IdentityStoreInvocationContext targetCtx = resolveInvocationContext(toStore, ctx);
+
+ toStore.updateCredential(targetCtx, identityObject, credential);
+ }
+
+
+ public Set<String> getSupportedAttributeNames(IdentityStoreInvocationContext invocationContext, IdentityObjectType identityType) throws IdentityException
+ {
+ Set<String> results;
+
+ IdentityStore toStore = resolveIdentityStore(identityType);
+ IdentityStoreInvocationContext targetCtx = resolveInvocationContext(toStore, invocationContext);
+
+ results = toStore.getSupportedAttributeNames(targetCtx, identityType);
+
+ if (toStore != defaultAttributeStore)
+ {
+ IdentityStoreInvocationContext defaultCtx = resolveInvocationContext(defaultAttributeStore, invocationContext);
+
+ results.addAll(defaultAttributeStore.getSupportedAttributeNames(defaultCtx, identityType));
+ }
+
+ return results;
+ }
+
+ public Map<String, IdentityObjectAttributeMetaData> getAttributesMetaData(IdentityStoreInvocationContext invocationContext,
+ IdentityObjectType identityObjectType)
+ {
+
+ IdentityStore targetStore = resolveIdentityStore(identityObjectType);
+ IdentityStoreInvocationContext targetCtx = resolveInvocationContext(targetStore, invocationContext);
+
+ Map<String, IdentityObjectAttributeMetaData> mdMap = new HashMap<String, IdentityObjectAttributeMetaData>();
+ mdMap.putAll(targetStore.getAttributesMetaData(targetCtx, identityObjectType));
+
+ if (targetStore != defaultAttributeStore)
+ {
+ IdentityStoreInvocationContext defaultCtx = resolveInvocationContext(defaultAttributeStore, invocationContext);
+
+ Map<String, IdentityObjectAttributeMetaData> defaultMDMap = defaultAttributeStore.getAttributesMetaData(defaultCtx, identityObjectType);
+
+
+ // put all missing attribute MD from default store
+ if (defaultMDMap != null)
+ {
+ for (Map.Entry<String, IdentityObjectAttributeMetaData> entry : defaultMDMap.entrySet())
+ {
+ if (!mdMap.containsKey(entry.getKey()))
+ {
+ mdMap.put(entry.getKey(), entry.getValue());
+ }
+ }
+ }
+ }
+
+ return mdMap;
+ }
+
+ public IdentityObjectAttribute getAttribute(IdentityStoreInvocationContext invocationContext, IdentityObject identity, String name) throws IdentityException
+ {
+ IdentityObjectAttribute result;
+
+ IdentityStore toStore = resolveIdentityStore(identity);
+ IdentityStoreInvocationContext targetCtx = resolveInvocationContext(toStore, invocationContext);
+
+ result = toStore.getAttribute(targetCtx, identity, name);
+
+ if (result == null && toStore != defaultAttributeStore)
+ {
+ IdentityStoreInvocationContext defaultCtx = resolveInvocationContext(defaultAttributeStore, invocationContext);
+
+ result = defaultAttributeStore.getAttribute(defaultCtx, identity, name);
+ }
+
+ return result;
+ }
+
+ public Map<String, IdentityObjectAttribute> getAttributes(IdentityStoreInvocationContext invocationContext, IdentityObject identity) throws IdentityException
+ {
+ Map<String, IdentityObjectAttribute> results;
+
+ IdentityStore toStore = resolveIdentityStore(identity);
+ IdentityStoreInvocationContext targetCtx = resolveInvocationContext(toStore, invocationContext);
+
+ results = toStore.getAttributes(targetCtx, identity);
+
+ if (toStore != defaultAttributeStore)
+ {
+ IdentityStoreInvocationContext defaultCtx = resolveInvocationContext(defaultAttributeStore, invocationContext);
+
+ Map<String, IdentityObjectAttribute> defaultAttrs = defaultAttributeStore.getAttributes(defaultCtx, identity);
+
+ // Add only those attributes which are missing - don't overwrite or merge existing values
+ for (Map.Entry<String, IdentityObjectAttribute> entry : defaultAttrs.entrySet())
+ {
+ if (!results.keySet().contains(entry.getKey()))
+ {
+ results.put(entry.getKey(), entry.getValue());
+ }
+ }
+ }
+
+ return results;
+ }
+
+ public void updateAttributes(IdentityStoreInvocationContext invocationCtx, IdentityObject identity, IdentityObjectAttribute[] attributes) throws IdentityException
+ {
+ ArrayList<IdentityObjectAttribute> filteredAttrs = new ArrayList<IdentityObjectAttribute>();
+ ArrayList<IdentityObjectAttribute> leftAttrs = new ArrayList<IdentityObjectAttribute>();
+
+ IdentityObjectAttribute[] attributesToAdd = null;
+
+ IdentityStore toStore = resolveIdentityStore(identity);
+ IdentityStoreInvocationContext targetCtx = resolveInvocationContext(toStore, invocationCtx);
+
+ // Put supported attrs to the main store
+ if (toStore != defaultAttributeStore)
+ {
+ Set<String> supportedAttrs = toStore.getSupportedAttributeNames(targetCtx, identity.getIdentityType());
+
+ // Filter out supported and not supported attributes
+ for (IdentityObjectAttribute entry : attributes)
+ {
+ if (supportedAttrs.contains(entry.getName()))
+ {
+ filteredAttrs.add(entry);
+ }
+ else
+ {
+ leftAttrs.add(entry);
+ }
+ }
+
+ toStore.updateAttributes(targetCtx, identity, filteredAttrs.toArray(new IdentityObjectAttribute[filteredAttrs.size()]));
+
+ attributesToAdd = leftAttrs.toArray(new IdentityObjectAttribute[leftAttrs.size()]);
+
+ }
+ else
+ {
+ attributesToAdd = attributes;
+ }
+
+ IdentityStoreInvocationContext defaultCtx = resolveInvocationContext(defaultAttributeStore, invocationCtx);
+
+ if (isAllowNotDefinedAttributes())
+ {
+ defaultAttributeStore.updateAttributes(defaultCtx, identity, attributesToAdd);
+ }
+ else
+ {
+ Set<String> supportedAttrs = defaultAttributeStore.getSupportedAttributeNames(defaultCtx, identity.getIdentityType());
+ for (IdentityObjectAttribute entry : leftAttrs)
+ {
+ if (!supportedAttrs.contains(entry.getName()))
+ {
+ throw new IdentityException("Cannot update not defined attribute. Use '"
+ + ALLOW_NOT_DEFINED_ATTRIBUTES + "' option to pass such attributes to default IdentityStore anyway." +
+ "Attribute name: " + entry.getName());
+ }
+ }
+ defaultAttributeStore.updateAttributes(defaultCtx, identity, attributesToAdd);
+ }
+
+ }
+
+ public void addAttributes(IdentityStoreInvocationContext invocationCtx, IdentityObject identity, IdentityObjectAttribute[] attributes) throws IdentityException
+ {
+
+ ArrayList<IdentityObjectAttribute> filteredAttrs = new ArrayList<IdentityObjectAttribute>();
+ ArrayList<IdentityObjectAttribute> leftAttrs = new ArrayList<IdentityObjectAttribute>();
+ IdentityObjectAttribute[] attributesToAdd = null;
+
+ IdentityStore toStore = resolveIdentityStore(identity);
+ IdentityStoreInvocationContext targetCtx = resolveInvocationContext(toStore, invocationCtx);
+
+ // Put supported attrs to the main store
+ if (toStore != defaultAttributeStore)
+ {
+ Set<String> supportedAttrs = toStore.getSupportedAttributeNames(targetCtx, identity.getIdentityType());
+
+ // Filter out supported and not supported attributes
+ for (IdentityObjectAttribute entry : attributes)
+ {
+ if (supportedAttrs.contains(entry.getName()))
+ {
+ filteredAttrs.add(entry);
+ }
+ else
+ {
+ leftAttrs.add(entry);
+ }
+ }
+
+ toStore.addAttributes(targetCtx, identity, filteredAttrs.toArray(new IdentityObjectAttribute[filteredAttrs.size()]));
+
+ attributesToAdd = leftAttrs.toArray(new IdentityObjectAttribute[leftAttrs.size()]);
+
+
+ }
+ else
+ {
+ attributesToAdd = attributes;
+ }
+
+ IdentityStoreInvocationContext defaultCtx = resolveInvocationContext(defaultAttributeStore, invocationCtx);
+
+ if (isAllowNotDefinedAttributes())
+ {
+ defaultAttributeStore.addAttributes(defaultCtx, identity, attributesToAdd);
+ }
+ else
+ {
+ Set<String> supportedAttrs = defaultAttributeStore.getSupportedAttributeNames(defaultCtx, identity.getIdentityType());
+ for (IdentityObjectAttribute entry : attributesToAdd)
+ {
+ // if we hit some unsupported attribute at this stage that we cannot store...
+ if (!supportedAttrs.contains(entry.getName()))
+ {
+ throw new IdentityException("Cannot add not defined attribute. Use '"
+ + ALLOW_NOT_DEFINED_ATTRIBUTES + "' option to pass such attributes to default IdentityStore anyway." +
+ "Attribute name: " + entry.getName());
+ }
+
+ }
+ defaultAttributeStore.addAttributes(defaultCtx, identity, attributesToAdd);
+ }
+
+ }
+
+ public void removeAttributes(IdentityStoreInvocationContext invocationCtx, IdentityObject identity, String[] attributes) throws IdentityException
+ {
+ List<String> filteredAttrs = new LinkedList<String>();
+ List<String> leftAttrs = new LinkedList<String>();
+
+ IdentityStore toStore = resolveIdentityStore(identity);
+ IdentityStoreInvocationContext targetCtx = resolveInvocationContext(toStore, invocationCtx);
+
+ // Put supported attrs to the main store
+ if (toStore != defaultAttributeStore)
+ {
+ Set<String> supportedAttrs = toStore.getSupportedAttributeNames(targetCtx, identity.getIdentityType());
+
+ // Filter out supported and not supported attributes
+ for (String name : attributes)
+ {
+ if (supportedAttrs.contains(name))
+ {
+ filteredAttrs.add(name);
+ }
+ else
+ {
+ leftAttrs.add(name);
+ }
+ }
+
+ toStore.removeAttributes(targetCtx, identity, filteredAttrs.toArray(new String[filteredAttrs.size()]));
+
+
+ }
+ else
+ {
+ leftAttrs = Arrays.asList(attributes);
+ }
+
+ IdentityStoreInvocationContext defaultCtx = resolveInvocationContext(defaultAttributeStore, invocationCtx);
+
+ if (isAllowNotDefinedAttributes())
+ {
+ defaultAttributeStore.removeAttributes(defaultCtx, identity, leftAttrs.toArray(new String[leftAttrs.size()]));
+ }
+ else
+ {
+ Set<String> supportedAttrs = defaultAttributeStore.getSupportedAttributeNames(defaultCtx, identity.getIdentityType());
+ for (String name : leftAttrs)
+ {
+ if (!supportedAttrs.contains(name))
+ {
+ throw new IdentityException("Cannot remove not defined attribute. Use '"
+ + ALLOW_NOT_DEFINED_ATTRIBUTES + "' option to pass such attributes to default IdentityStore anyway." +
+ "Attribute name: " + name);
+ }
+ }
+ defaultAttributeStore.removeAttributes(defaultCtx, identity, leftAttrs.toArray(new String[leftAttrs.size()]));
+ }
+ }
+
+ private void sortByName(List<IdentityObject> objects, final boolean ascending)
+ {
+ Collections.sort(objects, new Comparator<IdentityObject>(){
+ public int compare(IdentityObject o1, IdentityObject o2)
+ {
+ if (ascending)
+ {
+ return o1.getName().compareTo(o2.getName());
+ }
+ else
+ {
+ return o2.getName().compareTo(o1.getName());
+ }
+ }
+ });
+ }
+
+ //TODO: other way
+ private List<IdentityObject> cutPageFromResults(List<IdentityObject> objects, PageSearchControl pageControl)
+ {
+ List<IdentityObject> results = new LinkedList<IdentityObject>();
+ for (int i = pageControl.getOffset(); i < pageControl.getOffset() + pageControl.getLimit(); i++)
+ {
+ if (i < objects.size())
+ {
+ results.add(objects.get(i));
+ }
+ }
+ return results;
+ }
+
+ public boolean isAllowNotDefinedAttributes()
+ {
+ return allowNotDefinedAttributes;
+ }
+}
\ No newline at end of file
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/repository/RepositoryIdentityStoreSessionImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/repository/RepositoryIdentityStoreSessionImpl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/repository/RepositoryIdentityStoreSessionImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,146 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.repository;
-
-import org.jboss.identity.spi.store.IdentityStoreSession;
-import org.jboss.identity.exception.IdentityException;
-
-import java.util.Map;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class RepositoryIdentityStoreSessionImpl implements IdentityStoreSession
-{
-
- //TODO: more sophisticated impl needed.
-
- protected final Map<String, IdentityStoreSession> identityStoreSessionMappings;
-
- public RepositoryIdentityStoreSessionImpl(Map<String, IdentityStoreSession> identityStoreSessionMappings)
- {
- if (identityStoreSessionMappings == null)
- {
- throw new IllegalArgumentException();
- }
-
- this.identityStoreSessionMappings = identityStoreSessionMappings;
- }
-
- public Object getSessionContext() throws IdentityException
- {
- return null;
- }
-
- public IdentityStoreSession getIdentityStoreSession(String storeId)
- {
- return identityStoreSessionMappings.get(storeId);
- }
-
- public void close() throws IdentityException
- {
- for (IdentityStoreSession identityStoreSession : identityStoreSessionMappings.values())
- {
- identityStoreSession.close();
- }
- }
-
- public void save() throws IdentityException
- {
- for (IdentityStoreSession iss : identityStoreSessionMappings.values())
- {
- iss.save();
- }
-
- }
-
- public void clear() throws IdentityException
- {
- for (IdentityStoreSession iss : identityStoreSessionMappings.values())
- {
- iss.clear();
- }
-
- }
-
- public boolean isOpen()
- {
- for (IdentityStoreSession identityStoreSession : identityStoreSessionMappings.values())
- {
- if (identityStoreSession.isOpen())
- {
- return true;
- }
- }
- return false;
- }
-
- public boolean isTransactionSupported()
- {
- for (IdentityStoreSession identityStoreSession : identityStoreSessionMappings.values())
- {
- if (identityStoreSession.isTransactionSupported())
- {
- return true;
- }
- }
- return false;
- }
-
- public void startTransaction()
- {
- for (IdentityStoreSession identityStoreSession : identityStoreSessionMappings.values())
- {
- identityStoreSession.startTransaction();
- }
- }
-
- public void commitTransaction()
- {
- for (IdentityStoreSession identityStoreSession : identityStoreSessionMappings.values())
- {
- identityStoreSession.commitTransaction();
- }
- }
-
- public void rollbackTransaction()
- {
- for (IdentityStoreSession identityStoreSession : identityStoreSessionMappings.values())
- {
- identityStoreSession.rollbackTransaction();
- }
- }
-
- public boolean isTransactionActive()
- {
- for (IdentityStoreSession identityStoreSession : identityStoreSessionMappings.values())
- {
- if (identityStoreSession.isTransactionActive())
- {
- return true;
- }
- }
- return false;
- }
-}
Copied: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/repository/RepositoryIdentityStoreSessionImpl.java (from rev 211, trunk/identity-impl/src/main/java/org/jboss/identity/impl/repository/RepositoryIdentityStoreSessionImpl.java)
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/repository/RepositoryIdentityStoreSessionImpl.java (rev 0)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/repository/RepositoryIdentityStoreSessionImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,148 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.impl.repository;
+
+import org.jboss.identity.idm.spi.store.IdentityStoreSession;
+import org.jboss.identity.idm.exception.IdentityException;
+
+import java.util.Map;
+
+/**
+ * Wrapper around many IdentityStoreSession objects. Simply iterates and delegates method invocation
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class RepositoryIdentityStoreSessionImpl implements IdentityStoreSession
+{
+
+ //TODO: more sophisticated impl needed.
+
+ protected final Map<String, IdentityStoreSession> identityStoreSessionMappings;
+
+ public RepositoryIdentityStoreSessionImpl(Map<String, IdentityStoreSession> identityStoreSessionMappings)
+ {
+ if (identityStoreSessionMappings == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ this.identityStoreSessionMappings = identityStoreSessionMappings;
+ }
+
+ public Object getSessionContext() throws IdentityException
+ {
+ return null;
+ }
+
+ public IdentityStoreSession getIdentityStoreSession(String storeId)
+ {
+ return identityStoreSessionMappings.get(storeId);
+ }
+
+ public void close() throws IdentityException
+ {
+ for (IdentityStoreSession identityStoreSession : identityStoreSessionMappings.values())
+ {
+ identityStoreSession.close();
+ }
+ }
+
+ public void save() throws IdentityException
+ {
+ for (IdentityStoreSession iss : identityStoreSessionMappings.values())
+ {
+ iss.save();
+ }
+
+ }
+
+ public void clear() throws IdentityException
+ {
+ for (IdentityStoreSession iss : identityStoreSessionMappings.values())
+ {
+ iss.clear();
+ }
+
+ }
+
+ public boolean isOpen()
+ {
+ for (IdentityStoreSession identityStoreSession : identityStoreSessionMappings.values())
+ {
+ if (identityStoreSession.isOpen())
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean isTransactionSupported()
+ {
+ for (IdentityStoreSession identityStoreSession : identityStoreSessionMappings.values())
+ {
+ if (identityStoreSession.isTransactionSupported())
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void startTransaction()
+ {
+ for (IdentityStoreSession identityStoreSession : identityStoreSessionMappings.values())
+ {
+ identityStoreSession.startTransaction();
+ }
+ }
+
+ public void commitTransaction()
+ {
+ for (IdentityStoreSession identityStoreSession : identityStoreSessionMappings.values())
+ {
+ identityStoreSession.commitTransaction();
+ }
+ }
+
+ public void rollbackTransaction()
+ {
+ for (IdentityStoreSession identityStoreSession : identityStoreSessionMappings.values())
+ {
+ identityStoreSession.rollbackTransaction();
+ }
+ }
+
+ public boolean isTransactionActive()
+ {
+ for (IdentityStoreSession identityStoreSession : identityStoreSessionMappings.values())
+ {
+ if (identityStoreSession.isTransactionActive())
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+}
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/repository/WrapperIdentityStoreRepository.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/repository/WrapperIdentityStoreRepository.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/repository/WrapperIdentityStoreRepository.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,7 +20,7 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.repository;
+package org.jboss.identity.idm.impl.repository;
/**
* Simply wraps IdentityStore and AttributeStore and delegates all the calls
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/FeaturesMetaDataImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/FeaturesMetaDataImpl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/FeaturesMetaDataImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,210 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.store;
-
-import org.jboss.identity.spi.store.FeaturesMetaData;
-import org.jboss.identity.spi.model.IdentityObjectType;
-import org.jboss.identity.spi.model.IdentityObjectRelationshipType;
-import org.jboss.identity.spi.model.IdentityObjectCredentialType;
-import org.jboss.identity.spi.searchcontrol.IdentityObjectSearchControl;
-import org.jboss.identity.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
-import org.jboss.identity.spi.configuration.metadata.IdentityObjectTypeMetaData;
-import org.jboss.identity.spi.configuration.metadata.RelationshipMetaData;
-import org.jboss.identity.exception.IdentityException;
-
-import java.util.Set;
-import java.util.Map;
-import java.util.List;
-import java.util.HashSet;
-import java.util.Collections;
-import java.util.HashMap;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class FeaturesMetaDataImpl implements FeaturesMetaData
-{
- private Set<String> supportedTypeNames = new HashSet<String>();
-
- private final Set<Class> supportedSearchControls;
-
- private final Map<String, Set<String>> supportedCredentials;
-
- private final boolean namedRelationshipsSupport;
-
- // <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<Class> supportedControls,
- boolean namedRelationshipsSupport)
- {
- this.namedRelationshipsSupport = namedRelationshipsSupport;
-
- Map<String, Set<String>> supportedCredentials = new HashMap<String, Set<String>>();
-
- for (IdentityObjectTypeMetaData typeMetaData : configurationMD.getSupportedIdentityTypes())
- {
- supportedTypeNames.add(typeMetaData.getName());
-
- if (typeMetaData.getCredentials() != null)
- {
- Set<String> credentials = new HashSet<String>(typeMetaData.getCredentials());
- supportedCredentials.put(typeMetaData.getName(), credentials);
- }
-
- }
-
- supportedTypeNames = Collections.unmodifiableSet(supportedTypeNames);
-
- this.supportedCredentials = Collections.unmodifiableMap(supportedCredentials);
-
- this.supportedSearchControls = Collections.unmodifiableSet(supportedControls);
-
-
-
-
- // Supported relationships
-
- List<String> relationshipNames = configurationMD.getSupportedRelationshipTypes();
-
- for (IdentityObjectTypeMetaData identityObjectTypeMetaData : configurationMD.getSupportedIdentityTypes())
- {
- String fromTypeName = identityObjectTypeMetaData.getName();
-
- if (identityObjectTypeMetaData.getRelationships() == null)
- {
- continue;
- }
-
- for (RelationshipMetaData relationshipMetaData : identityObjectTypeMetaData.getRelationships())
- {
- String relationshipName = relationshipMetaData.getRelationshipTypeRef();
- String toTypeName = relationshipMetaData.getIdentityObjectTypeRef();
-
- // Check if metadata info is consistent
- if (relationshipNames.contains(relationshipName))
- {
- // Populate
-
- Map<String, Set<String>> mappings = null;
-
- if (supportedRelationshipMappings.containsKey(relationshipName))
- {
- mappings = supportedRelationshipMappings.get(relationshipName);
-
- }
- else
- {
- mappings = new HashMap<String, Set<String>>();
- supportedRelationshipMappings.put(relationshipName, mappings);
- }
-
- Set<String> toTypes = null;
- if (mappings.containsKey(fromTypeName))
- {
- toTypes = mappings.get(fromTypeName);
- }
- else
- {
- toTypes = new HashSet<String>();
- mappings.put(fromTypeName, toTypes);
- }
-
- toTypes.add(toTypeName);
-
- }
- }
-
-
- }
-
- }
-
- public boolean isNamedRelationshipsSupported()
- {
- return namedRelationshipsSupport;
- }
-
- public boolean isControlSupported(IdentityObjectType identityObjectType, IdentityObjectSearchControl control)
- {
- if (supportedSearchControls.contains(control.getClass()))
- {
- return true;
- }
- return false;
- }
-
- public boolean isControlSupported(IdentityObjectType identityObjectType, Class controlClazz)
- {
- if (supportedSearchControls.contains(controlClazz))
- {
- return true;
- }
- return false;
- }
-
- public Set<String> getSupportedIdentityObjectTypes()
- {
- return supportedTypeNames;
- }
-
- public boolean isIdentityObjectTypeSupported(IdentityObjectType identityObjectType)
- {
- if (supportedTypeNames.contains(identityObjectType.getName()))
- {
- return true;
- }
- return false;
- }
-
- public boolean isRelationshipTypeSupported(IdentityObjectType fromType, IdentityObjectType toType, IdentityObjectRelationshipType relationshipType) throws IdentityException
- {
- Map<String, Set<String>> mappings = supportedRelationshipMappings.get(relationshipType.getName());
- if (mappings != null && mappings.containsKey(fromType.getName()))
- {
- if (mappings.get(fromType.getName()).contains(toType.getName()))
- {
- return true;
- }
- }
- return false;
- }
-
- public Set<String> getSupportedRelationshipTypes()
- {
- return supportedRelationshipMappings.keySet();
- }
-
- public boolean isCredentialSupported(IdentityObjectType identityObjectType, IdentityObjectCredentialType credentialType)
- {
- Set<String> types = supportedCredentials.get(identityObjectType.getName());
- if (types != null && types.contains(credentialType.getName()))
- {
- return true;
- }
- return false;
- }
-}
Copied: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/FeaturesMetaDataImpl.java (from rev 211, trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/FeaturesMetaDataImpl.java)
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/FeaturesMetaDataImpl.java (rev 0)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/FeaturesMetaDataImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,207 @@
+/*
+* 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.store;
+
+import org.jboss.identity.idm.spi.store.FeaturesMetaData;
+import org.jboss.identity.idm.spi.model.IdentityObjectType;
+import org.jboss.identity.idm.spi.model.IdentityObjectRelationshipType;
+import org.jboss.identity.idm.spi.model.IdentityObjectCredentialType;
+import org.jboss.identity.idm.spi.searchcontrol.IdentityObjectSearchControl;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityObjectTypeMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.RelationshipMetaData;
+import org.jboss.identity.idm.exception.IdentityException;
+
+import java.util.Set;
+import java.util.Map;
+import java.util.List;
+import java.util.HashSet;
+import java.util.Collections;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class FeaturesMetaDataImpl implements FeaturesMetaData
+{
+ private Set<String> supportedTypeNames = new HashSet<String>();
+
+ private final Set<Class> supportedSearchControls;
+
+ private final Map<String, Set<String>> supportedCredentials;
+
+ private final boolean namedRelationshipsSupport;
+
+ // <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<Class> supportedControls,
+ boolean namedRelationshipsSupport)
+ {
+ this.namedRelationshipsSupport = namedRelationshipsSupport;
+
+ Map<String, Set<String>> supportedCredentials = new HashMap<String, Set<String>>();
+
+ for (IdentityObjectTypeMetaData typeMetaData : configurationMD.getSupportedIdentityTypes())
+ {
+ supportedTypeNames.add(typeMetaData.getName());
+
+ if (typeMetaData.getCredentials() != null)
+ {
+ Set<String> credentials = new HashSet<String>(typeMetaData.getCredentials());
+ supportedCredentials.put(typeMetaData.getName(), credentials);
+ }
+
+ }
+
+ supportedTypeNames = Collections.unmodifiableSet(supportedTypeNames);
+
+ this.supportedCredentials = Collections.unmodifiableMap(supportedCredentials);
+
+ this.supportedSearchControls = Collections.unmodifiableSet(supportedControls);
+
+
+
+
+ // Supported relationships
+
+ List<String> relationshipNames = configurationMD.getSupportedRelationshipTypes();
+
+ for (IdentityObjectTypeMetaData identityObjectTypeMetaData : configurationMD.getSupportedIdentityTypes())
+ {
+ String fromTypeName = identityObjectTypeMetaData.getName();
+
+ if (identityObjectTypeMetaData.getRelationships() == null)
+ {
+ continue;
+ }
+
+ for (RelationshipMetaData relationshipMetaData : identityObjectTypeMetaData.getRelationships())
+ {
+ String relationshipName = relationshipMetaData.getRelationshipTypeRef();
+ String toTypeName = relationshipMetaData.getIdentityObjectTypeRef();
+
+ // Populate
+
+ Map<String, Set<String>> mappings = null;
+
+ if (supportedRelationshipMappings.containsKey(relationshipName))
+ {
+ mappings = supportedRelationshipMappings.get(relationshipName);
+
+ }
+ else
+ {
+ mappings = new HashMap<String, Set<String>>();
+ supportedRelationshipMappings.put(relationshipName, mappings);
+ }
+
+ Set<String> toTypes = null;
+ if (mappings.containsKey(fromTypeName))
+ {
+ toTypes = mappings.get(fromTypeName);
+ }
+ else
+ {
+ toTypes = new HashSet<String>();
+ mappings.put(fromTypeName, toTypes);
+ }
+
+ toTypes.add(toTypeName);
+
+
+ }
+
+
+ }
+
+ }
+
+ public boolean isNamedRelationshipsSupported()
+ {
+ return namedRelationshipsSupport;
+ }
+
+ public boolean isControlSupported(IdentityObjectType identityObjectType, IdentityObjectSearchControl control)
+ {
+ if (supportedSearchControls.contains(control.getClass()))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ public boolean isControlSupported(IdentityObjectType identityObjectType, Class controlClazz)
+ {
+ if (supportedSearchControls.contains(controlClazz))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ public Set<String> getSupportedIdentityObjectTypes()
+ {
+ return supportedTypeNames;
+ }
+
+ public boolean isIdentityObjectTypeSupported(IdentityObjectType identityObjectType)
+ {
+ if (supportedTypeNames.contains(identityObjectType.getName()))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ public boolean isRelationshipTypeSupported(IdentityObjectType fromType, IdentityObjectType toType, IdentityObjectRelationshipType relationshipType) throws IdentityException
+ {
+ Map<String, Set<String>> mappings = supportedRelationshipMappings.get(relationshipType.getName());
+ if (mappings != null && mappings.containsKey(fromType.getName()))
+ {
+ if (mappings.get(fromType.getName()).contains(toType.getName()))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public Set<String> getSupportedRelationshipTypes()
+ {
+ return supportedRelationshipMappings.keySet();
+ }
+
+ public boolean isCredentialSupported(IdentityObjectType identityObjectType, IdentityObjectCredentialType credentialType)
+ {
+ Set<String> types = supportedCredentials.get(identityObjectType.getName());
+ if (types != null && types.contains(credentialType.getName()))
+ {
+ return true;
+ }
+ return false;
+ }
+}
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/FileBasedIdentityStore.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/FileBasedIdentityStore.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/FileBasedIdentityStore.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,170 +0,0 @@
-///*
-// * 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.impl.store;
-//
-//import java.io.IOException;
-//import java.util.ArrayList;
-//import java.util.Collection;
-//import java.util.List;
-//import java.util.Map;
-//import java.util.Set;
-//
-//import org.jboss.identity.exception.IdentityException;
-//import org.jboss.identity.impl.types.SimpleIdentity;
-//import org.jboss.identity.model.core.IdentityObject;
-//import org.jboss.identity.model.core.IdentityObjectRelationshipType;
-//import org.jboss.identity.model.core.IdentityObjectType;
-//import org.jboss.identity.spi.store.FeaturesDescription;
-//import org.jboss.identity.spi.store.IdentityStore;
-//
-///**
-// * File Based Identity Store
-// * @author Anil.Saldhana at redhat.com
-// * @since Aug 1, 2008
-// */
-//public class FileBasedIdentityStore implements IdentityStore
-//{
-// //TODO: Handle file semantics
-//
-// private List<IdentityObject> identities = new ArrayList<IdentityObject>();
-//
-// public void addAttributes(IdentityObject identity, Map<String, Set<String>> attributes)
-// throws IdentityException
-// {
-// }
-//
-// public void bootstrap() throws IOException
-// {
-// }
-//
-//
-//
-// public IdentityObject createIdentityObject(String name, IdentityObjectType type) throws IdentityException
-// {
-// //Is there one already available?
-// IdentityObject identity = this.findIdentityObject(name);
-// if(identity == null)
-// {
-// identity = new SimpleIdentity(name);
-// identities.add(identity);
-// }
-// return identity;
-// }
-//
-// public <R extends IdentityObjectRelationshipType> void createRelationship(IdentityObject fromIdentity,
-// IdentityObject toIdentity,
-// IdentityObjectRelationshipType relationshipType)
-// throws IdentityException
-// {
-// }
-//
-// public <T extends IdentityObjectType> Collection<IdentityObject> findIdentityObject(IdentityObjectType identityType,
-// int offset,
-// int limit,
-// boolean orderedByName, boolean ascending) throws IdentityException
-// {
-// return null;
-// }
-//
-// public <T extends IdentityObjectType> Collection<IdentityObject> findIdentityObject(IdentityObjectType identityType,
-// Map<String, String[]> attributes, int offset,
-// int limit, boolean orderByName, boolean ascending)
-// throws IdentityException
-// {
-// return null;
-// }
-//
-// public <T extends IdentityObjectType> Set<String> getSupportedAttributeNames(T identityType) throws IdentityException
-// {
-// return null;
-// }
-//
-// public IdentityObject findIdentityObject(String name, IdentityObjectType identityObjectType) throws IdentityException
-// {
-// return null;
-// }
-//
-// public IdentityObject findIdentityObject(Object id) throws IdentityException
-// {
-// return null;
-// }
-//
-// public Map<String, Set<String>> getAttributes(IdentityObject identity)
-// throws IdentityException
-// {
-// return null;
-// }
-//
-// public String getId()
-// {
-// return null;
-// }
-//
-//
-// public <T extends IdentityObjectType> int getIdentityObjectsCount(T identityType) throws IdentityException
-// {
-// return 0;
-// }
-//
-// public <R extends IdentityObjectRelationshipType> Collection<IdentityObject> findIdentityObject(IdentityObject identity, R relationshipType, boolean parent, int offset, int limit, boolean orderByName, boolean ascending) throws IdentityException
-// {
-// return null;
-// }
-//
-// public FeaturesDescription getSupportedFeatures()
-// {
-// return null;
-// }
-//
-// public void removeAttributes(IdentityObject identity, Set<String> attributes)
-// throws IdentityException
-// {
-// }
-//
-// public void removeIdentityObject(IdentityObject identity) throws IdentityException
-// {
-// }
-//
-// public <R extends IdentityObjectRelationshipType> void removeRelationship(IdentityObject fromIdentity,
-// IdentityObject toIdentity,
-// IdentityObjectRelationshipType relationshipType)
-// throws IdentityException
-// {
-// }
-//
-// public void removeRelationships(IdentityObject identity1, IdentityObject identity2)
-// throws IdentityException
-// {
-// }
-//
-// public Set<IdentityObjectRelationshipType> resolveRelationships(IdentityObject fromIdentity,
-// IdentityObject toIdentity)
-// throws IdentityException
-// {
-// return null;
-// }
-//
-// public void updateAttributes(IdentityObject identity, Map<String, Set<String>> attributes)
-// throws IdentityException
-// {
-// }
-//}
\ No newline at end of file
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/SimpleIdentityStoreInvocationContext.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/SimpleIdentityStoreInvocationContext.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/SimpleIdentityStoreInvocationContext.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,10 +20,10 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.store;
+package org.jboss.identity.idm.impl.store;
-import org.jboss.identity.spi.store.IdentityStoreInvocationContext;
-import org.jboss.identity.spi.store.IdentityStoreSession;
+import org.jboss.identity.idm.spi.store.IdentityStoreInvocationContext;
+import org.jboss.identity.idm.spi.store.IdentityStoreSession;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/hibernate/HibernateIdentityStoreImpl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,2163 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.store.hibernate;
-
-import org.jboss.identity.spi.store.IdentityStore;
-import org.jboss.identity.spi.store.FeaturesMetaData;
-import org.jboss.identity.spi.store.IdentityStoreInvocationContext;
-import org.jboss.identity.spi.store.IdentityStoreSession;
-import org.jboss.identity.spi.searchcontrol.IdentityObjectSearchControl;
-import org.jboss.identity.spi.model.IdentityObjectRelationshipType;
-import org.jboss.identity.spi.model.IdentityObject;
-import org.jboss.identity.spi.model.IdentityObjectType;
-import org.jboss.identity.spi.model.IdentityObjectRelationship;
-import org.jboss.identity.spi.model.IdentityObjectCredential;
-import org.jboss.identity.spi.exception.OperationNotSupportedException;
-import org.jboss.identity.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
-import org.jboss.identity.spi.configuration.metadata.IdentityObjectTypeMetaData;
-import org.jboss.identity.spi.model.IdentityObjectCredentialType;
-import org.jboss.identity.spi.model.IdentityObjectAttribute;
-import org.jboss.identity.spi.attribute.IdentityObjectAttributeMetaData;
-import org.jboss.identity.exception.IdentityException;
-import org.jboss.identity.impl.model.hibernate.HibernateIdentityObject;
-import org.jboss.identity.impl.model.hibernate.HibernateIdentityObjectRelationship;
-import org.jboss.identity.impl.model.hibernate.HibernateIdentityObjectRelationshipType;
-import org.jboss.identity.impl.model.hibernate.HibernateIdentityObjectType;
-import org.jboss.identity.impl.model.hibernate.HibernateIdentityObjectRelationshipName;
-import org.jboss.identity.impl.model.hibernate.HibernateRealm;
-import org.jboss.identity.impl.model.hibernate.HibernateIdentityObjectCredentialType;
-import org.jboss.identity.impl.model.hibernate.HibernateIdentityObjectCredential;
-import org.jboss.identity.impl.model.hibernate.HibernateIdentityObjectAttribute;
-import org.jboss.identity.impl.model.hibernate.HibernateIdentityObjectTextAttribute;
-import org.jboss.identity.impl.model.hibernate.HibernateIdentityObjectBinaryAttribute;
-import org.jboss.identity.impl.api.PageSearchControl;
-import org.jboss.identity.impl.api.SortByNameSearchControl;
-import org.jboss.identity.impl.api.AttributeFilterSearchControl;
-import org.jboss.identity.impl.api.NameFilterSearchControl;
-import org.jboss.identity.impl.store.FeaturesMetaDataImpl;
-import org.hibernate.ejb.HibernateEntityManager;
-import org.hibernate.ejb.HibernateEntityManagerFactory;
-import org.hibernate.criterion.Restrictions;
-import org.hibernate.HibernateException;
-import org.hibernate.Criteria;
-
-import javax.persistence.NoResultException;
-import javax.persistence.Query;
-import javax.persistence.Persistence;
-import java.util.Set;
-import java.util.Collection;
-import java.util.Map;
-import java.util.List;
-import java.util.Iterator;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Collections;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class HibernateIdentityStoreImpl implements IdentityStore
-{
-
- //TODO: logging
-
- private final String QUERY_RELATIONSHIP_BY_FROM_TO =
- "select r from HibernateIdentityObjectRelationship r where r.fromIdentityObject like :fromIO and " +
- "r.toIdentityObject like :toIO";
-
- private final String QUERY_RELATIONSHIP_BY_FROM_TO_TYPE =
- "select r from HibernateIdentityObjectRelationship r where r.fromIdentityObject like :fromIO and " +
- "r.toIdentityObject like :toIO and r.type.name like :typeName";
-
- private final String QUERY_RELATIONSHIP_BY_FROM_TO_TYPE_NAME =
- "select r from HibernateIdentityObjectRelationship r where r.fromIdentityObject like :fromIO and " +
- "r.toIdentityObject like :toIO and r.type.name like :typeName and r.name.name like :name";
-
-// private final String QUERY_RELATIONSHIP_BY_FROM =
-// "select r from HibernateIdentityObjectRelationship r where r.fromIdentityObject like :fromIO";
-//
-// private final String QUERY_RELATIONSHIP_BY_FROM_NAMED =
-// "select r from HibernateIdentityObjectRelationship r where r.fromIdentityObject like :fromIO and " +
-// "r.name is not null";
-//
-// private final String QUERY_RELATIONSHIP_BY_FROM_NAME =
-// "select r from HibernateIdentityObjectRelationship r where r.fromIdentityObject like :fromIO and " +
-// "r.name.name = :name";
-//
-// private final String QUERY_RELATIONSHIP_BY_TO =
-// "select r from HibernateIdentityObjectRelationship r where r.toIdentityObject like :toIO";
-//
-// private final String QUERY_RELATIONSHIP_BY_TO_NAMED =
-// "select r from HibernateIdentityObjectRelationship r where r.toIdentityObject like :toIO and" +
-// "r.name is not null";
-//
-// private final String QUERY_RELATIONSHIP_BY_TO_NAME =
-// "select r from HibernateIdentityObjectRelationship r where r.toIdentityObject like :toIO and " +
-// "r.name.name = :name";
-
-
- private final String QUERY_RELATIONSHIP_BY_IDENTITIES =
- "select r from HibernateIdentityObjectRelationship r where " +
- "(r.fromIdentityObject like :IO1 and r.toIdentityObject like :IO2) or " +
- "(r.fromIdentityObject like :IO2 and r.toIdentityObject like :IO1)";
-
- public static final String PERSISTENCE_UNIT = "persistenceUnit";
-
- public static final String POPULATE_MEMBERSHIP_TYPES = "populateRelationshipTypes";
-
- public static final String POPULATE_IDENTITY_OBJECT_TYPES = "populateIdentityObjectTypes";
-
- public static final String IS_REALM_AWARE = "isRealmAware";
-
- public static final String ALLOW_NOT_DEFINED_ATTRIBUTES = "allowNotDefinedAttributes";
-
- public static final String DEFAULT_REALM_NAME = HibernateIdentityStoreImpl.class.getName() + ".DEFAULT_REALM";
-
- public static final String CREDENTIAL_TYPE_PASSWORD = "PASSWORD";
-
- public static final String CREDENTIAL_TYPE_BINARY = "BINARY";
-
- private String id;
-
- private FeaturesMetaData supportedFeatures;
-
- private HibernateEntityManagerFactory emFactory;
-
- private boolean isRealmAware = false;
-
- private boolean isAllowNotDefinedAttributes = false;
-
- // TODO: rewrite this into some more handy object
- private IdentityStoreConfigurationMetaData configurationMD;
-
- private static Set<Class> supportedIdentityObjectSearchControls = new HashSet<Class>();
-
- private static Set<String> supportedCredentialTypes = new HashSet<String>();
-
- // <IdentityObjectType name, Set<Attribute name>>
- private Map<String, Set<String>> attributeMappings = new HashMap<String, Set<String>>();
-
- // <IdentityObjectType name, <Attribute name, MD>
- private Map<String, Map<String, IdentityObjectAttributeMetaData>> attributesMetaData = new HashMap<String, Map<String, IdentityObjectAttributeMetaData>>();
-
- // <IdentityObjectType name, <Attribute store mapping, Attribute name>
- private Map<String, Map<String, String>> reverseAttributeMappings = new HashMap<String, Map<String, String>>();
-
- static {
- // List all supported controls classes
-
- supportedIdentityObjectSearchControls.add(PageSearchControl.class);
- supportedIdentityObjectSearchControls.add(SortByNameSearchControl.class);
- supportedIdentityObjectSearchControls.add(AttributeFilterSearchControl.class);
- supportedIdentityObjectSearchControls.add(NameFilterSearchControl.class);
-
- // credential types supported by this impl
- supportedCredentialTypes.add(CREDENTIAL_TYPE_PASSWORD);
- supportedCredentialTypes.add(CREDENTIAL_TYPE_BINARY);
-
- }
-
- public HibernateIdentityStoreImpl(String id)
- {
- this.id = id;
- }
-
- public void bootstrap(IdentityStoreConfigurationMetaData configurationMD) throws IdentityException
- {
- this.configurationMD = configurationMD;
-
- id = configurationMD.getId();
-
- supportedFeatures = new FeaturesMetaDataImpl(configurationMD, supportedIdentityObjectSearchControls, true);
-
- String persistenceUnit = configurationMD.getOptionSingleValue(PERSISTENCE_UNIT);
-
- String populateMembershipTypes = configurationMD.getOptionSingleValue(POPULATE_MEMBERSHIP_TYPES);
- String populateIdentityObjectTypes = configurationMD.getOptionSingleValue(POPULATE_IDENTITY_OBJECT_TYPES);
-
- HibernateEntityManager em = bootstrapHibernateEntityManager(persistenceUnit);
-
- // Attribute mappings - helper structures
-
- for (IdentityObjectTypeMetaData identityObjectTypeMetaData : configurationMD.getSupportedIdentityTypes())
- {
- Set<String> names = new HashSet<String>();
- Map<String, IdentityObjectAttributeMetaData> metadataMap = new HashMap<String, IdentityObjectAttributeMetaData>();
- Map<String, String> reverseMap = new HashMap<String, String>();
- for (IdentityObjectAttributeMetaData attributeMetaData : identityObjectTypeMetaData.getAttributes())
- {
- names.add(attributeMetaData.getName());
- metadataMap.put(attributeMetaData.getName(), attributeMetaData);
- if (attributeMetaData.getStoreMapping() != null)
- {
- reverseMap.put(attributeMetaData.getStoreMapping(), attributeMetaData.getName());
- }
- }
-
- // Use unmodifiableSet as it'll be exposed directly
- attributeMappings.put(identityObjectTypeMetaData.getName(), Collections.unmodifiableSet(names));
-
- attributesMetaData.put(identityObjectTypeMetaData.getName(), metadataMap);
-
- reverseAttributeMappings.put(identityObjectTypeMetaData.getName(), reverseMap);
- }
-
- attributeMappings = Collections.unmodifiableMap(attributeMappings);
-
- if (populateMembershipTypes != null && populateMembershipTypes.equalsIgnoreCase("true"))
- {
- List<String> memberships = new LinkedList<String>();
-
- for (String membership : configurationMD.getSupportedRelationshipTypes())
- {
- memberships.add(membership);
- }
-
- try
- {
- populateRelationshipTypes(em, memberships.toArray(new String[memberships.size()]));
- }
- catch (Exception e)
- {
- throw new IdentityException("Failed to populate relationship types", e);
- }
-
-
- }
-
- if (populateIdentityObjectTypes != null && populateIdentityObjectTypes.equalsIgnoreCase("true"))
- {
- List<String> types = new LinkedList<String>();
-
- for (IdentityObjectTypeMetaData metaData : configurationMD.getSupportedIdentityTypes())
- {
- types.add(metaData.getName());
- }
-
- try
- {
- populateObjectTypes(em, types.toArray(new String[types.size()]));
- }
- catch (Exception e)
- {
- throw new IdentityException("Failed to populate identity object types", e);
- }
-
- }
-
- if (supportedCredentialTypes != null && supportedCredentialTypes.size() > 0)
- {
- try
- {
- populateCredentialTypes(em, supportedCredentialTypes.toArray(new String[supportedCredentialTypes.size()]));
- }
- catch (Exception e)
- {
- throw new IdentityException("Failed to populated credential types");
- }
- }
-
- String realmAware = configurationMD.getOptionSingleValue(IS_REALM_AWARE);
-
- if (realmAware != null && realmAware.equalsIgnoreCase("true"))
- {
- this.isRealmAware = true;
- }
-
- String allowNotDefineAttributes = configurationMD.getOptionSingleValue(ALLOW_NOT_DEFINED_ATTRIBUTES);
-
- if (allowNotDefineAttributes != null && allowNotDefineAttributes.equalsIgnoreCase("true"))
- {
- this.isAllowNotDefinedAttributes = true;
- }
-
- // Default realm
-
- HibernateRealm realm = null;
-
- try
- {
-
- em.getTransaction().begin();
-
- realm = (HibernateRealm)em.getSession().
- createCriteria(HibernateRealm.class).add(Restrictions.eq("name", DEFAULT_REALM_NAME)).uniqueResult();
-
- em.getTransaction().commit();
-
- }
- catch (HibernateException e)
- {
- // Realm does not exist
- }
-
- if (realm == null)
- {
- addRealm(em, DEFAULT_REALM_NAME);
- }
-
- }
-
- // this is separate method to allow easier testing
- protected HibernateEntityManager bootstrapHibernateEntityManager(String persistenceUnit) throws IdentityException
- {
- if (persistenceUnit == null)
- {
- throw new IdentityException("Persistence Unit not defined for IdentityStore: " + getId());
- }
-
- emFactory = (HibernateEntityManagerFactory)Persistence.createEntityManagerFactory(persistenceUnit);
-
- return (HibernateEntityManager)emFactory.createEntityManager();
-
- }
-
-
- public IdentityStoreSession createIdentityStoreSession() throws IdentityException
- {
- try
- {
- return new HibernateIdentityStoreSessionImpl((HibernateEntityManager)emFactory.createEntityManager());
- }
- catch (Exception e)
- {
- throw new IdentityException("Failed to obtain HibernateEntityManager",e);
- }
- }
-
- public String getId()
- {
- return id;
- }
-
- public void setId(String id)
- {
- this.id = id;
- }
-
- public FeaturesMetaData getSupportedFeatures()
- {
- return supportedFeatures;
- }
-
- public IdentityObject createIdentityObject(IdentityStoreInvocationContext invocationCtx, String name, IdentityObjectType identityObjectType) throws IdentityException
- {
- return createIdentityObject(invocationCtx, name, identityObjectType, null);
- }
-
- public IdentityObject createIdentityObject(IdentityStoreInvocationContext ctx,
- String name,
- IdentityObjectType identityObjectType,
- Map<String, String[]> attributes) throws IdentityException
- {
-
- if (name == null)
- {
- throw new IllegalArgumentException("IdentityObject name is null");
- }
-
- checkIOType(identityObjectType);
-
- HibernateEntityManager em = getHibernateEntityManager(ctx);
-
- HibernateRealm realm = getRealm(em, ctx);
-
- // Check if object with a given name and type is not present already
- List results = em.createNamedQuery("findIdentityObjectByNameAndType")
- .setParameter("realm", realm)
- .setParameter("name", name)
- .setParameter("typeName", identityObjectType.getName())
- .getResultList();
-
- if (results.size() != 0)
- {
- throw new IdentityException("IdentityObject already present in this IdentityStore");
- }
-
-
-
- HibernateIdentityObjectType hibernateType = getHibernateIdentityObjectType(ctx, identityObjectType);
-
- HibernateIdentityObject io = new HibernateIdentityObject(name, hibernateType, realm);
-
- if (attributes != null)
- {
- for (Map.Entry<String, String[]> entry : attributes.entrySet())
- {
- io.addTextAttribute(entry.getKey(), entry.getValue());
- }
- }
-
- try
- {
- getHibernateEntityManager(ctx).persist(io);
- }
- catch (Exception e)
- {
- throw new IdentityException("Cannot persist new IdentityObject" + io, e);
- }
-
-
- return io;
- }
-
- public void removeIdentityObject(IdentityStoreInvocationContext ctx, IdentityObject identity) throws IdentityException
- {
- HibernateIdentityObject hibernateObject = safeGet(ctx, identity);
-
- HibernateEntityManager hem = getHibernateEntityManager(ctx);
-
- try
- {
- // Remove all related relationships
- for (HibernateIdentityObjectRelationship relationship : hibernateObject.getFromRelationships())
- {
- relationship.getFromIdentityObject().getFromRelationships().remove(relationship);
- relationship.getToIdentityObject().getToRelationships().remove(relationship);
-
- hem.remove(relationship);
- }
-
- for (HibernateIdentityObjectRelationship relationship : hibernateObject.getToRelationships())
- {
- relationship.getFromIdentityObject().getFromRelationships().remove(relationship);
- relationship.getToIdentityObject().getToRelationships().remove(relationship);
-
- hem.remove(relationship);
- }
-
- hem.remove(hibernateObject);
- }
- catch (Exception e)
- {
- throw new IdentityException("Cannot remove IdentityObject" + identity, e);
- }
- }
-
- public int getIdentityObjectsCount(IdentityStoreInvocationContext ctx, IdentityObjectType identityType) throws IdentityException
- {
- checkIOType(identityType);
-
- HibernateIdentityObjectType jpaType = getHibernateIdentityObjectType(ctx, identityType);
-
- HibernateEntityManager em = getHibernateEntityManager(ctx);
-
- int count;
- try
- {
- count = ((Number)em
- .createNamedQuery("countIdentityObjectsByType")
- .setParameter("typeName", jpaType.getName())
- .setParameter("realm", getRealm(em, ctx))
- .getSingleResult()).intValue();
- }
- catch (Exception e)
- {
- throw new IdentityException("Cannot count stored IdentityObjects with type: " + identityType.getName(), e);
- }
-
- return count;
- }
-
- public IdentityObject findIdentityObject(IdentityStoreInvocationContext ctx, String name, IdentityObjectType type) throws IdentityException
- {
-
- if (name == null)
- {
- throw new IllegalArgumentException("IdentityObject name is null");
- }
-
- checkIOType(type);
-
- HibernateIdentityObjectType hibernateType = getHibernateIdentityObjectType(ctx, type);
-
- HibernateIdentityObject hibernateObject = null;
-
- HibernateEntityManager em = getHibernateEntityManager(ctx);
-
- try
- {
- hibernateObject = (HibernateIdentityObject)getHibernateEntityManager(ctx).
- createNamedQuery("findIdentityObjectByNameAndType")
- .setParameter("realm", getRealm(em, ctx))
- .setParameter("name", name)
- .setParameter("typeName", hibernateType.getName())
- .getSingleResult();
- }
- catch (Exception e)
- {
- throw new IdentityException("Cannot find IdentityObject with name '" + name + "' and type '" + type.getName() + "'", e);
- }
-
- return hibernateObject;
- }
-
- public IdentityObject findIdentityObject(IdentityStoreInvocationContext ctx, String id) throws IdentityException
- {
- if (id == null)
- {
- throw new IllegalArgumentException("id is null");
- }
-
- HibernateIdentityObject hibernateObject;
-
- try
- {
- hibernateObject = getHibernateEntityManager(ctx).find(HibernateIdentityObject.class, new Long(id));
- }
- catch(Exception e)
- {
- throw new IdentityException("Cannot find IdentityObject with id: " + id, e);
- }
-
- return hibernateObject;
- }
-
-
-
- public Collection<IdentityObject> findIdentityObject(IdentityStoreInvocationContext ctx,
- IdentityObjectType identityType,
- IdentityObjectSearchControl[] controls) throws IdentityException
- {
- checkIOType(identityType);
-
- checkControls(controls);
-
- PageSearchControl pageSearchControl = null;
- SortByNameSearchControl sortSearchControl = null;
- AttributeFilterSearchControl attributeFilterControl = null;
- NameFilterSearchControl nameFilterSearchControl = null;
-
- if (controls != null)
- {
- for (IdentityObjectSearchControl control : controls)
- {
- if (control instanceof PageSearchControl)
- {
- pageSearchControl = (PageSearchControl)control;
- }
- else if (control instanceof SortByNameSearchControl)
- {
- sortSearchControl = (SortByNameSearchControl)control;
- }
- else if (control instanceof AttributeFilterSearchControl)
- {
- attributeFilterControl = (AttributeFilterSearchControl)control;
- }
- else if (control instanceof NameFilterSearchControl)
- {
- nameFilterSearchControl = (NameFilterSearchControl)control;
- }
- }
- }
-
- HibernateIdentityObjectType hibernateType = getHibernateIdentityObjectType(ctx, identityType);
-
- List<IdentityObject> results;
-
- HibernateEntityManager em = getHibernateEntityManager(ctx);
-
- try
- {
-
- Query q = null;
-
- if (sortSearchControl != null)
- {
- if (sortSearchControl.isAscending())
- {
- q = em.createNamedQuery("findIdentityObjectsByTypeOrderedByNameAsc");
- }
- else
- {
- q = em.createNamedQuery("findIdentityObjectsByTypeOrderedByNameDesc");
- }
- }
- else
- {
- q = em.createNamedQuery("findIdentityObjectsByType");
- }
-
- if (pageSearchControl != null)
- {
- if (pageSearchControl.getLimit() > 0)
- {
- q.setMaxResults(pageSearchControl.getLimit());
- }
- q.setFirstResult(pageSearchControl.getOffset());
-
- }
-
- q.setParameter("realm", getRealm(em, ctx))
- .setParameter("typeName", hibernateType.getName());
-
- if (nameFilterSearchControl != null)
- {
- q.setParameter("nameFilter", nameFilterSearchControl.getFilter().replaceAll("\\*", "%"));
- }
- else
- {
- q.setParameter("nameFilter", "%");
- }
-
-
-
- results = (List<IdentityObject>)q.getResultList();
-
- }
- catch (Exception e)
- {
- throw new IdentityException("Cannot find IdentityObjects with type '" + identityType.getName() + "'", e);
- }
-
- if (attributeFilterControl != null)
- {
- filterByAttributesValues(results, attributeFilterControl.getValues());
- }
-
- return results;
- }
-
-
-
- public Collection<IdentityObject> findIdentityObject(IdentityStoreInvocationContext ctx, IdentityObjectType identityType) throws IdentityException
- {
- return findIdentityObject(ctx, identityType, null);
- }
-
-
- public Collection<IdentityObject> findIdentityObject(IdentityStoreInvocationContext ctx, IdentityObject identity, IdentityObjectRelationshipType relationshipType, boolean parent, IdentityObjectSearchControl[] controls) throws IdentityException
- {
- //TODO:test
-
- HibernateIdentityObject hibernateObject = safeGet(ctx, identity);
-
- List<IdentityObject> results;
-
- checkControls(controls);
-
- PageSearchControl pageSearchControl = null;
- SortByNameSearchControl sortSearchControl = null;
- AttributeFilterSearchControl attributeFilterControl = null;
- NameFilterSearchControl nameFilterSearchControl = null;
-
- if (controls != null)
- {
- for (IdentityObjectSearchControl control : controls)
- {
- if (control instanceof PageSearchControl)
- {
- pageSearchControl = (PageSearchControl)control;
- }
- else if (control instanceof SortByNameSearchControl)
- {
- sortSearchControl = (SortByNameSearchControl)control;
- }
- else if (control instanceof AttributeFilterSearchControl)
- {
- attributeFilterControl = (AttributeFilterSearchControl)control;
- }
- else if (control instanceof NameFilterSearchControl)
- {
- nameFilterSearchControl = (NameFilterSearchControl)control;
- }
- }
- }
-
- boolean orderByName = false;
- boolean ascending = true;
-
- if (sortSearchControl != null)
- {
- orderByName = true;
- ascending = sortSearchControl.isAscending();
- }
-
- try
- {
- org.hibernate.Query q = null;
-
- StringBuilder hqlString = new StringBuilder("");
-
- if (orderByName)
- {
- hqlString.append(" orderBy ior.toIdentityObject.name");
- if (ascending)
- {
- hqlString.append(" asc");
- }
- }
-
- if (parent)
- {
- hqlString.append("select ior.toIdentityObject from HibernateIdentityObjectRelationship ior where " +
- "ior.toIdentityObject.name like :nameFilter and ior.type.name like :relType and ior.fromIdentityObject like :identity");
-
- if (orderByName)
- {
- hqlString.append(" orderBy ior.toIdentityObject.name");
- if (ascending)
- {
- hqlString.append(" asc");
- }
- }
- }
- else
- {
- hqlString.append("select ior.fromIdentityObject from HibernateIdentityObjectRelationship ior where " +
- "ior.fromIdentityObject.name like :nameFilter and ior.type.name like :relType and ior.toIdentityObject like :identity");
-
-
- if (orderByName)
- {
- hqlString.append(" orderBy ior.toIdentityObject.name");
- if (ascending)
- {
- hqlString.append(" asc");
- }
- }
- }
-
-
-
- q = getHibernateEntityManager(ctx).getSession().createQuery(hqlString.toString())
- .setParameter("relType", relationshipType.getName())
- .setParameter("identity",hibernateObject);
-
- if (nameFilterSearchControl != null)
- {
- q.setParameter("nameFilter", nameFilterSearchControl.getFilter().replaceAll("\\*", "%"));
- }
- else
- {
- q.setParameter("nameFilter", "%");
- }
-
-
- if (pageSearchControl != null)
- {
- q.setFirstResult(pageSearchControl.getOffset());
- if (pageSearchControl.getLimit() > 0)
- {
- q.setMaxResults(pageSearchControl.getLimit());
- }
- }
-
-
-
- results = q.list();
-
-
- }
- catch (Exception e)
- {
- throw new IdentityException("Cannot find IdentityObjects", e);
- }
-
- if (attributeFilterControl != null)
- {
- filterByAttributesValues(results, attributeFilterControl.getValues());
- }
-
- return results;
- }
-
- public Collection<IdentityObject> findIdentityObject(IdentityStoreInvocationContext ctx,
- IdentityObject identity,
- IdentityObjectRelationshipType relationshipType,
- boolean parent) throws IdentityException
- {
-
- return findIdentityObject(ctx, identity, relationshipType, parent, null);
- }
-
- public IdentityObjectRelationship createRelationship(IdentityStoreInvocationContext ctx,
- IdentityObject fromIdentity,
- IdentityObject toIdentity,
- IdentityObjectRelationshipType relationshipType,
- String name, boolean createNames) throws IdentityException
- {
-
- if (relationshipType == null)
- {
- throw new IllegalArgumentException("RelationshipType is null");
- }
-
- HibernateIdentityObject fromIO = safeGet(ctx, fromIdentity);
- HibernateIdentityObject toIO = safeGet(ctx, toIdentity);
- HibernateIdentityObjectRelationshipType type = getHibernateIdentityObjectRelationshipType(ctx, relationshipType);
-
- getSupportedFeatures().isRelationshipTypeSupported(fromIO.getIdentityType(), toIO.getIdentityType(), relationshipType);
-
-
- org.hibernate.Query query = getHibernateEntityManager(ctx).getSession().createQuery(QUERY_RELATIONSHIP_BY_FROM_TO_TYPE_NAME)
- .setParameter("fromIO", fromIO)
- .setParameter("toIO", toIO)
- .setParameter("typeName", type.getName())
- .setParameter("name", name);
-
- List results = query.list();
-
- if (results.size() != 0)
- {
- throw new IdentityException("Relationship already present");
- }
-
- HibernateIdentityObjectRelationship relationship = null;
-
- if (name != null)
- {
-
- HibernateIdentityObjectRelationshipName relationshipName = (HibernateIdentityObjectRelationshipName)getHibernateEntityManager(ctx).getSession().createCriteria(HibernateIdentityObjectRelationshipName.class).add(Restrictions.eq("name", name)).uniqueResult();
-
- if (relationshipName == null)
- {
- throw new IdentityException("Relationship name not present in the store");
- }
-
- relationship = new HibernateIdentityObjectRelationship(type, fromIO, toIO, relationshipName);
- }
- else
- {
- relationship = new HibernateIdentityObjectRelationship(type, fromIO, toIO);
- }
-
- getHibernateEntityManager(ctx).persist(relationship);
-
- return relationship;
-
- }
-
-
-
- public void removeRelationship(IdentityStoreInvocationContext ctx, IdentityObject fromIdentity, IdentityObject toIdentity, IdentityObjectRelationshipType relationshipType, String name) throws IdentityException
- {
-
- if (relationshipType == null)
- {
- throw new IllegalArgumentException("RelationshipType is null");
- }
-
- HibernateIdentityObject fromIO = safeGet(ctx, fromIdentity);
- HibernateIdentityObject toIO = safeGet(ctx, toIdentity);
- HibernateIdentityObjectRelationshipType type = getHibernateIdentityObjectRelationshipType(ctx, relationshipType);
-
- getSupportedFeatures().isRelationshipTypeSupported(fromIO.getIdentityType(), toIO.getIdentityType(), relationshipType);
-
- org.hibernate.Query query = null;
-
- if (name == null)
- {
- query = getHibernateEntityManager(ctx).getSession().createQuery(QUERY_RELATIONSHIP_BY_FROM_TO_TYPE)
- .setParameter("fromIO", fromIO)
- .setParameter("toIO", toIO)
- .setParameter("typeName", type.getName());
- }
- else
- {
- HibernateIdentityObjectRelationshipName relationshipName = (HibernateIdentityObjectRelationshipName)getHibernateEntityManager(ctx).getSession().createCriteria(HibernateIdentityObjectRelationshipName.class).add(Restrictions.eq("name", name)).uniqueResult();
-
- if (relationshipName == null)
- {
- throw new IdentityException("Relationship name not present in the store");
- }
-
- query = getHibernateEntityManager(ctx).getSession().createQuery(QUERY_RELATIONSHIP_BY_FROM_TO_TYPE_NAME)
- .setParameter("fromIO", fromIO)
- .setParameter("toIO", toIO)
- .setParameter("typeName", type.getName())
- .setParameter("name", name);
- }
-
-
- List results = query.list();
-
- if (results == null)
- {
- throw new IdentityException("Relationship already present");
- }
-
- HibernateIdentityObjectRelationship relationship = (HibernateIdentityObjectRelationship)results.iterator().next();
-
- fromIO.getFromRelationships().remove(relationship);
- toIO.getToRelationships().remove(relationship);
- getHibernateEntityManager(ctx).remove(relationship);
-
- }
-
- public void removeRelationships(IdentityStoreInvocationContext ctx, IdentityObject identity1, IdentityObject identity2, boolean named) throws IdentityException
- {
- HibernateIdentityObject hio1 = safeGet(ctx, identity1);
- HibernateIdentityObject hio2 = safeGet(ctx, identity2);
-
- org.hibernate.Query query = getHibernateEntityManager(ctx).getSession().createQuery(QUERY_RELATIONSHIP_BY_IDENTITIES)
- .setParameter("IO1", hio1)
- .setParameter("IO2", hio2);
-
- List results = query.list();
-
- for (Iterator iterator = results.iterator(); iterator.hasNext();)
- {
- HibernateIdentityObjectRelationship relationship = (HibernateIdentityObjectRelationship) iterator.next();
-
- if ((named && relationship.getName() != null) ||
- (!named && relationship.getName() == null))
- {
- relationship.getFromIdentityObject().getFromRelationships().remove(relationship);
- relationship.getToIdentityObject().getToRelationships().remove(relationship);
- getHibernateEntityManager(ctx).remove(relationship);
- }
- }
- }
-
- public Set<IdentityObjectRelationship> resolveRelationships(IdentityStoreInvocationContext ctx,
- IdentityObject fromIdentity,
- IdentityObject toIdentity,
- IdentityObjectRelationshipType relationshipType) throws IdentityException
- {
-
- HibernateIdentityObject hio1 = safeGet(ctx, fromIdentity);
- HibernateIdentityObject hio2 = safeGet(ctx, toIdentity);
-
- org.hibernate.Query query = null;
-
- if (relationshipType == null)
- {
- query = getHibernateEntityManager(ctx).getSession().createQuery(QUERY_RELATIONSHIP_BY_FROM_TO);
- }
- else
- {
- query = getHibernateEntityManager(ctx).getSession().createQuery(QUERY_RELATIONSHIP_BY_FROM_TO_TYPE)
- .setParameter("typeName", relationshipType.getName());
-
- }
-
- query.setParameter("fromIO", hio1)
- .setParameter("toIO", hio2);
-
-
- List<HibernateIdentityObjectRelationship> results = query.list();
-
- return new HashSet<IdentityObjectRelationship>(results);
- }
-
- public Set<IdentityObjectRelationship> resolveRelationships(IdentityStoreInvocationContext ctx,
- IdentityObject identity,
- IdentityObjectRelationshipType type,
- boolean parent,
- boolean named,
- String name) throws IdentityException
- {
- HibernateIdentityObject hio = safeGet(ctx, identity);
-
-
- Criteria criteria = getHibernateEntityManager(ctx).getSession().createCriteria(HibernateIdentityObjectRelationship.class);
-
- if (type != null)
- {
- HibernateIdentityObjectRelationshipType hibernateType = getHibernateIdentityObjectRelationshipType(ctx, type);
-
- criteria.add(Restrictions.eq("type", hibernateType));
- }
-
- if (name != null)
- {
- criteria.add(Restrictions.eq("name.name", name));
- }
- else if (named)
- {
- criteria.add(Restrictions.isNotNull("name"));
- }
- else
- {
- criteria.add(Restrictions.isNull("name"));
- }
-
- if (parent)
- {
- criteria.add(Restrictions.eq("fromIdentityObject", hio));
- }
- else
- {
- criteria.add(Restrictions.eq("toIdentityObject", hio));
- }
-
- List<HibernateIdentityObjectRelationship> results = criteria.list();
-
- return new HashSet<IdentityObjectRelationship>(results);
- }
-
- public String createRelationshipName(IdentityStoreInvocationContext ctx, String name) throws IdentityException, OperationNotSupportedException
- {
- if (name == null)
- {
- throw new IllegalArgumentException("name is null");
- }
-
- HibernateEntityManager em = getHibernateEntityManager(ctx);
-
- HibernateRealm realm = getRealm(em, ctx);
-
- try
- {
- HibernateIdentityObjectRelationshipName hiorn = (HibernateIdentityObjectRelationshipName)em.getSession().createCriteria(HibernateIdentityObjectRelationshipName.class)
- .add(Restrictions.eq("name", name)).add(Restrictions.eq("realm", realm)).uniqueResult();
-
- if (hiorn != null)
- {
- throw new IdentityException("Relationship name already exists");
- }
-
- hiorn = new HibernateIdentityObjectRelationshipName(name, realm);
- getHibernateEntityManager(ctx).persist(hiorn);
-
- }
- catch (Exception e)
- {
- throw new IdentityException("Cannot create new relationship name: " + name, e);
- }
-
-
- return name;
- }
-
- public String removeRelationshipName(IdentityStoreInvocationContext ctx, String name) throws IdentityException, OperationNotSupportedException
- {
- if (name == null)
- {
- throw new IllegalArgumentException("name is null");
- }
-
- HibernateEntityManager em = getHibernateEntityManager(ctx);
-
-
- try
- {
- HibernateIdentityObjectRelationshipName hiorn = (HibernateIdentityObjectRelationshipName)em.getSession().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");
- }
-
- getHibernateEntityManager(ctx).remove(hiorn);
-
- }
- catch (Exception e)
- {
- throw new IdentityException("Cannot create new relationship name: " + name, e);
- }
-
-
- return name;
- }
-
- public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx, IdentityObjectSearchControl[] controls) throws IdentityException, OperationNotSupportedException
- {
-
- Set<String> names = new HashSet<String>();
-
- HibernateEntityManager em = getHibernateEntityManager(ctx);
-
- checkControls(controls);
-
- PageSearchControl pageSearchControl = null;
- SortByNameSearchControl sortSearchControl = null;
- AttributeFilterSearchControl attributeFilterControl = null;
- NameFilterSearchControl nameFilterSearchControl = null;
-
- if (controls != null)
- {
- for (IdentityObjectSearchControl control : controls)
- {
- if (control instanceof PageSearchControl)
- {
- pageSearchControl = (PageSearchControl)control;
- }
- else if (control instanceof SortByNameSearchControl)
- {
- sortSearchControl = (SortByNameSearchControl)control;
- }
- else if (control instanceof AttributeFilterSearchControl)
- {
- attributeFilterControl = (AttributeFilterSearchControl)control;
- }
- else if (control instanceof NameFilterSearchControl)
- {
- nameFilterSearchControl = (NameFilterSearchControl)control;
- }
- }
- }
-
-
- try
- {
- Query q = null;
-
- if (sortSearchControl != null)
- {
- if (sortSearchControl.isAscending())
- {
- q = em.createNamedQuery("findIdentityObjectRelationshipNamesOrderedByNameAsc");
- }
- else
- {
- q = em.createNamedQuery("findIdentityObjectRelationshipNamesOrderedByNameDesc");
- }
- }
- else
- {
- q = em.createNamedQuery("findIdentityObjectRelationshipNames");
- }
-
- q.setParameter("realm", getRealm(em, ctx));
-
- if (nameFilterSearchControl != null)
- {
- q.setParameter("nameFilter", nameFilterSearchControl.getFilter().replaceAll("\\*", "%"));
- }
- else
- {
- q.setParameter("nameFilter", "%");
- }
-
-
- if (pageSearchControl != null)
- {
- q.setFirstResult(pageSearchControl.getOffset());
- if (pageSearchControl.getLimit() > 0)
- {
- q.setMaxResults(pageSearchControl.getLimit());
- }
- }
-
- List<String> results = (List<String>)q.getResultList();
-
- names = new HashSet<String>(results);
-
- }
- catch (Exception e)
- {
- throw new IdentityException("Cannot get relationship names. ", e);
- }
-
- return names;
- }
-
- public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx) throws IdentityException, OperationNotSupportedException
- {
- return getRelationshipNames(ctx, new IdentityObjectSearchControl[]{});
- }
-
- public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx, IdentityObject identity, IdentityObjectSearchControl[] controls) throws IdentityException, OperationNotSupportedException
- {
-
- Set<String> names;
-
- HibernateIdentityObject hibernateObject = safeGet(ctx, identity);
-
- HibernateEntityManager em = getHibernateEntityManager(ctx);
-
- checkControls(controls);
-
- PageSearchControl pageSearchControl = null;
- SortByNameSearchControl sortSearchControl = null;
-
- if (controls != null)
- {
- for (IdentityObjectSearchControl control : controls)
- {
- if (control instanceof PageSearchControl)
- {
- pageSearchControl = (PageSearchControl)control;
- }
- else if (control instanceof SortByNameSearchControl)
- {
- sortSearchControl = (SortByNameSearchControl)control;
- }
- }
- }
-
- try
- {
- Query q = null;
-
- if (sortSearchControl != null)
- {
- if (sortSearchControl.isAscending())
- {
- q = em.createNamedQuery("findIdentityObjectRelationshipNamesForIdentityObjectOrderedByNameAsc");
- }
- else
- {
- q = em.createNamedQuery("findIdentityObjectRelationshipNamesForIdentityObjectOrderedByNameDesc");
- }
- }
- else
- {
- q = em.createNamedQuery("findIdentityObjectRelationshipNamesForIdentityObject");
- }
-
- q.setParameter("identityObject", hibernateObject);
-
- if (pageSearchControl != null)
- {
- q.setFirstResult(pageSearchControl.getOffset());
- if (pageSearchControl.getLimit() > 0)
- {
- q.setMaxResults(pageSearchControl.getLimit());
- }
- }
-
- List<String> results = (List<String>)q.getResultList();
-
- names = new HashSet<String>(results);
-
- }
- catch (Exception e)
- {
- throw new IdentityException("Cannot get relationship names. ", e);
- }
-
- return names;
- }
-
- public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx, IdentityObject identity) throws IdentityException, OperationNotSupportedException
- {
- return getRelationshipNames(ctx, identity, null);
- }
-
- // Attribute store
-
- public Set<String> getSupportedAttributeNames(IdentityStoreInvocationContext ctx, IdentityObjectType identityType) throws IdentityException
- {
- checkIOType(identityType);
-
- if (attributeMappings.containsKey(identityType.getName()))
- {
- return attributeMappings.get(identityType.getName());
- }
-
- return new HashSet<String>();
-
- }
-
- public IdentityObjectAttribute getAttribute(IdentityStoreInvocationContext ctx, IdentityObject identity, String name) throws IdentityException
- {
- HibernateIdentityObject hibernateObject = safeGet(ctx, identity);
-
- Set<HibernateIdentityObjectAttribute> storeAttributes = hibernateObject.getAttributes();
- Map<String, IdentityObjectAttribute> result = new HashMap<String, IdentityObjectAttribute>();
-
- // Remap the names
- for (HibernateIdentityObjectAttribute attribute : storeAttributes)
- {
- String mappedName = resolveAttributeNameFromStoreMapping(identity.getIdentityType(), name);
- if (mappedName != null)
- {
- return attribute;
- }
- }
-
- return null;
- }
-
- public Map<String, IdentityObjectAttribute> getAttributes(IdentityStoreInvocationContext ctx, IdentityObject identity) throws IdentityException
- {
-
- HibernateIdentityObject hibernateObject = safeGet(ctx, identity);
-
- Set<HibernateIdentityObjectAttribute> storeAttributes = hibernateObject.getAttributes();
- Map<String, IdentityObjectAttribute> result = new HashMap<String, IdentityObjectAttribute>();
-
- // Remap the names
- for (HibernateIdentityObjectAttribute attribute : storeAttributes)
- {
- String name = resolveAttributeNameFromStoreMapping(identity.getIdentityType(), attribute.getName());
- if (name != null)
- {
- result.put(name, attribute);
- }
- }
-
- return result;
-
- }
-
- public Map<String, IdentityObjectAttributeMetaData> getAttributesMetaData(IdentityStoreInvocationContext invocationContext,
- IdentityObjectType identityType)
- {
- return attributesMetaData.get(identityType.getName());
- }
-
-
-
- public void updateAttributes(IdentityStoreInvocationContext ctx, IdentityObject identity, IdentityObjectAttribute[] attributes) throws IdentityException
- {
-
- if (attributes == null)
- {
- throw new IllegalArgumentException("attributes are null");
- }
-
- //TODO: check if attribute values time is same as MD type
-
- Map<String, IdentityObjectAttribute> mappedAttributes = new HashMap<String, IdentityObjectAttribute>();
-
- Map<String, IdentityObjectAttributeMetaData> mdMap = attributesMetaData.get(identity.getIdentityType().getName());
-
- for (IdentityObjectAttribute attribute : attributes)
- {
- String name = resolveAttributeStoreMapping(identity.getIdentityType(), attribute.getName());
- mappedAttributes.put(name, attribute);
-
-
- if (mdMap == null || !mdMap.containsKey(attribute.getName()))
- {
- if (!isAllowNotDefinedAttributes)
- {
- throw new IdentityException("Cannot add not defined attribute. Use '" + ALLOW_NOT_DEFINED_ATTRIBUTES +
- "' option if needed. Attribute name: " + attribute.getName());
- }
- }
-
- IdentityObjectAttributeMetaData amd = mdMap.get(attribute.getName());
-
- if (amd != null)
- {
-
- if (!amd.isMultivalued() && attribute.getSize() > 1)
- {
- throw new IdentityException("Cannot assigned multiply values to single valued attribute: " + attribute.getName());
- }
- if (amd.isReadonly())
- {
- throw new IdentityException("Cannot update readonly attribute: " + attribute.getName());
- }
-
- String type = amd.getType();
-
- // check if all values have proper type
-
- for (Object value : attribute.getValues())
- {
- if (type.equals(IdentityObjectAttributeMetaData.TEXT_TYPE) && !(value instanceof String))
- {
- throw new IdentityException("Cannot update text type attribute with not String type value: "
- + attribute.getName() + " / " + value);
- }
- if (type.equals(IdentityObjectAttributeMetaData.BINARY_TYPE) && !(value instanceof byte[]))
- {
- throw new IdentityException("Cannot update binary type attribute with not byte[] type value: "
- + attribute.getName() + " / " + value);
- }
- }
- }
- }
-
-
- HibernateIdentityObject hibernateObject = safeGet(ctx, identity);
-
- for (String name : mappedAttributes.keySet())
- {
- IdentityObjectAttribute attribute = mappedAttributes.get(name);
-
- IdentityObjectAttributeMetaData amd = mdMap.get(attribute.getName());
-
- // Default to text
- String type = amd != null ? amd.getType() : IdentityObjectAttributeMetaData.TEXT_TYPE;
-
- for (HibernateIdentityObjectAttribute storeAttribute : hibernateObject.getAttributes())
- {
- if (storeAttribute.getName().equals(name))
- {
- if (storeAttribute instanceof HibernateIdentityObjectTextAttribute)
- {
- if (!type.equals(IdentityObjectAttributeMetaData.TEXT_TYPE))
- {
- throw new IdentityException("Wrong attribute mapping. Attribute persisted as text is mapped with: "
- + type + ". Attribute name: " + name);
- }
-
-
- Set<String> v = new HashSet<String>();
- for (Object value : attribute.getValues())
- {
- v.add(value.toString());
- }
-
- ((HibernateIdentityObjectTextAttribute)storeAttribute).setValues(v);
- }
- else if (storeAttribute instanceof HibernateIdentityObjectBinaryAttribute)
- {
-
- if (!type.equals(IdentityObjectAttributeMetaData.BINARY_TYPE))
- {
- throw new IdentityException("Wrong attribute mapping. Attribute persisted as binary is mapped with: "
- + type + ". Attribute name: " + name);
- }
-
- Set<byte[]> v = new HashSet<byte[]>();
- for (Object value : attribute.getValues())
- {
- v.add((byte[])value);
- }
-
- ((HibernateIdentityObjectBinaryAttribute)storeAttribute).setValues(v);
- }
- else
- {
- throw new IdentityException("Internal identity store error");
- }
- break;
- }
- }
- }
-
- }
-
- public void addAttributes(IdentityStoreInvocationContext ctx, IdentityObject identity, IdentityObjectAttribute[] attributes) throws IdentityException
- {
-
- if (attributes == null)
- {
- throw new IllegalArgumentException("attributes are null");
- }
-
- Map<String, IdentityObjectAttribute> mappedAttributes = new HashMap<String, IdentityObjectAttribute>();
-
- Map<String, IdentityObjectAttributeMetaData> mdMap = attributesMetaData.get(identity.getIdentityType().getName());
-
- for (IdentityObjectAttribute attribute : attributes)
- {
- String name = resolveAttributeStoreMapping(identity.getIdentityType(), attribute.getName());
- mappedAttributes.put(name, attribute);
-
-
- if ((mdMap == null || !mdMap.containsKey(attribute.getName())) &&
- !isAllowNotDefinedAttributes)
- {
- throw new IdentityException("Cannot add not defined attribute. Use '" + ALLOW_NOT_DEFINED_ATTRIBUTES +
- "' option if needed. Attribute name: " + attribute.getName());
-
- }
-
- IdentityObjectAttributeMetaData amd = mdMap.get(attribute.getName());
-
- if (amd != null)
- {
-
- if (!amd.isMultivalued() && attribute.getSize() > 1)
- {
- throw new IdentityException("Cannot add multiply values to single valued attribute: " + attribute.getName());
- }
- if (amd.isReadonly())
- {
- throw new IdentityException("Cannot add readonly attribute: " + attribute.getName());
- }
-
- String type = amd.getType();
-
- // check if all values have proper type
-
- for (Object value : attribute.getValues())
- {
- if (type.equals(IdentityObjectAttributeMetaData.TEXT_TYPE) && !(value instanceof String))
- {
- throw new IdentityException("Cannot add text type attribute with not String type value: "
- + attribute.getName() + " / " + value);
- }
- if (type.equals(IdentityObjectAttributeMetaData.BINARY_TYPE) && !(value instanceof byte[]))
- {
- throw new IdentityException("Cannot add binary type attribute with not byte[] type value: "
- + attribute.getName() + " / " + value);
- }
- }
- }
- }
-
- HibernateIdentityObject hibernateObject = safeGet(ctx, identity);
-
- for (String name : mappedAttributes.keySet())
- {
- IdentityObjectAttribute attribute = mappedAttributes.get(name);
-
- IdentityObjectAttributeMetaData amd = mdMap.get(attribute.getName());
-
- // Default to text
- String type = amd != null ? amd.getType() : IdentityObjectAttributeMetaData.TEXT_TYPE;
-
- HibernateIdentityObjectAttribute hibernateAttribute = null;
-
- for (HibernateIdentityObjectAttribute storeAttribute : hibernateObject.getAttributes())
- {
- if (storeAttribute.getName().equals(name))
- {
- hibernateAttribute = storeAttribute;
- break;
- }
- }
-
- if (hibernateAttribute != null)
- {
- if (hibernateAttribute instanceof HibernateIdentityObjectTextAttribute)
- {
- if (!type.equals(IdentityObjectAttributeMetaData.TEXT_TYPE))
- {
- throw new IdentityException("Wrong attribute mapping. Attribute persisted as text is mapped with: "
- + type + ". Attribute name: " + name);
- }
-
-
- Set<String> mergedValues = new HashSet<String>(hibernateAttribute.getValues());
- for (Object value : attribute.getValues())
- {
- mergedValues.add(value.toString());
- }
-
- ((HibernateIdentityObjectTextAttribute)hibernateAttribute).setValues(mergedValues);
- }
- else if (hibernateAttribute instanceof HibernateIdentityObjectBinaryAttribute)
- {
-
- if (!type.equals(IdentityObjectAttributeMetaData.BINARY_TYPE))
- {
- throw new IdentityException("Wrong attribute mapping. Attribute persisted as binary is mapped with: "
- + type + ". Attribute name: " + name);
- }
-
- Set<byte[]> mergedValues = new HashSet<byte[]>(hibernateAttribute.getValues());
- for (Object value : attribute.getValues())
- {
- mergedValues.add((byte[])value);
- }
-
- ((HibernateIdentityObjectBinaryAttribute)hibernateAttribute).setValues(mergedValues);
- }
- else
- {
- throw new IdentityException("Internal identity store error");
- }
- break;
-
- }
- else
- {
- if (type.equals(IdentityObjectAttributeMetaData.TEXT_TYPE))
- {
- Set<String> values = new HashSet<String>();
-
- for (Object value: attribute.getValues())
- {
- values.add(value.toString());
- }
- hibernateAttribute = new HibernateIdentityObjectTextAttribute(hibernateObject, name, values);
- }
- else if (type.equals(IdentityObjectAttributeMetaData.BINARY_TYPE))
- {
- Set<byte[]> values = new HashSet<byte[]>();
-
- for (Object value: attribute.getValues())
- {
- values.add((byte[])value);
- }
- hibernateAttribute = new HibernateIdentityObjectBinaryAttribute(hibernateObject, name, values);
- }
-
-
- hibernateObject.getAttributes().add(hibernateAttribute);
-
- }
- }
- }
-
- public void removeAttributes(IdentityStoreInvocationContext ctx, IdentityObject identity, String[] attributes) throws IdentityException
- {
-
- if (attributes == null)
- {
- throw new IllegalArgumentException("attributes are null");
- }
-
- String[] mappedAttributes = new String[attributes.length];
-
- for (int i = 0; i < attributes.length; i++)
- {
- String name = resolveAttributeStoreMapping(identity.getIdentityType(), attributes[i]);
- mappedAttributes[i] = name;
-
- Map<String, IdentityObjectAttributeMetaData> mdMap = attributesMetaData.get(identity.getIdentityType().getName());
-
- if (mdMap != null)
- {
- IdentityObjectAttributeMetaData amd = mdMap.get(attributes[i]);
- if (amd != null && amd.isRequired())
- {
- throw new IdentityException("Cannot remove required attribute: " + attributes[i]);
- }
- }
- else
- {
- if (!isAllowNotDefinedAttributes)
- {
- throw new IdentityException("Cannot remove not defined attribute. Use '" + ALLOW_NOT_DEFINED_ATTRIBUTES +
- "' option if needed. Attribute name: " + attributes[i]);
- }
- }
-
- }
-
- HibernateIdentityObject hibernateObject = safeGet(ctx, identity);
-
- for (String attr : mappedAttributes)
- {
- hibernateObject.removeAttribute(attr);
- }
- }
-
- public boolean validateCredential(IdentityStoreInvocationContext ctx, IdentityObject identityObject, IdentityObjectCredential credential) throws IdentityException
- {
- if (credential == null)
- {
- throw new IllegalArgumentException();
- }
-
- HibernateIdentityObject hibernateObject = safeGet(ctx, identityObject);
-
- if (supportedFeatures.isCredentialSupported(hibernateObject.getIdentityType(),credential.getType()))
- {
-
- HibernateIdentityObjectCredential hibernateCredential = hibernateObject.getCredentials().get(credential.getType().getName());
-
- if (hibernateCredential == null)
- {
- return false;
- }
-
- // Handle generic impl
-
- Object value = null;
-
- if (credential.getEncodedValue() != null)
- {
- value = credential.getEncodedValue();
- }
- else
- {
- //TODO: support for empty password should be configurable
- value = credential.getValue();
- }
-
- if (value instanceof String && hibernateCredential.getTextValue() != null)
- {
- return value.toString().equals(hibernateCredential.getTextValue());
- }
- else if (value instanceof byte[] && hibernateCredential.getBinaryValue() != null)
- {
- return Arrays.equals((byte[])value, hibernateCredential.getBinaryValue());
- }
- else
- {
- throw new IdentityException("Not supported credential value: " + value.getClass());
- }
- }
- else
- {
- throw new IdentityException("CredentialType not supported for a given IdentityObjectType");
- }
- }
-
- public void updateCredential(IdentityStoreInvocationContext ctx, IdentityObject identityObject, IdentityObjectCredential credential) throws IdentityException
- {
-
- if (credential == null)
- {
- throw new IllegalArgumentException();
- }
-
- HibernateIdentityObject hibernateObject = safeGet(ctx, identityObject);
-
- HibernateEntityManager em = getHibernateEntityManager(ctx);
-
- if (supportedFeatures.isCredentialSupported(hibernateObject.getIdentityType(),credential.getType()))
- {
-
- HibernateIdentityObjectCredentialType hibernateCredentialType = getHibernateIdentityObjectCredentialType(ctx, credential.getType());
-
- if (hibernateCredentialType == null)
- {
- throw new IllegalStateException("Credential type not present in this store: " + credential.getType().getName());
- }
-
- HibernateIdentityObjectCredential hibernateCredential = new HibernateIdentityObjectCredential();
- hibernateCredential.setIdentityObject(hibernateObject);
- hibernateCredential.setType(hibernateCredentialType);
-
- Object value = null;
-
- // Handle generic impl
-
- if (credential.getEncodedValue() != null)
- {
- value = credential.getEncodedValue();
- }
- else
- {
- //TODO: support for empty password should be configurable
- value = credential.getValue();
- }
-
- if (value instanceof String)
- {
- hibernateCredential.setTextValue(value.toString());
- }
- else if (value instanceof byte[])
- {
- hibernateCredential.setBinaryValue((byte[])value);
- }
- else
- {
- throw new IdentityException("Not supported credential value: " + value.getClass());
- }
-
- em.persist(hibernateCredential);
-
- hibernateObject.addCredential(hibernateCredential);
-
- }
- else
- {
- throw new IdentityException("CredentialType not supported for a given IdentityObjectType");
- }
- }
-
-
-
-
-
-
- // Internal
-
- public void addIdentityObjectType(IdentityStoreInvocationContext ctx, IdentityObjectType type) throws IdentityException
- {
- HibernateIdentityObjectType hibernateType = new HibernateIdentityObjectType(type);
- getHibernateEntityManager(ctx).persist(hibernateType);
- }
-
-
- public void addIdentityObjectRelationshipType(IdentityStoreInvocationContext ctx, IdentityObjectRelationshipType type) throws IdentityException
- {
- HibernateIdentityObjectRelationshipType hibernateType = new HibernateIdentityObjectRelationshipType(type);
- getHibernateEntityManager(ctx).persist(hibernateType);
- }
-
-
- protected HibernateEntityManager getHibernateEntityManager(IdentityStoreInvocationContext ctx) throws IdentityException
- {
- try
- {
- return (HibernateEntityManager)ctx.getIdentityStoreSession().getSessionContext();
- }
- catch (IdentityException e)
- {
- throw new IdentityException("Cannot obtain HibernateEntityManager", e);
- }
- }
-
- private void checkIOInstance(IdentityObject io)
- {
- if (io == null)
- {
- throw new IllegalArgumentException("IdentityObject is null");
- }
-
-
- }
-
- private HibernateIdentityObject safeGet(IdentityStoreInvocationContext ctx, IdentityObject io) throws IdentityException
- {
- checkIOInstance(io);
-
- if (io instanceof HibernateIdentityObject)
- {
- return (HibernateIdentityObject)io;
- }
-
- return getHibernateIdentityObject(ctx, io);
-
- }
-
-
- private void checkIOType(IdentityObjectType iot) throws IdentityException
- {
- if (iot == null)
- {
- throw new IllegalArgumentException("IdentityObjectType is null");
- }
-
- if (!getSupportedFeatures().isIdentityObjectTypeSupported(iot))
- {
- throw new IdentityException("IdentityType not supported by this IdentityStore implementation: " + iot);
- }
- }
-
- private HibernateIdentityObjectType getHibernateIdentityObjectType(IdentityStoreInvocationContext ctx, IdentityObjectType type) throws IdentityException
- {
-
- HibernateIdentityObjectType hibernateType = null;
-
- HibernateEntityManager em = getHibernateEntityManager(ctx);
-
-
- try
- {
- hibernateType = (HibernateIdentityObjectType)em.createNamedQuery("findIdentityObjectTypeByName")
- .setParameter("name", type.getName())
- .getSingleResult() ;
- }
- catch (NoResultException e)
- {
- throw new IdentityException("IdentityObjectType[" + type.getName() + "] not present in the store.");
- }
-
- return hibernateType;
- }
-
- private HibernateIdentityObject getHibernateIdentityObject(IdentityStoreInvocationContext ctx, IdentityObject io) throws IdentityException
- {
-
- HibernateIdentityObject hibernateObject = null;
-
- HibernateEntityManager em = getHibernateEntityManager(ctx);
-
-
- try
- {
- hibernateObject = (HibernateIdentityObject)em.createNamedQuery("findIdentityObjectByNameAndType")
- .setParameter("name", io.getName())
- .setParameter("typeName", io.getIdentityType().getName())
- .setParameter("realm", getRealm(em, ctx))
- .getSingleResult();
- }
- catch (Exception e)
- {
- throw new IdentityException("IdentityObject[ " + io.getName() + " | " + io.getIdentityType().getName() + "] not present in the store.", e);
- }
-
- return hibernateObject;
- }
-
- private HibernateIdentityObjectRelationshipType getHibernateIdentityObjectRelationshipType(IdentityStoreInvocationContext ctx, IdentityObjectRelationshipType iot) throws IdentityException
- {
-
- HibernateIdentityObjectRelationshipType relationshipType = null;
-
- HibernateEntityManager em = getHibernateEntityManager(ctx);
-
- try
- {
- relationshipType = (HibernateIdentityObjectRelationshipType)em.createNamedQuery("findIdentityObjectRelationshipTypeByName")
- .setParameter("name", iot.getName())
- .getSingleResult();
- }
- catch (Exception e)
- {
- throw new IdentityException("IdentityObjectRelationshipType[ " + iot.getName() + "] not present in the store.");
- }
-
- return relationshipType;
- }
-
- private HibernateIdentityObjectCredentialType getHibernateIdentityObjectCredentialType(IdentityStoreInvocationContext ctx, IdentityObjectCredentialType credentialType) throws IdentityException
- {
- HibernateEntityManager em = getHibernateEntityManager(ctx);
-
- HibernateIdentityObjectCredentialType hibernateType = null;
-
- try
- {
- hibernateType = (HibernateIdentityObjectCredentialType)em.getSession().
- createCriteria(HibernateIdentityObjectCredentialType.class).add(Restrictions.eq("name", credentialType.getName())).uniqueResult();
- }
- catch (HibernateException e)
- {
- throw new IdentityException("IdentityObjectCredentialType[ " + credentialType.getName() + "] not present in the store.");
- }
-
- return hibernateType;
-
- }
-
- public void populateObjectTypes(HibernateEntityManager em, String[] typeNames) throws Exception
- {
-
- em.getTransaction().begin();
-
- for (String typeName : typeNames)
- {
-
- //Check if present
-
- HibernateIdentityObjectType hibernateType = (HibernateIdentityObjectType)em.getSession().
- createCriteria(HibernateIdentityObjectType.class).add(Restrictions.eq("name", typeName)).uniqueResult();
-
- if (hibernateType == null)
- {
- hibernateType = new HibernateIdentityObjectType(typeName);
- em.persist(hibernateType);
- }
-
- }
-
- em.getTransaction().commit();
-
- }
-
- public void populateRelationshipTypes(HibernateEntityManager em, String[] typeNames) throws Exception
- {
-
- em.getTransaction().begin();
-
- for (String typeName : typeNames)
- {
- HibernateIdentityObjectRelationshipType hibernateType = (HibernateIdentityObjectRelationshipType)em.getSession().
- createCriteria(HibernateIdentityObjectRelationshipType.class).add(Restrictions.eq("name", typeName)).uniqueResult();
-
- if (hibernateType == null)
- {
- hibernateType = new HibernateIdentityObjectRelationshipType(typeName);
- em.persist(hibernateType);
- }
-
- }
-
- em.getTransaction().commit();
- }
-
-
- public void populateCredentialTypes(HibernateEntityManager em, String[] typeNames) throws Exception
- {
-
- em.getTransaction().begin();
-
- for (String typeName : typeNames)
- {
- HibernateIdentityObjectCredentialType hibernateType = (HibernateIdentityObjectCredentialType)em.getSession().
- createCriteria(HibernateIdentityObjectCredentialType.class).add(Restrictions.eq("name", typeName)).uniqueResult();
-
- if (hibernateType == null)
- {
- hibernateType = new HibernateIdentityObjectCredentialType(typeName);
- em.persist(hibernateType);
- }
-
- }
-
- em.getTransaction().commit();
- }
-
-
-
- public void addRealm(HibernateEntityManager em, String realmName) throws IdentityException
- {
-
- try
- {
- em.getTransaction().begin();
-
- HibernateRealm realm = new HibernateRealm(realmName);
- em.persist(realm);
-
- em.getTransaction().commit();
-
- }
- catch (Exception e)
- {
- throw new IdentityException("Failed to create store realm", e);
- }
- }
-
-
- public HibernateRealm getRealm(HibernateEntityManager em, IdentityStoreInvocationContext ctx) throws IdentityException
- {
- if (ctx.getRealmId() == null)
- {
- throw new IllegalStateException("Realm Id not present");
- }
-
- HibernateRealm realm = null;
-
- // If store is not realm aware return null to create/get objects accessible from other realms
- if (!isRealmAware())
- {
- realm = (HibernateRealm)em.getSession().
- createCriteria(HibernateRealm.class).add(Restrictions.eq("name", DEFAULT_REALM_NAME)).uniqueResult();
-
- if (realm == null)
- {
- throw new IllegalStateException("Default store realm is not present: " + DEFAULT_REALM_NAME);
- }
-
- }
- else
- {
- realm = (HibernateRealm)em.getSession().
- createCriteria(HibernateRealm.class).add(Restrictions.eq("name", ctx.getRealmId())).uniqueResult();
-
-
- // TODO: other way to not lazy initialize realm? special method called on every new session creation
- if (realm == null)
- {
- HibernateRealm newRealm = new HibernateRealm(ctx.getRealmId());
- em.persist(newRealm);
- return newRealm;
- }
- }
-
-
-
- return realm;
- }
-
- private boolean isRealmAware()
- {
- return isRealmAware;
- }
-
- private boolean isAllowNotDefinedAttributes()
- {
- return isAllowNotDefinedAttributes;
- }
-
- private void checkControls(IdentityObjectSearchControl[] controls) throws IdentityException
- {
- if (controls != null)
- {
- for (IdentityObjectSearchControl control : controls)
- {
- if (!supportedIdentityObjectSearchControls.contains(control.getClass()))
- {
- throw new IdentityException("IdentityObjectSearchControl not supported by this IdentityStore: " + control.getClass());
- }
- }
- }
- }
-
- /**
- * Resolve store mapping for attribute name. If attribute is not mapped and store doesn't allow not defined
- * attributes throw exception
- * @param type
- * @param name
- * @return
- */
- private String resolveAttributeStoreMapping(IdentityObjectType type, String name) throws IdentityException
- {
- String mapping = null;
-
- if (attributesMetaData.containsKey(type.getName()))
- {
- IdentityObjectAttributeMetaData amd = attributesMetaData.get(type.getName()).get(name);
-
- if (amd != null)
- {
- mapping = amd.getStoreMapping() != null ? amd.getStoreMapping() : amd.getName();
- return mapping;
- }
- }
-
- if (isAllowNotDefinedAttributes())
- {
- mapping = name;
- return mapping;
- }
-
- throw new IdentityException("Attribute name is not configured in this store");
- }
-
- private String resolveAttributeNameFromStoreMapping(IdentityObjectType type, String mapping)
- {
- if (reverseAttributeMappings.containsKey(type.getName()))
- {
- Map<String, String> map = reverseAttributeMappings.get(type.getName());
-
- if (map != null)
- {
- String name = map.containsKey(mapping) ? map.get(mapping) : mapping;
- return name;
- }
- }
-
- if (isAllowNotDefinedAttributes())
- {
- return mapping;
- }
- return null;
- }
-
- //TODO: this kills performance and is present here only as "quick" hack to have the feature present and let to add test cases
- //TODO: needs to be redone at the hibernate query level
- private void filterByAttributesValues(Collection<IdentityObject> objects, Map<String, String[]> attrs)
- {
- Set<IdentityObject> toRemove = new HashSet<IdentityObject>();
-
- for (IdentityObject object : objects)
- {
- Map<String, Collection> presentAttrs = ((HibernateIdentityObject)object).getAttributesAsMap();
- for (Map.Entry<String, String[]> entry : attrs.entrySet())
- {
- if (presentAttrs.containsKey(entry.getKey()))
- {
- Set<String> given = new HashSet<String>(Arrays.asList(entry.getValue()));
- Collection present = presentAttrs.get(entry.getKey());
-
- for (String s : given)
- {
- if (!present.contains(s))
- {
- toRemove.add(object);
- break;
- }
- }
-
- }
- else
- {
- toRemove.add(object);
- break;
-
- }
- }
- }
-
- for (IdentityObject identityObject : toRemove)
- {
- objects.remove(identityObject);
- }
- }
-
-
-}
Copied: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java (from rev 211, trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/hibernate/HibernateIdentityStoreImpl.java)
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java (rev 0)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,2140 @@
+/*
+* 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.store.hibernate;
+
+import org.jboss.identity.idm.spi.store.IdentityStore;
+import org.jboss.identity.idm.spi.store.FeaturesMetaData;
+import org.jboss.identity.idm.spi.store.IdentityStoreInvocationContext;
+import org.jboss.identity.idm.spi.store.IdentityStoreSession;
+import org.jboss.identity.idm.spi.searchcontrol.IdentityObjectSearchControl;
+import org.jboss.identity.idm.spi.model.IdentityObjectRelationshipType;
+import org.jboss.identity.idm.spi.model.IdentityObject;
+import org.jboss.identity.idm.spi.model.IdentityObjectType;
+import org.jboss.identity.idm.spi.model.IdentityObjectRelationship;
+import org.jboss.identity.idm.spi.model.IdentityObjectCredential;
+import org.jboss.identity.idm.spi.exception.OperationNotSupportedException;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityObjectTypeMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityObjectAttributeMetaData;
+import org.jboss.identity.idm.spi.model.IdentityObjectCredentialType;
+import org.jboss.identity.idm.spi.model.IdentityObjectAttribute;
+import org.jboss.identity.idm.exception.IdentityException;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObject;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationship;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipType;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectType;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipName;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateRealm;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredentialType;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredential;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectAttribute;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectTextAttribute;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectBinaryAttribute;
+import org.jboss.identity.idm.impl.api.PageSearchControl;
+import org.jboss.identity.idm.impl.api.SortByNameSearchControl;
+import org.jboss.identity.idm.impl.api.AttributeFilterSearchControl;
+import org.jboss.identity.idm.impl.api.NameFilterSearchControl;
+import org.jboss.identity.idm.impl.store.FeaturesMetaDataImpl;
+import org.hibernate.ejb.HibernateEntityManager;
+import org.hibernate.ejb.HibernateEntityManagerFactory;
+import org.hibernate.criterion.Restrictions;
+import org.hibernate.HibernateException;
+import org.hibernate.Criteria;
+
+import javax.persistence.NoResultException;
+import javax.persistence.Query;
+import javax.persistence.Persistence;
+import java.util.Set;
+import java.util.Collection;
+import java.util.Map;
+import java.util.List;
+import java.util.Iterator;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class HibernateIdentityStoreImpl implements IdentityStore
+{
+
+ //TODO: logging
+
+ private final String QUERY_RELATIONSHIP_BY_FROM_TO =
+ "select r from HibernateIdentityObjectRelationship r where r.fromIdentityObject like :fromIO and " +
+ "r.toIdentityObject like :toIO";
+
+ private final String QUERY_RELATIONSHIP_BY_FROM_TO_TYPE =
+ "select r from HibernateIdentityObjectRelationship r where r.fromIdentityObject like :fromIO and " +
+ "r.toIdentityObject like :toIO and r.type.name like :typeName";
+
+ private final String QUERY_RELATIONSHIP_BY_FROM_TO_TYPE_NAME =
+ "select r from HibernateIdentityObjectRelationship r where r.fromIdentityObject like :fromIO and " +
+ "r.toIdentityObject like :toIO and r.type.name like :typeName and r.name.name like :name";
+
+ private final String QUERY_RELATIONSHIP_BY_IDENTITIES =
+ "select r from HibernateIdentityObjectRelationship r where " +
+ "(r.fromIdentityObject like :IO1 and r.toIdentityObject like :IO2) or " +
+ "(r.fromIdentityObject like :IO2 and r.toIdentityObject like :IO1)";
+
+ public static final String PERSISTENCE_UNIT = "persistenceUnit";
+
+ public static final String POPULATE_MEMBERSHIP_TYPES = "populateRelationshipTypes";
+
+ public static final String POPULATE_IDENTITY_OBJECT_TYPES = "populateIdentityObjectTypes";
+
+ public static final String IS_REALM_AWARE = "isRealmAware";
+
+ public static final String ALLOW_NOT_DEFINED_ATTRIBUTES = "allowNotDefinedAttributes";
+
+ public static final String DEFAULT_REALM_NAME = HibernateIdentityStoreImpl.class.getName() + ".DEFAULT_REALM";
+
+ public static final String CREDENTIAL_TYPE_PASSWORD = "PASSWORD";
+
+ public static final String CREDENTIAL_TYPE_BINARY = "BINARY";
+
+ private String id;
+
+ private FeaturesMetaData supportedFeatures;
+
+ private HibernateEntityManagerFactory emFactory;
+
+ private boolean isRealmAware = false;
+
+ private boolean isAllowNotDefinedAttributes = false;
+
+ // TODO: rewrite this into some more handy object
+ private IdentityStoreConfigurationMetaData configurationMD;
+
+ private static Set<Class> supportedIdentityObjectSearchControls = new HashSet<Class>();
+
+ private static Set<String> supportedCredentialTypes = new HashSet<String>();
+
+ // <IdentityObjectType name, Set<Attribute name>>
+ private Map<String, Set<String>> attributeMappings = new HashMap<String, Set<String>>();
+
+ // <IdentityObjectType name, <Attribute name, MD>
+ private Map<String, Map<String, IdentityObjectAttributeMetaData>> attributesMetaData = new HashMap<String, Map<String, IdentityObjectAttributeMetaData>>();
+
+ // <IdentityObjectType name, <Attribute store mapping, Attribute name>
+ private Map<String, Map<String, String>> reverseAttributeMappings = new HashMap<String, Map<String, String>>();
+
+ static {
+ // List all supported controls classes
+
+ supportedIdentityObjectSearchControls.add(PageSearchControl.class);
+ supportedIdentityObjectSearchControls.add(SortByNameSearchControl.class);
+ supportedIdentityObjectSearchControls.add(AttributeFilterSearchControl.class);
+ supportedIdentityObjectSearchControls.add(NameFilterSearchControl.class);
+
+ // credential types supported by this impl
+ supportedCredentialTypes.add(CREDENTIAL_TYPE_PASSWORD);
+ supportedCredentialTypes.add(CREDENTIAL_TYPE_BINARY);
+
+ }
+
+ public HibernateIdentityStoreImpl(String id)
+ {
+ this.id = id;
+ }
+
+ public void bootstrap(IdentityStoreConfigurationMetaData configurationMD) throws IdentityException
+ {
+ this.configurationMD = configurationMD;
+
+ id = configurationMD.getId();
+
+ supportedFeatures = new FeaturesMetaDataImpl(configurationMD, supportedIdentityObjectSearchControls, true);
+
+ String persistenceUnit = configurationMD.getOptionSingleValue(PERSISTENCE_UNIT);
+
+ String populateMembershipTypes = configurationMD.getOptionSingleValue(POPULATE_MEMBERSHIP_TYPES);
+ String populateIdentityObjectTypes = configurationMD.getOptionSingleValue(POPULATE_IDENTITY_OBJECT_TYPES);
+
+ HibernateEntityManager em = bootstrapHibernateEntityManager(persistenceUnit);
+
+ // Attribute mappings - helper structures
+
+ for (IdentityObjectTypeMetaData identityObjectTypeMetaData : configurationMD.getSupportedIdentityTypes())
+ {
+ Set<String> names = new HashSet<String>();
+ Map<String, IdentityObjectAttributeMetaData> metadataMap = new HashMap<String, IdentityObjectAttributeMetaData>();
+ Map<String, String> reverseMap = new HashMap<String, String>();
+ for (IdentityObjectAttributeMetaData attributeMetaData : identityObjectTypeMetaData.getAttributes())
+ {
+ names.add(attributeMetaData.getName());
+ metadataMap.put(attributeMetaData.getName(), attributeMetaData);
+ if (attributeMetaData.getStoreMapping() != null)
+ {
+ reverseMap.put(attributeMetaData.getStoreMapping(), attributeMetaData.getName());
+ }
+ }
+
+ // Use unmodifiableSet as it'll be exposed directly
+ attributeMappings.put(identityObjectTypeMetaData.getName(), Collections.unmodifiableSet(names));
+
+ attributesMetaData.put(identityObjectTypeMetaData.getName(), metadataMap);
+
+ reverseAttributeMappings.put(identityObjectTypeMetaData.getName(), reverseMap);
+ }
+
+ attributeMappings = Collections.unmodifiableMap(attributeMappings);
+
+ if (populateMembershipTypes != null && populateMembershipTypes.equalsIgnoreCase("true"))
+ {
+ List<String> memberships = new LinkedList<String>();
+
+ for (String membership : configurationMD.getSupportedRelationshipTypes())
+ {
+ memberships.add(membership);
+ }
+
+ try
+ {
+ populateRelationshipTypes(em, memberships.toArray(new String[memberships.size()]));
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Failed to populate relationship types", e);
+ }
+
+
+ }
+
+ if (populateIdentityObjectTypes != null && populateIdentityObjectTypes.equalsIgnoreCase("true"))
+ {
+ List<String> types = new LinkedList<String>();
+
+ for (IdentityObjectTypeMetaData metaData : configurationMD.getSupportedIdentityTypes())
+ {
+ types.add(metaData.getName());
+ }
+
+ try
+ {
+ populateObjectTypes(em, types.toArray(new String[types.size()]));
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Failed to populate identity object types", e);
+ }
+
+ }
+
+ if (supportedCredentialTypes != null && supportedCredentialTypes.size() > 0)
+ {
+ try
+ {
+ populateCredentialTypes(em, supportedCredentialTypes.toArray(new String[supportedCredentialTypes.size()]));
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Failed to populated credential types");
+ }
+ }
+
+ String realmAware = configurationMD.getOptionSingleValue(IS_REALM_AWARE);
+
+ if (realmAware != null && realmAware.equalsIgnoreCase("true"))
+ {
+ this.isRealmAware = true;
+ }
+
+ String allowNotDefineAttributes = configurationMD.getOptionSingleValue(ALLOW_NOT_DEFINED_ATTRIBUTES);
+
+ if (allowNotDefineAttributes != null && allowNotDefineAttributes.equalsIgnoreCase("true"))
+ {
+ this.isAllowNotDefinedAttributes = true;
+ }
+
+ // Default realm
+
+ HibernateRealm realm = null;
+
+ try
+ {
+
+ em.getTransaction().begin();
+
+ realm = (HibernateRealm)em.getSession().
+ createCriteria(HibernateRealm.class).add(Restrictions.eq("name", DEFAULT_REALM_NAME)).uniqueResult();
+
+ em.getTransaction().commit();
+
+ }
+ catch (HibernateException e)
+ {
+ // Realm does not exist
+ }
+
+ if (realm == null)
+ {
+ addRealm(em, DEFAULT_REALM_NAME);
+ }
+
+ }
+
+ // this is separate method to allow easier testing
+ protected HibernateEntityManager bootstrapHibernateEntityManager(String persistenceUnit) throws IdentityException
+ {
+ if (persistenceUnit == null)
+ {
+ throw new IdentityException("Persistence Unit not defined for IdentityStore: " + getId());
+ }
+
+ emFactory = (HibernateEntityManagerFactory)Persistence.createEntityManagerFactory(persistenceUnit);
+
+ return (HibernateEntityManager)emFactory.createEntityManager();
+
+ }
+
+
+ public IdentityStoreSession createIdentityStoreSession() throws IdentityException
+ {
+ try
+ {
+ return new HibernateIdentityStoreSessionImpl((HibernateEntityManager)emFactory.createEntityManager());
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Failed to obtain HibernateEntityManager",e);
+ }
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public void setId(String id)
+ {
+ this.id = id;
+ }
+
+ public FeaturesMetaData getSupportedFeatures()
+ {
+ return supportedFeatures;
+ }
+
+ public IdentityObject createIdentityObject(IdentityStoreInvocationContext invocationCtx, String name, IdentityObjectType identityObjectType) throws IdentityException
+ {
+ return createIdentityObject(invocationCtx, name, identityObjectType, null);
+ }
+
+ public IdentityObject createIdentityObject(IdentityStoreInvocationContext ctx,
+ String name,
+ IdentityObjectType identityObjectType,
+ Map<String, String[]> attributes) throws IdentityException
+ {
+
+ if (name == null)
+ {
+ throw new IllegalArgumentException("IdentityObject name is null");
+ }
+
+ checkIOType(identityObjectType);
+
+ HibernateEntityManager em = getHibernateEntityManager(ctx);
+
+ HibernateRealm realm = getRealm(em, ctx);
+
+ // Check if object with a given name and type is not present already
+ List results = em.createNamedQuery("findIdentityObjectByNameAndType")
+ .setParameter("realm", realm)
+ .setParameter("name", name)
+ .setParameter("typeName", identityObjectType.getName())
+ .getResultList();
+
+ if (results.size() != 0)
+ {
+ throw new IdentityException("IdentityObject already present in this IdentityStore");
+ }
+
+
+
+ HibernateIdentityObjectType hibernateType = getHibernateIdentityObjectType(ctx, identityObjectType);
+
+ HibernateIdentityObject io = new HibernateIdentityObject(name, hibernateType, realm);
+
+ if (attributes != null)
+ {
+ for (Map.Entry<String, String[]> entry : attributes.entrySet())
+ {
+ io.addTextAttribute(entry.getKey(), entry.getValue());
+ }
+ }
+
+ try
+ {
+ getHibernateEntityManager(ctx).persist(io);
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Cannot persist new IdentityObject" + io, e);
+ }
+
+
+ return io;
+ }
+
+ public void removeIdentityObject(IdentityStoreInvocationContext ctx, IdentityObject identity) throws IdentityException
+ {
+ HibernateIdentityObject hibernateObject = safeGet(ctx, identity);
+
+ HibernateEntityManager hem = getHibernateEntityManager(ctx);
+
+ try
+ {
+ // Remove all related relationships
+ for (HibernateIdentityObjectRelationship relationship : hibernateObject.getFromRelationships())
+ {
+ relationship.getFromIdentityObject().getFromRelationships().remove(relationship);
+ relationship.getToIdentityObject().getToRelationships().remove(relationship);
+
+ hem.remove(relationship);
+ }
+
+ for (HibernateIdentityObjectRelationship relationship : hibernateObject.getToRelationships())
+ {
+ relationship.getFromIdentityObject().getFromRelationships().remove(relationship);
+ relationship.getToIdentityObject().getToRelationships().remove(relationship);
+
+ hem.remove(relationship);
+ }
+
+ hem.remove(hibernateObject);
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Cannot remove IdentityObject" + identity, e);
+ }
+ }
+
+ public int getIdentityObjectsCount(IdentityStoreInvocationContext ctx, IdentityObjectType identityType) throws IdentityException
+ {
+ checkIOType(identityType);
+
+ HibernateIdentityObjectType jpaType = getHibernateIdentityObjectType(ctx, identityType);
+
+ HibernateEntityManager em = getHibernateEntityManager(ctx);
+
+ int count;
+ try
+ {
+ count = ((Number)em
+ .createNamedQuery("countIdentityObjectsByType")
+ .setParameter("typeName", jpaType.getName())
+ .setParameter("realm", getRealm(em, ctx))
+ .getSingleResult()).intValue();
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Cannot count stored IdentityObjects with type: " + identityType.getName(), e);
+ }
+
+ return count;
+ }
+
+ public IdentityObject findIdentityObject(IdentityStoreInvocationContext ctx, String name, IdentityObjectType type) throws IdentityException
+ {
+
+ if (name == null)
+ {
+ throw new IllegalArgumentException("IdentityObject name is null");
+ }
+
+ checkIOType(type);
+
+ HibernateIdentityObjectType hibernateType = getHibernateIdentityObjectType(ctx, type);
+
+ HibernateIdentityObject hibernateObject = null;
+
+ HibernateEntityManager em = getHibernateEntityManager(ctx);
+
+ try
+ {
+ hibernateObject = (HibernateIdentityObject)getHibernateEntityManager(ctx).
+ createNamedQuery("findIdentityObjectByNameAndType")
+ .setParameter("realm", getRealm(em, ctx))
+ .setParameter("name", name)
+ .setParameter("typeName", hibernateType.getName())
+ .getSingleResult();
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Cannot find IdentityObject with name '" + name + "' and type '" + type.getName() + "'", e);
+ }
+
+ return hibernateObject;
+ }
+
+ public IdentityObject findIdentityObject(IdentityStoreInvocationContext ctx, String id) throws IdentityException
+ {
+ if (id == null)
+ {
+ throw new IllegalArgumentException("id is null");
+ }
+
+ HibernateIdentityObject hibernateObject;
+
+ try
+ {
+ hibernateObject = getHibernateEntityManager(ctx).find(HibernateIdentityObject.class, new Long(id));
+ }
+ catch(Exception e)
+ {
+ throw new IdentityException("Cannot find IdentityObject with id: " + id, e);
+ }
+
+ return hibernateObject;
+ }
+
+
+
+ public Collection<IdentityObject> findIdentityObject(IdentityStoreInvocationContext ctx,
+ IdentityObjectType identityType,
+ IdentityObjectSearchControl[] controls) throws IdentityException
+ {
+ checkIOType(identityType);
+
+ checkControls(controls);
+
+ PageSearchControl pageSearchControl = null;
+ SortByNameSearchControl sortSearchControl = null;
+ AttributeFilterSearchControl attributeFilterControl = null;
+ NameFilterSearchControl nameFilterSearchControl = null;
+
+ if (controls != null)
+ {
+ for (IdentityObjectSearchControl control : controls)
+ {
+ if (control instanceof PageSearchControl)
+ {
+ pageSearchControl = (PageSearchControl)control;
+ }
+ else if (control instanceof SortByNameSearchControl)
+ {
+ sortSearchControl = (SortByNameSearchControl)control;
+ }
+ else if (control instanceof AttributeFilterSearchControl)
+ {
+ attributeFilterControl = (AttributeFilterSearchControl)control;
+ }
+ else if (control instanceof NameFilterSearchControl)
+ {
+ nameFilterSearchControl = (NameFilterSearchControl)control;
+ }
+ }
+ }
+
+ HibernateIdentityObjectType hibernateType = getHibernateIdentityObjectType(ctx, identityType);
+
+ List<IdentityObject> results;
+
+ HibernateEntityManager em = getHibernateEntityManager(ctx);
+
+ try
+ {
+
+ Query q = null;
+
+ if (sortSearchControl != null)
+ {
+ if (sortSearchControl.isAscending())
+ {
+ q = em.createNamedQuery("findIdentityObjectsByTypeOrderedByNameAsc");
+ }
+ else
+ {
+ q = em.createNamedQuery("findIdentityObjectsByTypeOrderedByNameDesc");
+ }
+ }
+ else
+ {
+ q = em.createNamedQuery("findIdentityObjectsByType");
+ }
+
+ if (pageSearchControl != null)
+ {
+ if (pageSearchControl.getLimit() > 0)
+ {
+ q.setMaxResults(pageSearchControl.getLimit());
+ }
+ q.setFirstResult(pageSearchControl.getOffset());
+
+ }
+
+ q.setParameter("realm", getRealm(em, ctx))
+ .setParameter("typeName", hibernateType.getName());
+
+ if (nameFilterSearchControl != null)
+ {
+ q.setParameter("nameFilter", nameFilterSearchControl.getFilter().replaceAll("\\*", "%"));
+ }
+ else
+ {
+ q.setParameter("nameFilter", "%");
+ }
+
+
+
+ results = (List<IdentityObject>)q.getResultList();
+
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Cannot find IdentityObjects with type '" + identityType.getName() + "'", e);
+ }
+
+ if (attributeFilterControl != null)
+ {
+ filterByAttributesValues(results, attributeFilterControl.getValues());
+ }
+
+ return results;
+ }
+
+
+
+ public Collection<IdentityObject> findIdentityObject(IdentityStoreInvocationContext ctx, IdentityObjectType identityType) throws IdentityException
+ {
+ return findIdentityObject(ctx, identityType, null);
+ }
+
+
+ public Collection<IdentityObject> findIdentityObject(IdentityStoreInvocationContext ctx, IdentityObject identity, IdentityObjectRelationshipType relationshipType, boolean parent, IdentityObjectSearchControl[] controls) throws IdentityException
+ {
+ //TODO:test
+
+ HibernateIdentityObject hibernateObject = safeGet(ctx, identity);
+
+ List<IdentityObject> results;
+
+ checkControls(controls);
+
+ PageSearchControl pageSearchControl = null;
+ SortByNameSearchControl sortSearchControl = null;
+ AttributeFilterSearchControl attributeFilterControl = null;
+ NameFilterSearchControl nameFilterSearchControl = null;
+
+ if (controls != null)
+ {
+ for (IdentityObjectSearchControl control : controls)
+ {
+ if (control instanceof PageSearchControl)
+ {
+ pageSearchControl = (PageSearchControl)control;
+ }
+ else if (control instanceof SortByNameSearchControl)
+ {
+ sortSearchControl = (SortByNameSearchControl)control;
+ }
+ else if (control instanceof AttributeFilterSearchControl)
+ {
+ attributeFilterControl = (AttributeFilterSearchControl)control;
+ }
+ else if (control instanceof NameFilterSearchControl)
+ {
+ nameFilterSearchControl = (NameFilterSearchControl)control;
+ }
+ }
+ }
+
+ boolean orderByName = false;
+ boolean ascending = true;
+
+ if (sortSearchControl != null)
+ {
+ orderByName = true;
+ ascending = sortSearchControl.isAscending();
+ }
+
+ try
+ {
+ org.hibernate.Query q = null;
+
+ StringBuilder hqlString = new StringBuilder("");
+
+ if (orderByName)
+ {
+ hqlString.append(" orderBy ior.toIdentityObject.name");
+ if (ascending)
+ {
+ hqlString.append(" asc");
+ }
+ }
+
+ if (parent)
+ {
+ hqlString.append("select ior.toIdentityObject from HibernateIdentityObjectRelationship ior where " +
+ "ior.toIdentityObject.name like :nameFilter and ior.type.name like :relType and ior.fromIdentityObject like :identity");
+
+ if (orderByName)
+ {
+ hqlString.append(" orderBy ior.toIdentityObject.name");
+ if (ascending)
+ {
+ hqlString.append(" asc");
+ }
+ }
+ }
+ else
+ {
+ hqlString.append("select ior.fromIdentityObject from HibernateIdentityObjectRelationship ior where " +
+ "ior.fromIdentityObject.name like :nameFilter and ior.type.name like :relType and ior.toIdentityObject like :identity");
+
+
+ if (orderByName)
+ {
+ hqlString.append(" orderBy ior.toIdentityObject.name");
+ if (ascending)
+ {
+ hqlString.append(" asc");
+ }
+ }
+ }
+
+
+
+ q = getHibernateEntityManager(ctx).getSession().createQuery(hqlString.toString())
+ .setParameter("relType", relationshipType.getName())
+ .setParameter("identity",hibernateObject);
+
+ if (nameFilterSearchControl != null)
+ {
+ q.setParameter("nameFilter", nameFilterSearchControl.getFilter().replaceAll("\\*", "%"));
+ }
+ else
+ {
+ q.setParameter("nameFilter", "%");
+ }
+
+
+ if (pageSearchControl != null)
+ {
+ q.setFirstResult(pageSearchControl.getOffset());
+ if (pageSearchControl.getLimit() > 0)
+ {
+ q.setMaxResults(pageSearchControl.getLimit());
+ }
+ }
+
+
+
+ results = q.list();
+
+
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Cannot find IdentityObjects", e);
+ }
+
+ if (attributeFilterControl != null)
+ {
+ filterByAttributesValues(results, attributeFilterControl.getValues());
+ }
+
+ return results;
+ }
+
+ public Collection<IdentityObject> findIdentityObject(IdentityStoreInvocationContext ctx,
+ IdentityObject identity,
+ IdentityObjectRelationshipType relationshipType,
+ boolean parent) throws IdentityException
+ {
+
+ return findIdentityObject(ctx, identity, relationshipType, parent, null);
+ }
+
+ public IdentityObjectRelationship createRelationship(IdentityStoreInvocationContext ctx,
+ IdentityObject fromIdentity,
+ IdentityObject toIdentity,
+ IdentityObjectRelationshipType relationshipType,
+ String name, boolean createNames) throws IdentityException
+ {
+
+ if (relationshipType == null)
+ {
+ throw new IllegalArgumentException("RelationshipType is null");
+ }
+
+ HibernateIdentityObject fromIO = safeGet(ctx, fromIdentity);
+ HibernateIdentityObject toIO = safeGet(ctx, toIdentity);
+ HibernateIdentityObjectRelationshipType type = getHibernateIdentityObjectRelationshipType(ctx, relationshipType);
+
+ getSupportedFeatures().isRelationshipTypeSupported(fromIO.getIdentityType(), toIO.getIdentityType(), relationshipType);
+
+
+ org.hibernate.Query query = getHibernateEntityManager(ctx).getSession().createQuery(QUERY_RELATIONSHIP_BY_FROM_TO_TYPE_NAME)
+ .setParameter("fromIO", fromIO)
+ .setParameter("toIO", toIO)
+ .setParameter("typeName", type.getName())
+ .setParameter("name", name);
+
+ List results = query.list();
+
+ if (results.size() != 0)
+ {
+ throw new IdentityException("Relationship already present");
+ }
+
+ HibernateIdentityObjectRelationship relationship = null;
+
+ if (name != null)
+ {
+
+ HibernateIdentityObjectRelationshipName relationshipName = (HibernateIdentityObjectRelationshipName)getHibernateEntityManager(ctx).getSession().createCriteria(HibernateIdentityObjectRelationshipName.class).add(Restrictions.eq("name", name)).uniqueResult();
+
+ if (relationshipName == null)
+ {
+ throw new IdentityException("Relationship name not present in the store");
+ }
+
+ relationship = new HibernateIdentityObjectRelationship(type, fromIO, toIO, relationshipName);
+ }
+ else
+ {
+ relationship = new HibernateIdentityObjectRelationship(type, fromIO, toIO);
+ }
+
+ getHibernateEntityManager(ctx).persist(relationship);
+
+ return relationship;
+
+ }
+
+
+
+ public void removeRelationship(IdentityStoreInvocationContext ctx, IdentityObject fromIdentity, IdentityObject toIdentity, IdentityObjectRelationshipType relationshipType, String name) throws IdentityException
+ {
+
+ if (relationshipType == null)
+ {
+ throw new IllegalArgumentException("RelationshipType is null");
+ }
+
+ HibernateIdentityObject fromIO = safeGet(ctx, fromIdentity);
+ HibernateIdentityObject toIO = safeGet(ctx, toIdentity);
+ HibernateIdentityObjectRelationshipType type = getHibernateIdentityObjectRelationshipType(ctx, relationshipType);
+
+ getSupportedFeatures().isRelationshipTypeSupported(fromIO.getIdentityType(), toIO.getIdentityType(), relationshipType);
+
+ org.hibernate.Query query = null;
+
+ if (name == null)
+ {
+ query = getHibernateEntityManager(ctx).getSession().createQuery(QUERY_RELATIONSHIP_BY_FROM_TO_TYPE)
+ .setParameter("fromIO", fromIO)
+ .setParameter("toIO", toIO)
+ .setParameter("typeName", type.getName());
+ }
+ else
+ {
+ HibernateIdentityObjectRelationshipName relationshipName = (HibernateIdentityObjectRelationshipName)getHibernateEntityManager(ctx).getSession().createCriteria(HibernateIdentityObjectRelationshipName.class).add(Restrictions.eq("name", name)).uniqueResult();
+
+ if (relationshipName == null)
+ {
+ throw new IdentityException("Relationship name not present in the store");
+ }
+
+ query = getHibernateEntityManager(ctx).getSession().createQuery(QUERY_RELATIONSHIP_BY_FROM_TO_TYPE_NAME)
+ .setParameter("fromIO", fromIO)
+ .setParameter("toIO", toIO)
+ .setParameter("typeName", type.getName())
+ .setParameter("name", name);
+ }
+
+
+ List results = query.list();
+
+ if (results == null)
+ {
+ throw new IdentityException("Relationship already present");
+ }
+
+ HibernateIdentityObjectRelationship relationship = (HibernateIdentityObjectRelationship)results.iterator().next();
+
+ fromIO.getFromRelationships().remove(relationship);
+ toIO.getToRelationships().remove(relationship);
+ getHibernateEntityManager(ctx).remove(relationship);
+
+ }
+
+ public void removeRelationships(IdentityStoreInvocationContext ctx, IdentityObject identity1, IdentityObject identity2, boolean named) throws IdentityException
+ {
+ HibernateIdentityObject hio1 = safeGet(ctx, identity1);
+ HibernateIdentityObject hio2 = safeGet(ctx, identity2);
+
+ org.hibernate.Query query = getHibernateEntityManager(ctx).getSession().createQuery(QUERY_RELATIONSHIP_BY_IDENTITIES)
+ .setParameter("IO1", hio1)
+ .setParameter("IO2", hio2);
+
+ List results = query.list();
+
+ for (Iterator iterator = results.iterator(); iterator.hasNext();)
+ {
+ HibernateIdentityObjectRelationship relationship = (HibernateIdentityObjectRelationship) iterator.next();
+
+ if ((named && relationship.getName() != null) ||
+ (!named && relationship.getName() == null))
+ {
+ relationship.getFromIdentityObject().getFromRelationships().remove(relationship);
+ relationship.getToIdentityObject().getToRelationships().remove(relationship);
+ getHibernateEntityManager(ctx).remove(relationship);
+ }
+ }
+ }
+
+ public Set<IdentityObjectRelationship> resolveRelationships(IdentityStoreInvocationContext ctx,
+ IdentityObject fromIdentity,
+ IdentityObject toIdentity,
+ IdentityObjectRelationshipType relationshipType) throws IdentityException
+ {
+
+ HibernateIdentityObject hio1 = safeGet(ctx, fromIdentity);
+ HibernateIdentityObject hio2 = safeGet(ctx, toIdentity);
+
+ org.hibernate.Query query = null;
+
+ if (relationshipType == null)
+ {
+ query = getHibernateEntityManager(ctx).getSession().createQuery(QUERY_RELATIONSHIP_BY_FROM_TO);
+ }
+ else
+ {
+ query = getHibernateEntityManager(ctx).getSession().createQuery(QUERY_RELATIONSHIP_BY_FROM_TO_TYPE)
+ .setParameter("typeName", relationshipType.getName());
+
+ }
+
+ query.setParameter("fromIO", hio1)
+ .setParameter("toIO", hio2);
+
+
+ List<HibernateIdentityObjectRelationship> results = query.list();
+
+ return new HashSet<IdentityObjectRelationship>(results);
+ }
+
+ public Set<IdentityObjectRelationship> resolveRelationships(IdentityStoreInvocationContext ctx,
+ IdentityObject identity,
+ IdentityObjectRelationshipType type,
+ boolean parent,
+ boolean named,
+ String name) throws IdentityException
+ {
+ HibernateIdentityObject hio = safeGet(ctx, identity);
+
+
+ Criteria criteria = getHibernateEntityManager(ctx).getSession().createCriteria(HibernateIdentityObjectRelationship.class);
+
+ if (type != null)
+ {
+ HibernateIdentityObjectRelationshipType hibernateType = getHibernateIdentityObjectRelationshipType(ctx, type);
+
+ criteria.add(Restrictions.eq("type", hibernateType));
+ }
+
+ if (name != null)
+ {
+ criteria.add(Restrictions.eq("name.name", name));
+ }
+ else if (named)
+ {
+ criteria.add(Restrictions.isNotNull("name"));
+ }
+ else
+ {
+ criteria.add(Restrictions.isNull("name"));
+ }
+
+ if (parent)
+ {
+ criteria.add(Restrictions.eq("fromIdentityObject", hio));
+ }
+ else
+ {
+ criteria.add(Restrictions.eq("toIdentityObject", hio));
+ }
+
+ List<HibernateIdentityObjectRelationship> results = criteria.list();
+
+ return new HashSet<IdentityObjectRelationship>(results);
+ }
+
+ public String createRelationshipName(IdentityStoreInvocationContext ctx, String name) throws IdentityException, OperationNotSupportedException
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("name is null");
+ }
+
+ HibernateEntityManager em = getHibernateEntityManager(ctx);
+
+ HibernateRealm realm = getRealm(em, ctx);
+
+ try
+ {
+ HibernateIdentityObjectRelationshipName hiorn = (HibernateIdentityObjectRelationshipName)em.getSession().createCriteria(HibernateIdentityObjectRelationshipName.class)
+ .add(Restrictions.eq("name", name)).add(Restrictions.eq("realm", realm)).uniqueResult();
+
+ if (hiorn != null)
+ {
+ throw new IdentityException("Relationship name already exists");
+ }
+
+ hiorn = new HibernateIdentityObjectRelationshipName(name, realm);
+ getHibernateEntityManager(ctx).persist(hiorn);
+
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Cannot create new relationship name: " + name, e);
+ }
+
+
+ return name;
+ }
+
+ public String removeRelationshipName(IdentityStoreInvocationContext ctx, String name) throws IdentityException, OperationNotSupportedException
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("name is null");
+ }
+
+ HibernateEntityManager em = getHibernateEntityManager(ctx);
+
+
+ try
+ {
+ HibernateIdentityObjectRelationshipName hiorn = (HibernateIdentityObjectRelationshipName)em.getSession().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");
+ }
+
+ getHibernateEntityManager(ctx).remove(hiorn);
+
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Cannot create new relationship name: " + name, e);
+ }
+
+
+ return name;
+ }
+
+ public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx, IdentityObjectSearchControl[] controls) throws IdentityException, OperationNotSupportedException
+ {
+
+ Set<String> names = new HashSet<String>();
+
+ HibernateEntityManager em = getHibernateEntityManager(ctx);
+
+ checkControls(controls);
+
+ PageSearchControl pageSearchControl = null;
+ SortByNameSearchControl sortSearchControl = null;
+ AttributeFilterSearchControl attributeFilterControl = null;
+ NameFilterSearchControl nameFilterSearchControl = null;
+
+ if (controls != null)
+ {
+ for (IdentityObjectSearchControl control : controls)
+ {
+ if (control instanceof PageSearchControl)
+ {
+ pageSearchControl = (PageSearchControl)control;
+ }
+ else if (control instanceof SortByNameSearchControl)
+ {
+ sortSearchControl = (SortByNameSearchControl)control;
+ }
+ else if (control instanceof AttributeFilterSearchControl)
+ {
+ attributeFilterControl = (AttributeFilterSearchControl)control;
+ }
+ else if (control instanceof NameFilterSearchControl)
+ {
+ nameFilterSearchControl = (NameFilterSearchControl)control;
+ }
+ }
+ }
+
+
+ try
+ {
+ Query q = null;
+
+ if (sortSearchControl != null)
+ {
+ if (sortSearchControl.isAscending())
+ {
+ q = em.createNamedQuery("findIdentityObjectRelationshipNamesOrderedByNameAsc");
+ }
+ else
+ {
+ q = em.createNamedQuery("findIdentityObjectRelationshipNamesOrderedByNameDesc");
+ }
+ }
+ else
+ {
+ q = em.createNamedQuery("findIdentityObjectRelationshipNames");
+ }
+
+ q.setParameter("realm", getRealm(em, ctx));
+
+ if (nameFilterSearchControl != null)
+ {
+ q.setParameter("nameFilter", nameFilterSearchControl.getFilter().replaceAll("\\*", "%"));
+ }
+ else
+ {
+ q.setParameter("nameFilter", "%");
+ }
+
+
+ if (pageSearchControl != null)
+ {
+ q.setFirstResult(pageSearchControl.getOffset());
+ if (pageSearchControl.getLimit() > 0)
+ {
+ q.setMaxResults(pageSearchControl.getLimit());
+ }
+ }
+
+ List<String> results = (List<String>)q.getResultList();
+
+ names = new HashSet<String>(results);
+
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Cannot get relationship names. ", e);
+ }
+
+ return names;
+ }
+
+ public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx) throws IdentityException, OperationNotSupportedException
+ {
+ return getRelationshipNames(ctx, new IdentityObjectSearchControl[]{});
+ }
+
+ public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx, IdentityObject identity, IdentityObjectSearchControl[] controls) throws IdentityException, OperationNotSupportedException
+ {
+
+ Set<String> names;
+
+ HibernateIdentityObject hibernateObject = safeGet(ctx, identity);
+
+ HibernateEntityManager em = getHibernateEntityManager(ctx);
+
+ checkControls(controls);
+
+ PageSearchControl pageSearchControl = null;
+ SortByNameSearchControl sortSearchControl = null;
+
+ if (controls != null)
+ {
+ for (IdentityObjectSearchControl control : controls)
+ {
+ if (control instanceof PageSearchControl)
+ {
+ pageSearchControl = (PageSearchControl)control;
+ }
+ else if (control instanceof SortByNameSearchControl)
+ {
+ sortSearchControl = (SortByNameSearchControl)control;
+ }
+ }
+ }
+
+ try
+ {
+ Query q = null;
+
+ if (sortSearchControl != null)
+ {
+ if (sortSearchControl.isAscending())
+ {
+ q = em.createNamedQuery("findIdentityObjectRelationshipNamesForIdentityObjectOrderedByNameAsc");
+ }
+ else
+ {
+ q = em.createNamedQuery("findIdentityObjectRelationshipNamesForIdentityObjectOrderedByNameDesc");
+ }
+ }
+ else
+ {
+ q = em.createNamedQuery("findIdentityObjectRelationshipNamesForIdentityObject");
+ }
+
+ q.setParameter("identityObject", hibernateObject);
+
+ if (pageSearchControl != null)
+ {
+ q.setFirstResult(pageSearchControl.getOffset());
+ if (pageSearchControl.getLimit() > 0)
+ {
+ q.setMaxResults(pageSearchControl.getLimit());
+ }
+ }
+
+ List<String> results = (List<String>)q.getResultList();
+
+ names = new HashSet<String>(results);
+
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Cannot get relationship names. ", e);
+ }
+
+ return names;
+ }
+
+ public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx, IdentityObject identity) throws IdentityException, OperationNotSupportedException
+ {
+ return getRelationshipNames(ctx, identity, null);
+ }
+
+ // Attribute store
+
+ public Set<String> getSupportedAttributeNames(IdentityStoreInvocationContext ctx, IdentityObjectType identityType) throws IdentityException
+ {
+ checkIOType(identityType);
+
+ if (attributeMappings.containsKey(identityType.getName()))
+ {
+ return attributeMappings.get(identityType.getName());
+ }
+
+ return new HashSet<String>();
+
+ }
+
+ public IdentityObjectAttribute getAttribute(IdentityStoreInvocationContext ctx, IdentityObject identity, String name) throws IdentityException
+ {
+ HibernateIdentityObject hibernateObject = safeGet(ctx, identity);
+
+ Set<HibernateIdentityObjectAttribute> storeAttributes = hibernateObject.getAttributes();
+ Map<String, IdentityObjectAttribute> result = new HashMap<String, IdentityObjectAttribute>();
+
+ // Remap the names
+ for (HibernateIdentityObjectAttribute attribute : storeAttributes)
+ {
+ String mappedName = resolveAttributeNameFromStoreMapping(identity.getIdentityType(), name);
+ if (mappedName != null)
+ {
+ return attribute;
+ }
+ }
+
+ return null;
+ }
+
+ public Map<String, IdentityObjectAttribute> getAttributes(IdentityStoreInvocationContext ctx, IdentityObject identity) throws IdentityException
+ {
+
+ HibernateIdentityObject hibernateObject = safeGet(ctx, identity);
+
+ Set<HibernateIdentityObjectAttribute> storeAttributes = hibernateObject.getAttributes();
+ Map<String, IdentityObjectAttribute> result = new HashMap<String, IdentityObjectAttribute>();
+
+ // Remap the names
+ for (HibernateIdentityObjectAttribute attribute : storeAttributes)
+ {
+ String name = resolveAttributeNameFromStoreMapping(identity.getIdentityType(), attribute.getName());
+ if (name != null)
+ {
+ result.put(name, attribute);
+ }
+ }
+
+ return result;
+
+ }
+
+ public Map<String, IdentityObjectAttributeMetaData> getAttributesMetaData(IdentityStoreInvocationContext invocationContext,
+ IdentityObjectType identityType)
+ {
+ return attributesMetaData.get(identityType.getName());
+ }
+
+
+
+ public void updateAttributes(IdentityStoreInvocationContext ctx, IdentityObject identity, IdentityObjectAttribute[] attributes) throws IdentityException
+ {
+
+ if (attributes == null)
+ {
+ throw new IllegalArgumentException("attributes are null");
+ }
+
+ //TODO: check if attribute values time is same as MD type
+
+ Map<String, IdentityObjectAttribute> mappedAttributes = new HashMap<String, IdentityObjectAttribute>();
+
+ Map<String, IdentityObjectAttributeMetaData> mdMap = attributesMetaData.get(identity.getIdentityType().getName());
+
+ for (IdentityObjectAttribute attribute : attributes)
+ {
+ String name = resolveAttributeStoreMapping(identity.getIdentityType(), attribute.getName());
+ mappedAttributes.put(name, attribute);
+
+
+ if (mdMap == null || !mdMap.containsKey(attribute.getName()))
+ {
+ if (!isAllowNotDefinedAttributes)
+ {
+ throw new IdentityException("Cannot add not defined attribute. Use '" + ALLOW_NOT_DEFINED_ATTRIBUTES +
+ "' option if needed. Attribute name: " + attribute.getName());
+ }
+ }
+
+ IdentityObjectAttributeMetaData amd = mdMap.get(attribute.getName());
+
+ if (amd != null)
+ {
+
+ if (!amd.isMultivalued() && attribute.getSize() > 1)
+ {
+ throw new IdentityException("Cannot assigned multiply values to single valued attribute: " + attribute.getName());
+ }
+ if (amd.isReadonly())
+ {
+ throw new IdentityException("Cannot update readonly attribute: " + attribute.getName());
+ }
+
+ String type = amd.getType();
+
+ // check if all values have proper type
+
+ for (Object value : attribute.getValues())
+ {
+ if (type.equals(IdentityObjectAttributeMetaData.TEXT_TYPE) && !(value instanceof String))
+ {
+ throw new IdentityException("Cannot update text type attribute with not String type value: "
+ + attribute.getName() + " / " + value);
+ }
+ if (type.equals(IdentityObjectAttributeMetaData.BINARY_TYPE) && !(value instanceof byte[]))
+ {
+ throw new IdentityException("Cannot update binary type attribute with not byte[] type value: "
+ + attribute.getName() + " / " + value);
+ }
+ }
+ }
+ }
+
+
+ HibernateIdentityObject hibernateObject = safeGet(ctx, identity);
+
+ for (String name : mappedAttributes.keySet())
+ {
+ IdentityObjectAttribute attribute = mappedAttributes.get(name);
+
+ IdentityObjectAttributeMetaData amd = mdMap.get(attribute.getName());
+
+ // Default to text
+ String type = amd != null ? amd.getType() : IdentityObjectAttributeMetaData.TEXT_TYPE;
+
+ for (HibernateIdentityObjectAttribute storeAttribute : hibernateObject.getAttributes())
+ {
+ if (storeAttribute.getName().equals(name))
+ {
+ if (storeAttribute instanceof HibernateIdentityObjectTextAttribute)
+ {
+ if (!type.equals(IdentityObjectAttributeMetaData.TEXT_TYPE))
+ {
+ throw new IdentityException("Wrong attribute mapping. Attribute persisted as text is mapped with: "
+ + type + ". Attribute name: " + name);
+ }
+
+
+ Set<String> v = new HashSet<String>();
+ for (Object value : attribute.getValues())
+ {
+ v.add(value.toString());
+ }
+
+ ((HibernateIdentityObjectTextAttribute)storeAttribute).setValues(v);
+ }
+ else if (storeAttribute instanceof HibernateIdentityObjectBinaryAttribute)
+ {
+
+ if (!type.equals(IdentityObjectAttributeMetaData.BINARY_TYPE))
+ {
+ throw new IdentityException("Wrong attribute mapping. Attribute persisted as binary is mapped with: "
+ + type + ". Attribute name: " + name);
+ }
+
+ Set<byte[]> v = new HashSet<byte[]>();
+ for (Object value : attribute.getValues())
+ {
+ v.add((byte[])value);
+ }
+
+ ((HibernateIdentityObjectBinaryAttribute)storeAttribute).setValues(v);
+ }
+ else
+ {
+ throw new IdentityException("Internal identity store error");
+ }
+ break;
+ }
+ }
+ }
+
+ }
+
+ public void addAttributes(IdentityStoreInvocationContext ctx, IdentityObject identity, IdentityObjectAttribute[] attributes) throws IdentityException
+ {
+
+ if (attributes == null)
+ {
+ throw new IllegalArgumentException("attributes are null");
+ }
+
+ Map<String, IdentityObjectAttribute> mappedAttributes = new HashMap<String, IdentityObjectAttribute>();
+
+ Map<String, IdentityObjectAttributeMetaData> mdMap = attributesMetaData.get(identity.getIdentityType().getName());
+
+ for (IdentityObjectAttribute attribute : attributes)
+ {
+ String name = resolveAttributeStoreMapping(identity.getIdentityType(), attribute.getName());
+ mappedAttributes.put(name, attribute);
+
+
+ if ((mdMap == null || !mdMap.containsKey(attribute.getName())) &&
+ !isAllowNotDefinedAttributes)
+ {
+ throw new IdentityException("Cannot add not defined attribute. Use '" + ALLOW_NOT_DEFINED_ATTRIBUTES +
+ "' option if needed. Attribute name: " + attribute.getName());
+
+ }
+
+ IdentityObjectAttributeMetaData amd = mdMap.get(attribute.getName());
+
+ if (amd != null)
+ {
+
+ if (!amd.isMultivalued() && attribute.getSize() > 1)
+ {
+ throw new IdentityException("Cannot add multiply values to single valued attribute: " + attribute.getName());
+ }
+ if (amd.isReadonly())
+ {
+ throw new IdentityException("Cannot add readonly attribute: " + attribute.getName());
+ }
+
+ String type = amd.getType();
+
+ // check if all values have proper type
+
+ for (Object value : attribute.getValues())
+ {
+ if (type.equals(IdentityObjectAttributeMetaData.TEXT_TYPE) && !(value instanceof String))
+ {
+ throw new IdentityException("Cannot add text type attribute with not String type value: "
+ + attribute.getName() + " / " + value);
+ }
+ if (type.equals(IdentityObjectAttributeMetaData.BINARY_TYPE) && !(value instanceof byte[]))
+ {
+ throw new IdentityException("Cannot add binary type attribute with not byte[] type value: "
+ + attribute.getName() + " / " + value);
+ }
+ }
+ }
+ }
+
+ HibernateIdentityObject hibernateObject = safeGet(ctx, identity);
+
+ for (String name : mappedAttributes.keySet())
+ {
+ IdentityObjectAttribute attribute = mappedAttributes.get(name);
+
+ IdentityObjectAttributeMetaData amd = mdMap.get(attribute.getName());
+
+ // Default to text
+ String type = amd != null ? amd.getType() : IdentityObjectAttributeMetaData.TEXT_TYPE;
+
+ HibernateIdentityObjectAttribute hibernateAttribute = null;
+
+ for (HibernateIdentityObjectAttribute storeAttribute : hibernateObject.getAttributes())
+ {
+ if (storeAttribute.getName().equals(name))
+ {
+ hibernateAttribute = storeAttribute;
+ break;
+ }
+ }
+
+ if (hibernateAttribute != null)
+ {
+ if (hibernateAttribute instanceof HibernateIdentityObjectTextAttribute)
+ {
+ if (!type.equals(IdentityObjectAttributeMetaData.TEXT_TYPE))
+ {
+ throw new IdentityException("Wrong attribute mapping. Attribute persisted as text is mapped with: "
+ + type + ". Attribute name: " + name);
+ }
+
+
+ Set<String> mergedValues = new HashSet<String>(hibernateAttribute.getValues());
+ for (Object value : attribute.getValues())
+ {
+ mergedValues.add(value.toString());
+ }
+
+ ((HibernateIdentityObjectTextAttribute)hibernateAttribute).setValues(mergedValues);
+ }
+ else if (hibernateAttribute instanceof HibernateIdentityObjectBinaryAttribute)
+ {
+
+ if (!type.equals(IdentityObjectAttributeMetaData.BINARY_TYPE))
+ {
+ throw new IdentityException("Wrong attribute mapping. Attribute persisted as binary is mapped with: "
+ + type + ". Attribute name: " + name);
+ }
+
+ Set<byte[]> mergedValues = new HashSet<byte[]>(hibernateAttribute.getValues());
+ for (Object value : attribute.getValues())
+ {
+ mergedValues.add((byte[])value);
+ }
+
+ ((HibernateIdentityObjectBinaryAttribute)hibernateAttribute).setValues(mergedValues);
+ }
+ else
+ {
+ throw new IdentityException("Internal identity store error");
+ }
+ break;
+
+ }
+ else
+ {
+ if (type.equals(IdentityObjectAttributeMetaData.TEXT_TYPE))
+ {
+ Set<String> values = new HashSet<String>();
+
+ for (Object value: attribute.getValues())
+ {
+ values.add(value.toString());
+ }
+ hibernateAttribute = new HibernateIdentityObjectTextAttribute(hibernateObject, name, values);
+ }
+ else if (type.equals(IdentityObjectAttributeMetaData.BINARY_TYPE))
+ {
+ Set<byte[]> values = new HashSet<byte[]>();
+
+ for (Object value: attribute.getValues())
+ {
+ values.add((byte[])value);
+ }
+ hibernateAttribute = new HibernateIdentityObjectBinaryAttribute(hibernateObject, name, values);
+ }
+
+
+ hibernateObject.getAttributes().add(hibernateAttribute);
+
+ }
+ }
+ }
+
+ public void removeAttributes(IdentityStoreInvocationContext ctx, IdentityObject identity, String[] attributes) throws IdentityException
+ {
+
+ if (attributes == null)
+ {
+ throw new IllegalArgumentException("attributes are null");
+ }
+
+ String[] mappedAttributes = new String[attributes.length];
+
+ for (int i = 0; i < attributes.length; i++)
+ {
+ String name = resolveAttributeStoreMapping(identity.getIdentityType(), attributes[i]);
+ mappedAttributes[i] = name;
+
+ Map<String, IdentityObjectAttributeMetaData> mdMap = attributesMetaData.get(identity.getIdentityType().getName());
+
+ if (mdMap != null)
+ {
+ IdentityObjectAttributeMetaData amd = mdMap.get(attributes[i]);
+ if (amd != null && amd.isRequired())
+ {
+ throw new IdentityException("Cannot remove required attribute: " + attributes[i]);
+ }
+ }
+ else
+ {
+ if (!isAllowNotDefinedAttributes)
+ {
+ throw new IdentityException("Cannot remove not defined attribute. Use '" + ALLOW_NOT_DEFINED_ATTRIBUTES +
+ "' option if needed. Attribute name: " + attributes[i]);
+ }
+ }
+
+ }
+
+ HibernateIdentityObject hibernateObject = safeGet(ctx, identity);
+
+ for (String attr : mappedAttributes)
+ {
+ hibernateObject.removeAttribute(attr);
+ }
+ }
+
+ public boolean validateCredential(IdentityStoreInvocationContext ctx, IdentityObject identityObject, IdentityObjectCredential credential) throws IdentityException
+ {
+ if (credential == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ HibernateIdentityObject hibernateObject = safeGet(ctx, identityObject);
+
+ if (supportedFeatures.isCredentialSupported(hibernateObject.getIdentityType(),credential.getType()))
+ {
+
+ HibernateIdentityObjectCredential hibernateCredential = hibernateObject.getCredentials().get(credential.getType().getName());
+
+ if (hibernateCredential == null)
+ {
+ return false;
+ }
+
+ // Handle generic impl
+
+ Object value = null;
+
+ if (credential.getEncodedValue() != null)
+ {
+ value = credential.getEncodedValue();
+ }
+ else
+ {
+ //TODO: support for empty password should be configurable
+ value = credential.getValue();
+ }
+
+ if (value instanceof String && hibernateCredential.getTextValue() != null)
+ {
+ return value.toString().equals(hibernateCredential.getTextValue());
+ }
+ else if (value instanceof byte[] && hibernateCredential.getBinaryValue() != null)
+ {
+ return Arrays.equals((byte[])value, hibernateCredential.getBinaryValue());
+ }
+ else
+ {
+ throw new IdentityException("Not supported credential value: " + value.getClass());
+ }
+ }
+ else
+ {
+ throw new IdentityException("CredentialType not supported for a given IdentityObjectType");
+ }
+ }
+
+ public void updateCredential(IdentityStoreInvocationContext ctx, IdentityObject identityObject, IdentityObjectCredential credential) throws IdentityException
+ {
+
+ if (credential == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ HibernateIdentityObject hibernateObject = safeGet(ctx, identityObject);
+
+ HibernateEntityManager em = getHibernateEntityManager(ctx);
+
+ if (supportedFeatures.isCredentialSupported(hibernateObject.getIdentityType(),credential.getType()))
+ {
+
+ HibernateIdentityObjectCredentialType hibernateCredentialType = getHibernateIdentityObjectCredentialType(ctx, credential.getType());
+
+ if (hibernateCredentialType == null)
+ {
+ throw new IllegalStateException("Credential type not present in this store: " + credential.getType().getName());
+ }
+
+ HibernateIdentityObjectCredential hibernateCredential = new HibernateIdentityObjectCredential();
+ hibernateCredential.setIdentityObject(hibernateObject);
+ hibernateCredential.setType(hibernateCredentialType);
+
+ Object value = null;
+
+ // Handle generic impl
+
+ if (credential.getEncodedValue() != null)
+ {
+ value = credential.getEncodedValue();
+ }
+ else
+ {
+ //TODO: support for empty password should be configurable
+ value = credential.getValue();
+ }
+
+ if (value instanceof String)
+ {
+ hibernateCredential.setTextValue(value.toString());
+ }
+ else if (value instanceof byte[])
+ {
+ hibernateCredential.setBinaryValue((byte[])value);
+ }
+ else
+ {
+ throw new IdentityException("Not supported credential value: " + value.getClass());
+ }
+
+ em.persist(hibernateCredential);
+
+ hibernateObject.addCredential(hibernateCredential);
+
+ }
+ else
+ {
+ throw new IdentityException("CredentialType not supported for a given IdentityObjectType");
+ }
+ }
+
+
+
+
+
+
+ // Internal
+
+ public void addIdentityObjectType(IdentityStoreInvocationContext ctx, IdentityObjectType type) throws IdentityException
+ {
+ HibernateIdentityObjectType hibernateType = new HibernateIdentityObjectType(type);
+ getHibernateEntityManager(ctx).persist(hibernateType);
+ }
+
+
+ public void addIdentityObjectRelationshipType(IdentityStoreInvocationContext ctx, IdentityObjectRelationshipType type) throws IdentityException
+ {
+ HibernateIdentityObjectRelationshipType hibernateType = new HibernateIdentityObjectRelationshipType(type);
+ getHibernateEntityManager(ctx).persist(hibernateType);
+ }
+
+
+ protected HibernateEntityManager getHibernateEntityManager(IdentityStoreInvocationContext ctx) throws IdentityException
+ {
+ try
+ {
+ return (HibernateEntityManager)ctx.getIdentityStoreSession().getSessionContext();
+ }
+ catch (IdentityException e)
+ {
+ throw new IdentityException("Cannot obtain HibernateEntityManager", e);
+ }
+ }
+
+ private void checkIOInstance(IdentityObject io)
+ {
+ if (io == null)
+ {
+ throw new IllegalArgumentException("IdentityObject is null");
+ }
+
+
+ }
+
+ private HibernateIdentityObject safeGet(IdentityStoreInvocationContext ctx, IdentityObject io) throws IdentityException
+ {
+ checkIOInstance(io);
+
+ if (io instanceof HibernateIdentityObject)
+ {
+ return (HibernateIdentityObject)io;
+ }
+
+ return getHibernateIdentityObject(ctx, io);
+
+ }
+
+
+ private void checkIOType(IdentityObjectType iot) throws IdentityException
+ {
+ if (iot == null)
+ {
+ throw new IllegalArgumentException("IdentityObjectType is null");
+ }
+
+ if (!getSupportedFeatures().isIdentityObjectTypeSupported(iot))
+ {
+ throw new IdentityException("IdentityType not supported by this IdentityStore implementation: " + iot);
+ }
+ }
+
+ private HibernateIdentityObjectType getHibernateIdentityObjectType(IdentityStoreInvocationContext ctx, IdentityObjectType type) throws IdentityException
+ {
+
+ HibernateIdentityObjectType hibernateType = null;
+
+ HibernateEntityManager em = getHibernateEntityManager(ctx);
+
+
+ try
+ {
+ hibernateType = (HibernateIdentityObjectType)em.createNamedQuery("findIdentityObjectTypeByName")
+ .setParameter("name", type.getName())
+ .getSingleResult() ;
+ }
+ catch (NoResultException e)
+ {
+ throw new IdentityException("IdentityObjectType[" + type.getName() + "] not present in the store.");
+ }
+
+ return hibernateType;
+ }
+
+ private HibernateIdentityObject getHibernateIdentityObject(IdentityStoreInvocationContext ctx, IdentityObject io) throws IdentityException
+ {
+
+ HibernateIdentityObject hibernateObject = null;
+
+ HibernateEntityManager em = getHibernateEntityManager(ctx);
+
+
+ try
+ {
+ hibernateObject = (HibernateIdentityObject)em.createNamedQuery("findIdentityObjectByNameAndType")
+ .setParameter("name", io.getName())
+ .setParameter("typeName", io.getIdentityType().getName())
+ .setParameter("realm", getRealm(em, ctx))
+ .getSingleResult();
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("IdentityObject[ " + io.getName() + " | " + io.getIdentityType().getName() + "] not present in the store.", e);
+ }
+
+ return hibernateObject;
+ }
+
+ private HibernateIdentityObjectRelationshipType getHibernateIdentityObjectRelationshipType(IdentityStoreInvocationContext ctx, IdentityObjectRelationshipType iot) throws IdentityException
+ {
+
+ HibernateIdentityObjectRelationshipType relationshipType = null;
+
+ HibernateEntityManager em = getHibernateEntityManager(ctx);
+
+ try
+ {
+ relationshipType = (HibernateIdentityObjectRelationshipType)em.createNamedQuery("findIdentityObjectRelationshipTypeByName")
+ .setParameter("name", iot.getName())
+ .getSingleResult();
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("IdentityObjectRelationshipType[ " + iot.getName() + "] not present in the store.");
+ }
+
+ return relationshipType;
+ }
+
+ private HibernateIdentityObjectCredentialType getHibernateIdentityObjectCredentialType(IdentityStoreInvocationContext ctx, IdentityObjectCredentialType credentialType) throws IdentityException
+ {
+ HibernateEntityManager em = getHibernateEntityManager(ctx);
+
+ HibernateIdentityObjectCredentialType hibernateType = null;
+
+ try
+ {
+ hibernateType = (HibernateIdentityObjectCredentialType)em.getSession().
+ createCriteria(HibernateIdentityObjectCredentialType.class).add(Restrictions.eq("name", credentialType.getName())).uniqueResult();
+ }
+ catch (HibernateException e)
+ {
+ throw new IdentityException("IdentityObjectCredentialType[ " + credentialType.getName() + "] not present in the store.");
+ }
+
+ return hibernateType;
+
+ }
+
+ public void populateObjectTypes(HibernateEntityManager em, String[] typeNames) throws Exception
+ {
+
+ em.getTransaction().begin();
+
+ for (String typeName : typeNames)
+ {
+
+ //Check if present
+
+ HibernateIdentityObjectType hibernateType = (HibernateIdentityObjectType)em.getSession().
+ createCriteria(HibernateIdentityObjectType.class).add(Restrictions.eq("name", typeName)).uniqueResult();
+
+ if (hibernateType == null)
+ {
+ hibernateType = new HibernateIdentityObjectType(typeName);
+ em.persist(hibernateType);
+ }
+
+ }
+
+ em.getTransaction().commit();
+
+ }
+
+ public void populateRelationshipTypes(HibernateEntityManager em, String[] typeNames) throws Exception
+ {
+
+ em.getTransaction().begin();
+
+ for (String typeName : typeNames)
+ {
+ HibernateIdentityObjectRelationshipType hibernateType = (HibernateIdentityObjectRelationshipType)em.getSession().
+ createCriteria(HibernateIdentityObjectRelationshipType.class).add(Restrictions.eq("name", typeName)).uniqueResult();
+
+ if (hibernateType == null)
+ {
+ hibernateType = new HibernateIdentityObjectRelationshipType(typeName);
+ em.persist(hibernateType);
+ }
+
+ }
+
+ em.getTransaction().commit();
+ }
+
+
+ public void populateCredentialTypes(HibernateEntityManager em, String[] typeNames) throws Exception
+ {
+
+ em.getTransaction().begin();
+
+ for (String typeName : typeNames)
+ {
+ HibernateIdentityObjectCredentialType hibernateType = (HibernateIdentityObjectCredentialType)em.getSession().
+ createCriteria(HibernateIdentityObjectCredentialType.class).add(Restrictions.eq("name", typeName)).uniqueResult();
+
+ if (hibernateType == null)
+ {
+ hibernateType = new HibernateIdentityObjectCredentialType(typeName);
+ em.persist(hibernateType);
+ }
+
+ }
+
+ em.getTransaction().commit();
+ }
+
+
+
+ public void addRealm(HibernateEntityManager em, String realmName) throws IdentityException
+ {
+
+ try
+ {
+ em.getTransaction().begin();
+
+ HibernateRealm realm = new HibernateRealm(realmName);
+ em.persist(realm);
+
+ em.getTransaction().commit();
+
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Failed to create store realm", e);
+ }
+ }
+
+
+ public HibernateRealm getRealm(HibernateEntityManager em, IdentityStoreInvocationContext ctx) throws IdentityException
+ {
+ if (ctx.getRealmId() == null)
+ {
+ throw new IllegalStateException("Realm Id not present");
+ }
+
+ HibernateRealm realm = null;
+
+ // If store is not realm aware return null to create/get objects accessible from other realms
+ if (!isRealmAware())
+ {
+ realm = (HibernateRealm)em.getSession().
+ createCriteria(HibernateRealm.class).add(Restrictions.eq("name", DEFAULT_REALM_NAME)).uniqueResult();
+
+ if (realm == null)
+ {
+ throw new IllegalStateException("Default store realm is not present: " + DEFAULT_REALM_NAME);
+ }
+
+ }
+ else
+ {
+ realm = (HibernateRealm)em.getSession().
+ createCriteria(HibernateRealm.class).add(Restrictions.eq("name", ctx.getRealmId())).uniqueResult();
+
+
+ // TODO: other way to not lazy initialize realm? special method called on every new session creation
+ if (realm == null)
+ {
+ HibernateRealm newRealm = new HibernateRealm(ctx.getRealmId());
+ em.persist(newRealm);
+ return newRealm;
+ }
+ }
+
+
+
+ return realm;
+ }
+
+ private boolean isRealmAware()
+ {
+ return isRealmAware;
+ }
+
+ private boolean isAllowNotDefinedAttributes()
+ {
+ return isAllowNotDefinedAttributes;
+ }
+
+ private void checkControls(IdentityObjectSearchControl[] controls) throws IdentityException
+ {
+ if (controls != null)
+ {
+ for (IdentityObjectSearchControl control : controls)
+ {
+ if (!supportedIdentityObjectSearchControls.contains(control.getClass()))
+ {
+ throw new IdentityException("IdentityObjectSearchControl not supported by this IdentityStore: " + control.getClass());
+ }
+ }
+ }
+ }
+
+ /**
+ * Resolve store mapping for attribute name. If attribute is not mapped and store doesn't allow not defined
+ * attributes throw exception
+ * @param type
+ * @param name
+ * @return
+ */
+ private String resolveAttributeStoreMapping(IdentityObjectType type, String name) throws IdentityException
+ {
+ String mapping = null;
+
+ if (attributesMetaData.containsKey(type.getName()))
+ {
+ IdentityObjectAttributeMetaData amd = attributesMetaData.get(type.getName()).get(name);
+
+ if (amd != null)
+ {
+ mapping = amd.getStoreMapping() != null ? amd.getStoreMapping() : amd.getName();
+ return mapping;
+ }
+ }
+
+ if (isAllowNotDefinedAttributes())
+ {
+ mapping = name;
+ return mapping;
+ }
+
+ throw new IdentityException("Attribute name is not configured in this store");
+ }
+
+ private String resolveAttributeNameFromStoreMapping(IdentityObjectType type, String mapping)
+ {
+ if (reverseAttributeMappings.containsKey(type.getName()))
+ {
+ Map<String, String> map = reverseAttributeMappings.get(type.getName());
+
+ if (map != null)
+ {
+ String name = map.containsKey(mapping) ? map.get(mapping) : mapping;
+ return name;
+ }
+ }
+
+ if (isAllowNotDefinedAttributes())
+ {
+ return mapping;
+ }
+ return null;
+ }
+
+ //TODO: this kills performance and is present here only as "quick" hack to have the feature present and let to add test cases
+ //TODO: needs to be redone at the hibernate query level
+ private void filterByAttributesValues(Collection<IdentityObject> objects, Map<String, String[]> attrs)
+ {
+ Set<IdentityObject> toRemove = new HashSet<IdentityObject>();
+
+ for (IdentityObject object : objects)
+ {
+ Map<String, Collection> presentAttrs = ((HibernateIdentityObject)object).getAttributesAsMap();
+ for (Map.Entry<String, String[]> entry : attrs.entrySet())
+ {
+ if (presentAttrs.containsKey(entry.getKey()))
+ {
+ Set<String> given = new HashSet<String>(Arrays.asList(entry.getValue()));
+ Collection present = presentAttrs.get(entry.getKey());
+
+ for (String s : given)
+ {
+ if (!present.contains(s))
+ {
+ toRemove.add(object);
+ break;
+ }
+ }
+
+ }
+ else
+ {
+ toRemove.add(object);
+ break;
+
+ }
+ }
+ }
+
+ for (IdentityObject identityObject : toRemove)
+ {
+ objects.remove(identityObject);
+ }
+ }
+
+
+}
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreInvocationContext.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/hibernate/HibernateIdentityStoreInvocationContext.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreInvocationContext.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,37 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.store.hibernate;
-
-import org.jboss.identity.spi.store.IdentityStoreInvocationContext;
-import org.hibernate.ejb.HibernateEntityManager;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-//public interface HibernateIdentityStoreInvocationContext extends IdentityStoreInvocationContext
-//{
-//
-// public HibernateEntityManager getHibernateEntityManager();
-//
-//}
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreSessionImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/hibernate/HibernateIdentityStoreSessionImpl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreSessionImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,101 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.store.hibernate;
-
-import org.jboss.identity.spi.store.IdentityStoreSession;
-import org.jboss.identity.exception.IdentityException;
-import org.hibernate.ejb.HibernateEntityManagerFactory;
-import org.hibernate.ejb.HibernateEntityManager;
-
-import javax.persistence.Persistence;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class HibernateIdentityStoreSessionImpl implements IdentityStoreSession
-{
-
- private final HibernateEntityManager hem;
-
- public HibernateIdentityStoreSessionImpl(HibernateEntityManager hem)
- {
- this.hem = hem;
- }
-
- public HibernateIdentityStoreSessionImpl(String persistenceUnit)
- {
- HibernateEntityManagerFactory emFactory = (HibernateEntityManagerFactory)Persistence.createEntityManagerFactory(persistenceUnit);
- hem = (HibernateEntityManager)emFactory.createEntityManager();
- }
-
- public Object getSessionContext()
- {
- return hem;
- }
-
- public void close() throws IdentityException
- {
- hem.close();
- }
-
- public void save() throws IdentityException
- {
- hem.flush();
- }
-
- public void clear() throws IdentityException
- {
- hem.clear();
- }
-
- public boolean isOpen()
- {
- return hem.isOpen();
- }
-
- public boolean isTransactionSupported()
- {
- return true;
- }
-
- public void startTransaction()
- {
- hem.getTransaction().begin();
- }
-
- public void commitTransaction()
- {
- hem.getTransaction().commit();
- }
-
- public void rollbackTransaction()
- {
- hem.getTransaction().rollback();
- }
-
- public boolean isTransactionActive()
- {
- return hem.getTransaction().isActive();
- }
-}
Copied: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreSessionImpl.java (from rev 211, trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/hibernate/HibernateIdentityStoreSessionImpl.java)
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreSessionImpl.java (rev 0)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreSessionImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,103 @@
+/*
+* 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.store.hibernate;
+
+import org.jboss.identity.idm.spi.store.IdentityStoreSession;
+import org.jboss.identity.idm.exception.IdentityException;
+import org.hibernate.ejb.HibernateEntityManagerFactory;
+import org.hibernate.ejb.HibernateEntityManager;
+
+import javax.persistence.Persistence;
+
+/**
+ * Wrapper around HibernateEntityManager
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class HibernateIdentityStoreSessionImpl implements IdentityStoreSession
+{
+
+ private final HibernateEntityManager hem;
+
+ public HibernateIdentityStoreSessionImpl(HibernateEntityManager hem)
+ {
+ this.hem = hem;
+ }
+
+ public HibernateIdentityStoreSessionImpl(String persistenceUnit)
+ {
+ HibernateEntityManagerFactory emFactory = (HibernateEntityManagerFactory)Persistence.createEntityManagerFactory(persistenceUnit);
+ hem = (HibernateEntityManager)emFactory.createEntityManager();
+ }
+
+ public Object getSessionContext()
+ {
+ return hem;
+ }
+
+ public void close() throws IdentityException
+ {
+ hem.close();
+ }
+
+ public void save() throws IdentityException
+ {
+ hem.flush();
+ }
+
+ public void clear() throws IdentityException
+ {
+ hem.clear();
+ }
+
+ public boolean isOpen()
+ {
+ return hem.isOpen();
+ }
+
+ public boolean isTransactionSupported()
+ {
+ return true;
+ }
+
+ public void startTransaction()
+ {
+ hem.getTransaction().begin();
+ }
+
+ public void commitTransaction()
+ {
+ hem.getTransaction().commit();
+ }
+
+ public void rollbackTransaction()
+ {
+ hem.getTransaction().rollback();
+ }
+
+ public boolean isTransactionActive()
+ {
+ return hem.getTransaction().isActive();
+ }
+}
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityObjectTypeConfiguration.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/ldap/LDAPIdentityObjectTypeConfiguration.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityObjectTypeConfiguration.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,58 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.store.ldap;
-
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public interface LDAPIdentityObjectTypeConfiguration
-{
- String getIdAttributeName();
-
- String getPasswordAttributeName();
-
- String[] getCtxDNs();
-
- String getEntrySearchFilter();
-
- boolean isAllowCreateEntry();
-
- Map<String, String[]> getCreateEntryAttributeValues();
-
- String[] getAllowedMembershipTypes();
-
- String getMembershipAttributeName();
-
- boolean isMembershipAttributeDN();
-
- boolean allowEmptyMemberships();
-
- String getAttributeMapping(String identityAttribute);
-
- Set<String> getMappedAttributesNames();
-}
Copied: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityObjectTypeConfiguration.java (from rev 211, trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/ldap/LDAPIdentityObjectTypeConfiguration.java)
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityObjectTypeConfiguration.java (rev 0)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityObjectTypeConfiguration.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,59 @@
+/*
+* 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.store.ldap;
+
+import java.util.Set;
+import java.util.Map;
+
+/**
+ * Helper interface to expose LDAP IdentityStore configuration in a different way
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface LDAPIdentityObjectTypeConfiguration
+{
+ String getIdAttributeName();
+
+ String getPasswordAttributeName();
+
+ String[] getCtxDNs();
+
+ String getEntrySearchFilter();
+
+ boolean isAllowCreateEntry();
+
+ Map<String, String[]> getCreateEntryAttributeValues();
+
+ String[] getAllowedMembershipTypes();
+
+ String getMembershipAttributeName();
+
+ boolean isMembershipAttributeDN();
+
+ boolean allowEmptyMemberships();
+
+ String getAttributeMapping(String identityAttribute);
+
+ Set<String> getMappedAttributesNames();
+}
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreConfiguration.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/ldap/LDAPIdentityStoreConfiguration.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreConfiguration.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,46 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.store.ldap;
-
-import org.jboss.identity.spi.model.IdentityObjectType;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public interface LDAPIdentityStoreConfiguration
-{
-
- String getProviderURL();
-
- String getAdminDN();
-
- String getAdminPassword();
-
- int getSearchTimeLimit();
-
- LDAPIdentityObjectTypeConfiguration getTypeConfiguration(String typeName);
-
- IdentityObjectType[] getConfiguredTypes();
-
-}
Copied: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreConfiguration.java (from rev 211, trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/ldap/LDAPIdentityStoreConfiguration.java)
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreConfiguration.java (rev 0)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreConfiguration.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,48 @@
+/*
+* 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.store.ldap;
+
+import org.jboss.identity.idm.spi.model.IdentityObjectType;
+
+/**
+ * Helper interface to expose LDAP IdentityStore configuration in a different way
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface LDAPIdentityStoreConfiguration
+{
+
+ String getProviderURL();
+
+ String getAdminDN();
+
+ String getAdminPassword();
+
+ int getSearchTimeLimit();
+
+ LDAPIdentityObjectTypeConfiguration getTypeConfiguration(String typeName);
+
+ IdentityObjectType[] getConfiguredTypes();
+
+}
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/ldap/LDAPIdentityStoreImpl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,2115 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.store.ldap;
-
-import org.jboss.identity.spi.store.IdentityStore;
-import org.jboss.identity.spi.store.FeaturesMetaData;
-import org.jboss.identity.spi.store.IdentityStoreInvocationContext;
-import org.jboss.identity.spi.store.IdentityStoreSession;
-import org.jboss.identity.spi.searchcontrol.IdentityObjectSearchControl;
-import org.jboss.identity.spi.model.IdentityObject;
-import org.jboss.identity.spi.model.IdentityObjectType;
-import org.jboss.identity.spi.model.IdentityObjectRelationshipType;
-import org.jboss.identity.spi.model.IdentityObjectRelationship;
-import org.jboss.identity.spi.model.IdentityObjectCredential;
-import org.jboss.identity.spi.model.IdentityObjectAttribute;
-import org.jboss.identity.spi.exception.OperationNotSupportedException;
-import org.jboss.identity.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
-import org.jboss.identity.spi.configuration.metadata.IdentityObjectTypeMetaData;
-import org.jboss.identity.spi.attribute.IdentityObjectAttributeMetaData;
-import org.jboss.identity.exception.IdentityException;
-import org.jboss.identity.impl.store.FeaturesMetaDataImpl;
-import org.jboss.identity.impl.model.ldap.LDAPIdentityObjectImpl;
-import org.jboss.identity.impl.model.ldap.LDAPIdentityObjectRelationshipImpl;
-import org.jboss.identity.impl.helper.Tools;
-import org.jboss.identity.impl.NotYetImplementedException;
-import org.jboss.identity.impl.api.SortByNameSearchControl;
-import org.jboss.identity.impl.api.PageSearchControl;
-import org.jboss.identity.impl.api.AttributeFilterSearchControl;
-import org.jboss.identity.impl.api.NameFilterSearchControl;
-import org.jboss.identity.impl.api.SimpleAttributeImpl;
-
-import javax.naming.ldap.LdapContext;
-import javax.naming.ldap.LdapName;
-import javax.naming.ldap.Control;
-import javax.naming.ldap.SortControl;
-import javax.naming.ldap.InitialLdapContext;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.SearchControls;
-import javax.naming.directory.BasicAttributes;
-import javax.naming.directory.BasicAttribute;
-import javax.naming.directory.SearchResult;
-import javax.naming.directory.DirContext;
-import javax.naming.NamingException;
-import javax.naming.NamingEnumeration;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Set;
-import java.util.List;
-import java.util.LinkedList;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Hashtable;
-import java.util.Comparator;
-import java.util.regex.Pattern;
-import java.util.logging.Logger;
-import java.util.logging.Level;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class LDAPIdentityStoreImpl implements IdentityStore
-{
-
- //TODO: external JNDI
- //TODO: more options for connection configuration
- //TODO: JNDI connection credentials encoding (pluggable?)
-
- private static Logger log = Logger.getLogger(LDAPIdentityStoreImpl.class.getName());
-
- private final String id;
-
- private FeaturesMetaData supportedFeatures;
-
- LDAPIdentityStoreConfiguration configuration;
-
- IdentityStoreConfigurationMetaData configurationMD;
-
- private static Set<Class> supportedSearchControls = new HashSet<Class>();
-
- // <IdentityObjectType name, <Attribute name, MD>
- private Map<String, Map<String, IdentityObjectAttributeMetaData>> attributesMetaData = new HashMap<String, Map<String, IdentityObjectAttributeMetaData>>();
-
- static {
- // List all supported controls classes
-
- //TODO: attribute filter
- supportedSearchControls.add(SortByNameSearchControl.class);
- supportedSearchControls.add(PageSearchControl.class);
- supportedSearchControls.add(NameFilterSearchControl.class);
- //supportedSearchControls.add(AttributeFilterSearchControl.class);
- }
-
- public LDAPIdentityStoreImpl(String id)
- {
- this.id = id;
- }
-
- public void bootstrap(IdentityStoreConfigurationMetaData configurationMD) throws IdentityException
- {
- if (configurationMD == null)
- {
- throw new IllegalArgumentException("Configuration is null");
- }
-
- this.configurationMD = configurationMD;
-
- configuration = new SimpleLDAPIdentityStoreConfiguration(configurationMD);
-
- supportedFeatures = new FeaturesMetaDataImpl(configurationMD, supportedSearchControls, false);
-
- // Attribute mappings - helper structures
-
- for (IdentityObjectTypeMetaData identityObjectTypeMetaData : configurationMD.getSupportedIdentityTypes())
- {
- Map<String, IdentityObjectAttributeMetaData> metadataMap = new HashMap<String, IdentityObjectAttributeMetaData>();
- for (IdentityObjectAttributeMetaData attributeMetaData : identityObjectTypeMetaData.getAttributes())
- {
- metadataMap.put(attributeMetaData.getName(), attributeMetaData);
- }
-
- attributesMetaData.put(identityObjectTypeMetaData.getName(), metadataMap);
-
- }
- }
-
- public IdentityStoreSession createIdentityStoreSession()
- {
-
- return new LDAPIdentityStoreSessionImpl(
- "com.sun.jndi.ldap.LdapCtxFactory",
- configuration.getProviderURL(),
- "simple",
- configuration.getAdminDN(),
- configuration.getAdminPassword());
-
- }
-
- public String getId()
- {
- return id;
- }
-
- public FeaturesMetaData getSupportedFeatures()
- {
- return supportedFeatures;
- }
-
- public IdentityObject createIdentityObject(IdentityStoreInvocationContext invocationCtx, String name, IdentityObjectType identityObjectType) throws IdentityException
- {
- return createIdentityObject(invocationCtx, name, identityObjectType, null);
- }
-
- public IdentityObject createIdentityObject(IdentityStoreInvocationContext invocationCtx,
- String name,
- IdentityObjectType type,
- Map<String, String[]> attributes) throws IdentityException
- {
- if (name == null)
- {
- throw new IdentityException("Name cannot be null");
- }
-
- checkIOType(type);
-
- if (log.isLoggable(Level.FINER))
- {
- log.finer(toString() + ".createIdentityObject with name: " + name + " and type: " + type.getName());
- }
-
- LdapContext ldapContext = getLDAPContext(invocationCtx);
-
- try
- {
- // If there are many contexts specified in the configuration the first one is used
- LdapContext ctx = (LdapContext)ldapContext.lookup(getTypeConfiguration(invocationCtx, type).getCtxDNs()[0]);
-
- //We store new entry using set of attributes. This should give more flexibility then
- //extending identity object from ContextDir - configure what objectClass place there
- Attributes attrs = new BasicAttributes(true);
-
- //create attribute using provided configuration
- Map<String, String[]> attributesToAdd = getTypeConfiguration(invocationCtx, type).getCreateEntryAttributeValues();
-
- //merge
- if (attributes != null)
- {
- for (Map.Entry<String, String[]> entry : attributes.entrySet())
- {
-
- if (!attributesToAdd.containsKey(entry.getKey()))
- {
- attributesToAdd.put(entry.getKey(), entry.getValue());
- }
- else
- {
- List<String> list1 = Arrays.asList(attributesToAdd.get(entry.getKey()));
- List<String> list2 = Arrays.asList(entry.getValue());
-
- list1.addAll(list2);
-
- String[] vals = list1.toArray(new String[list1.size()]);
-
- attributesToAdd.put(entry.getKey(), vals);
-
- }
- }
- }
-
- //attributes
- for (Iterator it1 = attributesToAdd.keySet().iterator(); it1.hasNext();)
- {
- String attributeName = (String)it1.next();
-
-
- Attribute attr = new BasicAttribute(attributeName);
- String[] attributeValues = attributesToAdd.get(attributeName);
-
- //values
-
- for (String attrValue : attributeValues)
- {
- attr.add(attrValue);
- }
-
- attrs.put(attr);
- }
-
- // Make it RFC 2253 compliant
- LdapName validLDAPName = new LdapName(getTypeConfiguration(invocationCtx, type).getIdAttributeName().concat("=").concat(name));
-
- log.finer("creating ldap entry for: " + validLDAPName + "; " + attrs);
- ctx.createSubcontext(validLDAPName, attrs);
- }
- catch (Exception e)
- {
- throw new IdentityException("Failed to create identity object", e);
- }
- finally
- {
- try
- {
- ldapContext.close();
- }
- catch (NamingException e)
- {
- throw new IdentityException("Failed to close LDAP connection", e);
- }
- }
-
- return findIdentityObject(invocationCtx, name, type);
-
- }
-
- public void removeIdentityObject(IdentityStoreInvocationContext invocationCtx, IdentityObject identity) throws IdentityException
- {
- if (log.isLoggable(Level.FINER))
- {
- log.finer(toString() + ".removeIdentityObject: " + identity);
- }
-
- LDAPIdentityObjectImpl ldapIdentity = getSafeLDAPIO(invocationCtx, identity);
-
- String dn = ldapIdentity.getDn();
-
- if (dn == null)
- {
- throw new IdentityException("Cannot obtain DN of identity");
- }
-
- LdapContext ldapContext = getLDAPContext(invocationCtx);
-
- try
- {
- log.finer("removing entry: " + dn);
- ldapContext.unbind(dn);
- }
- catch (Exception e)
- {
- throw new IdentityException("Failed to remove identity: ", e);
- }
- finally
- {
- try
- {
- ldapContext.close();
- }
- catch (NamingException e)
- {
- throw new IdentityException("Failed to close LDAP connection", e);
- }
- }
-
- }
-
- public int getIdentityObjectsCount(IdentityStoreInvocationContext ctx, IdentityObjectType identityType) throws IdentityException
- {
- if (log.isLoggable(Level.FINER))
- {
- log.finer(toString() + ".getIdentityObjectsCount for type: " + identityType);
- }
-
- checkIOType(identityType);
-
- try
- {
- String filter = getTypeConfiguration(ctx, identityType).getEntrySearchFilter();
-
- if (filter != null && filter.length() > 0)
- {
- // chars are escaped in filterArgs so we must replace it manually
- filter = filter.replaceAll("\\{0\\}", "*");
- }
- else
- {
- //search all entries
- filter = "(".concat(getTypeConfiguration(ctx, identityType).getIdAttributeName()).concat("=").concat("*").concat(")");
- }
-
-
- String[] entryCtxs = getTypeConfiguration(ctx, identityType).getCtxDNs();
-
- //log.debug("Search filter: " + filter);
- List sr = searchIdentityObjects(ctx,
- entryCtxs,
- filter,
- null,
- new String[]{getTypeConfiguration(ctx, identityType).getIdAttributeName()},
- null);
-
- return sr.size();
-
- }
- catch (NoSuchElementException e)
- {
- //log.debug("No identity object found", e);
- }
- catch (Exception e)
- {
- throw new IdentityException("User search failed.", e);
- }
- return 0;
- }
-
- public IdentityObject findIdentityObject(IdentityStoreInvocationContext invocationCtx, String name, IdentityObjectType type) throws IdentityException
- {
-
- if (log.isLoggable(Level.FINER))
- {
- log.finer(toString() + ".findIdentityObject with name: " + name + "; and type: " + type);
- }
-
- Context ctx = null;
- checkIOType(type);
- try
- {
- //log.debug("name = " + name);
-
- if (name == null)
- {
- throw new IdentityException("Identity object name canot be null");
- }
-
- String filter = getTypeConfiguration(invocationCtx, type).getEntrySearchFilter();
- List sr = null;
-
-
- String[] entryCtxs = getTypeConfiguration(invocationCtx, type).getCtxDNs();
-
-
- if (filter != null && filter.length() > 0)
- {
- Object[] filterArgs = {name};
- sr = searchIdentityObjects(invocationCtx,
- entryCtxs,
- filter,
- filterArgs,
- new String[]{getTypeConfiguration(invocationCtx, type).getIdAttributeName()},
- null);
- }
- else
- {
- //search all entries
- filter = "(".concat(getTypeConfiguration(invocationCtx, type).getIdAttributeName()).concat("=").concat(name).concat(")");
- sr = searchIdentityObjects(invocationCtx,
- entryCtxs,
- filter,
- null,
- new String[]{getTypeConfiguration(invocationCtx, type).getIdAttributeName()},
- null);
- }
-
- //log.debug("Search filter: " + filter);
-
- if (sr.size() > 1)
- {
- throw new IdentityException("Found more than one identity object with name: " + name +
- "; Posible data inconsistency");
- }
- SearchResult res = (SearchResult)sr.iterator().next();
- ctx = (Context)res.getObject();
- String dn = ctx.getNameInNamespace();
- IdentityObject io = createIdentityObjectInstance(invocationCtx, type, res.getAttributes(), dn);
- ctx.close();
- return io;
-
- }
- catch (NoSuchElementException e)
- {
- //log.debug("No identity object found with name: " + name, e);
- }
- catch (NamingException e)
- {
- throw new IdentityException("IdentityObject search failed.", e);
- }
- finally
- {
- try
- {
- if (ctx != null)
- {
- ctx.close();
- }
- }
- catch (NamingException e)
- {
- throw new IdentityException("Failed to close LDAP connection", e);
- }
- }
-
- return null;
- }
-
- public IdentityObject findIdentityObject(IdentityStoreInvocationContext ctx, String id) throws IdentityException
- {
- if (log.isLoggable(Level.FINER))
- {
- log.finer(toString() + ".findIdentityObject with id: " + id);
- }
-
- LdapContext ldapContext = getLDAPContext(ctx);
-
- try
- {
- if (id == null)
- {
- throw new IdentityException("identity id cannot be null");
- }
-
- String dn = id;
-
- IdentityObjectType type = null;
-
- //Recognize the type by ctx DN
-
- IdentityObjectType[] possibleTypes = getConfiguration(ctx).getConfiguredTypes();
-
- for (IdentityObjectType possibleType : possibleTypes)
- {
- String[] typeCtxs = getTypeConfiguration(ctx, possibleType).getCtxDNs();
-
- for (String typeCtx : typeCtxs)
- {
- if (dn.endsWith(typeCtx))
- {
- type = possibleType;
- break;
- }
- }
- if (type != null)
- {
- break;
- }
- }
-
- if (type == null)
- {
- throw new IdentityException("Cannot recognize identity object type by its DN: " + dn);
- }
-
- // Grab entry
-
- Attributes attrs = ldapContext.getAttributes(dn);
-
- if (attrs == null)
- {
- throw new IdentityException("Can't find identity entry with DN: " + dn);
- }
-
- return createIdentityObjectInstance(ctx, type, attrs, dn);
-
- }
- catch (NoSuchElementException e)
- {
- //log.debug("No identity object found with dn: " + dn, e);
- }
- catch (NamingException e)
- {
- throw new IdentityException("Identity object search failed.", e);
- }
- finally
- {
- try
- {
- ldapContext.close();
- }
- catch (NamingException e)
- {
- throw new IdentityException("Failed to close LDAP connection", e);
- }
- }
- return null;
- }
-
- public Collection<IdentityObject> findIdentityObject(IdentityStoreInvocationContext invocationCtx, IdentityObjectType type, IdentityObjectSearchControl[] controls) throws IdentityException
- {
-
- checkControls(controls);
-
- //TODO: page control with LDAP request control
-
- PageSearchControl pageSearchControl = null;
- SortByNameSearchControl sortSearchControl = null;
- AttributeFilterSearchControl attributeFilterSearchControl = null;
- NameFilterSearchControl nameFilterSearchControl = null;
-
- if (controls != null)
- {
- for (IdentityObjectSearchControl control : controls)
- {
- if (control instanceof PageSearchControl)
- {
- pageSearchControl = (PageSearchControl)control;
- }
- else if (control instanceof SortByNameSearchControl)
- {
- sortSearchControl = (SortByNameSearchControl)control;
- }
- else if (control instanceof AttributeFilterSearchControl)
- {
- attributeFilterSearchControl = (AttributeFilterSearchControl)control;
- }
- else if (control instanceof NameFilterSearchControl)
- {
- nameFilterSearchControl = (NameFilterSearchControl)control;
- }
-
- }
- }
-
- String nameFilter = "*";
-
- //Filter by name
- if (nameFilterSearchControl != null)
- {
- nameFilter = nameFilterSearchControl.getFilter();
- }
-
-
- LdapContext ctx = getLDAPContext(invocationCtx);
-
-
- checkIOType(type);
-
- LinkedList<IdentityObject> objects = new LinkedList<IdentityObject>();
-
- LDAPIdentityObjectTypeConfiguration typeConfiguration = getTypeConfiguration(invocationCtx, type);
-
- try
- {
- Control[] requestControls = null;
-
- // Sort control
- if (sortSearchControl != null)
- {
- //TODO: make criticallity optional
- requestControls = new Control[]{
- new SortControl(typeConfiguration.getIdAttributeName(), Control.NONCRITICAL)
- };
- }
-
- StringBuilder af = new StringBuilder();
-
- // Filter by attribute values
- if (attributeFilterSearchControl != null)
- {
- af.append("(&");
-
- for (Map.Entry<String, String[]> stringEntry : attributeFilterSearchControl.getValues().entrySet())
- {
- for (String value : stringEntry.getValue())
- {
- af.append("(")
- .append(stringEntry.getKey())
- .append("=")
- .append(value)
- .append(")");
- }
- }
-
- af.append(")");
- }
-
- String filter = getTypeConfiguration(invocationCtx, type).getEntrySearchFilter();
- List<SearchResult> sr = null;
-
- String[] entryCtxs = getTypeConfiguration(invocationCtx, type).getCtxDNs();
-
- if (filter != null && filter.length() > 0)
- {
-
- Object[] filterArgs = {nameFilter};
- sr = searchIdentityObjects(invocationCtx,
- entryCtxs,
- "(&(" + filter + ")" + af.toString() + ")",
- filterArgs,
- new String[]{typeConfiguration.getIdAttributeName()},
- requestControls);
- }
- else
- {
- filter = "(".concat(typeConfiguration.getIdAttributeName()).concat("=").concat(nameFilter).concat(")");
- sr = searchIdentityObjects(invocationCtx,
- entryCtxs,
- "(&(" + filter + ")" + af.toString() + ")",
- null,
- new String[]{typeConfiguration.getIdAttributeName()},
- requestControls);
- }
-
-
- for (SearchResult res : sr)
- {
- ctx = (LdapContext)res.getObject();
- String dn = ctx.getNameInNamespace();
- if (sortSearchControl != null)
- {
- // It seams that the sort order is not configurable and
- // sort control returns entries in descending order by default...
- if (!sortSearchControl.isAscending())
- {
- objects.addFirst(createIdentityObjectInstance(invocationCtx, type, res.getAttributes(), dn));
- }
- else
- {
- objects.addLast(createIdentityObjectInstance(invocationCtx, type, res.getAttributes(), dn));
- }
- }
- else
- {
- objects.add(createIdentityObjectInstance(invocationCtx, type, res.getAttributes(), dn));
- }
- }
-
- ctx.close();
-
-
- }
- catch (NoSuchElementException e)
- {
- //log.debug("No identity object found with name: " + name, e);
- }
- catch (Exception e)
- {
- throw new IdentityException("IdentityObject search failed.", e);
- }
- finally
- {
- try
- {
- if (ctx != null)
- {
- ctx.close();
- }
- }
- catch (NamingException e)
- {
- throw new IdentityException("Failed to close LDAP connection", e);
- }
- }
-
- if (pageSearchControl != null)
- {
- objects = (LinkedList)cutPageFromResults(objects, pageSearchControl);
- }
-
- return objects;
- }
-
- public Collection<IdentityObject> findIdentityObject(IdentityStoreInvocationContext invocationCtx, IdentityObjectType type) throws IdentityException
- {
- return findIdentityObject(invocationCtx, type, null);
- }
-
-
- public Collection<IdentityObject> findIdentityObject(IdentityStoreInvocationContext ctx, IdentityObject identity, IdentityObjectRelationshipType relationshipType, boolean parent, IdentityObjectSearchControl[] controls) throws IdentityException
- {
-
- //TODO: relationshipType is ignored - maybe check and allow only MEMBERSHIP?
-
-
-
- checkControls(controls);
-
- PageSearchControl pageSearchControl = null;
- SortByNameSearchControl sortSearchControl = null;
- AttributeFilterSearchControl attributeFilterSearchControl = null;
- NameFilterSearchControl nameFilterSearchControl = null;
-
- if (controls != null)
- {
- for (IdentityObjectSearchControl control : controls)
- {
- if (control instanceof PageSearchControl)
- {
- pageSearchControl = (PageSearchControl)control;
- }
- else if (control instanceof SortByNameSearchControl)
- {
- sortSearchControl = (SortByNameSearchControl)control;
- }
- else if (control instanceof AttributeFilterSearchControl)
- {
- attributeFilterSearchControl = (AttributeFilterSearchControl)control;
- }
- else if (control instanceof NameFilterSearchControl)
- {
- nameFilterSearchControl = (NameFilterSearchControl)control;
- }
-
- }
- }
-
- LDAPIdentityObjectImpl ldapFromIO = getSafeLDAPIO(ctx, identity);
-
- LDAPIdentityObjectTypeConfiguration typeConfig = getTypeConfiguration(ctx, identity.getIdentityType());
-
- LdapContext ldapContext = getLDAPContext(ctx);
-
- List<IdentityObject> objects = new LinkedList<IdentityObject>();
-
- try
- {
-
- // If parent simply look for all its members
- if (parent)
- {
- Attributes attrs = ldapContext.getAttributes(ldapFromIO.getDn());
- Attribute member = attrs.get(typeConfig.getMembershipAttributeName());
-
- if (member != null)
- {
- NamingEnumeration memberValues = member.getAll();
- while (memberValues.hasMoreElements())
- {
- String memberRef = memberValues.nextElement().toString();
-
- if (typeConfig.isMembershipAttributeDN())
- {
- //TODO: use direct LDAP query instaed of other find method and add attributesFilter
-
- if (nameFilterSearchControl != null)
- {
- String name = Tools.stripDnToName(memberRef);
- String regex = Tools.wildcardToRegex(nameFilterSearchControl.getFilter());
-
- if (Pattern.matches(regex, name))
- {
- objects.add(findIdentityObject(ctx, memberRef));
- }
- }
- else
- {
- objects.add(findIdentityObject(ctx, memberRef));
- }
- }
- else
- {
- //TODO: if relationships are not refered with DNs and only names its not possible to map
- //TODO: them to proper IdentityType and keep name uniqnes per type. Workaround needed
- throw new NotYetImplementedException("LDAP limitation. If relationship targets are not refered with FQDNs " +
- "and only names, it's not possible to map them to proper IdentityType and keep name uniqnes per type. " +
- "Workaround needed");
- }
- //break;
- }
- }
- }
-
- // if not parent then all parent entries need to be found
- else
- {
- // Search in all other type contexts
- for (IdentityObjectType parentType : configuration.getConfiguredTypes())
- {
- checkIOType(parentType);
-
- LDAPIdentityObjectTypeConfiguration parentTypeConfiguration = getTypeConfiguration(ctx, parentType);
-
- List<String> allowedTypes = Arrays.asList(parentTypeConfiguration.getAllowedMembershipTypes());
-
- // Check if given identity type can be parent
- if (!allowedTypes.contains(identity.getIdentityType().getName()))
- {
- continue;
- }
-
- String nameFilter = "*";
-
- //Filter by name
- if (nameFilterSearchControl != null)
- {
- nameFilter = nameFilterSearchControl.getFilter();
- }
-
- Control[] requestControls = null;
-
- StringBuilder af = new StringBuilder();
-
- // Filter by attribute values
- if (attributeFilterSearchControl != null)
- {
- af.append("(&");
-
- for (Map.Entry<String, String[]> stringEntry : attributeFilterSearchControl.getValues().entrySet())
- {
- for (String value : stringEntry.getValue())
- {
- af.append("(")
- .append(stringEntry.getKey())
- .append("=")
- .append(value)
- .append(")");
- }
- }
-
- af.append(")");
- }
-
- // Add filter to search only parents of the given entry
- af.append("(")
- .append(parentTypeConfiguration.getMembershipAttributeName())
- .append("=");
- if (parentTypeConfiguration.isMembershipAttributeDN())
- {
- af.append(ldapFromIO.getDn());
- }
- else
- {
- //TODO: this doesn't make much sense unless parent/child are same identity types and resides in the same LDAP context
- af.append(ldapFromIO.getName());
- }
- af.append(")");
-
-
- String filter = parentTypeConfiguration.getEntrySearchFilter();
- List<SearchResult> sr = null;
-
- String[] entryCtxs = parentTypeConfiguration.getCtxDNs();
-
- if (filter != null && filter.length() > 0)
- {
-
- Object[] filterArgs = {nameFilter};
- sr = searchIdentityObjects(ctx,
- entryCtxs,
- "(&(" + filter + ")" + af.toString() + ")",
- filterArgs,
- new String[]{parentTypeConfiguration.getIdAttributeName()},
- requestControls);
- }
- else
- {
- filter = "(".concat(parentTypeConfiguration.getIdAttributeName()).concat("=").concat(nameFilter).concat(")");
- sr = searchIdentityObjects(ctx,
- entryCtxs,
- "(&(" + filter + ")" + af.toString() + ")",
- null,
- new String[]{parentTypeConfiguration.getIdAttributeName()},
- requestControls);
- }
-
- for (SearchResult res : sr)
- {
- LdapContext ldapCtx = (LdapContext)res.getObject();
- String dn = ldapCtx.getNameInNamespace();
-
- objects.add(createIdentityObjectInstance(ctx, parentType, res.getAttributes(), dn));
- }
- }
-
-
- }
-
- }
- catch (NamingException e)
- {
- throw new IdentityException("Failed to resolve relationship", e);
- }
- finally
- {
- try
- {
- ldapContext.close();
- }
- catch (NamingException e)
- {
- throw new IdentityException("Failed to close LDAP connection", e);
- }
- }
-
- if (pageSearchControl != null)
- {
- objects = cutPageFromResults(objects, pageSearchControl);
- }
-
- if (sortSearchControl != null)
- {
- sortByName(objects, sortSearchControl.isAscending());
- }
-
- return objects;
- }
-
- public Set<IdentityObjectRelationship> resolveRelationships(IdentityStoreInvocationContext ctx,
- IdentityObject identity,
- IdentityObjectRelationshipType type,
- boolean parent,
- boolean named,
- String name) throws IdentityException
- {
- //TODO: relationshipType is ignored - maybe check and allow only MEMBERSHIP?
-
-
-
- LDAPIdentityObjectImpl ldapIO = getSafeLDAPIO(ctx, identity);
-
- LDAPIdentityObjectTypeConfiguration typeConfig = getTypeConfiguration(ctx, identity.getIdentityType());
-
- LdapContext ldapContext = getLDAPContext(ctx);
-
- Set<IdentityObjectRelationship> relationships = new HashSet<IdentityObjectRelationship>();
-
- try
- {
-
- // If parent simply look for all its members
- if (parent)
- {
- Attributes attrs = ldapContext.getAttributes(ldapIO.getDn());
- Attribute member = attrs.get(typeConfig.getMembershipAttributeName());
-
- if (member != null)
- {
- NamingEnumeration memberValues = member.getAll();
- while (memberValues.hasMoreElements())
- {
- String memberRef = memberValues.nextElement().toString();
-
- if (typeConfig.isMembershipAttributeDN())
- {
- //TODO: use direct LDAP query instaed of other find method and add attributesFilter
-
-
- relationships.add(new LDAPIdentityObjectRelationshipImpl(null, ldapIO, findIdentityObject(ctx, memberRef)));
-
- }
- else
- {
- //TODO: if relationships are not refered with DNs and only names its not possible to map
- //TODO: them to proper IdentityType and keep name uniqnes per type. Workaround needed
- throw new NotYetImplementedException("LDAP limitation. If relationship targets are not refered with FQDNs " +
- "and only names, it's not possible to map them to proper IdentityType and keep name uniqnes per type. " +
- "Workaround needed");
- }
- //break;
- }
- }
- }
-
- // if not parent then all parent entries need to be found
- else
- {
- // Search in all other type contexts
- for (IdentityObjectType parentType : configuration.getConfiguredTypes())
- {
- checkIOType(parentType);
-
- LDAPIdentityObjectTypeConfiguration parentTypeConfiguration = getTypeConfiguration(ctx, parentType);
-
- List<String> allowedTypes = Arrays.asList(parentTypeConfiguration.getAllowedMembershipTypes());
-
- // Check if given identity type can be parent
- if (!allowedTypes.contains(identity.getIdentityType().getName()))
- {
- continue;
- }
-
- String nameFilter = "*";
-
- //Filter by name
- Control[] requestControls = null;
-
- StringBuilder af = new StringBuilder();
-
-
- // Add filter to search only parents of the given entry
- af.append("(")
- .append(parentTypeConfiguration.getMembershipAttributeName())
- .append("=");
- if (parentTypeConfiguration.isMembershipAttributeDN())
- {
- af.append(ldapIO.getDn());
- }
- else
- {
- //TODO: this doesn't make much sense unless parent/child are same identity types and resides in the same LDAP context
- af.append(ldapIO.getName());
- }
- af.append(")");
-
-
- String filter = parentTypeConfiguration.getEntrySearchFilter();
- List<SearchResult> sr = null;
-
- String[] entryCtxs = parentTypeConfiguration.getCtxDNs();
-
- if (filter != null && filter.length() > 0)
- {
-
- Object[] filterArgs = {nameFilter};
- sr = searchIdentityObjects(ctx,
- entryCtxs,
- "(&(" + filter + ")" + af.toString() + ")",
- filterArgs,
- new String[]{parentTypeConfiguration.getIdAttributeName()},
- requestControls);
- }
- else
- {
- filter = "(".concat(parentTypeConfiguration.getIdAttributeName()).concat("=").concat(nameFilter).concat(")");
- sr = searchIdentityObjects(ctx,
- entryCtxs,
- "(&(" + filter + ")" + af.toString() + ")",
- null,
- new String[]{parentTypeConfiguration.getIdAttributeName()},
- requestControls);
- }
-
- for (SearchResult res : sr)
- {
- LdapContext ldapCtx = (LdapContext)res.getObject();
- String dn = ldapCtx.getNameInNamespace();
-
- relationships.add(new LDAPIdentityObjectRelationshipImpl(null, createIdentityObjectInstance(ctx, parentType, res.getAttributes(), dn), ldapIO));
- }
- }
-
-
- }
-
- }
- catch (NamingException e)
- {
- throw new IdentityException("Failed to resolve relationship", e);
- }
- finally
- {
- try
- {
- ldapContext.close();
- }
- catch (NamingException e)
- {
- throw new IdentityException("Failed to close LDAP connection", e);
- }
- }
-
-
- return relationships;
- }
-
- public Collection<IdentityObject> findIdentityObject(IdentityStoreInvocationContext ctx,
- IdentityObject identity,
- IdentityObjectRelationshipType relationshipType,
- boolean parent) throws IdentityException
- {
- return findIdentityObject(ctx, identity, relationshipType, parent, null);
- }
-
- public IdentityObjectRelationship createRelationship(IdentityStoreInvocationContext ctx, IdentityObject fromIdentity, IdentityObject toIdentity,
- IdentityObjectRelationshipType relationshipType,
- String name, boolean createNames) throws IdentityException
- {
-
- //TODO: relationshipType is ignored for now
-
- if (log.isLoggable(Level.FINER))
- {
- log.finer(toString() + ".createRelationship with "
- + "fromIdentity: " + fromIdentity
- + "; toIdentity: " + toIdentity
- + "; relationshipType: " + relationshipType
- );
- }
-
- LDAPIdentityObjectRelationshipImpl relationship = null;
-
- LDAPIdentityObjectImpl ldapFromIO = getSafeLDAPIO(ctx, fromIdentity);
-
- LDAPIdentityObjectImpl ldapToIO = getSafeLDAPIO(ctx, toIdentity);
-
- LDAPIdentityObjectTypeConfiguration fromTypeConfig = getTypeConfiguration(ctx, fromIdentity.getIdentityType());
-
- LdapContext ldapContext = getLDAPContext(ctx);
-
- // Check posibilities
- if (!getSupportedFeatures().isRelationshipTypeSupported(fromIdentity.getIdentityType(), toIdentity.getIdentityType(), relationshipType))
- {
- throw new IdentityException("Relationship not supported");
- }
-
- try
- {
- // Construct new member attribute values
- Attributes attrs = new BasicAttributes(true);
-
- Attribute member = new BasicAttribute(fromTypeConfig.getMembershipAttributeName());
-
- if (fromTypeConfig.isMembershipAttributeDN())
- {
- member.add(ldapToIO.getDn());
- }
- else
- {
- member.add(toIdentity.getName());
- }
-
- attrs.put(member);
-
- ldapContext.modifyAttributes(ldapFromIO.getDn(), DirContext.ADD_ATTRIBUTE, attrs);
-
- relationship = new LDAPIdentityObjectRelationshipImpl(name, ldapFromIO, ldapToIO);
-
- }
- catch (NamingException e)
- {
- throw new IdentityException("Failed to create relationship", e);
- }
- finally
- {
- try
- {
- ldapContext.close();
- }
- catch (NamingException e)
- {
- throw new IdentityException("Failed to close LDAP connection", e);
- }
- }
-
-
- return relationship;
- }
-
- public void removeRelationship(IdentityStoreInvocationContext ctx, IdentityObject fromIdentity, IdentityObject toIdentity, IdentityObjectRelationshipType relationshipType, String name) throws IdentityException
- {
- // relationshipType is ignored for now
-
- if (log.isLoggable(Level.FINER))
- {
- log.finer(toString() + ".removeRelationship with "
- + "fromIdentity: " + fromIdentity
- + "; toIdentity: " + toIdentity
- + "; relationshipType: " + relationshipType
- );
- }
-
- LDAPIdentityObjectImpl ldapFromIO = getSafeLDAPIO(ctx, fromIdentity);
- LDAPIdentityObjectImpl ldapToIO = getSafeLDAPIO(ctx, toIdentity);
-
- LDAPIdentityObjectTypeConfiguration fromTypeConfig = getTypeConfiguration(ctx, fromIdentity.getIdentityType());
-
- // If relationship is not allowed simply return
- //TODO: use features description instead
- if (!Arrays.asList(fromTypeConfig.getAllowedMembershipTypes()).contains(ldapToIO.getIdentityType().getName()))
- {
- return;
- }
-
- LdapContext ldapContext = getLDAPContext(ctx);
-
- // Check posibilities
-
- //TODO: null RelationshipType passed from removeRelationships
- if (relationshipType != null &&
- !getSupportedFeatures().isRelationshipTypeSupported(fromIdentity.getIdentityType(), toIdentity.getIdentityType(), relationshipType))
- {
- throw new IdentityException("Relationship not supported");
- }
-
- try
- {
- //construct new member attribute values
- Attributes attrs = new BasicAttributes(true);
-
- Attribute member = new BasicAttribute(fromTypeConfig.getMembershipAttributeName());
-
- if (fromTypeConfig.isMembershipAttributeDN())
- {
- member.add(ldapToIO.getDn());
- }
- else
- {
- member.add(toIdentity.getName());
- }
-
- attrs.put(member);
-
- ldapContext.modifyAttributes(ldapFromIO.getDn(), DirContext.REMOVE_ATTRIBUTE, attrs);
-
- }
- catch (NamingException e)
- {
- throw new IdentityException("Failed to remove relationship", e);
- }
- finally
- {
- try
- {
- ldapContext.close();
- }
- catch (NamingException e)
- {
- throw new IdentityException("Failed to close LDAP connection", e);
- }
- }
- }
-
- public void removeRelationships(IdentityStoreInvocationContext ctx, IdentityObject identity1, IdentityObject identity2, boolean named) throws IdentityException
- {
- if (log.isLoggable(Level.FINER))
- {
- log.finer(toString() + ".removeRelationships with "
- + "identity1: " + identity1
- + "; identity2: " + identity2
- );
- }
-
- // as relationship type is ignored in this impl for now...
- removeRelationship(ctx, identity1, identity2, null, null);
- removeRelationship(ctx, identity2, identity1, null, null);
-
- }
-
- public Set<IdentityObjectRelationship> resolveRelationships(IdentityStoreInvocationContext ctx, IdentityObject fromIdentity, IdentityObject toIdentity, IdentityObjectRelationshipType relationshipType) throws IdentityException
- {
- // relationshipType is ignored for now
-
-
- if (log.isLoggable(Level.FINER))
- {
- log.finer(toString() + ".resolveRelationships with "
- + "fromIdentity: " + fromIdentity
- + "; toIdentity: " + toIdentity
- );
- }
-
- Set<IdentityObjectRelationship> relationships = new HashSet<IdentityObjectRelationship>();
-
- LDAPIdentityObjectImpl ldapFromIO = getSafeLDAPIO(ctx, fromIdentity);
- LDAPIdentityObjectImpl ldapToIO = getSafeLDAPIO(ctx, toIdentity);
-
- LDAPIdentityObjectTypeConfiguration fromTypeConfig = getTypeConfiguration(ctx, fromIdentity.getIdentityType());
-
- // If relationship is not allowed return empty set
- //TODO: use features description instead
-
- if (!Arrays.asList(fromTypeConfig.getAllowedMembershipTypes()).contains(ldapToIO.getIdentityType().getName()))
- {
- return relationships;
- }
-
- LdapContext ldapContext = getLDAPContext(ctx);
-
- try
- {
- Attributes attrs = ldapContext.getAttributes(ldapFromIO.getDn());
- Attribute member = attrs.get(fromTypeConfig.getMembershipAttributeName());
-
- if (member != null)
- {
- NamingEnumeration memberValues = member.getAll();
- while (memberValues.hasMoreElements())
- {
- String memberRef = memberValues.nextElement().toString();
-
- if ((fromTypeConfig.isMembershipAttributeDN() && memberRef.equals(ldapToIO.getDn())) ||
- (!fromTypeConfig.isMembershipAttributeDN() && memberRef.equals(ldapToIO.getName())))
- {
- //TODO: impl lacks support for rel type
- relationships.add(new LDAPIdentityObjectRelationshipImpl(null, ldapFromIO, ldapToIO));
- }
- break;
- }
- }
-
- }
- catch (NamingException e)
- {
- throw new IdentityException("Failed to resolve relationship", e);
- }
- finally
- {
- try
- {
- ldapContext.close();
- }
- catch (NamingException e)
- {
- throw new IdentityException("Failed to close LDAP connection", e);
- }
- }
- return relationships;
- }
-
- public String createRelationshipName(IdentityStoreInvocationContext ctx, String name) throws IdentityException, OperationNotSupportedException
- {
- throw new OperationNotSupportedException("Named relationships are not supported by this implementation of LDAP IdentityStore");
- }
-
- public String removeRelationshipName(IdentityStoreInvocationContext ctx, String name) throws IdentityException, OperationNotSupportedException
- {
- throw new OperationNotSupportedException("Named relationships are not supported by this implementation of LDAP IdentityStore");
- }
-
- public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx, IdentityObjectSearchControl[] controls) throws IdentityException, OperationNotSupportedException
- {
- throw new OperationNotSupportedException("Named relationships are not supported by this implementation of LDAP IdentityStore");
- }
-
- public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx) throws IdentityException, OperationNotSupportedException
- {
- throw new OperationNotSupportedException("Named relationships are not supported by this implementation of LDAP IdentityStore");
- }
-
- public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx, IdentityObject identity, IdentityObjectSearchControl[] controls) throws IdentityException, OperationNotSupportedException
- {
- throw new OperationNotSupportedException("Named relationships are not supported by this implementation of LDAP IdentityStore");
-
- }
-
- public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx, IdentityObject identity) throws IdentityException, OperationNotSupportedException
- {
- throw new OperationNotSupportedException("Named relationships are not supported by this implementation of LDAP IdentityStore");
- }
-
- public boolean validateCredential(IdentityStoreInvocationContext ctx, IdentityObject identityObject, IdentityObjectCredential credential) throws IdentityException
- {
- if (credential == null)
- {
- throw new IllegalArgumentException();
- }
-
- LDAPIdentityObjectImpl ldapIO = getSafeLDAPIO(ctx, identityObject);
-
- if (supportedFeatures.isCredentialSupported(ldapIO.getIdentityType(),credential.getType()))
- {
-
- String passwordString = null;
-
- // Handle generic impl
-
- if (credential.getValue() != null)
- {
- //TODO: support for empty password should be configurable
- passwordString = credential.getValue().toString();
- }
- else
- {
- throw new IdentityException("Null password value");
- }
-
- LdapContext ldapContext = getLDAPContext(ctx);
-
- try
- {
-
- Hashtable env = ldapContext.getEnvironment();
-
- env.put(Context.SECURITY_PRINCIPAL, ldapIO.getDn());
- env.put(Context.SECURITY_CREDENTIALS, passwordString);
-
- InitialContext initialCtx = new InitialLdapContext(env, null);
-
- if (initialCtx != null)
- {
- initialCtx.close();
- return true;
- }
-
- }
- catch (NamingException e)
- {
- //
- }
- finally
- {
- try
- {
- ldapContext.close();
- }
- catch (NamingException e)
- {
- throw new IdentityException("Failed to close LDAP connection", e);
- }
- }
- return false;
-
-
- }
- else
- {
- throw new IdentityException("CredentialType not supported for a given IdentityObjectType");
- }
- }
-
- public void updateCredential(IdentityStoreInvocationContext ctx, IdentityObject identityObject, IdentityObjectCredential credential) throws IdentityException
- {
- if (credential == null)
- {
- throw new IllegalArgumentException();
- }
-
- LDAPIdentityObjectImpl ldapIO = getSafeLDAPIO(ctx, identityObject);
-
- if (supportedFeatures.isCredentialSupported(ldapIO.getIdentityType(),credential.getType()))
- {
-
- String passwordString = null;
-
- // Handle generic impl
-
- if (credential.getValue() != null)
- {
- //TODO: support for empty password should be configurable
- passwordString = credential.getValue().toString();
- }
- else
- {
- throw new IdentityException("Null password value");
- }
-
- String attributeName = getTypeConfiguration(ctx, ldapIO.getIdentityType()).getPasswordAttributeName();
-
- if (attributeName == null)
- {
- throw new IdentityException("IdentityType doesn't have passwordAttributeName option set: "
- + ldapIO.getIdentityType().getName());
- }
-
- LdapContext ldapContext = getLDAPContext(ctx);
-
- try
- {
- //TODO: maybe perform a schema check if this attribute is allowed for such entry
-
- Attributes attrs = new BasicAttributes(true);
- Attribute attr = new BasicAttribute(attributeName);
- attr.add(passwordString);
- attrs.put(attr);
-
- ldapContext.modifyAttributes(ldapIO.getDn(), DirContext.REPLACE_ATTRIBUTE,attrs);
- }
- catch (NamingException e)
- {
- throw new IdentityException("Cannot set identity password value.", e);
- }
- finally
- {
- try
- {
- ldapContext.close();
- }
- catch (NamingException e)
- {
- throw new IdentityException("Failed to close LDAP connection", e);
- }
- }
-
- }
- else
- {
- throw new IdentityException("CredentialType not supported for a given IdentityObjectType");
- }
- }
-
-
- // Attributes
-
- public Set<String> getSupportedAttributeNames(IdentityStoreInvocationContext invocationContext, IdentityObjectType identityType) throws IdentityException
- {
- if (log.isLoggable(Level.FINER))
- {
- log.finer(toString() + ".getSupportedAttributeNames with "
- + "identityType: " + identityType
- );
- }
-
- checkIOType(identityType);
-
- return getTypeConfiguration(invocationContext, identityType).getMappedAttributesNames();
- }
-
- public Map<String, IdentityObjectAttributeMetaData> getAttributesMetaData(IdentityStoreInvocationContext invocationContext, IdentityObjectType identityObjectType)
- {
- return attributesMetaData.get(identityObjectType.getName());
- }
-
-
- public IdentityObjectAttribute getAttribute(IdentityStoreInvocationContext invocationContext, IdentityObject identity, String name) throws IdentityException
- {
- //TODO: dummy temporary implementation
- return getAttributes(invocationContext, identity).get(name);
- }
-
- public Map<String, IdentityObjectAttribute> getAttributes(IdentityStoreInvocationContext ctx, IdentityObject identity) throws IdentityException
- {
-
- if (log.isLoggable(Level.FINER))
- {
- log.finer(toString() + ".getAttributes with "
- + "identity: " + identity
- );
- }
-
- Map<String, IdentityObjectAttribute> attrsMap = new HashMap<String, IdentityObjectAttribute>();
-
- LDAPIdentityObjectImpl ldapIdentity = getSafeLDAPIO(ctx, identity);
-
-
- LdapContext ldapContext = getLDAPContext(ctx);
-
- try
- {
- Set<String> mappedNames = getTypeConfiguration(ctx, identity.getIdentityType()).getMappedAttributesNames();
-
- // as this is valid LDAPIdentityObjectImpl DN is obtained from the Id
-
- String dn = ldapIdentity.getDn();
-
- Attributes attrs = ldapContext.getAttributes(dn);
-
- for (Iterator iterator = mappedNames.iterator(); iterator.hasNext();)
- {
- String name = (String)iterator.next();
- String attrName = getTypeConfiguration(ctx, identity.getIdentityType()).getAttributeMapping(name);
- Attribute attr = attrs.get(attrName);
-
- if (attr != null)
- {
-
- IdentityObjectAttribute identityObjectAttribute = new SimpleAttributeImpl(name);
-
- NamingEnumeration values = attr.getAll();
-
- while (values.hasMoreElements())
- {
- identityObjectAttribute.addValue(values.nextElement().toString());
- }
-
- attrsMap.put(name, identityObjectAttribute);
- }
- else
- {
- log.fine("No such attribute ('" + attrName + "') in entry: " + dn);
- }
- }
- }
- catch (NamingException e)
- {
- throw new IdentityException("Cannot get attributes value.", e);
- }
- finally
- {
- try
- {
- ldapContext.close();
- }
- catch (NamingException e)
- {
- throw new IdentityException("Failed to close LDAP connection", e);
- }
- }
-
- return attrsMap;
-
- }
-
- public void updateAttributes(IdentityStoreInvocationContext ctx, IdentityObject identity, IdentityObjectAttribute[] attributes) throws IdentityException
- {
-
- if (log.isLoggable(Level.FINER))
- {
- log.finer(toString() + ".updateAttributes with "
- + "identity: " + identity
- + "attributes: " + attributes
- );
- }
-
- if (attributes == null)
- {
- throw new IllegalArgumentException("attributes is null");
- }
-
- LDAPIdentityObjectImpl ldapIdentity = getSafeLDAPIO(ctx, identity);
-
-
- // as this is valid LDAPIdentityObjectImpl DN is obtained from the Id
-
- String dn = ldapIdentity.getDn();
-
- LdapContext ldapContext = getLDAPContext(ctx);
-
- try
- {
-
- for (IdentityObjectAttribute attribute : attributes)
- {
- String name = attribute.getName();
-
- String attributeName = getTypeConfiguration(ctx, identity.getIdentityType()).getAttributeMapping(name);
-
- if (attributeName == null)
- {
- log.fine("Proper LDAP attribute mapping not found for such property name: " + name);
- continue;
- }
-
- //TODO: maybe perform a schema check if this attribute is not required
-
- Attributes attrs = new BasicAttributes(true);
- Attribute attr = new BasicAttribute(attributeName);
-
- Collection values = attribute.getValues();
-
- Map<String, IdentityObjectAttributeMetaData> mdMap = attributesMetaData.get(identity.getIdentityType().getName());
-
- if (mdMap != null)
- {
- IdentityObjectAttributeMetaData amd = mdMap.get(attributeName);
- if (amd != null && !amd.isMultivalued() && values.size() > 1)
- {
- throw new IdentityException("Cannot assigned multiply values to single valued attribute: " + attributeName);
- }
- if (amd != null && amd.isReadonly())
- {
- throw new IdentityException("Cannot update readonly attribute: " + attributeName);
- }
- }
-
- if (values != null)
- {
- for (Object value : values)
- {
- attr.add(value);
- }
-
- attrs.put(attr);
-
- try
- {
- ldapContext.modifyAttributes(dn, DirContext.REPLACE_ATTRIBUTE, attrs);
- }
- catch (NamingException e)
- {
- throw new IdentityException("Cannot add attribute", e);
- }
- }
-
- }
- }
- finally
- {
- try
- {
- ldapContext.close();
- }
- catch (NamingException e)
- {
- throw new IdentityException("Failed to close LDAP connection", e);
- }
- }
- }
-
- public void addAttributes(IdentityStoreInvocationContext ctx, IdentityObject identity, IdentityObjectAttribute[] attributes) throws IdentityException
- {
-
- if (log.isLoggable(Level.FINER))
- {
- log.finer(toString() + ".addAttributes with "
- + "identity: " + identity
- + "attributes: " + attributes
- );
- }
-
-
- if (attributes == null)
- {
- throw new IllegalArgumentException("attributes is null");
- }
-
- LDAPIdentityObjectImpl ldapIdentity = getSafeLDAPIO(ctx, identity);
-
-
- // as this is valid LDAPIdentityObjectImpl DN is obtained from the Id
-
- String dn = ldapIdentity.getDn();
-
- LdapContext ldapContext = getLDAPContext(ctx);
-
- try
- {
- for (IdentityObjectAttribute attribute : attributes)
- {
- String name = attribute.getName();
-
- String attributeName = getTypeConfiguration(ctx, identity.getIdentityType()).getAttributeMapping(name);
-
- if (attributeName == null)
- {
- log.fine("Proper LDAP attribute mapping not found for such property name: " + name);
- continue;
- }
-
- //TODO: maybe perform a schema check if this attribute is not required
-
- Attributes attrs = new BasicAttributes(true);
- Attribute attr = new BasicAttribute(attributeName);
-
- Collection values = attribute.getValues();
-
- Map<String, IdentityObjectAttributeMetaData> mdMap = attributesMetaData.get(identity.getIdentityType().getName());
-
- if (mdMap != null)
- {
- IdentityObjectAttributeMetaData amd = mdMap.get(attributeName);
- if (amd != null && !amd.isMultivalued() && values.size() > 1)
- {
- throw new IdentityException("Cannot assigned multiply values to single valued attribute: " + attributeName);
- }
- if (amd != null && amd.isReadonly())
- {
- throw new IdentityException("Cannot update readonly attribute: " + attributeName);
- }
- }
-
-
- if (values != null)
- {
- for (Object value : values)
- {
- attr.add(value);
- }
-
- attrs.put(attr);
-
- try
- {
- ldapContext.modifyAttributes(dn, DirContext.ADD_ATTRIBUTE, attrs);
- }
- catch (NamingException e)
- {
- throw new IdentityException("Cannot add attribute", e);
- }
- }
-
- }
- }
- finally
- {
- try
- {
- ldapContext.close();
- }
- catch (NamingException e)
- {
- throw new IdentityException("Failed to close LDAP connection", e);
- }
- }
- }
-
- public void removeAttributes(IdentityStoreInvocationContext ctx, IdentityObject identity, String[] attributeNames) throws IdentityException
- {
-
- if (log.isLoggable(Level.FINER))
- {
- log.finer(toString() + ".removeAttributes with "
- + "identity: " + identity
- + "attributeNames: " + attributeNames
- );
- }
-
- if (attributeNames == null)
- {
- throw new IllegalArgumentException("attributes is null");
- }
-
- LDAPIdentityObjectImpl ldapIdentity = getSafeLDAPIO(ctx, identity);
-
- // as this is valid LDAPIdentityObjectImpl DN is obtained from the Id
-
- String dn = ldapIdentity.getDn();
-
- LdapContext ldapContext = getLDAPContext(ctx);
-
- try
- {
- for (String name : attributeNames)
- {
- String attributeName = getTypeConfiguration(ctx, identity.getIdentityType()).getAttributeMapping(name);
-
- if (attributeName == null)
- {
- log.fine("Proper LDAP attribute mapping not found for such property name: " + name);
- continue;
- }
-
- Map<String, IdentityObjectAttributeMetaData> mdMap = attributesMetaData.get(identity.getIdentityType().getName());
-
- if (mdMap != null)
- {
- //TODO: maybe perform a schema check if this attribute is not required on the LDAP level
- IdentityObjectAttributeMetaData amd = mdMap.get(name);
- if (amd != null && amd.isRequired())
- {
- throw new IdentityException("Cannot remove required attribute: " + name);
- }
- }
-
-
-
- Attributes attrs = new BasicAttributes(true);
- Attribute attr = new BasicAttribute(attributeName);
- attrs.put(attr);
-
- try
- {
- ldapContext.modifyAttributes(dn, DirContext.REMOVE_ATTRIBUTE, attrs);
- }
- catch (NamingException e)
- {
- throw new IdentityException("Cannot remove attribute", e);
- }
-
- }
- }
- finally
- {
- try
- {
- ldapContext.close();
- }
- catch (NamingException e)
- {
- throw new IdentityException("Failed to close LDAP connection", e);
- }
- }
- }
-
- //Internal
-
- public LDAPIdentityObjectImpl createIdentityObjectInstance(IdentityStoreInvocationContext ctx, IdentityObjectType type, Attributes attrs, String dn) throws IdentityException
- {
- LDAPIdentityObjectImpl ldapio = null;
- try
- {
- String idAttrName = getTypeConfiguration(ctx, type).getIdAttributeName();
-
- Attribute ida = attrs.get(idAttrName);
- if (ida == null)
- {
- throw new IdentityException("LDAP entry doesn't contain proper attribute:" + idAttrName);
- }
-
- //make DN as user ID
- ldapio = new LDAPIdentityObjectImpl(dn, ida.get().toString(), type);
-
- }
- catch (Exception e)
- {
- throw new IdentityException("Couldn't create LDAPIdentityObjectImpl object from ldap entry (SearchResult)", e);
- }
-
- return ldapio;
- }
-
- public List<SearchResult> searchIdentityObjects(IdentityStoreInvocationContext ctx,
- String[] entryCtxs,
- String filter,
- Object[] filterArgs,
- String[] returningAttributes,
- Control[] requestControls) throws NamingException, IdentityException
- {
-
- LdapContext ldapContext = getLDAPContext(ctx);
-
- if (ldapContext != null)
- {
- ldapContext.setRequestControls(requestControls);
- }
-
- NamingEnumeration results = null;
-
- try
- {
-
- SearchControls searchControls = new SearchControls();
- searchControls.setSearchScope(SearchControls.ONELEVEL_SCOPE);
- searchControls.setReturningObjFlag(true);
- searchControls.setTimeLimit(getConfiguration(ctx).getSearchTimeLimit());
-
-
- if (returningAttributes != null)
- {
- searchControls.setReturningAttributes(returningAttributes);
- }
-
-
- if (entryCtxs.length == 1)
- {
- if (filterArgs == null)
- {
- results = ldapContext.search(entryCtxs[0], filter, searchControls);
- }
- else
- {
- results = ldapContext.search(entryCtxs[0], filter, filterArgs, searchControls);
- }
- return Tools.toList(results);
-
-
- }
- else
- {
- List<SearchResult> merged = new LinkedList();
-
- for (String entryCtx : entryCtxs)
- {
- if (filterArgs == null)
- {
- results = ldapContext.search(entryCtx, filter, searchControls);
- }
- else
- {
- results = ldapContext.search(entryCtx, filter, filterArgs, searchControls);
- }
- merged.addAll(Tools.toList(results));
- results.close();
- }
-
- return merged;
- }
- }
- finally
- {
- if (results != null)
- {
- results.close();
- }
- ldapContext.close();
- }
- }
-
- // HELPER
-
- private LDAPIdentityObjectImpl getSafeLDAPIO(IdentityStoreInvocationContext ctx, IdentityObject io) throws IdentityException
- {
- if (io == null)
- {
- throw new IllegalArgumentException("IdentityObject is null");
- }
-
- if (io instanceof LDAPIdentityObjectImpl)
- {
- return (LDAPIdentityObjectImpl)io;
- }
- else
- {
- try
- {
- return (LDAPIdentityObjectImpl)findIdentityObject(ctx, io.getName(), io.getIdentityType());
- }
- catch (IdentityException e)
- {
- throw new IdentityException("Provided IdentityObject is not present in the store. Cannot operate on not stored objects.", e);
- }
- }
-
- }
-
- private void checkIOType(IdentityObjectType iot) throws IdentityException
- {
- if (iot == null)
- {
- throw new IllegalArgumentException("IdentityObjectType is null");
- }
-
- if (!getSupportedFeatures().isIdentityObjectTypeSupported(iot))
- {
- throw new IdentityException("IdentityType not supported by this IdentityStore implementation: " + iot);
- }
- }
-
-
- private LdapContext getLDAPContext(IdentityStoreInvocationContext ctx) throws IdentityException
- {
- try
- {
- return (LdapContext)ctx.getIdentityStoreSession().getSessionContext();
- }
- catch (Exception e)
- {
- throw new IdentityException("Could not obtain LDAP connection: ", e);
- }
- }
-
- private LDAPIdentityStoreConfiguration getConfiguration(IdentityStoreInvocationContext ctx) throws IdentityException
- {
- return configuration;
- }
-
- private LDAPIdentityObjectTypeConfiguration getTypeConfiguration(IdentityStoreInvocationContext ctx, IdentityObjectType type) throws IdentityException
- {
- return getConfiguration(ctx).getTypeConfiguration(type.getName());
- }
-
- public String toString()
- {
- return this.getClass().getName() + "[" + getId() +"]";
- }
-
- private void checkControls(IdentityObjectSearchControl[] controls) throws IdentityException
- {
- if (controls != null)
- {
- for (IdentityObjectSearchControl control : controls)
- {
- if (!supportedSearchControls.contains(control.getClass()))
- {
- throw new IdentityException("IdentityObjectSearchControl not supported by this IdentityStore: " + control.getClass());
- }
- }
- }
- }
-
- private void sortByName(List<IdentityObject> objects, final boolean ascending)
- {
- Collections.sort(objects, new Comparator<IdentityObject>(){
- public int compare(IdentityObject o1, IdentityObject o2)
- {
- if (ascending)
- {
- return o1.getName().compareTo(o2.getName());
- }
- else
- {
- return o2.getName().compareTo(o1.getName());
- }
- }
- });
- }
-
- //TODO: dummy and inefficient temporary workaround. Need to be implemented with ldap request control
- private List<IdentityObject> cutPageFromResults(List<IdentityObject> objects, PageSearchControl pageControl)
- {
- List<IdentityObject> results = new LinkedList<IdentityObject>();
- for (int i = pageControl.getOffset(); i < pageControl.getOffset() + pageControl.getLimit(); i++)
- {
- if (i < objects.size())
- {
- results.add(objects.get(i));
- }
- }
- return results;
- }
-
-}
Copied: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreImpl.java (from rev 211, trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/ldap/LDAPIdentityStoreImpl.java)
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreImpl.java (rev 0)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,2115 @@
+/*
+* 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.store.ldap;
+
+import org.jboss.identity.idm.spi.store.IdentityStore;
+import org.jboss.identity.idm.spi.store.FeaturesMetaData;
+import org.jboss.identity.idm.spi.store.IdentityStoreInvocationContext;
+import org.jboss.identity.idm.spi.store.IdentityStoreSession;
+import org.jboss.identity.idm.spi.searchcontrol.IdentityObjectSearchControl;
+import org.jboss.identity.idm.spi.model.IdentityObject;
+import org.jboss.identity.idm.spi.model.IdentityObjectType;
+import org.jboss.identity.idm.spi.model.IdentityObjectRelationshipType;
+import org.jboss.identity.idm.spi.model.IdentityObjectRelationship;
+import org.jboss.identity.idm.spi.model.IdentityObjectCredential;
+import org.jboss.identity.idm.spi.model.IdentityObjectAttribute;
+import org.jboss.identity.idm.spi.exception.OperationNotSupportedException;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityObjectTypeMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityObjectAttributeMetaData;
+import org.jboss.identity.idm.exception.IdentityException;
+import org.jboss.identity.idm.impl.store.FeaturesMetaDataImpl;
+import org.jboss.identity.idm.impl.model.ldap.LDAPIdentityObjectImpl;
+import org.jboss.identity.idm.impl.model.ldap.LDAPIdentityObjectRelationshipImpl;
+import org.jboss.identity.idm.impl.helper.Tools;
+import org.jboss.identity.idm.impl.NotYetImplementedException;
+import org.jboss.identity.idm.impl.api.SortByNameSearchControl;
+import org.jboss.identity.idm.impl.api.PageSearchControl;
+import org.jboss.identity.idm.impl.api.AttributeFilterSearchControl;
+import org.jboss.identity.idm.impl.api.NameFilterSearchControl;
+import org.jboss.identity.idm.impl.api.SimpleAttribute;
+
+import javax.naming.ldap.LdapContext;
+import javax.naming.ldap.LdapName;
+import javax.naming.ldap.Control;
+import javax.naming.ldap.SortControl;
+import javax.naming.ldap.InitialLdapContext;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.SearchResult;
+import javax.naming.directory.DirContext;
+import javax.naming.NamingException;
+import javax.naming.NamingEnumeration;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+import java.util.List;
+import java.util.LinkedList;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Hashtable;
+import java.util.Comparator;
+import java.util.regex.Pattern;
+import java.util.logging.Logger;
+import java.util.logging.Level;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class LDAPIdentityStoreImpl implements IdentityStore
+{
+
+ //TODO: external JNDI
+ //TODO: more options for connection configuration
+ //TODO: JNDI connection credentials encoding (pluggable?)
+
+ private static Logger log = Logger.getLogger(LDAPIdentityStoreImpl.class.getName());
+
+ private final String id;
+
+ private FeaturesMetaData supportedFeatures;
+
+ LDAPIdentityStoreConfiguration configuration;
+
+ IdentityStoreConfigurationMetaData configurationMD;
+
+ private static Set<Class> supportedSearchControls = new HashSet<Class>();
+
+ // <IdentityObjectType name, <Attribute name, MD>
+ private Map<String, Map<String, IdentityObjectAttributeMetaData>> attributesMetaData = new HashMap<String, Map<String, IdentityObjectAttributeMetaData>>();
+
+ static {
+ // List all supported controls classes
+
+ //TODO: attribute filter
+ supportedSearchControls.add(SortByNameSearchControl.class);
+ supportedSearchControls.add(PageSearchControl.class);
+ supportedSearchControls.add(NameFilterSearchControl.class);
+ //supportedSearchControls.add(AttributeFilterSearchControl.class);
+ }
+
+ public LDAPIdentityStoreImpl(String id)
+ {
+ this.id = id;
+ }
+
+ public void bootstrap(IdentityStoreConfigurationMetaData configurationMD) throws IdentityException
+ {
+ if (configurationMD == null)
+ {
+ throw new IllegalArgumentException("Configuration is null");
+ }
+
+ this.configurationMD = configurationMD;
+
+ configuration = new SimpleLDAPIdentityStoreConfiguration(configurationMD);
+
+ supportedFeatures = new FeaturesMetaDataImpl(configurationMD, supportedSearchControls, false);
+
+ // Attribute mappings - helper structures
+
+ for (IdentityObjectTypeMetaData identityObjectTypeMetaData : configurationMD.getSupportedIdentityTypes())
+ {
+ Map<String, IdentityObjectAttributeMetaData> metadataMap = new HashMap<String, IdentityObjectAttributeMetaData>();
+ for (IdentityObjectAttributeMetaData attributeMetaData : identityObjectTypeMetaData.getAttributes())
+ {
+ metadataMap.put(attributeMetaData.getName(), attributeMetaData);
+ }
+
+ attributesMetaData.put(identityObjectTypeMetaData.getName(), metadataMap);
+
+ }
+ }
+
+ public IdentityStoreSession createIdentityStoreSession()
+ {
+
+ return new LDAPIdentityStoreSessionImpl(
+ "com.sun.jndi.ldap.LdapCtxFactory",
+ configuration.getProviderURL(),
+ "simple",
+ configuration.getAdminDN(),
+ configuration.getAdminPassword());
+
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public FeaturesMetaData getSupportedFeatures()
+ {
+ return supportedFeatures;
+ }
+
+ public IdentityObject createIdentityObject(IdentityStoreInvocationContext invocationCtx, String name, IdentityObjectType identityObjectType) throws IdentityException
+ {
+ return createIdentityObject(invocationCtx, name, identityObjectType, null);
+ }
+
+ public IdentityObject createIdentityObject(IdentityStoreInvocationContext invocationCtx,
+ String name,
+ IdentityObjectType type,
+ Map<String, String[]> attributes) throws IdentityException
+ {
+ if (name == null)
+ {
+ throw new IdentityException("Name cannot be null");
+ }
+
+ checkIOType(type);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(toString() + ".createIdentityObject with name: " + name + " and type: " + type.getName());
+ }
+
+ LdapContext ldapContext = getLDAPContext(invocationCtx);
+
+ try
+ {
+ // If there are many contexts specified in the configuration the first one is used
+ LdapContext ctx = (LdapContext)ldapContext.lookup(getTypeConfiguration(invocationCtx, type).getCtxDNs()[0]);
+
+ //We store new entry using set of attributes. This should give more flexibility then
+ //extending identity object from ContextDir - configure what objectClass place there
+ Attributes attrs = new BasicAttributes(true);
+
+ //create attribute using provided configuration
+ Map<String, String[]> attributesToAdd = getTypeConfiguration(invocationCtx, type).getCreateEntryAttributeValues();
+
+ //merge
+ if (attributes != null)
+ {
+ for (Map.Entry<String, String[]> entry : attributes.entrySet())
+ {
+
+ if (!attributesToAdd.containsKey(entry.getKey()))
+ {
+ attributesToAdd.put(entry.getKey(), entry.getValue());
+ }
+ else
+ {
+ List<String> list1 = Arrays.asList(attributesToAdd.get(entry.getKey()));
+ List<String> list2 = Arrays.asList(entry.getValue());
+
+ list1.addAll(list2);
+
+ String[] vals = list1.toArray(new String[list1.size()]);
+
+ attributesToAdd.put(entry.getKey(), vals);
+
+ }
+ }
+ }
+
+ //attributes
+ for (Iterator it1 = attributesToAdd.keySet().iterator(); it1.hasNext();)
+ {
+ String attributeName = (String)it1.next();
+
+
+ Attribute attr = new BasicAttribute(attributeName);
+ String[] attributeValues = attributesToAdd.get(attributeName);
+
+ //values
+
+ for (String attrValue : attributeValues)
+ {
+ attr.add(attrValue);
+ }
+
+ attrs.put(attr);
+ }
+
+ // Make it RFC 2253 compliant
+ LdapName validLDAPName = new LdapName(getTypeConfiguration(invocationCtx, type).getIdAttributeName().concat("=").concat(name));
+
+ log.finer("creating ldap entry for: " + validLDAPName + "; " + attrs);
+ ctx.createSubcontext(validLDAPName, attrs);
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Failed to create identity object", e);
+ }
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
+
+ return findIdentityObject(invocationCtx, name, type);
+
+ }
+
+ public void removeIdentityObject(IdentityStoreInvocationContext invocationCtx, IdentityObject identity) throws IdentityException
+ {
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(toString() + ".removeIdentityObject: " + identity);
+ }
+
+ LDAPIdentityObjectImpl ldapIdentity = getSafeLDAPIO(invocationCtx, identity);
+
+ String dn = ldapIdentity.getDn();
+
+ if (dn == null)
+ {
+ throw new IdentityException("Cannot obtain DN of identity");
+ }
+
+ LdapContext ldapContext = getLDAPContext(invocationCtx);
+
+ try
+ {
+ log.finer("removing entry: " + dn);
+ ldapContext.unbind(dn);
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Failed to remove identity: ", e);
+ }
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
+
+ }
+
+ public int getIdentityObjectsCount(IdentityStoreInvocationContext ctx, IdentityObjectType identityType) throws IdentityException
+ {
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(toString() + ".getIdentityObjectsCount for type: " + identityType);
+ }
+
+ checkIOType(identityType);
+
+ try
+ {
+ String filter = getTypeConfiguration(ctx, identityType).getEntrySearchFilter();
+
+ if (filter != null && filter.length() > 0)
+ {
+ // chars are escaped in filterArgs so we must replace it manually
+ filter = filter.replaceAll("\\{0\\}", "*");
+ }
+ else
+ {
+ //search all entries
+ filter = "(".concat(getTypeConfiguration(ctx, identityType).getIdAttributeName()).concat("=").concat("*").concat(")");
+ }
+
+
+ String[] entryCtxs = getTypeConfiguration(ctx, identityType).getCtxDNs();
+
+ //log.debug("Search filter: " + filter);
+ List sr = searchIdentityObjects(ctx,
+ entryCtxs,
+ filter,
+ null,
+ new String[]{getTypeConfiguration(ctx, identityType).getIdAttributeName()},
+ null);
+
+ return sr.size();
+
+ }
+ catch (NoSuchElementException e)
+ {
+ //log.debug("No identity object found", e);
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("User search failed.", e);
+ }
+ return 0;
+ }
+
+ public IdentityObject findIdentityObject(IdentityStoreInvocationContext invocationCtx, String name, IdentityObjectType type) throws IdentityException
+ {
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(toString() + ".findIdentityObject with name: " + name + "; and type: " + type);
+ }
+
+ Context ctx = null;
+ checkIOType(type);
+ try
+ {
+ //log.debug("name = " + name);
+
+ if (name == null)
+ {
+ throw new IdentityException("Identity object name canot be null");
+ }
+
+ String filter = getTypeConfiguration(invocationCtx, type).getEntrySearchFilter();
+ List sr = null;
+
+
+ String[] entryCtxs = getTypeConfiguration(invocationCtx, type).getCtxDNs();
+
+
+ if (filter != null && filter.length() > 0)
+ {
+ Object[] filterArgs = {name};
+ sr = searchIdentityObjects(invocationCtx,
+ entryCtxs,
+ filter,
+ filterArgs,
+ new String[]{getTypeConfiguration(invocationCtx, type).getIdAttributeName()},
+ null);
+ }
+ else
+ {
+ //search all entries
+ filter = "(".concat(getTypeConfiguration(invocationCtx, type).getIdAttributeName()).concat("=").concat(name).concat(")");
+ sr = searchIdentityObjects(invocationCtx,
+ entryCtxs,
+ filter,
+ null,
+ new String[]{getTypeConfiguration(invocationCtx, type).getIdAttributeName()},
+ null);
+ }
+
+ //log.debug("Search filter: " + filter);
+
+ if (sr.size() > 1)
+ {
+ throw new IdentityException("Found more than one identity object with name: " + name +
+ "; Posible data inconsistency");
+ }
+ SearchResult res = (SearchResult)sr.iterator().next();
+ ctx = (Context)res.getObject();
+ String dn = ctx.getNameInNamespace();
+ IdentityObject io = createIdentityObjectInstance(invocationCtx, type, res.getAttributes(), dn);
+ ctx.close();
+ return io;
+
+ }
+ catch (NoSuchElementException e)
+ {
+ //log.debug("No identity object found with name: " + name, e);
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("IdentityObject search failed.", e);
+ }
+ finally
+ {
+ try
+ {
+ if (ctx != null)
+ {
+ ctx.close();
+ }
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
+
+ return null;
+ }
+
+ public IdentityObject findIdentityObject(IdentityStoreInvocationContext ctx, String id) throws IdentityException
+ {
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(toString() + ".findIdentityObject with id: " + id);
+ }
+
+ LdapContext ldapContext = getLDAPContext(ctx);
+
+ try
+ {
+ if (id == null)
+ {
+ throw new IdentityException("identity id cannot be null");
+ }
+
+ String dn = id;
+
+ IdentityObjectType type = null;
+
+ //Recognize the type by ctx DN
+
+ IdentityObjectType[] possibleTypes = getConfiguration(ctx).getConfiguredTypes();
+
+ for (IdentityObjectType possibleType : possibleTypes)
+ {
+ String[] typeCtxs = getTypeConfiguration(ctx, possibleType).getCtxDNs();
+
+ for (String typeCtx : typeCtxs)
+ {
+ if (dn.endsWith(typeCtx))
+ {
+ type = possibleType;
+ break;
+ }
+ }
+ if (type != null)
+ {
+ break;
+ }
+ }
+
+ if (type == null)
+ {
+ throw new IdentityException("Cannot recognize identity object type by its DN: " + dn);
+ }
+
+ // Grab entry
+
+ Attributes attrs = ldapContext.getAttributes(dn);
+
+ if (attrs == null)
+ {
+ throw new IdentityException("Can't find identity entry with DN: " + dn);
+ }
+
+ return createIdentityObjectInstance(ctx, type, attrs, dn);
+
+ }
+ catch (NoSuchElementException e)
+ {
+ //log.debug("No identity object found with dn: " + dn, e);
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Identity object search failed.", e);
+ }
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
+ return null;
+ }
+
+ public Collection<IdentityObject> findIdentityObject(IdentityStoreInvocationContext invocationCtx, IdentityObjectType type, IdentityObjectSearchControl[] controls) throws IdentityException
+ {
+
+ checkControls(controls);
+
+ //TODO: page control with LDAP request control
+
+ PageSearchControl pageSearchControl = null;
+ SortByNameSearchControl sortSearchControl = null;
+ AttributeFilterSearchControl attributeFilterSearchControl = null;
+ NameFilterSearchControl nameFilterSearchControl = null;
+
+ if (controls != null)
+ {
+ for (IdentityObjectSearchControl control : controls)
+ {
+ if (control instanceof PageSearchControl)
+ {
+ pageSearchControl = (PageSearchControl)control;
+ }
+ else if (control instanceof SortByNameSearchControl)
+ {
+ sortSearchControl = (SortByNameSearchControl)control;
+ }
+ else if (control instanceof AttributeFilterSearchControl)
+ {
+ attributeFilterSearchControl = (AttributeFilterSearchControl)control;
+ }
+ else if (control instanceof NameFilterSearchControl)
+ {
+ nameFilterSearchControl = (NameFilterSearchControl)control;
+ }
+
+ }
+ }
+
+ String nameFilter = "*";
+
+ //Filter by name
+ if (nameFilterSearchControl != null)
+ {
+ nameFilter = nameFilterSearchControl.getFilter();
+ }
+
+
+ LdapContext ctx = getLDAPContext(invocationCtx);
+
+
+ checkIOType(type);
+
+ LinkedList<IdentityObject> objects = new LinkedList<IdentityObject>();
+
+ LDAPIdentityObjectTypeConfiguration typeConfiguration = getTypeConfiguration(invocationCtx, type);
+
+ try
+ {
+ Control[] requestControls = null;
+
+ // Sort control
+ if (sortSearchControl != null)
+ {
+ //TODO: make criticallity optional
+ requestControls = new Control[]{
+ new SortControl(typeConfiguration.getIdAttributeName(), Control.NONCRITICAL)
+ };
+ }
+
+ StringBuilder af = new StringBuilder();
+
+ // Filter by attribute values
+ if (attributeFilterSearchControl != null)
+ {
+ af.append("(&");
+
+ for (Map.Entry<String, String[]> stringEntry : attributeFilterSearchControl.getValues().entrySet())
+ {
+ for (String value : stringEntry.getValue())
+ {
+ af.append("(")
+ .append(stringEntry.getKey())
+ .append("=")
+ .append(value)
+ .append(")");
+ }
+ }
+
+ af.append(")");
+ }
+
+ String filter = getTypeConfiguration(invocationCtx, type).getEntrySearchFilter();
+ List<SearchResult> sr = null;
+
+ String[] entryCtxs = getTypeConfiguration(invocationCtx, type).getCtxDNs();
+
+ if (filter != null && filter.length() > 0)
+ {
+
+ Object[] filterArgs = {nameFilter};
+ sr = searchIdentityObjects(invocationCtx,
+ entryCtxs,
+ "(&(" + filter + ")" + af.toString() + ")",
+ filterArgs,
+ new String[]{typeConfiguration.getIdAttributeName()},
+ requestControls);
+ }
+ else
+ {
+ filter = "(".concat(typeConfiguration.getIdAttributeName()).concat("=").concat(nameFilter).concat(")");
+ sr = searchIdentityObjects(invocationCtx,
+ entryCtxs,
+ "(&(" + filter + ")" + af.toString() + ")",
+ null,
+ new String[]{typeConfiguration.getIdAttributeName()},
+ requestControls);
+ }
+
+
+ for (SearchResult res : sr)
+ {
+ ctx = (LdapContext)res.getObject();
+ String dn = ctx.getNameInNamespace();
+ if (sortSearchControl != null)
+ {
+ // It seams that the sort order is not configurable and
+ // sort control returns entries in descending order by default...
+ if (!sortSearchControl.isAscending())
+ {
+ objects.addFirst(createIdentityObjectInstance(invocationCtx, type, res.getAttributes(), dn));
+ }
+ else
+ {
+ objects.addLast(createIdentityObjectInstance(invocationCtx, type, res.getAttributes(), dn));
+ }
+ }
+ else
+ {
+ objects.add(createIdentityObjectInstance(invocationCtx, type, res.getAttributes(), dn));
+ }
+ }
+
+ ctx.close();
+
+
+ }
+ catch (NoSuchElementException e)
+ {
+ //log.debug("No identity object found with name: " + name, e);
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("IdentityObject search failed.", e);
+ }
+ finally
+ {
+ try
+ {
+ if (ctx != null)
+ {
+ ctx.close();
+ }
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
+
+ if (pageSearchControl != null)
+ {
+ objects = (LinkedList)cutPageFromResults(objects, pageSearchControl);
+ }
+
+ return objects;
+ }
+
+ public Collection<IdentityObject> findIdentityObject(IdentityStoreInvocationContext invocationCtx, IdentityObjectType type) throws IdentityException
+ {
+ return findIdentityObject(invocationCtx, type, null);
+ }
+
+
+ public Collection<IdentityObject> findIdentityObject(IdentityStoreInvocationContext ctx, IdentityObject identity, IdentityObjectRelationshipType relationshipType, boolean parent, IdentityObjectSearchControl[] controls) throws IdentityException
+ {
+
+ //TODO: relationshipType is ignored - maybe check and allow only MEMBERSHIP?
+
+
+
+ checkControls(controls);
+
+ PageSearchControl pageSearchControl = null;
+ SortByNameSearchControl sortSearchControl = null;
+ AttributeFilterSearchControl attributeFilterSearchControl = null;
+ NameFilterSearchControl nameFilterSearchControl = null;
+
+ if (controls != null)
+ {
+ for (IdentityObjectSearchControl control : controls)
+ {
+ if (control instanceof PageSearchControl)
+ {
+ pageSearchControl = (PageSearchControl)control;
+ }
+ else if (control instanceof SortByNameSearchControl)
+ {
+ sortSearchControl = (SortByNameSearchControl)control;
+ }
+ else if (control instanceof AttributeFilterSearchControl)
+ {
+ attributeFilterSearchControl = (AttributeFilterSearchControl)control;
+ }
+ else if (control instanceof NameFilterSearchControl)
+ {
+ nameFilterSearchControl = (NameFilterSearchControl)control;
+ }
+
+ }
+ }
+
+ LDAPIdentityObjectImpl ldapFromIO = getSafeLDAPIO(ctx, identity);
+
+ LDAPIdentityObjectTypeConfiguration typeConfig = getTypeConfiguration(ctx, identity.getIdentityType());
+
+ LdapContext ldapContext = getLDAPContext(ctx);
+
+ List<IdentityObject> objects = new LinkedList<IdentityObject>();
+
+ try
+ {
+
+ // If parent simply look for all its members
+ if (parent)
+ {
+ Attributes attrs = ldapContext.getAttributes(ldapFromIO.getDn());
+ Attribute member = attrs.get(typeConfig.getMembershipAttributeName());
+
+ if (member != null)
+ {
+ NamingEnumeration memberValues = member.getAll();
+ while (memberValues.hasMoreElements())
+ {
+ String memberRef = memberValues.nextElement().toString();
+
+ if (typeConfig.isMembershipAttributeDN())
+ {
+ //TODO: use direct LDAP query instaed of other find method and add attributesFilter
+
+ if (nameFilterSearchControl != null)
+ {
+ String name = Tools.stripDnToName(memberRef);
+ String regex = Tools.wildcardToRegex(nameFilterSearchControl.getFilter());
+
+ if (Pattern.matches(regex, name))
+ {
+ objects.add(findIdentityObject(ctx, memberRef));
+ }
+ }
+ else
+ {
+ objects.add(findIdentityObject(ctx, memberRef));
+ }
+ }
+ else
+ {
+ //TODO: if relationships are not refered with DNs and only names its not possible to map
+ //TODO: them to proper IdentityType and keep name uniqnes per type. Workaround needed
+ throw new NotYetImplementedException("LDAP limitation. If relationship targets are not refered with FQDNs " +
+ "and only names, it's not possible to map them to proper IdentityType and keep name uniqnes per type. " +
+ "Workaround needed");
+ }
+ //break;
+ }
+ }
+ }
+
+ // if not parent then all parent entries need to be found
+ else
+ {
+ // Search in all other type contexts
+ for (IdentityObjectType parentType : configuration.getConfiguredTypes())
+ {
+ checkIOType(parentType);
+
+ LDAPIdentityObjectTypeConfiguration parentTypeConfiguration = getTypeConfiguration(ctx, parentType);
+
+ List<String> allowedTypes = Arrays.asList(parentTypeConfiguration.getAllowedMembershipTypes());
+
+ // Check if given identity type can be parent
+ if (!allowedTypes.contains(identity.getIdentityType().getName()))
+ {
+ continue;
+ }
+
+ String nameFilter = "*";
+
+ //Filter by name
+ if (nameFilterSearchControl != null)
+ {
+ nameFilter = nameFilterSearchControl.getFilter();
+ }
+
+ Control[] requestControls = null;
+
+ StringBuilder af = new StringBuilder();
+
+ // Filter by attribute values
+ if (attributeFilterSearchControl != null)
+ {
+ af.append("(&");
+
+ for (Map.Entry<String, String[]> stringEntry : attributeFilterSearchControl.getValues().entrySet())
+ {
+ for (String value : stringEntry.getValue())
+ {
+ af.append("(")
+ .append(stringEntry.getKey())
+ .append("=")
+ .append(value)
+ .append(")");
+ }
+ }
+
+ af.append(")");
+ }
+
+ // Add filter to search only parents of the given entry
+ af.append("(")
+ .append(parentTypeConfiguration.getMembershipAttributeName())
+ .append("=");
+ if (parentTypeConfiguration.isMembershipAttributeDN())
+ {
+ af.append(ldapFromIO.getDn());
+ }
+ else
+ {
+ //TODO: this doesn't make much sense unless parent/child are same identity types and resides in the same LDAP context
+ af.append(ldapFromIO.getName());
+ }
+ af.append(")");
+
+
+ String filter = parentTypeConfiguration.getEntrySearchFilter();
+ List<SearchResult> sr = null;
+
+ String[] entryCtxs = parentTypeConfiguration.getCtxDNs();
+
+ if (filter != null && filter.length() > 0)
+ {
+
+ Object[] filterArgs = {nameFilter};
+ sr = searchIdentityObjects(ctx,
+ entryCtxs,
+ "(&(" + filter + ")" + af.toString() + ")",
+ filterArgs,
+ new String[]{parentTypeConfiguration.getIdAttributeName()},
+ requestControls);
+ }
+ else
+ {
+ filter = "(".concat(parentTypeConfiguration.getIdAttributeName()).concat("=").concat(nameFilter).concat(")");
+ sr = searchIdentityObjects(ctx,
+ entryCtxs,
+ "(&(" + filter + ")" + af.toString() + ")",
+ null,
+ new String[]{parentTypeConfiguration.getIdAttributeName()},
+ requestControls);
+ }
+
+ for (SearchResult res : sr)
+ {
+ LdapContext ldapCtx = (LdapContext)res.getObject();
+ String dn = ldapCtx.getNameInNamespace();
+
+ objects.add(createIdentityObjectInstance(ctx, parentType, res.getAttributes(), dn));
+ }
+ }
+
+
+ }
+
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to resolve relationship", e);
+ }
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
+
+ if (pageSearchControl != null)
+ {
+ objects = cutPageFromResults(objects, pageSearchControl);
+ }
+
+ if (sortSearchControl != null)
+ {
+ sortByName(objects, sortSearchControl.isAscending());
+ }
+
+ return objects;
+ }
+
+ public Set<IdentityObjectRelationship> resolveRelationships(IdentityStoreInvocationContext ctx,
+ IdentityObject identity,
+ IdentityObjectRelationshipType type,
+ boolean parent,
+ boolean named,
+ String name) throws IdentityException
+ {
+ //TODO: relationshipType is ignored - maybe check and allow only MEMBERSHIP?
+
+
+
+ LDAPIdentityObjectImpl ldapIO = getSafeLDAPIO(ctx, identity);
+
+ LDAPIdentityObjectTypeConfiguration typeConfig = getTypeConfiguration(ctx, identity.getIdentityType());
+
+ LdapContext ldapContext = getLDAPContext(ctx);
+
+ Set<IdentityObjectRelationship> relationships = new HashSet<IdentityObjectRelationship>();
+
+ try
+ {
+
+ // If parent simply look for all its members
+ if (parent)
+ {
+ Attributes attrs = ldapContext.getAttributes(ldapIO.getDn());
+ Attribute member = attrs.get(typeConfig.getMembershipAttributeName());
+
+ if (member != null)
+ {
+ NamingEnumeration memberValues = member.getAll();
+ while (memberValues.hasMoreElements())
+ {
+ String memberRef = memberValues.nextElement().toString();
+
+ if (typeConfig.isMembershipAttributeDN())
+ {
+ //TODO: use direct LDAP query instaed of other find method and add attributesFilter
+
+
+ relationships.add(new LDAPIdentityObjectRelationshipImpl(null, ldapIO, findIdentityObject(ctx, memberRef)));
+
+ }
+ else
+ {
+ //TODO: if relationships are not refered with DNs and only names its not possible to map
+ //TODO: them to proper IdentityType and keep name uniqnes per type. Workaround needed
+ throw new NotYetImplementedException("LDAP limitation. If relationship targets are not refered with FQDNs " +
+ "and only names, it's not possible to map them to proper IdentityType and keep name uniqnes per type. " +
+ "Workaround needed");
+ }
+ //break;
+ }
+ }
+ }
+
+ // if not parent then all parent entries need to be found
+ else
+ {
+ // Search in all other type contexts
+ for (IdentityObjectType parentType : configuration.getConfiguredTypes())
+ {
+ checkIOType(parentType);
+
+ LDAPIdentityObjectTypeConfiguration parentTypeConfiguration = getTypeConfiguration(ctx, parentType);
+
+ List<String> allowedTypes = Arrays.asList(parentTypeConfiguration.getAllowedMembershipTypes());
+
+ // Check if given identity type can be parent
+ if (!allowedTypes.contains(identity.getIdentityType().getName()))
+ {
+ continue;
+ }
+
+ String nameFilter = "*";
+
+ //Filter by name
+ Control[] requestControls = null;
+
+ StringBuilder af = new StringBuilder();
+
+
+ // Add filter to search only parents of the given entry
+ af.append("(")
+ .append(parentTypeConfiguration.getMembershipAttributeName())
+ .append("=");
+ if (parentTypeConfiguration.isMembershipAttributeDN())
+ {
+ af.append(ldapIO.getDn());
+ }
+ else
+ {
+ //TODO: this doesn't make much sense unless parent/child are same identity types and resides in the same LDAP context
+ af.append(ldapIO.getName());
+ }
+ af.append(")");
+
+
+ String filter = parentTypeConfiguration.getEntrySearchFilter();
+ List<SearchResult> sr = null;
+
+ String[] entryCtxs = parentTypeConfiguration.getCtxDNs();
+
+ if (filter != null && filter.length() > 0)
+ {
+
+ Object[] filterArgs = {nameFilter};
+ sr = searchIdentityObjects(ctx,
+ entryCtxs,
+ "(&(" + filter + ")" + af.toString() + ")",
+ filterArgs,
+ new String[]{parentTypeConfiguration.getIdAttributeName()},
+ requestControls);
+ }
+ else
+ {
+ filter = "(".concat(parentTypeConfiguration.getIdAttributeName()).concat("=").concat(nameFilter).concat(")");
+ sr = searchIdentityObjects(ctx,
+ entryCtxs,
+ "(&(" + filter + ")" + af.toString() + ")",
+ null,
+ new String[]{parentTypeConfiguration.getIdAttributeName()},
+ requestControls);
+ }
+
+ for (SearchResult res : sr)
+ {
+ LdapContext ldapCtx = (LdapContext)res.getObject();
+ String dn = ldapCtx.getNameInNamespace();
+
+ relationships.add(new LDAPIdentityObjectRelationshipImpl(null, createIdentityObjectInstance(ctx, parentType, res.getAttributes(), dn), ldapIO));
+ }
+ }
+
+
+ }
+
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to resolve relationship", e);
+ }
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
+
+
+ return relationships;
+ }
+
+ public Collection<IdentityObject> findIdentityObject(IdentityStoreInvocationContext ctx,
+ IdentityObject identity,
+ IdentityObjectRelationshipType relationshipType,
+ boolean parent) throws IdentityException
+ {
+ return findIdentityObject(ctx, identity, relationshipType, parent, null);
+ }
+
+ public IdentityObjectRelationship createRelationship(IdentityStoreInvocationContext ctx, IdentityObject fromIdentity, IdentityObject toIdentity,
+ IdentityObjectRelationshipType relationshipType,
+ String name, boolean createNames) throws IdentityException
+ {
+
+ //TODO: relationshipType is ignored for now
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(toString() + ".createRelationship with "
+ + "fromIdentity: " + fromIdentity
+ + "; toIdentity: " + toIdentity
+ + "; relationshipType: " + relationshipType
+ );
+ }
+
+ LDAPIdentityObjectRelationshipImpl relationship = null;
+
+ LDAPIdentityObjectImpl ldapFromIO = getSafeLDAPIO(ctx, fromIdentity);
+
+ LDAPIdentityObjectImpl ldapToIO = getSafeLDAPIO(ctx, toIdentity);
+
+ LDAPIdentityObjectTypeConfiguration fromTypeConfig = getTypeConfiguration(ctx, fromIdentity.getIdentityType());
+
+ LdapContext ldapContext = getLDAPContext(ctx);
+
+ // Check posibilities
+ if (!getSupportedFeatures().isRelationshipTypeSupported(fromIdentity.getIdentityType(), toIdentity.getIdentityType(), relationshipType))
+ {
+ throw new IdentityException("Relationship not supported");
+ }
+
+ try
+ {
+ // Construct new member attribute values
+ Attributes attrs = new BasicAttributes(true);
+
+ Attribute member = new BasicAttribute(fromTypeConfig.getMembershipAttributeName());
+
+ if (fromTypeConfig.isMembershipAttributeDN())
+ {
+ member.add(ldapToIO.getDn());
+ }
+ else
+ {
+ member.add(toIdentity.getName());
+ }
+
+ attrs.put(member);
+
+ ldapContext.modifyAttributes(ldapFromIO.getDn(), DirContext.ADD_ATTRIBUTE, attrs);
+
+ relationship = new LDAPIdentityObjectRelationshipImpl(name, ldapFromIO, ldapToIO);
+
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to create relationship", e);
+ }
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
+
+
+ return relationship;
+ }
+
+ public void removeRelationship(IdentityStoreInvocationContext ctx, IdentityObject fromIdentity, IdentityObject toIdentity, IdentityObjectRelationshipType relationshipType, String name) throws IdentityException
+ {
+ // relationshipType is ignored for now
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(toString() + ".removeRelationship with "
+ + "fromIdentity: " + fromIdentity
+ + "; toIdentity: " + toIdentity
+ + "; relationshipType: " + relationshipType
+ );
+ }
+
+ LDAPIdentityObjectImpl ldapFromIO = getSafeLDAPIO(ctx, fromIdentity);
+ LDAPIdentityObjectImpl ldapToIO = getSafeLDAPIO(ctx, toIdentity);
+
+ LDAPIdentityObjectTypeConfiguration fromTypeConfig = getTypeConfiguration(ctx, fromIdentity.getIdentityType());
+
+ // If relationship is not allowed simply return
+ //TODO: use features description instead
+ if (!Arrays.asList(fromTypeConfig.getAllowedMembershipTypes()).contains(ldapToIO.getIdentityType().getName()))
+ {
+ return;
+ }
+
+ LdapContext ldapContext = getLDAPContext(ctx);
+
+ // Check posibilities
+
+ //TODO: null RelationshipType passed from removeRelationships
+ if (relationshipType != null &&
+ !getSupportedFeatures().isRelationshipTypeSupported(fromIdentity.getIdentityType(), toIdentity.getIdentityType(), relationshipType))
+ {
+ throw new IdentityException("Relationship not supported");
+ }
+
+ try
+ {
+ //construct new member attribute values
+ Attributes attrs = new BasicAttributes(true);
+
+ Attribute member = new BasicAttribute(fromTypeConfig.getMembershipAttributeName());
+
+ if (fromTypeConfig.isMembershipAttributeDN())
+ {
+ member.add(ldapToIO.getDn());
+ }
+ else
+ {
+ member.add(toIdentity.getName());
+ }
+
+ attrs.put(member);
+
+ ldapContext.modifyAttributes(ldapFromIO.getDn(), DirContext.REMOVE_ATTRIBUTE, attrs);
+
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to remove relationship", e);
+ }
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
+ }
+
+ public void removeRelationships(IdentityStoreInvocationContext ctx, IdentityObject identity1, IdentityObject identity2, boolean named) throws IdentityException
+ {
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(toString() + ".removeRelationships with "
+ + "identity1: " + identity1
+ + "; identity2: " + identity2
+ );
+ }
+
+ // as relationship type is ignored in this impl for now...
+ removeRelationship(ctx, identity1, identity2, null, null);
+ removeRelationship(ctx, identity2, identity1, null, null);
+
+ }
+
+ public Set<IdentityObjectRelationship> resolveRelationships(IdentityStoreInvocationContext ctx, IdentityObject fromIdentity, IdentityObject toIdentity, IdentityObjectRelationshipType relationshipType) throws IdentityException
+ {
+ // relationshipType is ignored for now
+
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(toString() + ".resolveRelationships with "
+ + "fromIdentity: " + fromIdentity
+ + "; toIdentity: " + toIdentity
+ );
+ }
+
+ Set<IdentityObjectRelationship> relationships = new HashSet<IdentityObjectRelationship>();
+
+ LDAPIdentityObjectImpl ldapFromIO = getSafeLDAPIO(ctx, fromIdentity);
+ LDAPIdentityObjectImpl ldapToIO = getSafeLDAPIO(ctx, toIdentity);
+
+ LDAPIdentityObjectTypeConfiguration fromTypeConfig = getTypeConfiguration(ctx, fromIdentity.getIdentityType());
+
+ // If relationship is not allowed return empty set
+ //TODO: use features description instead
+
+ if (!Arrays.asList(fromTypeConfig.getAllowedMembershipTypes()).contains(ldapToIO.getIdentityType().getName()))
+ {
+ return relationships;
+ }
+
+ LdapContext ldapContext = getLDAPContext(ctx);
+
+ try
+ {
+ Attributes attrs = ldapContext.getAttributes(ldapFromIO.getDn());
+ Attribute member = attrs.get(fromTypeConfig.getMembershipAttributeName());
+
+ if (member != null)
+ {
+ NamingEnumeration memberValues = member.getAll();
+ while (memberValues.hasMoreElements())
+ {
+ String memberRef = memberValues.nextElement().toString();
+
+ if ((fromTypeConfig.isMembershipAttributeDN() && memberRef.equals(ldapToIO.getDn())) ||
+ (!fromTypeConfig.isMembershipAttributeDN() && memberRef.equals(ldapToIO.getName())))
+ {
+ //TODO: impl lacks support for rel type
+ relationships.add(new LDAPIdentityObjectRelationshipImpl(null, ldapFromIO, ldapToIO));
+ }
+ break;
+ }
+ }
+
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to resolve relationship", e);
+ }
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
+ return relationships;
+ }
+
+ public String createRelationshipName(IdentityStoreInvocationContext ctx, String name) throws IdentityException, OperationNotSupportedException
+ {
+ throw new OperationNotSupportedException("Named relationships are not supported by this implementation of LDAP IdentityStore");
+ }
+
+ public String removeRelationshipName(IdentityStoreInvocationContext ctx, String name) throws IdentityException, OperationNotSupportedException
+ {
+ throw new OperationNotSupportedException("Named relationships are not supported by this implementation of LDAP IdentityStore");
+ }
+
+ public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx, IdentityObjectSearchControl[] controls) throws IdentityException, OperationNotSupportedException
+ {
+ throw new OperationNotSupportedException("Named relationships are not supported by this implementation of LDAP IdentityStore");
+ }
+
+ public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx) throws IdentityException, OperationNotSupportedException
+ {
+ throw new OperationNotSupportedException("Named relationships are not supported by this implementation of LDAP IdentityStore");
+ }
+
+ public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx, IdentityObject identity, IdentityObjectSearchControl[] controls) throws IdentityException, OperationNotSupportedException
+ {
+ throw new OperationNotSupportedException("Named relationships are not supported by this implementation of LDAP IdentityStore");
+
+ }
+
+ public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx, IdentityObject identity) throws IdentityException, OperationNotSupportedException
+ {
+ throw new OperationNotSupportedException("Named relationships are not supported by this implementation of LDAP IdentityStore");
+ }
+
+ public boolean validateCredential(IdentityStoreInvocationContext ctx, IdentityObject identityObject, IdentityObjectCredential credential) throws IdentityException
+ {
+ if (credential == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ LDAPIdentityObjectImpl ldapIO = getSafeLDAPIO(ctx, identityObject);
+
+ if (supportedFeatures.isCredentialSupported(ldapIO.getIdentityType(),credential.getType()))
+ {
+
+ String passwordString = null;
+
+ // Handle generic impl
+
+ if (credential.getValue() != null)
+ {
+ //TODO: support for empty password should be configurable
+ passwordString = credential.getValue().toString();
+ }
+ else
+ {
+ throw new IdentityException("Null password value");
+ }
+
+ LdapContext ldapContext = getLDAPContext(ctx);
+
+ try
+ {
+
+ Hashtable env = ldapContext.getEnvironment();
+
+ env.put(Context.SECURITY_PRINCIPAL, ldapIO.getDn());
+ env.put(Context.SECURITY_CREDENTIALS, passwordString);
+
+ InitialContext initialCtx = new InitialLdapContext(env, null);
+
+ if (initialCtx != null)
+ {
+ initialCtx.close();
+ return true;
+ }
+
+ }
+ catch (NamingException e)
+ {
+ //
+ }
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
+ return false;
+
+
+ }
+ else
+ {
+ throw new IdentityException("CredentialType not supported for a given IdentityObjectType");
+ }
+ }
+
+ public void updateCredential(IdentityStoreInvocationContext ctx, IdentityObject identityObject, IdentityObjectCredential credential) throws IdentityException
+ {
+ if (credential == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ LDAPIdentityObjectImpl ldapIO = getSafeLDAPIO(ctx, identityObject);
+
+ if (supportedFeatures.isCredentialSupported(ldapIO.getIdentityType(),credential.getType()))
+ {
+
+ String passwordString = null;
+
+ // Handle generic impl
+
+ if (credential.getValue() != null)
+ {
+ //TODO: support for empty password should be configurable
+ passwordString = credential.getValue().toString();
+ }
+ else
+ {
+ throw new IdentityException("Null password value");
+ }
+
+ String attributeName = getTypeConfiguration(ctx, ldapIO.getIdentityType()).getPasswordAttributeName();
+
+ if (attributeName == null)
+ {
+ throw new IdentityException("IdentityType doesn't have passwordAttributeName option set: "
+ + ldapIO.getIdentityType().getName());
+ }
+
+ LdapContext ldapContext = getLDAPContext(ctx);
+
+ try
+ {
+ //TODO: maybe perform a schema check if this attribute is allowed for such entry
+
+ Attributes attrs = new BasicAttributes(true);
+ Attribute attr = new BasicAttribute(attributeName);
+ attr.add(passwordString);
+ attrs.put(attr);
+
+ ldapContext.modifyAttributes(ldapIO.getDn(), DirContext.REPLACE_ATTRIBUTE,attrs);
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Cannot set identity password value.", e);
+ }
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
+
+ }
+ else
+ {
+ throw new IdentityException("CredentialType not supported for a given IdentityObjectType");
+ }
+ }
+
+
+ // Attributes
+
+ public Set<String> getSupportedAttributeNames(IdentityStoreInvocationContext invocationContext, IdentityObjectType identityType) throws IdentityException
+ {
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(toString() + ".getSupportedAttributeNames with "
+ + "identityType: " + identityType
+ );
+ }
+
+ checkIOType(identityType);
+
+ return getTypeConfiguration(invocationContext, identityType).getMappedAttributesNames();
+ }
+
+ public Map<String, IdentityObjectAttributeMetaData> getAttributesMetaData(IdentityStoreInvocationContext invocationContext, IdentityObjectType identityObjectType)
+ {
+ return attributesMetaData.get(identityObjectType.getName());
+ }
+
+
+ public IdentityObjectAttribute getAttribute(IdentityStoreInvocationContext invocationContext, IdentityObject identity, String name) throws IdentityException
+ {
+ //TODO: dummy temporary implementation
+ return getAttributes(invocationContext, identity).get(name);
+ }
+
+ public Map<String, IdentityObjectAttribute> getAttributes(IdentityStoreInvocationContext ctx, IdentityObject identity) throws IdentityException
+ {
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(toString() + ".getAttributes with "
+ + "identity: " + identity
+ );
+ }
+
+ Map<String, IdentityObjectAttribute> attrsMap = new HashMap<String, IdentityObjectAttribute>();
+
+ LDAPIdentityObjectImpl ldapIdentity = getSafeLDAPIO(ctx, identity);
+
+
+ LdapContext ldapContext = getLDAPContext(ctx);
+
+ try
+ {
+ Set<String> mappedNames = getTypeConfiguration(ctx, identity.getIdentityType()).getMappedAttributesNames();
+
+ // as this is valid LDAPIdentityObjectImpl DN is obtained from the Id
+
+ String dn = ldapIdentity.getDn();
+
+ Attributes attrs = ldapContext.getAttributes(dn);
+
+ for (Iterator iterator = mappedNames.iterator(); iterator.hasNext();)
+ {
+ String name = (String)iterator.next();
+ String attrName = getTypeConfiguration(ctx, identity.getIdentityType()).getAttributeMapping(name);
+ Attribute attr = attrs.get(attrName);
+
+ if (attr != null)
+ {
+
+ IdentityObjectAttribute identityObjectAttribute = new SimpleAttribute(name);
+
+ NamingEnumeration values = attr.getAll();
+
+ while (values.hasMoreElements())
+ {
+ identityObjectAttribute.addValue(values.nextElement().toString());
+ }
+
+ attrsMap.put(name, identityObjectAttribute);
+ }
+ else
+ {
+ log.fine("No such attribute ('" + attrName + "') in entry: " + dn);
+ }
+ }
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Cannot get attributes value.", e);
+ }
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
+
+ return attrsMap;
+
+ }
+
+ public void updateAttributes(IdentityStoreInvocationContext ctx, IdentityObject identity, IdentityObjectAttribute[] attributes) throws IdentityException
+ {
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(toString() + ".updateAttributes with "
+ + "identity: " + identity
+ + "attributes: " + attributes
+ );
+ }
+
+ if (attributes == null)
+ {
+ throw new IllegalArgumentException("attributes is null");
+ }
+
+ LDAPIdentityObjectImpl ldapIdentity = getSafeLDAPIO(ctx, identity);
+
+
+ // as this is valid LDAPIdentityObjectImpl DN is obtained from the Id
+
+ String dn = ldapIdentity.getDn();
+
+ LdapContext ldapContext = getLDAPContext(ctx);
+
+ try
+ {
+
+ for (IdentityObjectAttribute attribute : attributes)
+ {
+ String name = attribute.getName();
+
+ String attributeName = getTypeConfiguration(ctx, identity.getIdentityType()).getAttributeMapping(name);
+
+ if (attributeName == null)
+ {
+ log.fine("Proper LDAP attribute mapping not found for such property name: " + name);
+ continue;
+ }
+
+ //TODO: maybe perform a schema check if this attribute is not required
+
+ Attributes attrs = new BasicAttributes(true);
+ Attribute attr = new BasicAttribute(attributeName);
+
+ Collection values = attribute.getValues();
+
+ Map<String, IdentityObjectAttributeMetaData> mdMap = attributesMetaData.get(identity.getIdentityType().getName());
+
+ if (mdMap != null)
+ {
+ IdentityObjectAttributeMetaData amd = mdMap.get(attributeName);
+ if (amd != null && !amd.isMultivalued() && values.size() > 1)
+ {
+ throw new IdentityException("Cannot assigned multiply values to single valued attribute: " + attributeName);
+ }
+ if (amd != null && amd.isReadonly())
+ {
+ throw new IdentityException("Cannot update readonly attribute: " + attributeName);
+ }
+ }
+
+ if (values != null)
+ {
+ for (Object value : values)
+ {
+ attr.add(value);
+ }
+
+ attrs.put(attr);
+
+ try
+ {
+ ldapContext.modifyAttributes(dn, DirContext.REPLACE_ATTRIBUTE, attrs);
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Cannot add attribute", e);
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
+ }
+
+ public void addAttributes(IdentityStoreInvocationContext ctx, IdentityObject identity, IdentityObjectAttribute[] attributes) throws IdentityException
+ {
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(toString() + ".addAttributes with "
+ + "identity: " + identity
+ + "attributes: " + attributes
+ );
+ }
+
+
+ if (attributes == null)
+ {
+ throw new IllegalArgumentException("attributes is null");
+ }
+
+ LDAPIdentityObjectImpl ldapIdentity = getSafeLDAPIO(ctx, identity);
+
+
+ // as this is valid LDAPIdentityObjectImpl DN is obtained from the Id
+
+ String dn = ldapIdentity.getDn();
+
+ LdapContext ldapContext = getLDAPContext(ctx);
+
+ try
+ {
+ for (IdentityObjectAttribute attribute : attributes)
+ {
+ String name = attribute.getName();
+
+ String attributeName = getTypeConfiguration(ctx, identity.getIdentityType()).getAttributeMapping(name);
+
+ if (attributeName == null)
+ {
+ log.fine("Proper LDAP attribute mapping not found for such property name: " + name);
+ continue;
+ }
+
+ //TODO: maybe perform a schema check if this attribute is not required
+
+ Attributes attrs = new BasicAttributes(true);
+ Attribute attr = new BasicAttribute(attributeName);
+
+ Collection values = attribute.getValues();
+
+ Map<String, IdentityObjectAttributeMetaData> mdMap = attributesMetaData.get(identity.getIdentityType().getName());
+
+ if (mdMap != null)
+ {
+ IdentityObjectAttributeMetaData amd = mdMap.get(attributeName);
+ if (amd != null && !amd.isMultivalued() && values.size() > 1)
+ {
+ throw new IdentityException("Cannot assigned multiply values to single valued attribute: " + attributeName);
+ }
+ if (amd != null && amd.isReadonly())
+ {
+ throw new IdentityException("Cannot update readonly attribute: " + attributeName);
+ }
+ }
+
+
+ if (values != null)
+ {
+ for (Object value : values)
+ {
+ attr.add(value);
+ }
+
+ attrs.put(attr);
+
+ try
+ {
+ ldapContext.modifyAttributes(dn, DirContext.ADD_ATTRIBUTE, attrs);
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Cannot add attribute", e);
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
+ }
+
+ public void removeAttributes(IdentityStoreInvocationContext ctx, IdentityObject identity, String[] attributeNames) throws IdentityException
+ {
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(toString() + ".removeAttributes with "
+ + "identity: " + identity
+ + "attributeNames: " + attributeNames
+ );
+ }
+
+ if (attributeNames == null)
+ {
+ throw new IllegalArgumentException("attributes is null");
+ }
+
+ LDAPIdentityObjectImpl ldapIdentity = getSafeLDAPIO(ctx, identity);
+
+ // as this is valid LDAPIdentityObjectImpl DN is obtained from the Id
+
+ String dn = ldapIdentity.getDn();
+
+ LdapContext ldapContext = getLDAPContext(ctx);
+
+ try
+ {
+ for (String name : attributeNames)
+ {
+ String attributeName = getTypeConfiguration(ctx, identity.getIdentityType()).getAttributeMapping(name);
+
+ if (attributeName == null)
+ {
+ log.fine("Proper LDAP attribute mapping not found for such property name: " + name);
+ continue;
+ }
+
+ Map<String, IdentityObjectAttributeMetaData> mdMap = attributesMetaData.get(identity.getIdentityType().getName());
+
+ if (mdMap != null)
+ {
+ //TODO: maybe perform a schema check if this attribute is not required on the LDAP level
+ IdentityObjectAttributeMetaData amd = mdMap.get(name);
+ if (amd != null && amd.isRequired())
+ {
+ throw new IdentityException("Cannot remove required attribute: " + name);
+ }
+ }
+
+
+
+ Attributes attrs = new BasicAttributes(true);
+ Attribute attr = new BasicAttribute(attributeName);
+ attrs.put(attr);
+
+ try
+ {
+ ldapContext.modifyAttributes(dn, DirContext.REMOVE_ATTRIBUTE, attrs);
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Cannot remove attribute", e);
+ }
+
+ }
+ }
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
+ }
+
+ //Internal
+
+ public LDAPIdentityObjectImpl createIdentityObjectInstance(IdentityStoreInvocationContext ctx, IdentityObjectType type, Attributes attrs, String dn) throws IdentityException
+ {
+ LDAPIdentityObjectImpl ldapio = null;
+ try
+ {
+ String idAttrName = getTypeConfiguration(ctx, type).getIdAttributeName();
+
+ Attribute ida = attrs.get(idAttrName);
+ if (ida == null)
+ {
+ throw new IdentityException("LDAP entry doesn't contain proper attribute:" + idAttrName);
+ }
+
+ //make DN as user ID
+ ldapio = new LDAPIdentityObjectImpl(dn, ida.get().toString(), type);
+
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Couldn't create LDAPIdentityObjectImpl object from ldap entry (SearchResult)", e);
+ }
+
+ return ldapio;
+ }
+
+ public List<SearchResult> searchIdentityObjects(IdentityStoreInvocationContext ctx,
+ String[] entryCtxs,
+ String filter,
+ Object[] filterArgs,
+ String[] returningAttributes,
+ Control[] requestControls) throws NamingException, IdentityException
+ {
+
+ LdapContext ldapContext = getLDAPContext(ctx);
+
+ if (ldapContext != null)
+ {
+ ldapContext.setRequestControls(requestControls);
+ }
+
+ NamingEnumeration results = null;
+
+ try
+ {
+
+ SearchControls searchControls = new SearchControls();
+ searchControls.setSearchScope(SearchControls.ONELEVEL_SCOPE);
+ searchControls.setReturningObjFlag(true);
+ searchControls.setTimeLimit(getConfiguration(ctx).getSearchTimeLimit());
+
+
+ if (returningAttributes != null)
+ {
+ searchControls.setReturningAttributes(returningAttributes);
+ }
+
+
+ if (entryCtxs.length == 1)
+ {
+ if (filterArgs == null)
+ {
+ results = ldapContext.search(entryCtxs[0], filter, searchControls);
+ }
+ else
+ {
+ results = ldapContext.search(entryCtxs[0], filter, filterArgs, searchControls);
+ }
+ return Tools.toList(results);
+
+
+ }
+ else
+ {
+ List<SearchResult> merged = new LinkedList();
+
+ for (String entryCtx : entryCtxs)
+ {
+ if (filterArgs == null)
+ {
+ results = ldapContext.search(entryCtx, filter, searchControls);
+ }
+ else
+ {
+ results = ldapContext.search(entryCtx, filter, filterArgs, searchControls);
+ }
+ merged.addAll(Tools.toList(results));
+ results.close();
+ }
+
+ return merged;
+ }
+ }
+ finally
+ {
+ if (results != null)
+ {
+ results.close();
+ }
+ ldapContext.close();
+ }
+ }
+
+ // HELPER
+
+ private LDAPIdentityObjectImpl getSafeLDAPIO(IdentityStoreInvocationContext ctx, IdentityObject io) throws IdentityException
+ {
+ if (io == null)
+ {
+ throw new IllegalArgumentException("IdentityObject is null");
+ }
+
+ if (io instanceof LDAPIdentityObjectImpl)
+ {
+ return (LDAPIdentityObjectImpl)io;
+ }
+ else
+ {
+ try
+ {
+ return (LDAPIdentityObjectImpl)findIdentityObject(ctx, io.getName(), io.getIdentityType());
+ }
+ catch (IdentityException e)
+ {
+ throw new IdentityException("Provided IdentityObject is not present in the store. Cannot operate on not stored objects.", e);
+ }
+ }
+
+ }
+
+ private void checkIOType(IdentityObjectType iot) throws IdentityException
+ {
+ if (iot == null)
+ {
+ throw new IllegalArgumentException("IdentityObjectType is null");
+ }
+
+ if (!getSupportedFeatures().isIdentityObjectTypeSupported(iot))
+ {
+ throw new IdentityException("IdentityType not supported by this IdentityStore implementation: " + iot);
+ }
+ }
+
+
+ private LdapContext getLDAPContext(IdentityStoreInvocationContext ctx) throws IdentityException
+ {
+ try
+ {
+ return (LdapContext)ctx.getIdentityStoreSession().getSessionContext();
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Could not obtain LDAP connection: ", e);
+ }
+ }
+
+ private LDAPIdentityStoreConfiguration getConfiguration(IdentityStoreInvocationContext ctx) throws IdentityException
+ {
+ return configuration;
+ }
+
+ private LDAPIdentityObjectTypeConfiguration getTypeConfiguration(IdentityStoreInvocationContext ctx, IdentityObjectType type) throws IdentityException
+ {
+ return getConfiguration(ctx).getTypeConfiguration(type.getName());
+ }
+
+ public String toString()
+ {
+ return this.getClass().getName() + "[" + getId() +"]";
+ }
+
+ private void checkControls(IdentityObjectSearchControl[] controls) throws IdentityException
+ {
+ if (controls != null)
+ {
+ for (IdentityObjectSearchControl control : controls)
+ {
+ if (!supportedSearchControls.contains(control.getClass()))
+ {
+ throw new IdentityException("IdentityObjectSearchControl not supported by this IdentityStore: " + control.getClass());
+ }
+ }
+ }
+ }
+
+ private void sortByName(List<IdentityObject> objects, final boolean ascending)
+ {
+ Collections.sort(objects, new Comparator<IdentityObject>(){
+ public int compare(IdentityObject o1, IdentityObject o2)
+ {
+ if (ascending)
+ {
+ return o1.getName().compareTo(o2.getName());
+ }
+ else
+ {
+ return o2.getName().compareTo(o1.getName());
+ }
+ }
+ });
+ }
+
+ //TODO: dummy and inefficient temporary workaround. Need to be implemented with ldap request control
+ private List<IdentityObject> cutPageFromResults(List<IdentityObject> objects, PageSearchControl pageControl)
+ {
+ List<IdentityObject> results = new LinkedList<IdentityObject>();
+ for (int i = pageControl.getOffset(); i < pageControl.getOffset() + pageControl.getLimit(); i++)
+ {
+ if (i < objects.size())
+ {
+ results.add(objects.get(i));
+ }
+ }
+ return results;
+ }
+
+}
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreSessionImpl.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/ldap/LDAPIdentityStoreSessionImpl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreSessionImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,132 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.store.ldap;
-
-import org.jboss.identity.spi.store.IdentityStoreSession;
-import org.jboss.identity.exception.IdentityException;
-
-import javax.naming.ldap.LdapContext;
-import javax.naming.ldap.InitialLdapContext;
-import javax.naming.Context;
-import java.util.Hashtable;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class LDAPIdentityStoreSessionImpl implements IdentityStoreSession
-{
-
- private final String INITIAL_CONTEXT_FACTORY;
-
- private final String PROVIDER_URL;
-
- private final String SECURITY_AUTHENTICATION;
-
- private final String SECURITY_PRINCIPAL;
-
- private final String SECURITY_CREDENTIALS;
-
-
- public LDAPIdentityStoreSessionImpl(String INITIAL_CONTEXT_FACTORY,
- String PROVIDER_URL,
- String SECURITY_AUTHENTICATION,
- String SECURITY_PRINCIPAL,
- String SECURITY_CREDENTIALS)
- {
- this.INITIAL_CONTEXT_FACTORY = INITIAL_CONTEXT_FACTORY;
- this.PROVIDER_URL = PROVIDER_URL;
- this.SECURITY_AUTHENTICATION = SECURITY_AUTHENTICATION;
- this.SECURITY_PRINCIPAL = SECURITY_PRINCIPAL;
- this.SECURITY_CREDENTIALS = SECURITY_CREDENTIALS;
- }
-
- public LdapContext getLdapContext() throws Exception
- {
- Hashtable<String,String> env = new Hashtable<String,String>();
- env.put(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY);
- env.put(Context.PROVIDER_URL, PROVIDER_URL);
- env.put(Context.SECURITY_AUTHENTICATION, SECURITY_AUTHENTICATION);
- env.put(Context.SECURITY_PRINCIPAL, SECURITY_PRINCIPAL);
- env.put(Context.SECURITY_CREDENTIALS, SECURITY_CREDENTIALS);
-
- return new InitialLdapContext(env, null);
- }
-
- public Object getSessionContext() throws IdentityException
- {
- try
- {
- return getLdapContext();
- }
- catch (Exception e)
- {
- throw new IdentityException("Could not create LdapContext", e);
- }
- }
-
- public void close() throws IdentityException
- {
-
- }
-
- public void save() throws IdentityException
- {
-
- }
-
- public void clear() throws IdentityException
- {
-
- }
-
- public boolean isOpen()
- {
- return false;
- }
-
- public boolean isTransactionSupported()
- {
- return false;
- }
-
- public void startTransaction()
- {
-
- }
-
- public void commitTransaction()
- {
-
- }
-
- public void rollbackTransaction()
- {
-
- }
-
- public boolean isTransactionActive()
- {
- return false;
- }
-}
Copied: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreSessionImpl.java (from rev 211, trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/ldap/LDAPIdentityStoreSessionImpl.java)
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreSessionImpl.java (rev 0)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreSessionImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,134 @@
+/*
+* 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.store.ldap;
+
+import org.jboss.identity.idm.spi.store.IdentityStoreSession;
+import org.jboss.identity.idm.exception.IdentityException;
+
+import javax.naming.ldap.LdapContext;
+import javax.naming.ldap.InitialLdapContext;
+import javax.naming.Context;
+import java.util.Hashtable;
+
+/**
+ * Session around LDAP store. Exposes LDAP connection (LdapContext) and does nothing for transaction related methods
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class LDAPIdentityStoreSessionImpl implements IdentityStoreSession
+{
+
+ private final String INITIAL_CONTEXT_FACTORY;
+
+ private final String PROVIDER_URL;
+
+ private final String SECURITY_AUTHENTICATION;
+
+ private final String SECURITY_PRINCIPAL;
+
+ private final String SECURITY_CREDENTIALS;
+
+
+ public LDAPIdentityStoreSessionImpl(String INITIAL_CONTEXT_FACTORY,
+ String PROVIDER_URL,
+ String SECURITY_AUTHENTICATION,
+ String SECURITY_PRINCIPAL,
+ String SECURITY_CREDENTIALS)
+ {
+ this.INITIAL_CONTEXT_FACTORY = INITIAL_CONTEXT_FACTORY;
+ this.PROVIDER_URL = PROVIDER_URL;
+ this.SECURITY_AUTHENTICATION = SECURITY_AUTHENTICATION;
+ this.SECURITY_PRINCIPAL = SECURITY_PRINCIPAL;
+ this.SECURITY_CREDENTIALS = SECURITY_CREDENTIALS;
+ }
+
+ public LdapContext getLdapContext() throws Exception
+ {
+ Hashtable<String,String> env = new Hashtable<String,String>();
+ env.put(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY);
+ env.put(Context.PROVIDER_URL, PROVIDER_URL);
+ env.put(Context.SECURITY_AUTHENTICATION, SECURITY_AUTHENTICATION);
+ env.put(Context.SECURITY_PRINCIPAL, SECURITY_PRINCIPAL);
+ env.put(Context.SECURITY_CREDENTIALS, SECURITY_CREDENTIALS);
+
+ return new InitialLdapContext(env, null);
+ }
+
+ public Object getSessionContext() throws IdentityException
+ {
+ try
+ {
+ return getLdapContext();
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Could not create LdapContext", e);
+ }
+ }
+
+ public void close() throws IdentityException
+ {
+
+ }
+
+ public void save() throws IdentityException
+ {
+
+ }
+
+ public void clear() throws IdentityException
+ {
+
+ }
+
+ public boolean isOpen()
+ {
+ return false;
+ }
+
+ public boolean isTransactionSupported()
+ {
+ return false;
+ }
+
+ public void startTransaction()
+ {
+
+ }
+
+ public void commitTransaction()
+ {
+
+ }
+
+ public void rollbackTransaction()
+ {
+
+ }
+
+ public boolean isTransactionActive()
+ {
+ return false;
+ }
+}
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/SimpleLDAPIdentityObjectTypeConfiguration.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/ldap/SimpleLDAPIdentityObjectTypeConfiguration.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/SimpleLDAPIdentityObjectTypeConfiguration.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,339 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.store.ldap;
-
-import org.jboss.identity.spi.configuration.metadata.IdentityObjectTypeMetaData;
-import org.jboss.identity.spi.configuration.metadata.RelationshipMetaData;
-import org.jboss.identity.spi.attribute.IdentityObjectAttributeMetaData;
-
-import java.util.Map;
-import java.util.Set;
-import java.util.Collections;
-import java.util.List;
-import java.util.LinkedList;
-import java.util.HashMap;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class SimpleLDAPIdentityObjectTypeConfiguration implements LDAPIdentityObjectTypeConfiguration
-{
- private final String idAttributeName;
-
- private final String passwordAttributeName;
-
- private final String[] ctxDNs;
-
- private final String entrySearchFilter;
-
- private final boolean allowCreateEntry;
-
- private final Map<String, String[]> createEntryAttributeValues;
-
- private final String[] allowedMembershipTypes;
-
- private final String membershipAttributeName;
-
- private final boolean isMembershipAttributeDN;
-
- private final boolean allowEmptyMemberships;
-
- private final Map<String, String> attributeNames;
-
-
- //Consts
-
- public static final String ID_ATTRIBUTE_NAME = "idAttributeName";
-
- public static final String PASSWORD_ATTRIBUTE_NAME = "passwordAttributeName";
-
- public static final String CTX_DNS = "ctxDNs";
-
- public static final String ENTRY_SEARCH_FILTER = "entrySearchFilter";
-
- public static final String ALLOW_CREATE_ENTRY = "allowCreateEntry";
-
- public static final String MEMBERSHIP_ATTRIBUTE_NAME = "membershipAttributeName";
-
- public static final String IS_MEMBERSHIP_ATTRIBUTE_DN = "isMembershipAttributeDN";
-
- public static final String ALLOW_EMPTY_MEMBERSHIPS = "allowEmptyMemberships";
-
- public static final String CREATE_ENTRY_ATTRIBUTE_VALUES = "createEntryAttributeValues";
-
-
-
- public SimpleLDAPIdentityObjectTypeConfiguration(IdentityObjectTypeMetaData objectTypeMD)
- {
- this.idAttributeName = objectTypeMD.getOptionSingleValue(ID_ATTRIBUTE_NAME);
- this.passwordAttributeName = objectTypeMD.getOptionSingleValue(PASSWORD_ATTRIBUTE_NAME);
- this.entrySearchFilter = objectTypeMD.getOptionSingleValue(ENTRY_SEARCH_FILTER);
- this.membershipAttributeName = objectTypeMD.getOptionSingleValue(MEMBERSHIP_ATTRIBUTE_NAME);
- String allowCreateEntry = objectTypeMD.getOptionSingleValue(ALLOW_CREATE_ENTRY);
- if (allowCreateEntry != null && allowCreateEntry.equalsIgnoreCase("true"))
- {
- this.allowCreateEntry = true;
- }
- else
- {
- this.allowCreateEntry = false;
- }
-
- String isMembershipAttributeDN = objectTypeMD.getOptionSingleValue(IS_MEMBERSHIP_ATTRIBUTE_DN);
- if (isMembershipAttributeDN != null && isMembershipAttributeDN.equalsIgnoreCase("true"))
- {
- this.isMembershipAttributeDN = true;
- }
- else
- {
- this.isMembershipAttributeDN = false;
- }
-
- String allowEmptyMemberships = objectTypeMD.getOptionSingleValue(ALLOW_EMPTY_MEMBERSHIPS);
- if (allowEmptyMemberships != null && allowEmptyMemberships.equalsIgnoreCase("true"))
- {
- this.allowEmptyMemberships = true;
- }
- else
- {
- this.allowEmptyMemberships = false;
- }
-
- List<String> relationships = new LinkedList<String>();
-
- if (objectTypeMD.getRelationships() != null)
- {
- for (RelationshipMetaData relationshipMetaData : objectTypeMD.getRelationships())
- {
- relationships.add(relationshipMetaData.getIdentityObjectTypeRef());
- }
- }
-
- allowedMembershipTypes = relationships.toArray(new String[relationships.size()]);
-
- attributeNames = new HashMap<String, String>();
-
- for (IdentityObjectAttributeMetaData attributeMetaData : objectTypeMD.getAttributes())
- {
- attributeNames.put(attributeMetaData.getName(), attributeMetaData.getStoreMapping());
- }
-
- List<String> dns = objectTypeMD.getOption(CTX_DNS);
- if (dns != null)
- {
- this.ctxDNs = dns.toArray(new String[dns.size()]);
- }
- else
- {
- this.ctxDNs = null;
- }
-
- Map<String, List<String>> createEntryAttributesMap = new HashMap<String, List<String>>();
-
-
-
- List<String> createAttributes = objectTypeMD.getOption(CREATE_ENTRY_ATTRIBUTE_VALUES);
-
- if (createAttributes != null && createAttributes.size() > 0 )
- {
- for (String attribute : createAttributes)
- {
- String[] parts = attribute.split("=", 2);
- if (parts.length != 2)
- {
- continue;
- }
-
- String name = parts[0];
- String value = parts[1];
-
- if (!createEntryAttributesMap.containsKey(name))
- {
- List<String> list = new LinkedList<String>();
- list.add(value);
- createEntryAttributesMap.put(name, list);
- }
- else
- {
- createEntryAttributesMap.get(name).add(value);
- }
- }
-
- Map<String, String[]> createEntryAttributesArray = new HashMap<String, String[]>();
-
- for (Map.Entry<String, List<String>> entry : createEntryAttributesMap.entrySet())
- {
- createEntryAttributesArray.put(entry.getKey(), entry.getValue().toArray(new String[entry.getValue().size()]));
- }
-
- this.createEntryAttributeValues = createEntryAttributesArray;
- }
- else
- {
- this.createEntryAttributeValues = new HashMap<String, String[]>();
- }
-
- //TODO: validate all required options - throw exception for missing ones and set defaults for others
-
-
-
- }
-
- public SimpleLDAPIdentityObjectTypeConfiguration(String idAttributeName,
- String passwordAttributeName,
- String[] ctxDNs,
- String entrySearchFilter,
- boolean allowCreateEntry,
- Map<String, String[]> createEntryAttributeValues,
- String[] allowedMembershipTypes,
- String membershipAttributeName,
- boolean membershipAttributeDN,
- boolean allowEmptyMemberships,
- Map<String, String> attributeNames)
- {
- this.idAttributeName = idAttributeName;
- this.passwordAttributeName = passwordAttributeName;
- this.ctxDNs = ctxDNs;
- this.entrySearchFilter = entrySearchFilter;
- this.allowCreateEntry = allowCreateEntry;
- this.createEntryAttributeValues = createEntryAttributeValues;
- this.allowedMembershipTypes = allowedMembershipTypes;
- this.membershipAttributeName = membershipAttributeName;
- isMembershipAttributeDN = membershipAttributeDN;
- this.allowEmptyMemberships = allowEmptyMemberships;
- this.attributeNames = attributeNames;
- }
-
-
-
- public String getIdAttributeName()
- {
- return idAttributeName;
- }
-
- public String[] getCtxDNs()
- {
- return ctxDNs;
- }
-
- public String getEntrySearchFilter()
- {
- return entrySearchFilter;
- }
-
- public boolean isAllowCreateEntry()
- {
- return allowCreateEntry;
- }
-
- public Map<String, String[]> getCreateEntryAttributeValues()
- {
- return createEntryAttributeValues;
- }
-
- public String[] getAllowedMembershipTypes()
- {
- return allowedMembershipTypes;
- }
-
- public String getMembershipAttributeName()
- {
- return membershipAttributeName;
- }
-
- public boolean isMembershipAttributeDN()
- {
- return isMembershipAttributeDN;
- }
-
- public boolean allowEmptyMemberships()
- {
- return allowEmptyMemberships;
- }
-
- public String getAttributeMapping(String name)
- {
- return attributeNames.get(name);
- }
-
- public String getPasswordAttributeName()
- {
- return passwordAttributeName;
- }
-
- // public void setIdAttributeName(String idAttributeName)
-// {
-// this.idAttributeName = idAttributeName;
-// }
-//
-// public void setCtxDNs(String[] ctxDNs)
-// {
-// this.ctxDNs = ctxDNs;
-// }
-//
-// public void setEntrySearchFilter(String entrySearchFilter)
-// {
-// this.entrySearchFilter = entrySearchFilter;
-// }
-//
-// public void setAllowCreateEntry(boolean allowCreateEntry)
-// {
-// this.allowCreateEntry = allowCreateEntry;
-// }
-//
-// public void setCreateEntryAttributeValues(Map<String, String[]> createEntryAttributeValues)
-// {
-// this.createEntryAttributeValues = createEntryAttributeValues;
-// }
-//
-// public void setAllowedMembershipTypes(String[] allowedMembershipTypes)
-// {
-// this.allowedMembershipTypes = allowedMembershipTypes;
-// }
-//
-// public void setMembershipAttributeName(String membershipAttributeName)
-// {
-// this.membershipAttributeName = membershipAttributeName;
-// }
-//
-// public void setMembershipAttributeDN(boolean membershipAttributeDN)
-// {
-// isMembershipAttributeDN = membershipAttributeDN;
-// }
-//
-// public void setAllowEmptyMemberships(boolean allowEmptyMemberships)
-// {
-// this.allowEmptyMemberships = allowEmptyMemberships;
-// }
-//
-// public void setAttributeNames(Map<String, String> attributeNames)
-// {
-// this.attributeNames = attributeNames;
-// }
-
- public Set<String> getMappedAttributesNames()
- {
- return Collections.unmodifiableSet(attributeNames.keySet());
- }
-}
Copied: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/SimpleLDAPIdentityObjectTypeConfiguration.java (from rev 211, trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/ldap/SimpleLDAPIdentityObjectTypeConfiguration.java)
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/SimpleLDAPIdentityObjectTypeConfiguration.java (rev 0)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/SimpleLDAPIdentityObjectTypeConfiguration.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,339 @@
+/*
+* 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.store.ldap;
+
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityObjectTypeMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.RelationshipMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityObjectAttributeMetaData;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.Collections;
+import java.util.List;
+import java.util.LinkedList;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class SimpleLDAPIdentityObjectTypeConfiguration implements LDAPIdentityObjectTypeConfiguration
+{
+ private final String idAttributeName;
+
+ private final String passwordAttributeName;
+
+ private final String[] ctxDNs;
+
+ private final String entrySearchFilter;
+
+ private final boolean allowCreateEntry;
+
+ private final Map<String, String[]> createEntryAttributeValues;
+
+ private final String[] allowedMembershipTypes;
+
+ private final String membershipAttributeName;
+
+ private final boolean isMembershipAttributeDN;
+
+ private final boolean allowEmptyMemberships;
+
+ private final Map<String, String> attributeNames;
+
+
+ //Consts
+
+ public static final String ID_ATTRIBUTE_NAME = "idAttributeName";
+
+ public static final String PASSWORD_ATTRIBUTE_NAME = "passwordAttributeName";
+
+ public static final String CTX_DNS = "ctxDNs";
+
+ public static final String ENTRY_SEARCH_FILTER = "entrySearchFilter";
+
+ public static final String ALLOW_CREATE_ENTRY = "allowCreateEntry";
+
+ public static final String MEMBERSHIP_ATTRIBUTE_NAME = "membershipAttributeName";
+
+ public static final String IS_MEMBERSHIP_ATTRIBUTE_DN = "isMembershipAttributeDN";
+
+ public static final String ALLOW_EMPTY_MEMBERSHIPS = "allowEmptyMemberships";
+
+ public static final String CREATE_ENTRY_ATTRIBUTE_VALUES = "createEntryAttributeValues";
+
+
+
+ public SimpleLDAPIdentityObjectTypeConfiguration(IdentityObjectTypeMetaData objectTypeMD)
+ {
+ this.idAttributeName = objectTypeMD.getOptionSingleValue(ID_ATTRIBUTE_NAME);
+ this.passwordAttributeName = objectTypeMD.getOptionSingleValue(PASSWORD_ATTRIBUTE_NAME);
+ this.entrySearchFilter = objectTypeMD.getOptionSingleValue(ENTRY_SEARCH_FILTER);
+ this.membershipAttributeName = objectTypeMD.getOptionSingleValue(MEMBERSHIP_ATTRIBUTE_NAME);
+ String allowCreateEntry = objectTypeMD.getOptionSingleValue(ALLOW_CREATE_ENTRY);
+ if (allowCreateEntry != null && allowCreateEntry.equalsIgnoreCase("true"))
+ {
+ this.allowCreateEntry = true;
+ }
+ else
+ {
+ this.allowCreateEntry = false;
+ }
+
+ String isMembershipAttributeDN = objectTypeMD.getOptionSingleValue(IS_MEMBERSHIP_ATTRIBUTE_DN);
+ if (isMembershipAttributeDN != null && isMembershipAttributeDN.equalsIgnoreCase("true"))
+ {
+ this.isMembershipAttributeDN = true;
+ }
+ else
+ {
+ this.isMembershipAttributeDN = false;
+ }
+
+ String allowEmptyMemberships = objectTypeMD.getOptionSingleValue(ALLOW_EMPTY_MEMBERSHIPS);
+ if (allowEmptyMemberships != null && allowEmptyMemberships.equalsIgnoreCase("true"))
+ {
+ this.allowEmptyMemberships = true;
+ }
+ else
+ {
+ this.allowEmptyMemberships = false;
+ }
+
+ List<String> relationships = new LinkedList<String>();
+
+ if (objectTypeMD.getRelationships() != null)
+ {
+ for (RelationshipMetaData relationshipMetaData : objectTypeMD.getRelationships())
+ {
+ relationships.add(relationshipMetaData.getIdentityObjectTypeRef());
+ }
+ }
+
+ allowedMembershipTypes = relationships.toArray(new String[relationships.size()]);
+
+ attributeNames = new HashMap<String, String>();
+
+ for (IdentityObjectAttributeMetaData attributeMetaData : objectTypeMD.getAttributes())
+ {
+ attributeNames.put(attributeMetaData.getName(), attributeMetaData.getStoreMapping());
+ }
+
+ List<String> dns = objectTypeMD.getOption(CTX_DNS);
+ if (dns != null)
+ {
+ this.ctxDNs = dns.toArray(new String[dns.size()]);
+ }
+ else
+ {
+ this.ctxDNs = null;
+ }
+
+ Map<String, List<String>> createEntryAttributesMap = new HashMap<String, List<String>>();
+
+
+
+ List<String> createAttributes = objectTypeMD.getOption(CREATE_ENTRY_ATTRIBUTE_VALUES);
+
+ if (createAttributes != null && createAttributes.size() > 0 )
+ {
+ for (String attribute : createAttributes)
+ {
+ String[] parts = attribute.split("=", 2);
+ if (parts.length != 2)
+ {
+ continue;
+ }
+
+ String name = parts[0];
+ String value = parts[1];
+
+ if (!createEntryAttributesMap.containsKey(name))
+ {
+ List<String> list = new LinkedList<String>();
+ list.add(value);
+ createEntryAttributesMap.put(name, list);
+ }
+ else
+ {
+ createEntryAttributesMap.get(name).add(value);
+ }
+ }
+
+ Map<String, String[]> createEntryAttributesArray = new HashMap<String, String[]>();
+
+ for (Map.Entry<String, List<String>> entry : createEntryAttributesMap.entrySet())
+ {
+ createEntryAttributesArray.put(entry.getKey(), entry.getValue().toArray(new String[entry.getValue().size()]));
+ }
+
+ this.createEntryAttributeValues = createEntryAttributesArray;
+ }
+ else
+ {
+ this.createEntryAttributeValues = new HashMap<String, String[]>();
+ }
+
+ //TODO: validate all required options - throw exception for missing ones and set defaults for others
+
+
+
+ }
+
+ public SimpleLDAPIdentityObjectTypeConfiguration(String idAttributeName,
+ String passwordAttributeName,
+ String[] ctxDNs,
+ String entrySearchFilter,
+ boolean allowCreateEntry,
+ Map<String, String[]> createEntryAttributeValues,
+ String[] allowedMembershipTypes,
+ String membershipAttributeName,
+ boolean membershipAttributeDN,
+ boolean allowEmptyMemberships,
+ Map<String, String> attributeNames)
+ {
+ this.idAttributeName = idAttributeName;
+ this.passwordAttributeName = passwordAttributeName;
+ this.ctxDNs = ctxDNs;
+ this.entrySearchFilter = entrySearchFilter;
+ this.allowCreateEntry = allowCreateEntry;
+ this.createEntryAttributeValues = createEntryAttributeValues;
+ this.allowedMembershipTypes = allowedMembershipTypes;
+ this.membershipAttributeName = membershipAttributeName;
+ isMembershipAttributeDN = membershipAttributeDN;
+ this.allowEmptyMemberships = allowEmptyMemberships;
+ this.attributeNames = attributeNames;
+ }
+
+
+
+ public String getIdAttributeName()
+ {
+ return idAttributeName;
+ }
+
+ public String[] getCtxDNs()
+ {
+ return ctxDNs;
+ }
+
+ public String getEntrySearchFilter()
+ {
+ return entrySearchFilter;
+ }
+
+ public boolean isAllowCreateEntry()
+ {
+ return allowCreateEntry;
+ }
+
+ public Map<String, String[]> getCreateEntryAttributeValues()
+ {
+ return createEntryAttributeValues;
+ }
+
+ public String[] getAllowedMembershipTypes()
+ {
+ return allowedMembershipTypes;
+ }
+
+ public String getMembershipAttributeName()
+ {
+ return membershipAttributeName;
+ }
+
+ public boolean isMembershipAttributeDN()
+ {
+ return isMembershipAttributeDN;
+ }
+
+ public boolean allowEmptyMemberships()
+ {
+ return allowEmptyMemberships;
+ }
+
+ public String getAttributeMapping(String name)
+ {
+ return attributeNames.get(name);
+ }
+
+ public String getPasswordAttributeName()
+ {
+ return passwordAttributeName;
+ }
+
+ // public void setIdAttributeName(String idAttributeName)
+// {
+// this.idAttributeName = idAttributeName;
+// }
+//
+// public void setCtxDNs(String[] ctxDNs)
+// {
+// this.ctxDNs = ctxDNs;
+// }
+//
+// public void setEntrySearchFilter(String entrySearchFilter)
+// {
+// this.entrySearchFilter = entrySearchFilter;
+// }
+//
+// public void setAllowCreateEntry(boolean allowCreateEntry)
+// {
+// this.allowCreateEntry = allowCreateEntry;
+// }
+//
+// public void setCreateEntryAttributeValues(Map<String, String[]> createEntryAttributeValues)
+// {
+// this.createEntryAttributeValues = createEntryAttributeValues;
+// }
+//
+// public void setAllowedMembershipTypes(String[] allowedMembershipTypes)
+// {
+// this.allowedMembershipTypes = allowedMembershipTypes;
+// }
+//
+// public void setMembershipAttributeName(String membershipAttributeName)
+// {
+// this.membershipAttributeName = membershipAttributeName;
+// }
+//
+// public void setMembershipAttributeDN(boolean membershipAttributeDN)
+// {
+// isMembershipAttributeDN = membershipAttributeDN;
+// }
+//
+// public void setAllowEmptyMemberships(boolean allowEmptyMemberships)
+// {
+// this.allowEmptyMemberships = allowEmptyMemberships;
+// }
+//
+// public void setAttributeNames(Map<String, String> attributeNames)
+// {
+// this.attributeNames = attributeNames;
+// }
+
+ public Set<String> getMappedAttributesNames()
+ {
+ return Collections.unmodifiableSet(attributeNames.keySet());
+ }
+}
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/SimpleLDAPIdentityStoreConfiguration.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/ldap/SimpleLDAPIdentityStoreConfiguration.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/SimpleLDAPIdentityStoreConfiguration.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,147 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.store.ldap;
-
-import org.jboss.identity.spi.model.IdentityObjectType;
-import org.jboss.identity.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
-import org.jboss.identity.spi.configuration.metadata.IdentityObjectTypeMetaData;
-import org.jboss.identity.impl.types.SimpleIdentityObjectType;
-
-import java.util.Map;
-import java.util.HashMap;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class SimpleLDAPIdentityStoreConfiguration implements LDAPIdentityStoreConfiguration
-{
- private final String providerURL;
-
- private final String adminDN;
-
- private final String adminPassword;
-
- private final int searchTimeLimit;
-
- private final Map<String, LDAPIdentityObjectTypeConfiguration> typesConfiguration;
-
-
- // Consts
-
- public static final String PROVIDER_URL = "providerURL";
-
- public static final String ADMIN_DN = "adminDN";
-
- public static final String ADMIN_PASSWORD = "adminPassword";
-
- public static final String SEARCH_TIME_LIMIT = "searchTimeLimit";
-
- public static final int SEARCH_TIME_LIMIT_DEFAULT = 10000;
-
-// public SimpleLDAPIdentityStoreConfiguration(String providerURL, String adminDN, String adminPassword, int searchTimeLimit, Map<String, LDAPIdentityObjectTypeConfiguration> typesConfiguration)
-// {
-// this.providerURL = providerURL;
-// this.adminDN = adminDN;
-// this.adminPassword = adminPassword;
-// this.searchTimeLimit = searchTimeLimit;
-// this.typesConfiguration = typesConfiguration;
-// }
-
- public SimpleLDAPIdentityStoreConfiguration(IdentityStoreConfigurationMetaData storeMD)
- {
- if (storeMD == null)
- {
- throw new IllegalArgumentException();
- }
-
- providerURL = storeMD.getOptionSingleValue(PROVIDER_URL);
- adminDN = storeMD.getOptionSingleValue(ADMIN_DN);
- adminPassword = storeMD.getOptionSingleValue(ADMIN_PASSWORD);
- String searchTL = storeMD.getOptionSingleValue(SEARCH_TIME_LIMIT);
-
- if (searchTL != null)
- {
- searchTimeLimit = Integer.valueOf(searchTL);
- }
- else
- {
- searchTimeLimit = SEARCH_TIME_LIMIT_DEFAULT;
- }
-
- Map<String, LDAPIdentityObjectTypeConfiguration> types = new HashMap<String, LDAPIdentityObjectTypeConfiguration>();
-
- for (IdentityObjectTypeMetaData identityObjectTypeMetaData : storeMD.getSupportedIdentityTypes())
- {
- LDAPIdentityObjectTypeConfiguration typeConfig = new SimpleLDAPIdentityObjectTypeConfiguration(identityObjectTypeMetaData);
- types.put(identityObjectTypeMetaData.getName(), typeConfig);
-
- }
-
- typesConfiguration = types;
-
- //TODO: validate if critical values are present
-
-
- }
-
- public String getProviderURL()
- {
- return providerURL;
- }
-
- public String getAdminDN()
- {
- return adminDN;
- }
-
- public String getAdminPassword()
- {
- return adminPassword;
- }
-
- public int getSearchTimeLimit()
- {
- return searchTimeLimit;
- }
-
- public LDAPIdentityObjectTypeConfiguration getTypeConfiguration(String typeName)
- {
- return typesConfiguration.get(typeName);
- }
-
- public IdentityObjectType[] getConfiguredTypes()
- {
- IdentityObjectType[] types = new IdentityObjectType[typesConfiguration.size()];
- Object[] names = typesConfiguration.keySet().toArray();
-
- for (int i = 0; i < names.length; i++)
- {
- String name = names[i].toString();
- types[i] = new SimpleIdentityObjectType(name);
- }
-
- return types;
- }
-
-}
Copied: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/SimpleLDAPIdentityStoreConfiguration.java (from rev 211, trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/ldap/SimpleLDAPIdentityStoreConfiguration.java)
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/SimpleLDAPIdentityStoreConfiguration.java (rev 0)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/store/ldap/SimpleLDAPIdentityStoreConfiguration.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,138 @@
+/*
+* 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.store.ldap;
+
+import org.jboss.identity.idm.spi.model.IdentityObjectType;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityObjectTypeMetaData;
+import org.jboss.identity.idm.impl.types.SimpleIdentityObjectType;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class SimpleLDAPIdentityStoreConfiguration implements LDAPIdentityStoreConfiguration
+{
+ private final String providerURL;
+
+ private final String adminDN;
+
+ private final String adminPassword;
+
+ private final int searchTimeLimit;
+
+ private final Map<String, LDAPIdentityObjectTypeConfiguration> typesConfiguration;
+
+
+ // Consts
+
+ public static final String PROVIDER_URL = "providerURL";
+
+ public static final String ADMIN_DN = "adminDN";
+
+ public static final String ADMIN_PASSWORD = "adminPassword";
+
+ public static final String SEARCH_TIME_LIMIT = "searchTimeLimit";
+
+ public static final int SEARCH_TIME_LIMIT_DEFAULT = 10000;
+
+ public SimpleLDAPIdentityStoreConfiguration(IdentityStoreConfigurationMetaData storeMD)
+ {
+ if (storeMD == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ providerURL = storeMD.getOptionSingleValue(PROVIDER_URL);
+ adminDN = storeMD.getOptionSingleValue(ADMIN_DN);
+ adminPassword = storeMD.getOptionSingleValue(ADMIN_PASSWORD);
+ String searchTL = storeMD.getOptionSingleValue(SEARCH_TIME_LIMIT);
+
+ if (searchTL != null)
+ {
+ searchTimeLimit = Integer.valueOf(searchTL);
+ }
+ else
+ {
+ searchTimeLimit = SEARCH_TIME_LIMIT_DEFAULT;
+ }
+
+ Map<String, LDAPIdentityObjectTypeConfiguration> types = new HashMap<String, LDAPIdentityObjectTypeConfiguration>();
+
+ for (IdentityObjectTypeMetaData identityObjectTypeMetaData : storeMD.getSupportedIdentityTypes())
+ {
+ LDAPIdentityObjectTypeConfiguration typeConfig = new SimpleLDAPIdentityObjectTypeConfiguration(identityObjectTypeMetaData);
+ types.put(identityObjectTypeMetaData.getName(), typeConfig);
+
+ }
+
+ typesConfiguration = types;
+
+ //TODO: validate if critical values are present
+
+
+ }
+
+ public String getProviderURL()
+ {
+ return providerURL;
+ }
+
+ public String getAdminDN()
+ {
+ return adminDN;
+ }
+
+ public String getAdminPassword()
+ {
+ return adminPassword;
+ }
+
+ public int getSearchTimeLimit()
+ {
+ return searchTimeLimit;
+ }
+
+ public LDAPIdentityObjectTypeConfiguration getTypeConfiguration(String typeName)
+ {
+ return typesConfiguration.get(typeName);
+ }
+
+ public IdentityObjectType[] getConfiguredTypes()
+ {
+ IdentityObjectType[] types = new IdentityObjectType[typesConfiguration.size()];
+ Object[] names = typesConfiguration.keySet().toArray();
+
+ for (int i = 0; i < names.length; i++)
+ {
+ String name = names[i].toString();
+ types[i] = new SimpleIdentityObjectType(name);
+ }
+
+ return types;
+ }
+
+}
Deleted: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/types/SimpleIdentityObject.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/types/SimpleIdentityObject.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/types/SimpleIdentityObject.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,88 +0,0 @@
-/*
- * 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.impl.types;
-
-import org.jboss.identity.exception.PolicyValidationException;
-import org.jboss.identity.spi.model.IdentityObject;
-import org.jboss.identity.spi.model.IdentityObjectType;
-
-
-/**
- * Very simple identity object
- * @author boleslaw dot dawidowicz at redhat anotherdot com
- *
- * @since Aug 6, 2008
- */
-public class SimpleIdentityObject implements IdentityObject
-{
-
- private final String name;
-
- private final String id;
-
- private final IdentityObjectType type;
-
- public SimpleIdentityObject(String name, String id, IdentityObjectType type)
- {
- if (name == null)
- {
- throw new IllegalArgumentException("name is null");
- }
- if (id == null)
- {
- throw new IllegalArgumentException("id is null");
- }
- if (type == null)
- {
- throw new IllegalArgumentException("type is null");
- }
-
- this.name = name;
- this.id = id;
- this.type = type;
- }
-
- public String getName()
- {
- return name;
- }
-
- public String getId()
- {
- return id;
- }
-
- public IdentityObjectType getIdentityType()
- {
- return type;
- }
-
- public String getFQDN()
- {
- return null;
- }
-
- public void validatePolicy() throws PolicyValidationException
- {
-
- }
-}
\ No newline at end of file
Copied: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/types/SimpleIdentityObject.java (from rev 211, trunk/identity-impl/src/main/java/org/jboss/identity/impl/types/SimpleIdentityObject.java)
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/types/SimpleIdentityObject.java (rev 0)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/types/SimpleIdentityObject.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,84 @@
+/*
+ * 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.idm.impl.types;
+
+import org.jboss.identity.idm.exception.PolicyValidationException;
+import org.jboss.identity.idm.spi.model.IdentityObject;
+import org.jboss.identity.idm.spi.model.IdentityObjectType;
+
+
+/**
+ * Very simple identity object
+ *
+ * @author boleslaw dot dawidowicz at redhat anotherdot com
+ *
+ * @since Aug 6, 2008
+ */
+public class SimpleIdentityObject implements IdentityObject
+{
+
+ private final String name;
+
+ private final String id;
+
+ private final IdentityObjectType type;
+
+ public SimpleIdentityObject(String name, String id, IdentityObjectType type)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("name is null");
+ }
+ if (id == null)
+ {
+ throw new IllegalArgumentException("id is null");
+ }
+ if (type == null)
+ {
+ throw new IllegalArgumentException("type is null");
+ }
+
+ this.name = name;
+ this.id = id;
+ this.type = type;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public IdentityObjectType getIdentityType()
+ {
+ return type;
+ }
+
+ public void validatePolicy() throws PolicyValidationException
+ {
+
+ }
+}
\ No newline at end of file
Modified: trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/types/SimpleIdentityObjectType.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/types/SimpleIdentityObjectType.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/main/java/org/jboss/identity/idm/impl/types/SimpleIdentityObjectType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,9 +20,9 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.types;
+package org.jboss.identity.idm.impl.types;
-import org.jboss.identity.spi.model.IdentityObjectType;
+import org.jboss.identity.idm.spi.model.IdentityObjectType;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Copied: trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl (from rev 198, trunk/identity-impl/src/test/java/org/jboss/identity/impl)
Modified: trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/HibernateTestSupport.java
===================================================================
--- trunk/identity-impl/src/test/java/org/jboss/identity/impl/HibernateTestSupport.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/HibernateTestSupport.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,10 +20,10 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl;
+package org.jboss.identity.idm.impl;
-import org.jboss.identity.impl.model.hibernate.HibernateIdentityObjectRelationshipType;
-import org.jboss.identity.impl.model.hibernate.HibernateIdentityObjectType;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipType;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectType;
import org.hibernate.ejb.HibernateEntityManagerFactory;
import org.hibernate.ejb.HibernateEntityManager;
Modified: trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/SimpleIdentityObjectRelationshipTypeImpl.java
===================================================================
--- trunk/identity-impl/src/test/java/org/jboss/identity/impl/SimpleIdentityObjectRelationshipTypeImpl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/SimpleIdentityObjectRelationshipTypeImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,9 +20,9 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl;
+package org.jboss.identity.idm.impl;
-import org.jboss.identity.spi.model.IdentityObjectRelationshipType;
+import org.jboss.identity.idm.spi.model.IdentityObjectRelationshipType;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Modified: trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/SimpleIdentityObjectTypeImpl.java
===================================================================
--- trunk/identity-impl/src/test/java/org/jboss/identity/impl/SimpleIdentityObjectTypeImpl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/SimpleIdentityObjectTypeImpl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,9 +20,9 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl;
+package org.jboss.identity.idm.impl;
-import org.jboss.identity.spi.model.IdentityObjectType;
+import org.jboss.identity.idm.spi.model.IdentityObjectType;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Modified: trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/api/APITestCase.java
===================================================================
--- trunk/identity-impl/src/test/java/org/jboss/identity/impl/api/APITestCase.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/api/APITestCase.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,12 +20,12 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.api;
+package org.jboss.identity.idm.impl.api;
import junit.framework.TestCase;
-import org.jboss.identity.impl.HibernateTestSupport;
-import org.jboss.identity.api.IdentitySessionFactory;
-import org.jboss.identity.opends.OpenDSService;
+import org.jboss.identity.idm.impl.HibernateTestSupport;
+import org.jboss.identity.idm.api.IdentitySessionFactory;
+import org.jboss.identity.idm.opends.OpenDSService;
import org.opends.server.tools.LDAPModify;
import javax.naming.directory.DirContext;
Modified: trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/api/APITestContext.java
===================================================================
--- trunk/identity-impl/src/test/java/org/jboss/identity/impl/api/APITestContext.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/api/APITestContext.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,10 +20,9 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.api;
+package org.jboss.identity.idm.impl.api;
-import org.jboss.identity.api.IdentitySession;
-import org.jboss.identity.api.IdentitySessionFactory;
+import org.jboss.identity.idm.api.IdentitySessionFactory;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Modified: trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/api/GroupTypeEnum.java
===================================================================
--- trunk/identity-impl/src/test/java/org/jboss/identity/impl/api/GroupTypeEnum.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/api/GroupTypeEnum.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -21,9 +21,9 @@
*/
-package org.jboss.identity.impl.api;
+package org.jboss.identity.idm.impl.api;
-import org.jboss.identity.api.GroupType;
+import org.jboss.identity.idm.api.GroupType;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Deleted: trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTest.java
===================================================================
--- trunk/identity-impl/src/test/java/org/jboss/identity/impl/api/OrganizationTest.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTest.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,521 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.api;
-
-import org.jboss.identity.api.IdentitySession;
-import org.jboss.identity.api.Group;
-import org.jboss.identity.api.GroupType;
-import org.jboss.identity.api.Identity;
-import org.jboss.identity.api.RoleType;
-import org.jboss.identity.api.IdentitySessionFactory;
-import org.jboss.identity.api.Attribute;
-import org.jboss.identity.api.AttributeDescription;
-import org.jboss.identity.p3p.P3PConstants;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Random;
-import java.util.Arrays;
-
-import junit.framework.Assert;
-
-/**
- * Abstract test mapping real life structures using the API
- *
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class OrganizationTest extends Assert
-{
- APITestContext ctx;
-
- public OrganizationTest(APITestContext ctx)
- {
- this.ctx = ctx;
- }
-
- public void setCtx(APITestContext ctx)
- {
- this.ctx = ctx;
- }
-
- public APITestContext getCtx()
- {
- return ctx;
- }
-
- public void testRedHatOrganization(String realmName) throws Exception
- {
- // GroupType
-
- GroupType ORGANIZATION = new SimpleGroupType("ORGANIZATION");
- GroupType ORGANIZATION_UNIT = new SimpleGroupType("ORGANIZATION_UNIT");
- GroupType DIVISION = new SimpleGroupType("DIVISION");
- GroupType DEPARTMENT = new SimpleGroupType("DEPARTMENT");
- GroupType PROJECT = new SimpleGroupType("PROJECT");
- GroupType PEOPLE = new SimpleGroupType("PEOPLE");
-
- IdentitySessionFactory factory = ctx.getIdentitySessionFactory();
-
- IdentitySession session = factory.createIdentitySession(realmName);
-
- session.getTransaction().start();
-
- // Organization structure
-
- Group rhOrg = session.getPersistenceManager().createGroup("RedHat", ORGANIZATION);
-
- Group jbossDivision = session.getPersistenceManager().createGroup("JBoss", DIVISION);
- Group rhelDivision = session.getPersistenceManager().createGroup("RHEL", DIVISION);
-
- session.getRelationshipManager().associateGroups(rhOrg, jbossDivision);
- session.getRelationshipManager().associateGroups(rhOrg, rhelDivision);
-
- Group itDepartment = session.getPersistenceManager().createGroup("IT", DEPARTMENT);
- Group hrDepartment = session.getPersistenceManager().createGroup("HR", DEPARTMENT);
-
- session.getRelationshipManager().associateGroups(jbossDivision, itDepartment);
- session.getRelationshipManager().associateGroups(jbossDivision, hrDepartment);
-
- Group rndDepartment = session.getPersistenceManager().createGroup("RnD", DEPARTMENT);
-
- session.getRelationshipManager().associateGroups(itDepartment, rndDepartment);
-
- Group projectsOU = session.getPersistenceManager().createGroup("Projects", ORGANIZATION_UNIT);
- Group commonFrameworksOU = session.getPersistenceManager().createGroup("Common Frameworks", ORGANIZATION_UNIT);
-
- session.getRelationshipManager().associateGroups(rndDepartment, projectsOU);
-
- // Projects
-
- Group portalProject = session.getPersistenceManager().createGroup("Portal", PROJECT);
- Group soaProject = session.getPersistenceManager().createGroup("SOA", PROJECT);
- Group jbpmProject = session.getPersistenceManager().createGroup("jBPM", PROJECT);
- Group seamProject = session.getPersistenceManager().createGroup("Seam", PROJECT);
- Group asProject = session.getPersistenceManager().createGroup("AS", PROJECT);
- Group securityProject = session.getPersistenceManager().createGroup("Security", PROJECT);
-
- session.getRelationshipManager().associateGroups(projectsOU, portalProject);
- session.getRelationshipManager().associateGroups(projectsOU, soaProject);
- session.getRelationshipManager().associateGroups(projectsOU, jbpmProject);
- session.getRelationshipManager().associateGroups(projectsOU, asProject);
- session.getRelationshipManager().associateGroups(projectsOU, seamProject);
-
- // Portal is part of common frameworks
- session.getRelationshipManager().associateGroups(commonFrameworksOU, portalProject);
-
- // People
-
- Group employeesGroup = session.getPersistenceManager().createGroup("Employees", PEOPLE);
-
- // Management
-
- Identity theuteUser = session.getPersistenceManager().createIdentity("theute");
- Identity mlittleUser = session.getPersistenceManager().createIdentity("mlittle");
- Identity bgeorgesUser = session.getPersistenceManager().createIdentity("bgeorges");
- Identity asaldhanaUser = session.getPersistenceManager().createIdentity("asaldhana");
- Identity janderseUser = session.getPersistenceManager().createIdentity("janderse");
-
- // Portal Team
-
- Identity bdawidowUser = session.getPersistenceManager().createIdentity("bdawidow");
- Identity claprunUser = session.getPersistenceManager().createIdentity("claprun");
- Identity whalesUser = session.getPersistenceManager().createIdentity("whales");
- Identity sshahUser = session.getPersistenceManager().createIdentity("sshah");
- Identity mwringeUser = session.getPersistenceManager().createIdentity("mwringe");
-
- // Store as employees
-
- session.getRelationshipManager().associateIdentities(employeesGroup, theuteUser);
- session.getRelationshipManager().associateIdentities(employeesGroup, mlittleUser);
- session.getRelationshipManager().associateIdentities(employeesGroup, asaldhanaUser);
- session.getRelationshipManager().associateIdentities(employeesGroup, bdawidowUser);
- session.getRelationshipManager().associateIdentities(employeesGroup, claprunUser);
- session.getRelationshipManager().associateIdentities(employeesGroup, whalesUser);
- session.getRelationshipManager().associateIdentities(employeesGroup, sshahUser);
- session.getRelationshipManager().associateIdentities(employeesGroup, mwringeUser);
-
- // Portal team for management purposes
-
- Group portalTeamGroup = session.getPersistenceManager().createGroup("Portal Team", PEOPLE);
- session.getRelationshipManager().associateIdentities(portalTeamGroup, bdawidowUser);
- session.getRelationshipManager().associateIdentities(portalTeamGroup, claprunUser);
- session.getRelationshipManager().associateIdentities(portalTeamGroup, whalesUser);
- session.getRelationshipManager().associateIdentities(portalTeamGroup, sshahUser);
- session.getRelationshipManager().associateIdentities(portalTeamGroup, mwringeUser);
-
- // Portal team is under common frameworks
-
- session.getRelationshipManager().associateGroups(commonFrameworksOU, portalTeamGroup);
-
- // Role Types
-
- RoleType developerRT = session.getRoleManager().createRoleType("Developer");
- RoleType managerRT = session.getRoleManager().createRoleType("Manager");
- RoleType leadDeveloperRT = session.getRoleManager().createRoleType("Lead Developer");
- RoleType productManagerRT = session.getRoleManager().createRoleType("Product Manager");
-
- // Assign roles
-
- // Common frameworks manager
-
- session.getRoleManager().createRole(managerRT, bgeorgesUser, commonFrameworksOU);
-
- // Portal developers
-
- session.getRoleManager().createRole(developerRT, theuteUser, portalProject);
- session.getRoleManager().createRole(developerRT, bdawidowUser, portalProject);
- session.getRoleManager().createRole(developerRT, claprunUser, portalProject);
- session.getRoleManager().createRole(developerRT, whalesUser, portalProject);
- session.getRoleManager().createRole(developerRT, sshahUser, portalProject);
- session.getRoleManager().createRole(developerRT, mwringeUser, portalProject);
-
- // Portal management
- session.getRoleManager().createRole(leadDeveloperRT, theuteUser, portalProject);
- session.getRoleManager().createRole(managerRT, theuteUser, portalTeamGroup);
- session.getRoleManager().createRole(productManagerRT, janderseUser, portalProject);
-
- // SOA
-
- session.getRoleManager().createRole(developerRT, mlittleUser, portalProject);
- session.getRoleManager().createRole(productManagerRT, mlittleUser, portalProject);
-
- // AS & Security
-
- session.getRoleManager().createRole(developerRT, asaldhanaUser, asProject);
- session.getRoleManager().createRole(developerRT, asaldhanaUser, securityProject);
- session.getRoleManager().createRole(leadDeveloperRT, asaldhanaUser, securityProject);
-
-
- // Check what RoleTypes has user theute
- Collection<RoleType> roleTypes = session.getRoleManager().findIdentityRoleTypes(theuteUser);
- assertEquals(3, roleTypes.size());
- assertTrue(roleTypes.contains(developerRT));
- assertTrue(roleTypes.contains(leadDeveloperRT));
- assertTrue(roleTypes.contains(managerRT));
- assertFalse(roleTypes.contains(productManagerRT));
-
- assertTrue(session.getRoleManager().hasRole(theuteUser, portalProject, developerRT));
- assertTrue(session.getRoleManager().hasRole(theuteUser, portalProject, leadDeveloperRT));
- assertTrue(session.getRoleManager().hasRole(theuteUser, portalTeamGroup, managerRT));
-
- // Check where anil is Lead Developer and where Developer
-
- roleTypes = session.getRoleManager().findIdentityRoleTypes(asaldhanaUser);
- assertEquals(2, roleTypes.size());
- assertTrue(roleTypes.contains(developerRT));
- assertTrue(roleTypes.contains(leadDeveloperRT));
-
- roleTypes = session.getRoleManager().findRoleTypes(asaldhanaUser, securityProject);
- assertEquals(2, roleTypes.size());
- assertTrue(roleTypes.contains(leadDeveloperRT));
-
- roleTypes = session.getRoleManager().findRoleTypes(asaldhanaUser, asProject);
- assertEquals(1, roleTypes.size());
- assertTrue(roleTypes.contains(developerRT));
-
- // and simpler...
- assertTrue(session.getRoleManager().hasRole(asaldhanaUser, asProject, developerRT));
-
- // Assert relationships
-
- Collection<Identity> identities = session.getRelationshipManager().findAssociatedIdentities(portalTeamGroup, false);
- assertEquals(5, identities.size());
- assertTrue(identities.contains(claprunUser));
- assertTrue(identities.contains(mwringeUser));
- assertTrue(identities.contains(sshahUser));
- assertTrue(identities.contains(whalesUser));
- assertTrue(identities.contains(bdawidowUser));
-
- Collection<Group> groups = session.getRelationshipManager().findAssociatedGroups(rndDepartment, PROJECT, true, false);
- assertEquals(0, groups.size());
-
- // Check to which group Anil belongs
- groups = session.getRelationshipManager().findAssociatedGroups(asaldhanaUser, PEOPLE);
- assertEquals(1, groups.size());
- assertTrue(groups.contains(employeesGroup));
-
- // Now check sshah
- groups = session.getRelationshipManager().findAssociatedGroups(sshahUser, PEOPLE);
- assertEquals(2, groups.size());
- assertTrue(groups.contains(employeesGroup));
- assertTrue(groups.contains(portalTeamGroup));
-
-
- // Check that binary attribute picture is mapped
-
- AttributeDescription attributeDescription = session.getAttributesManager().getAttributeDescription(bdawidowUser, "picture");
- assertNotNull(attributeDescription);
- assertEquals("binary", attributeDescription.getType());
-
-
- // Generate random binary data for binary attribute
- Random random = new Random();
-
- byte[] picture = new byte[5120];
- random.nextBytes(picture);
-
- // User attributes
- Attribute[] userInfo = new Attribute[]
- {
- new SimpleAttributeImpl(P3PConstants.INFO_USER_NAME_GIVEN, new String[]{"Boleslaw"}),
- new SimpleAttributeImpl(P3PConstants.INFO_USER_NAME_FAMILY, new String[]{"Dawidowicz"}),
- new SimpleAttributeImpl("picture", new byte[][]{picture})
- };
-
- session.getAttributesManager().addAttributes(bdawidowUser, userInfo);
-
- Map<String, Attribute> attributes = session.getAttributesManager().getAttributes(bdawidowUser);
- assertEquals(3, attributes.keySet().size());
- assertEquals("Dawidowicz", (attributes.get(P3PConstants.INFO_USER_NAME_FAMILY)).getValue());
- assertTrue(Arrays.equals((byte[])attributes.get("picture").getValue(), picture));
-
- session.getTransaction().commit();
-
- }
-
- public void testSamplePortal(String realmName) throws Exception
- {
- GroupType SYSTEM = new SimpleGroupType("SYSTEM");
- GroupType ADMINISTRATION = new SimpleGroupType("ADMINISTRATION");
- GroupType COMMUNITY = new SimpleGroupType("COMMUNITY");
- GroupType ORGANIZATION = new SimpleGroupType("ORGANIZATION");
- GroupType ORGANIZATION_UNIT = new SimpleGroupType("ORGANIZATION_UNIT");
- GroupType OFFICE = new SimpleGroupType("OFFICE");
- GroupType DIVISION = new SimpleGroupType("DIVISION");
- GroupType DEPARTMENT = new SimpleGroupType("DEPARTMENT");
- GroupType SECURITY = new SimpleGroupType("SECURITY");
- GroupType PEOPLE = new SimpleGroupType("PEOPLE");
-
- IdentitySessionFactory factory = ctx.getIdentitySessionFactory();
-
- //TODO: alter realm policies to make ORGANIZATION, ORGANIZATION_UNIT, DIVISION, DEPARTMENT and OFFICE hierarchical groups
-
- IdentitySession session = factory.createIdentitySession(realmName);
-
- session.getTransaction().start();
-
- // Create all role types
- RoleType adminRT = session.getRoleManager().createRoleType("Admin");
- RoleType accountAdminRT = session.getRoleManager().createRoleType("Account Admin");
- RoleType managerRT = session.getRoleManager().createRoleType("Manager");
- RoleType officeManagerRT = session.getRoleManager().createRoleType("Office Manager");
- RoleType contributorRT = session.getRoleManager().createRoleType("Contributor");
- RoleType communityOwnerRT = session.getRoleManager().createRoleType("Community Owner");
- RoleType communityMemberRT = session.getRoleManager().createRoleType("Community Member");
- RoleType communityForumModeratorRT = session.getRoleManager().createRoleType("Community Forum Moderator");
- RoleType communityCMSAdminRT = session.getRoleManager().createRoleType("Community CMS Admin");
-
-
- // Create system root groups - groups containing all communities, global security groups and organization
-
- Group communityRootGroup = session.getPersistenceManager().createGroup("COMMUNITY_ROOT", SYSTEM);
- Group securityRootGroup = session.getPersistenceManager().createGroup("SECURITY_ROOT", SYSTEM);
- Group organizationRootGroup = session.getPersistenceManager().createGroup("ORGANIZATION_ROOT",SYSTEM);
- Group usersROOTGroup = session.getPersistenceManager().createGroup("USERS_ROOT",SYSTEM);
-
- // Communities
-
- Group portalLoversCommunity = session.getPersistenceManager().createGroup("Portal Lovers", COMMUNITY);
- Group baseJumpingCommunity = session.getPersistenceManager().createGroup("BASE Jumping", COMMUNITY);
- Group geeksCommunity = session.getPersistenceManager().createGroup("Geeks", COMMUNITY);
-
- session.getRelationshipManager().associateGroups(communityRootGroup, portalLoversCommunity);
- session.getRelationshipManager().associateGroups(communityRootGroup, baseJumpingCommunity);
- session.getRelationshipManager().associateGroups(communityRootGroup, geeksCommunity);
-
- // Security groups - act like global portal roles
-
- Group portalAdminGroup = session.getPersistenceManager().createGroup("Poral Admin", SECURITY);
- Group cmsAdminGroup = session.getPersistenceManager().createGroup("CMS Admin", SECURITY);
- Group userAdminGroup = session.getPersistenceManager().createGroup("User Admin", SECURITY);
- Group cmsEditorGroup = session.getPersistenceManager().createGroup("CMS Editor", SECURITY);
-
- session.getRelationshipManager().associateGroups(securityRootGroup, portalAdminGroup);
- session.getRelationshipManager().associateGroups(securityRootGroup, cmsAdminGroup);
- session.getRelationshipManager().associateGroups(securityRootGroup, userAdminGroup);
- session.getRelationshipManager().associateGroups(securityRootGroup, cmsEditorGroup);
-
- // Organization structure
-
- Group acmeOrg = session.getPersistenceManager().createGroup("ACME", ORGANIZATION);
-
- session.getRelationshipManager().associateGroups(organizationRootGroup, acmeOrg);
-
- Group departmentsOU = session.getPersistenceManager().createGroup("Departments", ORGANIZATION_UNIT);
- Group officesOU = session.getPersistenceManager().createGroup("Offices", ORGANIZATION_UNIT);
- Group employeesOU = session.getPersistenceManager().createGroup("Employees", ORGANIZATION_UNIT);
-
- session.getRelationshipManager().associateGroups(acmeOrg, departmentsOU);
- session.getRelationshipManager().associateGroups(acmeOrg, officesOU);
- session.getRelationshipManager().associateGroups(acmeOrg, employeesOU);
-
- // Departments
-
- Group hrDepart = session.getPersistenceManager().createGroup("HR", DEPARTMENT);
- Group financeDepart = session.getPersistenceManager().createGroup("Finance", DEPARTMENT);
- Group rndDepart = session.getPersistenceManager().createGroup("R&D", DEPARTMENT);
-
- session.getRelationshipManager().associateGroups(departmentsOU, hrDepart);
- session.getRelationshipManager().associateGroups(departmentsOU, financeDepart);
- session.getRelationshipManager().associateGroups(departmentsOU, rndDepart);
-
- // Offices
-
- Group parisOffice =session.getPersistenceManager().createGroup("Paris", OFFICE);
- Group londonOffice =session.getPersistenceManager().createGroup("London", OFFICE);
- Group nyOffice =session.getPersistenceManager().createGroup("New York", OFFICE);
-
- session.getRelationshipManager().associateGroups(officesOU, parisOffice);
- session.getRelationshipManager().associateGroups(officesOU, londonOffice);
- session.getRelationshipManager().associateGroups(officesOU, nyOffice);
-
- // People
-
- Identity anneUser = session.getPersistenceManager().createIdentity("anne");
- Identity marieUser = session.getPersistenceManager().createIdentity("marie");
- Identity eveUser = session.getPersistenceManager().createIdentity("eve");
- Identity angelinaUser = session.getPersistenceManager().createIdentity("angelina");
- Identity joannaUser = session.getPersistenceManager().createIdentity("joanna");
- Identity merilUser = session.getPersistenceManager().createIdentity("meril");
- Identity johnUser = session.getPersistenceManager().createIdentity("john");
- Identity stanUser = session.getPersistenceManager().createIdentity("stan");
- Identity chrisUser = session.getPersistenceManager().createIdentity("chris");
- Identity billUser = session.getPersistenceManager().createIdentity("bill");
- Identity jackUser = session.getPersistenceManager().createIdentity("jack");
-
- // All users are under people root
-
- session.getRelationshipManager().associateIdentities(usersROOTGroup, anneUser);
- session.getRelationshipManager().associateIdentities(usersROOTGroup, marieUser);
- session.getRelationshipManager().associateIdentities(usersROOTGroup, eveUser);
- session.getRelationshipManager().associateIdentities(usersROOTGroup, angelinaUser);
- session.getRelationshipManager().associateIdentities(usersROOTGroup, joannaUser);
- session.getRelationshipManager().associateIdentities(usersROOTGroup, merilUser);
- session.getRelationshipManager().associateIdentities(usersROOTGroup, johnUser);
- session.getRelationshipManager().associateIdentities(usersROOTGroup, stanUser);
- session.getRelationshipManager().associateIdentities(usersROOTGroup, chrisUser);
- session.getRelationshipManager().associateIdentities(usersROOTGroup, billUser);
- session.getRelationshipManager().associateIdentities(usersROOTGroup, jackUser);
-
-
- //
-
-
- // Anna is...
-
- // Anna Smith...
-
-
- session.getAttributesManager().addAttribute(anneUser, P3PConstants.INFO_USER_NAME_GIVEN, "Anne");
- session.getAttributesManager().addAttribute(anneUser, P3PConstants.INFO_USER_NAME_FAMILY, "Smith");
- session.getAttributesManager().addAttribute(anneUser, P3PConstants.INFO_USER_JOB_TITLE, "Senior Software Developer");
- session.getAttributesManager().addAttribute(anneUser, P3PConstants.INFO_USER_BUSINESS_INFO_ONLINE_EMAIL, "anne.smith at acme.com");
- session.getAttributesManager().addAttribute(anneUser, P3PConstants.INFO_USER_BUSINESS_INFO_TELECOM_MOBILE_NUMBER, "777 777 777 7 77");
-
- // Anna works in Paris office and participates in BASE jumping community as a forum moderator and CMS admin
-
- session.getRelationshipManager().associateIdentities(parisOffice, anneUser);
-
- // Anne could be just associated with BASE jumping community group using RelationshipManager but insted Role mechanism
- // is used to have more fine grained control of access rights inside of a community
-
- session.getRoleManager().createRole(communityMemberRT, anneUser, baseJumpingCommunity);
- session.getRoleManager().createRole(communityForumModeratorRT, anneUser, baseJumpingCommunity);
- session.getRoleManager().createRole(communityCMSAdminRT, anneUser, baseJumpingCommunity);
-
- // Anne belongs to CMS portal admins security group
-
- session.getRelationshipManager().associateIdentities(cmsAdminGroup, anneUser);
-
- // Ann is also an owner of geeks community
-
- session.getRoleManager().createRole(communityOwnerRT, anneUser, geeksCommunity);
-
-
- //
-
-
- // Angelina ...
-
- session.getAttributesManager().addAttribute(angelinaUser, P3PConstants.INFO_USER_NAME_GIVEN, "Angelina");
- session.getAttributesManager().addAttribute(angelinaUser, P3PConstants.INFO_USER_NAME_FAMILY, "Blond");
- session.getAttributesManager().addAttribute(angelinaUser, P3PConstants.INFO_USER_JOB_TITLE, "Very important looking job title");
- session.getAttributesManager().addAttribute(angelinaUser, P3PConstants.INFO_USER_BUSINESS_INFO_ONLINE_EMAIL, "angelina1979 at acme.com");
- session.getAttributesManager().addAttribute(angelinaUser, P3PConstants.INFO_USER_BUSINESS_INFO_TELECOM_MOBILE_NUMBER, "888 88 88 8888");
-
- // She works in London and is office manager there - se both RelationshipManager and RoleManager used against
- // the same pair of identity objects
-
- session.getRelationshipManager().associateIdentities(londonOffice, angelinaUser);
-
- session.getRoleManager().createRole(officeManagerRT, angelinaUser, londonOffice);
-
- // Angelina is member of geeks community and manages cms content there
-
- session.getRoleManager().createRole(communityMemberRT, angelinaUser, geeksCommunity);
- session.getRoleManager().createRole(communityCMSAdminRT, angelinaUser, geeksCommunity);
-
- // As office manager she also edits portal cms content
-
- session.getRelationshipManager().associateIdentities(cmsEditorGroup, angelinaUser);
-
-
- //
-
-
- // Some assertions
-
- // How many users do we have in whole acme org and how many people in paris and london offices
- assertEquals(11, session.getRelationshipManager().findAssociatedIdentities(usersROOTGroup, false).size());
- assertEquals(1, session.getRelationshipManager().findAssociatedIdentities(parisOffice, false).size());
- assertEquals(1, session.getRelationshipManager().findAssociatedIdentities(londonOffice, false).size());
-
-
- // Is anne geeks community owner?
- assertTrue(session.getRoleManager().hasRole(anneUser, geeksCommunity, communityOwnerRT));
-
- // Does she belong to cms admins
- assertTrue(session.getRelationshipManager().isAssociated(cmsAdminGroup, anneUser));
-
- // Check all groups that anna belongs to
- Collection<Group> groups = session.getRelationshipManager().findAssociatedGroups(anneUser);
- assertEquals(3, groups.size());
- assertTrue(groups.contains(usersROOTGroup));
- assertTrue(groups.contains(parisOffice));
- assertTrue(groups.contains(cmsAdminGroup));
-
-
-
- session.getTransaction().commit();
-
- }
-
-
-
-
-
-
-
-}
Copied: trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTest.java (from rev 211, trunk/identity-impl/src/test/java/org/jboss/identity/impl/api/OrganizationTest.java)
===================================================================
--- trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTest.java (rev 0)
+++ trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTest.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,526 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.impl.api;
+
+import org.jboss.identity.idm.api.IdentitySession;
+import org.jboss.identity.idm.api.Group;
+import org.jboss.identity.idm.api.GroupType;
+import org.jboss.identity.idm.api.Identity;
+import org.jboss.identity.idm.api.RoleType;
+import org.jboss.identity.idm.api.IdentitySessionFactory;
+import org.jboss.identity.idm.api.Attribute;
+import org.jboss.identity.idm.api.AttributeDescription;
+import org.jboss.identity.idm.p3p.P3PConstants;
+import org.jboss.identity.idm.impl.api.model.SimpleGroupType;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Random;
+import java.util.Arrays;
+
+import junit.framework.Assert;
+
+/**
+ * Abstract test mapping real life structures using the API
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class OrganizationTest extends Assert
+{
+ APITestContext ctx;
+
+ public OrganizationTest(APITestContext ctx)
+ {
+ this.ctx = ctx;
+ }
+
+ public void setCtx(APITestContext ctx)
+ {
+ this.ctx = ctx;
+ }
+
+ public APITestContext getCtx()
+ {
+ return ctx;
+ }
+
+ public void testRedHatOrganization(String realmName) throws Exception
+ {
+ // GroupType
+
+ GroupType ORGANIZATION = new SimpleGroupType("ORGANIZATION");
+ GroupType ORGANIZATION_UNIT = new SimpleGroupType("ORGANIZATION_UNIT");
+ GroupType DIVISION = new SimpleGroupType("DIVISION");
+ GroupType DEPARTMENT = new SimpleGroupType("DEPARTMENT");
+ GroupType PROJECT = new SimpleGroupType("PROJECT");
+ GroupType PEOPLE = new SimpleGroupType("PEOPLE");
+
+ IdentitySessionFactory factory = ctx.getIdentitySessionFactory();
+
+ IdentitySession session = factory.createIdentitySession(realmName);
+
+ session.getTransaction().start();
+
+ // Organization structure
+
+ Group rhOrg = session.getPersistenceManager().createGroup("RedHat", ORGANIZATION);
+
+ Group jbossDivision = session.getPersistenceManager().createGroup("JBoss", DIVISION);
+ Group rhelDivision = session.getPersistenceManager().createGroup("RHEL", DIVISION);
+
+ session.getRelationshipManager().associateGroups(rhOrg, jbossDivision);
+ session.getRelationshipManager().associateGroups(rhOrg, rhelDivision);
+
+ Group itDepartment = session.getPersistenceManager().createGroup("IT", DEPARTMENT);
+ Group hrDepartment = session.getPersistenceManager().createGroup("HR", DEPARTMENT);
+
+ session.getRelationshipManager().associateGroups(jbossDivision, itDepartment);
+ session.getRelationshipManager().associateGroups(jbossDivision, hrDepartment);
+
+ Group rndDepartment = session.getPersistenceManager().createGroup("RnD", DEPARTMENT);
+
+ session.getRelationshipManager().associateGroups(itDepartment, rndDepartment);
+
+ Group projectsOU = session.getPersistenceManager().createGroup("Projects", ORGANIZATION_UNIT);
+ Group commonFrameworksOU = session.getPersistenceManager().createGroup("Common Frameworks", ORGANIZATION_UNIT);
+
+ session.getRelationshipManager().associateGroups(rndDepartment, projectsOU);
+
+ // Projects
+
+ Group portalProject = session.getPersistenceManager().createGroup("Portal", PROJECT);
+ Group soaProject = session.getPersistenceManager().createGroup("SOA", PROJECT);
+ Group jbpmProject = session.getPersistenceManager().createGroup("jBPM", PROJECT);
+ Group seamProject = session.getPersistenceManager().createGroup("Seam", PROJECT);
+ Group asProject = session.getPersistenceManager().createGroup("AS", PROJECT);
+ Group securityProject = session.getPersistenceManager().createGroup("Security", PROJECT);
+
+ session.getRelationshipManager().associateGroups(projectsOU, portalProject);
+ session.getRelationshipManager().associateGroups(projectsOU, soaProject);
+ session.getRelationshipManager().associateGroups(projectsOU, jbpmProject);
+ session.getRelationshipManager().associateGroups(projectsOU, asProject);
+ session.getRelationshipManager().associateGroups(projectsOU, seamProject);
+
+ // Check...
+ assertTrue(session.getRelationshipManager().isAssociated(projectsOU, portalProject));
+ assertTrue(session.getRelationshipManager().isAssociated(projectsOU, soaProject));
+ assertTrue(session.getRelationshipManager().isAssociated(projectsOU, jbpmProject));
+ assertTrue(session.getRelationshipManager().isAssociated(projectsOU, asProject));
+ assertTrue(session.getRelationshipManager().isAssociated(projectsOU, seamProject));
+
+ // Portal is part of common frameworks
+ session.getRelationshipManager().associateGroups(commonFrameworksOU, portalProject);
+
+ // People
+
+ Group employeesGroup = session.getPersistenceManager().createGroup("Employees", PEOPLE);
+
+ // Management
+
+ Identity theuteUser = session.getPersistenceManager().createIdentity("theute");
+ Identity mlittleUser = session.getPersistenceManager().createIdentity("mlittle");
+ Identity bgeorgesUser = session.getPersistenceManager().createIdentity("bgeorges");
+ Identity asaldhanaUser = session.getPersistenceManager().createIdentity("asaldhana");
+ Identity janderseUser = session.getPersistenceManager().createIdentity("janderse");
+
+ // Portal Team
+
+ Identity bdawidowUser = session.getPersistenceManager().createIdentity("bdawidow");
+ Identity claprunUser = session.getPersistenceManager().createIdentity("claprun");
+ Identity whalesUser = session.getPersistenceManager().createIdentity("whales");
+ Identity sshahUser = session.getPersistenceManager().createIdentity("sshah");
+ Identity mwringeUser = session.getPersistenceManager().createIdentity("mwringe");
+
+ // Store as employees
+
+ session.getRelationshipManager().associateIdentities(employeesGroup, theuteUser);
+ session.getRelationshipManager().associateIdentities(employeesGroup, mlittleUser);
+ session.getRelationshipManager().associateIdentities(employeesGroup, asaldhanaUser);
+ session.getRelationshipManager().associateIdentities(employeesGroup, bdawidowUser);
+ session.getRelationshipManager().associateIdentities(employeesGroup, claprunUser);
+ session.getRelationshipManager().associateIdentities(employeesGroup, whalesUser);
+ session.getRelationshipManager().associateIdentities(employeesGroup, sshahUser);
+ session.getRelationshipManager().associateIdentities(employeesGroup, mwringeUser);
+
+ // Portal team for management purposes
+
+ Group portalTeamGroup = session.getPersistenceManager().createGroup("Portal Team", PEOPLE);
+ session.getRelationshipManager().associateIdentities(portalTeamGroup, bdawidowUser);
+ session.getRelationshipManager().associateIdentities(portalTeamGroup, claprunUser);
+ session.getRelationshipManager().associateIdentities(portalTeamGroup, whalesUser);
+ session.getRelationshipManager().associateIdentities(portalTeamGroup, sshahUser);
+ session.getRelationshipManager().associateIdentities(portalTeamGroup, mwringeUser);
+
+ // Portal team is under common frameworks
+
+ session.getRelationshipManager().associateGroups(commonFrameworksOU, portalTeamGroup);
+
+ // Role Types
+
+ RoleType developerRT = session.getRoleManager().createRoleType("Developer");
+ RoleType managerRT = session.getRoleManager().createRoleType("Manager");
+ RoleType leadDeveloperRT = session.getRoleManager().createRoleType("Lead Developer");
+ RoleType productManagerRT = session.getRoleManager().createRoleType("Product Manager");
+
+ // Assign roles
+
+ // Common frameworks manager
+
+ session.getRoleManager().createRole(managerRT, bgeorgesUser, commonFrameworksOU);
+
+ // Portal developers
+
+ session.getRoleManager().createRole(developerRT, theuteUser, portalProject);
+ session.getRoleManager().createRole(developerRT, bdawidowUser, portalProject);
+ session.getRoleManager().createRole(developerRT, claprunUser, portalProject);
+ session.getRoleManager().createRole(developerRT, whalesUser, portalProject);
+ session.getRoleManager().createRole(developerRT, sshahUser, portalProject);
+ session.getRoleManager().createRole(developerRT, mwringeUser, portalProject);
+
+ // Portal management
+ session.getRoleManager().createRole(leadDeveloperRT, theuteUser, portalProject);
+ session.getRoleManager().createRole(managerRT, theuteUser, portalTeamGroup);
+ session.getRoleManager().createRole(productManagerRT, janderseUser, portalProject);
+
+ // SOA
+
+ session.getRoleManager().createRole(developerRT, mlittleUser, portalProject);
+ session.getRoleManager().createRole(productManagerRT, mlittleUser, portalProject);
+
+ // AS & Security
+
+ session.getRoleManager().createRole(developerRT, asaldhanaUser, asProject);
+ session.getRoleManager().createRole(developerRT, asaldhanaUser, securityProject);
+ session.getRoleManager().createRole(leadDeveloperRT, asaldhanaUser, securityProject);
+
+
+ // Check what RoleTypes has user theute
+ Collection<RoleType> roleTypes = session.getRoleManager().findIdentityRoleTypes(theuteUser);
+ assertEquals(3, roleTypes.size());
+ assertTrue(roleTypes.contains(developerRT));
+ assertTrue(roleTypes.contains(leadDeveloperRT));
+ assertTrue(roleTypes.contains(managerRT));
+ assertFalse(roleTypes.contains(productManagerRT));
+
+ assertTrue(session.getRoleManager().hasRole(theuteUser, portalProject, developerRT));
+ assertTrue(session.getRoleManager().hasRole(theuteUser, portalProject, leadDeveloperRT));
+ assertTrue(session.getRoleManager().hasRole(theuteUser, portalTeamGroup, managerRT));
+
+ // Check where anil is Lead Developer and where Developer
+
+ roleTypes = session.getRoleManager().findIdentityRoleTypes(asaldhanaUser);
+ assertEquals(2, roleTypes.size());
+ assertTrue(roleTypes.contains(developerRT));
+ assertTrue(roleTypes.contains(leadDeveloperRT));
+
+ roleTypes = session.getRoleManager().findRoleTypes(asaldhanaUser, securityProject);
+ assertEquals(2, roleTypes.size());
+ assertTrue(roleTypes.contains(leadDeveloperRT));
+
+ roleTypes = session.getRoleManager().findRoleTypes(asaldhanaUser, asProject);
+ assertEquals(1, roleTypes.size());
+ assertTrue(roleTypes.contains(developerRT));
+
+ // and simpler...
+ assertTrue(session.getRoleManager().hasRole(asaldhanaUser, asProject, developerRT));
+
+ // Assert relationships
+
+ Collection<Identity> identities = session.getRelationshipManager().findAssociatedIdentities(portalTeamGroup, false);
+ assertEquals(5, identities.size());
+ assertTrue(identities.contains(claprunUser));
+ assertTrue(identities.contains(mwringeUser));
+ assertTrue(identities.contains(sshahUser));
+ assertTrue(identities.contains(whalesUser));
+ assertTrue(identities.contains(bdawidowUser));
+
+ Collection<Group> groups = session.getRelationshipManager().findAssociatedGroups(rndDepartment, PROJECT, true, false);
+ assertEquals(0, groups.size());
+
+ // Check to which group Anil belongs
+ groups = session.getRelationshipManager().findAssociatedGroups(asaldhanaUser, PEOPLE);
+ assertEquals(1, groups.size());
+ assertTrue(groups.contains(employeesGroup));
+
+ // Now check sshah
+ groups = session.getRelationshipManager().findAssociatedGroups(sshahUser, PEOPLE);
+ assertEquals(2, groups.size());
+ assertTrue(groups.contains(employeesGroup));
+ assertTrue(groups.contains(portalTeamGroup));
+
+
+ // Check that binary attribute picture is mapped
+
+ AttributeDescription attributeDescription = session.getAttributesManager().getAttributeDescription(bdawidowUser, "picture");
+ assertNotNull(attributeDescription);
+ assertEquals("binary", attributeDescription.getType());
+
+
+ // Generate random binary data for binary attribute
+ Random random = new Random();
+
+ byte[] picture = new byte[5120];
+ random.nextBytes(picture);
+
+ // User attributes
+ Attribute[] userInfo = new Attribute[]
+ {
+ new SimpleAttribute(P3PConstants.INFO_USER_NAME_GIVEN, new String[]{"Boleslaw"}),
+ new SimpleAttribute(P3PConstants.INFO_USER_NAME_FAMILY, new String[]{"Dawidowicz"}),
+ new SimpleAttribute("picture", new byte[][]{picture})
+ };
+
+ session.getAttributesManager().addAttributes(bdawidowUser, userInfo);
+
+ Map<String, Attribute> attributes = session.getAttributesManager().getAttributes(bdawidowUser);
+ assertEquals(3, attributes.keySet().size());
+ assertEquals("Dawidowicz", (attributes.get(P3PConstants.INFO_USER_NAME_FAMILY)).getValue());
+ assertTrue(Arrays.equals((byte[])attributes.get("picture").getValue(), picture));
+
+ session.getTransaction().commit();
+
+ }
+
+ public void testSamplePortal(String realmName) throws Exception
+ {
+ GroupType SYSTEM = new SimpleGroupType("SYSTEM");
+ GroupType ADMINISTRATION = new SimpleGroupType("ADMINISTRATION");
+ GroupType COMMUNITY = new SimpleGroupType("COMMUNITY");
+ GroupType ORGANIZATION = new SimpleGroupType("ORGANIZATION");
+ GroupType ORGANIZATION_UNIT = new SimpleGroupType("ORGANIZATION_UNIT");
+ GroupType OFFICE = new SimpleGroupType("OFFICE");
+ GroupType DIVISION = new SimpleGroupType("DIVISION");
+ GroupType DEPARTMENT = new SimpleGroupType("DEPARTMENT");
+ GroupType SECURITY = new SimpleGroupType("SECURITY");
+ GroupType PEOPLE = new SimpleGroupType("PEOPLE");
+
+ IdentitySessionFactory factory = ctx.getIdentitySessionFactory();
+
+ IdentitySession session = factory.createIdentitySession(realmName);
+
+ session.getTransaction().start();
+
+ // Create all role types
+ RoleType adminRT = session.getRoleManager().createRoleType("Admin");
+ RoleType accountAdminRT = session.getRoleManager().createRoleType("Account Admin");
+ RoleType managerRT = session.getRoleManager().createRoleType("Manager");
+ RoleType officeManagerRT = session.getRoleManager().createRoleType("Office Manager");
+ RoleType contributorRT = session.getRoleManager().createRoleType("Contributor");
+ RoleType communityOwnerRT = session.getRoleManager().createRoleType("Community Owner");
+ RoleType communityMemberRT = session.getRoleManager().createRoleType("Community Member");
+ RoleType communityForumModeratorRT = session.getRoleManager().createRoleType("Community Forum Moderator");
+ RoleType communityCMSAdminRT = session.getRoleManager().createRoleType("Community CMS Admin");
+
+
+ // Create system root groups - groups containing all communities, global security groups and organization
+
+ Group communityRootGroup = session.getPersistenceManager().createGroup("COMMUNITY_ROOT", SYSTEM);
+ Group securityRootGroup = session.getPersistenceManager().createGroup("SECURITY_ROOT", SYSTEM);
+ Group organizationRootGroup = session.getPersistenceManager().createGroup("ORGANIZATION_ROOT",SYSTEM);
+ Group usersROOTGroup = session.getPersistenceManager().createGroup("USERS_ROOT",SYSTEM);
+
+ // Communities
+
+ Group portalLoversCommunity = session.getPersistenceManager().createGroup("Portal Lovers", COMMUNITY);
+ Group baseJumpingCommunity = session.getPersistenceManager().createGroup("BASE Jumping", COMMUNITY);
+ Group geeksCommunity = session.getPersistenceManager().createGroup("Geeks", COMMUNITY);
+
+ session.getRelationshipManager().associateGroups(communityRootGroup, portalLoversCommunity);
+ session.getRelationshipManager().associateGroups(communityRootGroup, baseJumpingCommunity);
+ session.getRelationshipManager().associateGroups(communityRootGroup, geeksCommunity);
+
+ // Security groups - act like global portal roles
+
+ Group portalAdminGroup = session.getPersistenceManager().createGroup("Poral Admin", SECURITY);
+ Group cmsAdminGroup = session.getPersistenceManager().createGroup("CMS Admin", SECURITY);
+ Group userAdminGroup = session.getPersistenceManager().createGroup("User Admin", SECURITY);
+ Group cmsEditorGroup = session.getPersistenceManager().createGroup("CMS Editor", SECURITY);
+
+ session.getRelationshipManager().associateGroups(securityRootGroup, portalAdminGroup);
+ session.getRelationshipManager().associateGroups(securityRootGroup, cmsAdminGroup);
+ session.getRelationshipManager().associateGroups(securityRootGroup, userAdminGroup);
+ session.getRelationshipManager().associateGroups(securityRootGroup, cmsEditorGroup);
+
+ // Organization structure
+
+ Group acmeOrg = session.getPersistenceManager().createGroup("ACME", ORGANIZATION);
+
+ session.getRelationshipManager().associateGroups(organizationRootGroup, acmeOrg);
+
+ Group departmentsOU = session.getPersistenceManager().createGroup("Departments", ORGANIZATION_UNIT);
+ Group officesOU = session.getPersistenceManager().createGroup("Offices", ORGANIZATION_UNIT);
+ Group employeesOU = session.getPersistenceManager().createGroup("Employees", ORGANIZATION_UNIT);
+
+ session.getRelationshipManager().associateGroups(acmeOrg, departmentsOU);
+ session.getRelationshipManager().associateGroups(acmeOrg, officesOU);
+ session.getRelationshipManager().associateGroups(acmeOrg, employeesOU);
+
+ // Departments
+
+ Group hrDepart = session.getPersistenceManager().createGroup("HR", DEPARTMENT);
+ Group financeDepart = session.getPersistenceManager().createGroup("Finance", DEPARTMENT);
+ Group rndDepart = session.getPersistenceManager().createGroup("R&D", DEPARTMENT);
+
+ session.getRelationshipManager().associateGroups(departmentsOU, hrDepart);
+ session.getRelationshipManager().associateGroups(departmentsOU, financeDepart);
+ session.getRelationshipManager().associateGroups(departmentsOU, rndDepart);
+
+ // Offices
+
+ Group parisOffice =session.getPersistenceManager().createGroup("Paris", OFFICE);
+ Group londonOffice =session.getPersistenceManager().createGroup("London", OFFICE);
+ Group nyOffice =session.getPersistenceManager().createGroup("New York", OFFICE);
+
+ session.getRelationshipManager().associateGroups(officesOU, parisOffice);
+ session.getRelationshipManager().associateGroups(officesOU, londonOffice);
+ session.getRelationshipManager().associateGroups(officesOU, nyOffice);
+
+ // People
+
+ Identity anneUser = session.getPersistenceManager().createIdentity("anne");
+ Identity marieUser = session.getPersistenceManager().createIdentity("marie");
+ Identity eveUser = session.getPersistenceManager().createIdentity("eve");
+ Identity angelinaUser = session.getPersistenceManager().createIdentity("angelina");
+ Identity joannaUser = session.getPersistenceManager().createIdentity("joanna");
+ Identity merilUser = session.getPersistenceManager().createIdentity("meril");
+ Identity johnUser = session.getPersistenceManager().createIdentity("john");
+ Identity stanUser = session.getPersistenceManager().createIdentity("stan");
+ Identity chrisUser = session.getPersistenceManager().createIdentity("chris");
+ Identity billUser = session.getPersistenceManager().createIdentity("bill");
+ Identity jackUser = session.getPersistenceManager().createIdentity("jack");
+
+ // All users are under people root
+
+ session.getRelationshipManager().associateIdentities(usersROOTGroup, anneUser);
+ session.getRelationshipManager().associateIdentities(usersROOTGroup, marieUser);
+ session.getRelationshipManager().associateIdentities(usersROOTGroup, eveUser);
+ session.getRelationshipManager().associateIdentities(usersROOTGroup, angelinaUser);
+ session.getRelationshipManager().associateIdentities(usersROOTGroup, joannaUser);
+ session.getRelationshipManager().associateIdentities(usersROOTGroup, merilUser);
+ session.getRelationshipManager().associateIdentities(usersROOTGroup, johnUser);
+ session.getRelationshipManager().associateIdentities(usersROOTGroup, stanUser);
+ session.getRelationshipManager().associateIdentities(usersROOTGroup, chrisUser);
+ session.getRelationshipManager().associateIdentities(usersROOTGroup, billUser);
+ session.getRelationshipManager().associateIdentities(usersROOTGroup, jackUser);
+
+
+ //
+
+
+ // Anna is...
+
+ // Anna Smith...
+
+
+ session.getAttributesManager().addAttribute(anneUser, P3PConstants.INFO_USER_NAME_GIVEN, "Anne");
+ session.getAttributesManager().addAttribute(anneUser, P3PConstants.INFO_USER_NAME_FAMILY, "Smith");
+ session.getAttributesManager().addAttribute(anneUser, P3PConstants.INFO_USER_JOB_TITLE, "Senior Software Developer");
+ session.getAttributesManager().addAttribute(anneUser, P3PConstants.INFO_USER_BUSINESS_INFO_ONLINE_EMAIL, "anne.smith at acme.com");
+ session.getAttributesManager().addAttribute(anneUser, P3PConstants.INFO_USER_BUSINESS_INFO_TELECOM_MOBILE_NUMBER, "777 777 777 7 77");
+
+ // Anna works in Paris office and participates in BASE jumping community as a forum moderator and CMS admin
+
+ session.getRelationshipManager().associateIdentities(parisOffice, anneUser);
+
+ // Anne could be just associated with BASE jumping community group using RelationshipManager but insted Role mechanism
+ // is used to have more fine grained control of access rights inside of a community
+
+ session.getRoleManager().createRole(communityMemberRT, anneUser, baseJumpingCommunity);
+ session.getRoleManager().createRole(communityForumModeratorRT, anneUser, baseJumpingCommunity);
+ session.getRoleManager().createRole(communityCMSAdminRT, anneUser, baseJumpingCommunity);
+
+ // Anne belongs to CMS portal admins security group
+
+ session.getRelationshipManager().associateIdentities(cmsAdminGroup, anneUser);
+
+ // Ann is also an owner of geeks community
+
+ session.getRoleManager().createRole(communityOwnerRT, anneUser, geeksCommunity);
+
+
+ //
+
+
+ // Angelina ...
+
+ session.getAttributesManager().addAttribute(angelinaUser, P3PConstants.INFO_USER_NAME_GIVEN, "Angelina");
+ session.getAttributesManager().addAttribute(angelinaUser, P3PConstants.INFO_USER_NAME_FAMILY, "Blond");
+ session.getAttributesManager().addAttribute(angelinaUser, P3PConstants.INFO_USER_JOB_TITLE, "Very important looking job title");
+ session.getAttributesManager().addAttribute(angelinaUser, P3PConstants.INFO_USER_BUSINESS_INFO_ONLINE_EMAIL, "angelina1979 at acme.com");
+ session.getAttributesManager().addAttribute(angelinaUser, P3PConstants.INFO_USER_BUSINESS_INFO_TELECOM_MOBILE_NUMBER, "888 88 88 8888");
+
+ // She works in London and is office manager there - se both RelationshipManager and RoleManager used against
+ // the same pair of identity objects
+
+ session.getRelationshipManager().associateIdentities(londonOffice, angelinaUser);
+
+ session.getRoleManager().createRole(officeManagerRT, angelinaUser, londonOffice);
+
+ // Angelina is member of geeks community and manages cms content there
+
+ session.getRoleManager().createRole(communityMemberRT, angelinaUser, geeksCommunity);
+ session.getRoleManager().createRole(communityCMSAdminRT, angelinaUser, geeksCommunity);
+
+ // As office manager she also edits portal cms content
+
+ session.getRelationshipManager().associateIdentities(cmsEditorGroup, angelinaUser);
+
+
+ //
+
+
+ // Some assertions
+
+ // How many users do we have in whole acme org and how many people in paris and london offices
+ assertEquals(11, session.getRelationshipManager().findAssociatedIdentities(usersROOTGroup, false).size());
+ assertEquals(1, session.getRelationshipManager().findAssociatedIdentities(parisOffice, false).size());
+ assertEquals(1, session.getRelationshipManager().findAssociatedIdentities(londonOffice, false).size());
+
+
+ // Is anne geeks community owner?
+ assertTrue(session.getRoleManager().hasRole(anneUser, geeksCommunity, communityOwnerRT));
+
+ // Does she belong to cms admins
+ assertTrue(session.getRelationshipManager().isAssociated(cmsAdminGroup, anneUser));
+
+ // Check all groups that anna belongs to
+ Collection<Group> groups = session.getRelationshipManager().findAssociatedGroups(anneUser);
+ assertEquals(3, groups.size());
+ assertTrue(groups.contains(usersROOTGroup));
+ assertTrue(groups.contains(parisOffice));
+ assertTrue(groups.contains(cmsAdminGroup));
+
+
+
+ session.getTransaction().commit();
+
+ }
+
+
+
+
+
+
+
+}
Modified: trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/configuration/ConfigurationTestCase.java
===================================================================
--- trunk/identity-impl/src/test/java/org/jboss/identity/impl/configuration/ConfigurationTestCase.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/configuration/ConfigurationTestCase.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,14 +20,14 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.configuration;
+package org.jboss.identity.idm.impl.configuration;
import junit.framework.TestCase;
import java.io.File;
-import org.jboss.identity.impl.configuration.jaxb2.JAXB2IdentityConfiguration;
-import org.jboss.identity.spi.configuration.metadata.IdentityConfigurationMetaData;
+import org.jboss.identity.idm.impl.configuration.jaxb2.JAXB2IdentityConfiguration;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityConfigurationMetaData;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Modified: trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/fedid/PseudonymGeneratorUnitTestCase.java
===================================================================
--- trunk/identity-impl/src/test/java/org/jboss/identity/impl/fedid/PseudonymGeneratorUnitTestCase.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/fedid/PseudonymGeneratorUnitTestCase.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -19,10 +19,10 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.fedid;
+package org.jboss.identity.idm.impl.fedid;
-import org.jboss.identity.impl.fedid.UUIDPseudonymGenerator;
-import org.jboss.identity.spi.fedid.PseudonymGenerator;
+import org.jboss.identity.idm.impl.fedid.UUIDPseudonymGenerator;
+import org.jboss.identity.idm.spi.fedid.PseudonymGenerator;
import junit.framework.TestCase;
Deleted: trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/store/CommonIdentityStoreTest.java
===================================================================
--- trunk/identity-impl/src/test/java/org/jboss/identity/impl/store/CommonIdentityStoreTest.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/store/CommonIdentityStoreTest.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,528 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.store;
-
-import org.jboss.identity.spi.model.IdentityObject;
-import org.jboss.identity.spi.model.IdentityObjectCredential;
-import org.jboss.identity.spi.model.IdentityObjectAttribute;
-import org.jboss.identity.spi.searchcontrol.IdentityObjectSearchControl;
-import org.jboss.identity.impl.api.PasswordCredential;
-import org.jboss.identity.impl.api.BinaryCredential;
-import org.jboss.identity.impl.api.NameFilterSearchControl;
-import org.jboss.identity.impl.api.SortByNameSearchControl;
-import org.jboss.identity.impl.api.AttributeFilterSearchControl;
-import org.jboss.identity.impl.api.PageSearchControl;
-import org.jboss.identity.impl.api.SimpleAttributeImpl;
-import org.jboss.identity.api.Attribute;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Random;
-import java.util.List;
-
-import junit.framework.Assert;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class CommonIdentityStoreTest extends Assert
-{
-
- IdentityStoreTestContext testContext;
-
- public CommonIdentityStoreTest(IdentityStoreTestContext context)
- {
- this.testContext = context;
- }
-
- public void setTestContext(IdentityStoreTestContext testContext)
- {
- this.testContext = testContext;
- }
-
- public IdentityStoreTestContext getTestContext()
- {
- return testContext;
- }
-
- public void testStorePersistence() throws Exception
- {
-
- testContext.begin();
-
- IdentityObject user1 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Adam", IdentityTypeEnum.IDENTITY);
- IdentityObject user2 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Eva", IdentityTypeEnum.IDENTITY);
-
- IdentityObject group1 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Devision1", IdentityTypeEnum.ORGANIZATION);
- IdentityObject group2 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Devision2", IdentityTypeEnum.ORGANIZATION);
- IdentityObject group3 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Devision3", IdentityTypeEnum.ORGANIZATION);
- IdentityObject group4 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Devision4", IdentityTypeEnum.ORGANIZATION);
-
- testContext.flush();
-
- assertEquals(0, testContext.getStore().getIdentityObjectsCount(testContext.getCtx(), IdentityTypeEnum.ROLE));
- assertEquals(2, testContext.getStore().getIdentityObjectsCount(testContext.getCtx(), IdentityTypeEnum.IDENTITY));
- assertEquals(4, testContext.getStore().getIdentityObjectsCount(testContext.getCtx(), IdentityTypeEnum.ORGANIZATION));
-
- testContext.flush();
-
- testContext.getStore().removeIdentityObject(testContext.getCtx(), user1);
- testContext.getStore().removeIdentityObject(testContext.getCtx(), group1);
- testContext.getStore().removeIdentityObject(testContext.getCtx(), group2);
-
- assertEquals(1, testContext.getStore().getIdentityObjectsCount(testContext.getCtx(), IdentityTypeEnum.IDENTITY));
- assertEquals(2, testContext.getStore().getIdentityObjectsCount(testContext.getCtx(), IdentityTypeEnum.ORGANIZATION));
-
- testContext.getStore().removeIdentityObject(testContext.getCtx(), user2);
- testContext.getStore().removeIdentityObject(testContext.getCtx(), group3);
- testContext.getStore().removeIdentityObject(testContext.getCtx(), group4);
-
- assertEquals(0, testContext.getStore().getIdentityObjectsCount(testContext.getCtx(), IdentityTypeEnum.IDENTITY));
- assertEquals(0, testContext.getStore().getIdentityObjectsCount(testContext.getCtx(), IdentityTypeEnum.ORGANIZATION));
-
- testContext.commit();
-
- }
-
- public void testFindMethods() throws Exception
- {
-
- testContext.begin();
-
- IdentityObject user1 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Adam", IdentityTypeEnum.IDENTITY);
- IdentityObject user2 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Eva", IdentityTypeEnum.IDENTITY);
-
- IdentityObject group1 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Devision1", IdentityTypeEnum.ORGANIZATION);
- IdentityObject group2 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Devision2", IdentityTypeEnum.ORGANIZATION);
- IdentityObject group3 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Devision3", IdentityTypeEnum.ORGANIZATION);
- IdentityObject group4 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Devision4", IdentityTypeEnum.ORGANIZATION);
-
- testContext.flush();
-
- IdentityObject xx = testContext.getStore().findIdentityObject(testContext.getCtx(), "Adam", IdentityTypeEnum.IDENTITY);
- assertEquals(xx.getId(), user1.getId());
-
- xx = testContext.getStore().findIdentityObject(testContext.getCtx(), user2.getId());
- assertEquals(xx.getId(), user2.getId());
-
- Collection results = testContext.getStore().findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, null);
- assertEquals(2, results.size());
-
- results = testContext.getStore().findIdentityObject(testContext.getCtx(), IdentityTypeEnum.ORGANIZATION, null);
- assertEquals(4, results.size());
-
- results = testContext.getStore().findIdentityObject(testContext.getCtx(), IdentityTypeEnum.ROLE, null);
- assertEquals(0, results.size());
-
-
- testContext.commit();
-
- }
-
- public void testAttributes() throws Exception
- {
-
- testContext.begin();
-
- IdentityObject user1 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Adam", IdentityTypeEnum.IDENTITY);
- IdentityObject user2 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Eva", IdentityTypeEnum.IDENTITY);
-
- testContext.flush();
-
- //Map<String, String[]> attrs = new HashMap<String, String[]>();
- IdentityObjectAttribute[] attrs = new IdentityObjectAttribute[]{
- new SimpleAttributeImpl("key1", new String[]{"val1", "val2", "val3"}),
- new SimpleAttributeImpl("key2", new String[]{"val1", "val2", "val3", "val4"})
- };
-
- testContext.getStore().addAttributes(testContext.getCtx(), user1, attrs);
-
- testContext.flush();
-
- Map<String, IdentityObjectAttribute> persistedAttrs = testContext.getStore().getAttributes(testContext.getCtx(), user1);
-
- assertEquals(2, persistedAttrs.keySet().size());
-
- assertTrue(persistedAttrs.containsKey("key1"));
- assertEquals(3, persistedAttrs.get("key1").getSize());
-
- assertTrue(persistedAttrs.containsKey("key2"));
- assertEquals(4, persistedAttrs.get("key2").getSize());
-
- testContext.flush();
-
- attrs = new IdentityObjectAttribute[]{
- new SimpleAttributeImpl("key3", new String[]{"val1"})
- };
-
- testContext.getStore().addAttributes(testContext.getCtx(), user1, attrs);
-
- testContext.flush();
-
- persistedAttrs = testContext.getStore().getAttributes(testContext.getCtx(), user1);
-
- assertEquals(3, persistedAttrs.keySet().size());
-
- assertTrue(persistedAttrs.containsKey("key1"));
- assertEquals(3, persistedAttrs.get("key1").getSize());
-
- assertTrue(persistedAttrs.containsKey("key2"));
- assertEquals(4, persistedAttrs.get("key2").getSize());
-
- assertTrue(persistedAttrs.containsKey("key3"));
- assertEquals(1, persistedAttrs.get("key3").getSize());
-
- testContext.flush();
-
- attrs = new IdentityObjectAttribute[]{
- new SimpleAttributeImpl("key3", new String[]{"val2"})
- };
-
- testContext.getStore().addAttributes(testContext.getCtx(), user1, attrs);
-
- testContext.flush();
-
- persistedAttrs = testContext.getStore().getAttributes(testContext.getCtx(), user1);
-
- assertEquals(3, persistedAttrs.keySet().size());
-
- assertTrue(persistedAttrs.containsKey("key3"));
- assertEquals(2, persistedAttrs.get("key3").getSize());
-
- testContext.flush();
-
- testContext.getStore().updateAttributes(testContext.getCtx(), user1, attrs);
-
- testContext.flush();
-
- persistedAttrs = testContext.getStore().getAttributes(testContext.getCtx(), user1);
-
- assertEquals(3, persistedAttrs.keySet().size());
-
- assertTrue(persistedAttrs.containsKey("key3"));
- assertEquals(1, persistedAttrs.get("key3").getSize());
-
- testContext.flush();
-
- testContext.getStore().removeAttributes(testContext.getCtx(), user1, new String[] {"key3"});
-
- testContext.flush();
-
- persistedAttrs = testContext.getStore().getAttributes(testContext.getCtx(), user1);
-
- assertEquals(2, persistedAttrs.keySet().size());
-
-
- testContext.commit();
-
- }
-
- public void testRelationships() throws Exception
- {
-
- testContext.begin();
-
- IdentityObject user1 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Adam", IdentityTypeEnum.IDENTITY);
- IdentityObject user2 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Eva", IdentityTypeEnum.IDENTITY);
-
- IdentityObject group1 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Devision1", IdentityTypeEnum.ORGANIZATION);
- IdentityObject group2 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Devision2", IdentityTypeEnum.ORGANIZATION);
- IdentityObject group3 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Devision3", IdentityTypeEnum.ORGANIZATION);
- IdentityObject group4 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Devision4", IdentityTypeEnum.ORGANIZATION);
-
- testContext.flush();
-
- testContext.getStore().createRelationship(testContext.getCtx(), group1, user1, RelationshipTypeEnum.JBOSS_IDENTITY_MEMBERSHIP, null, false);
- testContext.getStore().createRelationship(testContext.getCtx(), group2, user1, RelationshipTypeEnum.JBOSS_IDENTITY_MEMBERSHIP, null, false);
-
- testContext.flush();
-
- assertEquals(1, testContext.getStore().resolveRelationships(testContext.getCtx(), group1, user1, null).size());
- assertEquals(0, testContext.getStore().resolveRelationships(testContext.getCtx(), user1, group1, null).size());
- assertEquals(1, testContext.getStore().resolveRelationships(testContext.getCtx(), group2, user1, null).size());
- assertEquals(0, testContext.getStore().resolveRelationships(testContext.getCtx(), user1, group2, null).size());
-
- testContext.getStore().removeRelationship(testContext.getCtx(), group2, user1, RelationshipTypeEnum.JBOSS_IDENTITY_MEMBERSHIP, null);
-
- testContext.flush();
-
- assertEquals(1, testContext.getStore().resolveRelationships(testContext.getCtx(), group1, user1, null).size());
- assertEquals(0, testContext.getStore().resolveRelationships(testContext.getCtx(), user1, group1, null).size());
- assertEquals(0, testContext.getStore().resolveRelationships(testContext.getCtx(), group2, user1, null).size());
- assertEquals(0, testContext.getStore().resolveRelationships(testContext.getCtx(), user1, group2, null).size());
-
- testContext.getStore().removeRelationships(testContext.getCtx(), user1, group1, false);
-
- assertEquals(0, testContext.getStore().resolveRelationships(testContext.getCtx(), group1, user1, null).size());
- assertEquals(0, testContext.getStore().resolveRelationships(testContext.getCtx(), user1, group1, null).size());
- assertEquals(0, testContext.getStore().resolveRelationships(testContext.getCtx(), group2, user1, null).size());
- assertEquals(0, testContext.getStore().resolveRelationships(testContext.getCtx(), user1, group2, null).size());
-
- testContext.flush();
-
- // test find methods with relationships
-
- testContext.getStore().createRelationship(testContext.getCtx(), group1, user1, RelationshipTypeEnum.JBOSS_IDENTITY_MEMBERSHIP, null, false);
- testContext.getStore().createRelationship(testContext.getCtx(), group1, user2, RelationshipTypeEnum.JBOSS_IDENTITY_MEMBERSHIP, null, false);
-
- testContext.flush();
-
- assertEquals(2, testContext.getStore().findIdentityObject(testContext.getCtx(), group1, RelationshipTypeEnum.JBOSS_IDENTITY_MEMBERSHIP, true, null).size());
- assertEquals(0, testContext.getStore().findIdentityObject(testContext.getCtx(), group1, RelationshipTypeEnum.JBOSS_IDENTITY_MEMBERSHIP, false, null).size());
- assertEquals(1, testContext.getStore().findIdentityObject(testContext.getCtx(), user1, RelationshipTypeEnum.JBOSS_IDENTITY_MEMBERSHIP, false, null).size());
- assertEquals(1, testContext.getStore().findIdentityObject(testContext.getCtx(), user2, RelationshipTypeEnum.JBOSS_IDENTITY_MEMBERSHIP, false, null).size());
- assertEquals(0, testContext.getStore().findIdentityObject(testContext.getCtx(), group2, RelationshipTypeEnum.JBOSS_IDENTITY_MEMBERSHIP, false, null).size());
- assertEquals(0, testContext.getStore().findIdentityObject(testContext.getCtx(), group2, RelationshipTypeEnum.JBOSS_IDENTITY_MEMBERSHIP, true, null).size());
-
- testContext.commit();
-
- }
-
- public void testPasswordCredential() throws Exception
- {
- testContext.begin();
-
- IdentityObject user1 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Adam", IdentityTypeEnum.IDENTITY);
- IdentityObject user2 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Eva", IdentityTypeEnum.IDENTITY);
-
- IdentityObjectCredential passwordCredential1 = new PasswordCredential("SamplePasswordOne");
- IdentityObjectCredential passwordCredential2 = new PasswordCredential("SamplePasswordTwo");
-
- // If PASSWORD is supported
- assertTrue(testContext.getStore().getSupportedFeatures().isCredentialSupported(IdentityTypeEnum.IDENTITY, passwordCredential1.getType()));
-
- testContext.getStore().updateCredential(testContext.getCtx(), user1, passwordCredential1);
- testContext.getStore().updateCredential(testContext.getCtx(), user2, passwordCredential2);
-
- assertTrue(testContext.getStore().validateCredential(testContext.getCtx(), user1, passwordCredential1));
- assertTrue(testContext.getStore().validateCredential(testContext.getCtx(), user2, passwordCredential2));
- assertFalse(testContext.getStore().validateCredential(testContext.getCtx(), user1, passwordCredential2));
- assertFalse(testContext.getStore().validateCredential(testContext.getCtx(), user2, passwordCredential1));
-
- testContext.commit();
- }
-
- public void testBinaryCredential() throws Exception
- {
- testContext.begin();
-
- IdentityObject user1 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Adam2", IdentityTypeEnum.IDENTITY);
- IdentityObject user2 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Eva2", IdentityTypeEnum.IDENTITY);
-
- Random random = new Random();
-
- byte[] data1 = new byte[5120];
- random.nextBytes(data1);
- byte[] data2 = new byte[1024];
- random.nextBytes(data2);
-
- IdentityObjectCredential binaryCredential1 = new BinaryCredential(data1);
- IdentityObjectCredential binaryCredential2 = new BinaryCredential(data2);
-
-
- // If BINARY is supported
- assertTrue(testContext.getStore().getSupportedFeatures().isCredentialSupported(IdentityTypeEnum.IDENTITY, binaryCredential1.getType()));
-
- testContext.getStore().updateCredential(testContext.getCtx(), user1, binaryCredential1);
- testContext.getStore().updateCredential(testContext.getCtx(), user2, binaryCredential2);
-
- assertTrue(testContext.getStore().validateCredential(testContext.getCtx(), user1, binaryCredential1));
- assertTrue(testContext.getStore().validateCredential(testContext.getCtx(), user2, binaryCredential2));
- assertFalse(testContext.getStore().validateCredential(testContext.getCtx(), user1, binaryCredential2));
- assertFalse(testContext.getStore().validateCredential(testContext.getCtx(), user2, binaryCredential1));
-
- testContext.commit();
- }
-
-
-
-
- public void testControls() throws Exception
- {
- testContext.begin();
-
- IdentityObject group1 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Division1", IdentityTypeEnum.IDENTITY);
- IdentityObject group2 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Division2", IdentityTypeEnum.IDENTITY);
- IdentityObject group3 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Division3", IdentityTypeEnum.IDENTITY);
- IdentityObject group4 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Company1", IdentityTypeEnum.IDENTITY);
- IdentityObject group5 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Company2", IdentityTypeEnum.IDENTITY);
- IdentityObject group6 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Entity1", IdentityTypeEnum.IDENTITY);
- IdentityObject group7 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Entity2", IdentityTypeEnum.IDENTITY);
- IdentityObject group8 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Entity3", IdentityTypeEnum.IDENTITY);
-
- Collection<IdentityObject> results = null;
- IdentityObjectSearchControl control = null;
-
- // TODO: by RelationshipType
-
- if (testContext.getStore().getSupportedFeatures().isControlSupported(IdentityTypeEnum.IDENTITY, NameFilterSearchControl.class))
- {
- control = new NameFilterSearchControl("*");
-
- results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new IdentityObjectSearchControl[]{control});
-
- assertEquals(8, results.size());
-
- control = new NameFilterSearchControl("D*");
-
- results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new IdentityObjectSearchControl[]{control});
-
- assertEquals(3, results.size());
-
- control = new NameFilterSearchControl("*2");
-
- results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new IdentityObjectSearchControl[]{control});
-
- assertEquals(3, results.size());
-
- control = new NameFilterSearchControl("*3");
-
- results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new IdentityObjectSearchControl[]{control});
-
- assertEquals(2, results.size());
-
- control = new NameFilterSearchControl("Company1");
-
- results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new IdentityObjectSearchControl[]{control});
-
- assertEquals(1, results.size());
-
- control = new NameFilterSearchControl("Totoro");
-
- results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new IdentityObjectSearchControl[]{control});
-
- assertEquals(0, results.size());
- }
-
-
- if (testContext.getStore().getSupportedFeatures().isControlSupported(IdentityTypeEnum.IDENTITY, PageSearchControl.class))
- {
-
- control = new PageSearchControl(0, 3);
-
- results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new IdentityObjectSearchControl[]{control});
-
- assertEquals(3, results.size());
-
- control = new PageSearchControl(2, 2);
-
- results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new IdentityObjectSearchControl[]{control});
-
- assertEquals(2, results.size());
-
- }
- if (testContext.getStore().getSupportedFeatures().isControlSupported(IdentityTypeEnum.IDENTITY, SortByNameSearchControl.class))
- {
-
-
- control = new SortByNameSearchControl(true);
-
- results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new IdentityObjectSearchControl[]{control});
-
- assertEquals(8, results.size());
-
- // Just check the first and the last one
- assertEquals("Company1", ((List<IdentityObject>)results).get(0).getName());
- assertEquals("Entity3", ((List<IdentityObject>)results).get(7).getName());
-
-
- // And reverse order
- control = new SortByNameSearchControl(false);
-
- results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new IdentityObjectSearchControl[]{control});
-
- assertEquals(8, results.size());
-
- // Just check the first and the last one
- assertEquals("Company1", ((List<IdentityObject>)results).get(7).getName());
- assertEquals("Entity3", ((List<IdentityObject>)results).get(0).getName());
-
-
-
-
-
- // Combine controls to check that the results are diffrent for pagination
- if (testContext.getStore().getSupportedFeatures().isControlSupported(IdentityTypeEnum.IDENTITY, PageSearchControl.class))
- {
- control = new SortByNameSearchControl(true);
- IdentityObjectSearchControl control2 = new PageSearchControl(0, 3);
-
- results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new IdentityObjectSearchControl[]{control, control2});
-
- assertEquals(3, results.size());
- assertEquals("Company1", ((List<IdentityObject>)results).get(0).getName());
- assertEquals("Division1", ((List<IdentityObject>)results).get(2).getName());
-
- control2 = new PageSearchControl(3, 1);
-
- results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new IdentityObjectSearchControl[]{control, control2});
-
- assertEquals(1, results.size());
-
- assertEquals(1, results.size());
- assertEquals("Division2", ((List<IdentityObject>)results).get(0).getName());
-
- }
-
- }
-
- if (testContext.getStore().getSupportedFeatures().isControlSupported(IdentityTypeEnum.IDENTITY, AttributeFilterSearchControl.class))
- {
- Map<String, String[]> attrs = new HashMap<String, String[]>();
- attrs.put("phone", new String[] {"777 777 777"});
- attrs.put("description", new String[] {"sample desc"});
-
- IdentityObjectAttribute phone = new SimpleAttributeImpl("phone", new String[] {"777 777 777"});
- IdentityObjectAttribute description = new SimpleAttributeImpl("description", new String[] {"sample desc"});
-
- testContext.getStore().addAttributes(testContext.getCtx(), group1, new IdentityObjectAttribute[]{phone, description});
-
- control = new AttributeFilterSearchControl(attrs);
-
- results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new IdentityObjectSearchControl[]{control});
-
- assertEquals(1, results.size());
-
- }
-
- testContext.commit();
-
- }
-
-
-}
\ No newline at end of file
Copied: trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/store/CommonIdentityStoreTest.java (from rev 211, trunk/identity-impl/src/test/java/org/jboss/identity/impl/store/CommonIdentityStoreTest.java)
===================================================================
--- trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/store/CommonIdentityStoreTest.java (rev 0)
+++ trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/store/CommonIdentityStoreTest.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,527 @@
+/*
+* 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.store;
+
+import org.jboss.identity.idm.spi.model.IdentityObject;
+import org.jboss.identity.idm.spi.model.IdentityObjectCredential;
+import org.jboss.identity.idm.spi.model.IdentityObjectAttribute;
+import org.jboss.identity.idm.spi.searchcontrol.IdentityObjectSearchControl;
+import org.jboss.identity.idm.impl.api.PasswordCredential;
+import org.jboss.identity.idm.impl.api.BinaryCredential;
+import org.jboss.identity.idm.impl.api.NameFilterSearchControl;
+import org.jboss.identity.idm.impl.api.SortByNameSearchControl;
+import org.jboss.identity.idm.impl.api.AttributeFilterSearchControl;
+import org.jboss.identity.idm.impl.api.PageSearchControl;
+import org.jboss.identity.idm.impl.api.SimpleAttribute;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Random;
+import java.util.List;
+
+import junit.framework.Assert;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class CommonIdentityStoreTest extends Assert
+{
+
+ IdentityStoreTestContext testContext;
+
+ public CommonIdentityStoreTest(IdentityStoreTestContext context)
+ {
+ this.testContext = context;
+ }
+
+ public void setTestContext(IdentityStoreTestContext testContext)
+ {
+ this.testContext = testContext;
+ }
+
+ public IdentityStoreTestContext getTestContext()
+ {
+ return testContext;
+ }
+
+ public void testStorePersistence() throws Exception
+ {
+
+ testContext.begin();
+
+ IdentityObject user1 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Adam", IdentityTypeEnum.IDENTITY);
+ IdentityObject user2 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Eva", IdentityTypeEnum.IDENTITY);
+
+ IdentityObject group1 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Devision1", IdentityTypeEnum.ORGANIZATION);
+ IdentityObject group2 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Devision2", IdentityTypeEnum.ORGANIZATION);
+ IdentityObject group3 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Devision3", IdentityTypeEnum.ORGANIZATION);
+ IdentityObject group4 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Devision4", IdentityTypeEnum.ORGANIZATION);
+
+ testContext.flush();
+
+ assertEquals(0, testContext.getStore().getIdentityObjectsCount(testContext.getCtx(), IdentityTypeEnum.ROLE));
+ assertEquals(2, testContext.getStore().getIdentityObjectsCount(testContext.getCtx(), IdentityTypeEnum.IDENTITY));
+ assertEquals(4, testContext.getStore().getIdentityObjectsCount(testContext.getCtx(), IdentityTypeEnum.ORGANIZATION));
+
+ testContext.flush();
+
+ testContext.getStore().removeIdentityObject(testContext.getCtx(), user1);
+ testContext.getStore().removeIdentityObject(testContext.getCtx(), group1);
+ testContext.getStore().removeIdentityObject(testContext.getCtx(), group2);
+
+ assertEquals(1, testContext.getStore().getIdentityObjectsCount(testContext.getCtx(), IdentityTypeEnum.IDENTITY));
+ assertEquals(2, testContext.getStore().getIdentityObjectsCount(testContext.getCtx(), IdentityTypeEnum.ORGANIZATION));
+
+ testContext.getStore().removeIdentityObject(testContext.getCtx(), user2);
+ testContext.getStore().removeIdentityObject(testContext.getCtx(), group3);
+ testContext.getStore().removeIdentityObject(testContext.getCtx(), group4);
+
+ assertEquals(0, testContext.getStore().getIdentityObjectsCount(testContext.getCtx(), IdentityTypeEnum.IDENTITY));
+ assertEquals(0, testContext.getStore().getIdentityObjectsCount(testContext.getCtx(), IdentityTypeEnum.ORGANIZATION));
+
+ testContext.commit();
+
+ }
+
+ public void testFindMethods() throws Exception
+ {
+
+ testContext.begin();
+
+ IdentityObject user1 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Adam", IdentityTypeEnum.IDENTITY);
+ IdentityObject user2 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Eva", IdentityTypeEnum.IDENTITY);
+
+ IdentityObject group1 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Devision1", IdentityTypeEnum.ORGANIZATION);
+ IdentityObject group2 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Devision2", IdentityTypeEnum.ORGANIZATION);
+ IdentityObject group3 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Devision3", IdentityTypeEnum.ORGANIZATION);
+ IdentityObject group4 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Devision4", IdentityTypeEnum.ORGANIZATION);
+
+ testContext.flush();
+
+ IdentityObject xx = testContext.getStore().findIdentityObject(testContext.getCtx(), "Adam", IdentityTypeEnum.IDENTITY);
+ assertEquals(xx.getId(), user1.getId());
+
+ xx = testContext.getStore().findIdentityObject(testContext.getCtx(), user2.getId());
+ assertEquals(xx.getId(), user2.getId());
+
+ Collection results = testContext.getStore().findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, null);
+ assertEquals(2, results.size());
+
+ results = testContext.getStore().findIdentityObject(testContext.getCtx(), IdentityTypeEnum.ORGANIZATION, null);
+ assertEquals(4, results.size());
+
+ results = testContext.getStore().findIdentityObject(testContext.getCtx(), IdentityTypeEnum.ROLE, null);
+ assertEquals(0, results.size());
+
+
+ testContext.commit();
+
+ }
+
+ public void testAttributes() throws Exception
+ {
+
+ testContext.begin();
+
+ IdentityObject user1 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Adam", IdentityTypeEnum.IDENTITY);
+ IdentityObject user2 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Eva", IdentityTypeEnum.IDENTITY);
+
+ testContext.flush();
+
+ //Map<String, String[]> attrs = new HashMap<String, String[]>();
+ IdentityObjectAttribute[] attrs = new IdentityObjectAttribute[]{
+ new SimpleAttribute("key1", new String[]{"val1", "val2", "val3"}),
+ new SimpleAttribute("key2", new String[]{"val1", "val2", "val3", "val4"})
+ };
+
+ testContext.getStore().addAttributes(testContext.getCtx(), user1, attrs);
+
+ testContext.flush();
+
+ Map<String, IdentityObjectAttribute> persistedAttrs = testContext.getStore().getAttributes(testContext.getCtx(), user1);
+
+ assertEquals(2, persistedAttrs.keySet().size());
+
+ assertTrue(persistedAttrs.containsKey("key1"));
+ assertEquals(3, persistedAttrs.get("key1").getSize());
+
+ assertTrue(persistedAttrs.containsKey("key2"));
+ assertEquals(4, persistedAttrs.get("key2").getSize());
+
+ testContext.flush();
+
+ attrs = new IdentityObjectAttribute[]{
+ new SimpleAttribute("key3", new String[]{"val1"})
+ };
+
+ testContext.getStore().addAttributes(testContext.getCtx(), user1, attrs);
+
+ testContext.flush();
+
+ persistedAttrs = testContext.getStore().getAttributes(testContext.getCtx(), user1);
+
+ assertEquals(3, persistedAttrs.keySet().size());
+
+ assertTrue(persistedAttrs.containsKey("key1"));
+ assertEquals(3, persistedAttrs.get("key1").getSize());
+
+ assertTrue(persistedAttrs.containsKey("key2"));
+ assertEquals(4, persistedAttrs.get("key2").getSize());
+
+ assertTrue(persistedAttrs.containsKey("key3"));
+ assertEquals(1, persistedAttrs.get("key3").getSize());
+
+ testContext.flush();
+
+ attrs = new IdentityObjectAttribute[]{
+ new SimpleAttribute("key3", new String[]{"val2"})
+ };
+
+ testContext.getStore().addAttributes(testContext.getCtx(), user1, attrs);
+
+ testContext.flush();
+
+ persistedAttrs = testContext.getStore().getAttributes(testContext.getCtx(), user1);
+
+ assertEquals(3, persistedAttrs.keySet().size());
+
+ assertTrue(persistedAttrs.containsKey("key3"));
+ assertEquals(2, persistedAttrs.get("key3").getSize());
+
+ testContext.flush();
+
+ testContext.getStore().updateAttributes(testContext.getCtx(), user1, attrs);
+
+ testContext.flush();
+
+ persistedAttrs = testContext.getStore().getAttributes(testContext.getCtx(), user1);
+
+ assertEquals(3, persistedAttrs.keySet().size());
+
+ assertTrue(persistedAttrs.containsKey("key3"));
+ assertEquals(1, persistedAttrs.get("key3").getSize());
+
+ testContext.flush();
+
+ testContext.getStore().removeAttributes(testContext.getCtx(), user1, new String[] {"key3"});
+
+ testContext.flush();
+
+ persistedAttrs = testContext.getStore().getAttributes(testContext.getCtx(), user1);
+
+ assertEquals(2, persistedAttrs.keySet().size());
+
+
+ testContext.commit();
+
+ }
+
+ public void testRelationships() throws Exception
+ {
+
+ testContext.begin();
+
+ IdentityObject user1 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Adam", IdentityTypeEnum.IDENTITY);
+ IdentityObject user2 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Eva", IdentityTypeEnum.IDENTITY);
+
+ IdentityObject group1 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Devision1", IdentityTypeEnum.ORGANIZATION);
+ IdentityObject group2 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Devision2", IdentityTypeEnum.ORGANIZATION);
+ IdentityObject group3 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Devision3", IdentityTypeEnum.ORGANIZATION);
+ IdentityObject group4 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Devision4", IdentityTypeEnum.ORGANIZATION);
+
+ testContext.flush();
+
+ testContext.getStore().createRelationship(testContext.getCtx(), group1, user1, RelationshipTypeEnum.JBOSS_IDENTITY_MEMBERSHIP, null, false);
+ testContext.getStore().createRelationship(testContext.getCtx(), group2, user1, RelationshipTypeEnum.JBOSS_IDENTITY_MEMBERSHIP, null, false);
+
+ testContext.flush();
+
+ assertEquals(1, testContext.getStore().resolveRelationships(testContext.getCtx(), group1, user1, null).size());
+ assertEquals(0, testContext.getStore().resolveRelationships(testContext.getCtx(), user1, group1, null).size());
+ assertEquals(1, testContext.getStore().resolveRelationships(testContext.getCtx(), group2, user1, null).size());
+ assertEquals(0, testContext.getStore().resolveRelationships(testContext.getCtx(), user1, group2, null).size());
+
+ testContext.getStore().removeRelationship(testContext.getCtx(), group2, user1, RelationshipTypeEnum.JBOSS_IDENTITY_MEMBERSHIP, null);
+
+ testContext.flush();
+
+ assertEquals(1, testContext.getStore().resolveRelationships(testContext.getCtx(), group1, user1, null).size());
+ assertEquals(0, testContext.getStore().resolveRelationships(testContext.getCtx(), user1, group1, null).size());
+ assertEquals(0, testContext.getStore().resolveRelationships(testContext.getCtx(), group2, user1, null).size());
+ assertEquals(0, testContext.getStore().resolveRelationships(testContext.getCtx(), user1, group2, null).size());
+
+ testContext.getStore().removeRelationships(testContext.getCtx(), user1, group1, false);
+
+ assertEquals(0, testContext.getStore().resolveRelationships(testContext.getCtx(), group1, user1, null).size());
+ assertEquals(0, testContext.getStore().resolveRelationships(testContext.getCtx(), user1, group1, null).size());
+ assertEquals(0, testContext.getStore().resolveRelationships(testContext.getCtx(), group2, user1, null).size());
+ assertEquals(0, testContext.getStore().resolveRelationships(testContext.getCtx(), user1, group2, null).size());
+
+ testContext.flush();
+
+ // test find methods with relationships
+
+ testContext.getStore().createRelationship(testContext.getCtx(), group1, user1, RelationshipTypeEnum.JBOSS_IDENTITY_MEMBERSHIP, null, false);
+ testContext.getStore().createRelationship(testContext.getCtx(), group1, user2, RelationshipTypeEnum.JBOSS_IDENTITY_MEMBERSHIP, null, false);
+
+ testContext.flush();
+
+ assertEquals(2, testContext.getStore().findIdentityObject(testContext.getCtx(), group1, RelationshipTypeEnum.JBOSS_IDENTITY_MEMBERSHIP, true, null).size());
+ assertEquals(0, testContext.getStore().findIdentityObject(testContext.getCtx(), group1, RelationshipTypeEnum.JBOSS_IDENTITY_MEMBERSHIP, false, null).size());
+ assertEquals(1, testContext.getStore().findIdentityObject(testContext.getCtx(), user1, RelationshipTypeEnum.JBOSS_IDENTITY_MEMBERSHIP, false, null).size());
+ assertEquals(1, testContext.getStore().findIdentityObject(testContext.getCtx(), user2, RelationshipTypeEnum.JBOSS_IDENTITY_MEMBERSHIP, false, null).size());
+ assertEquals(0, testContext.getStore().findIdentityObject(testContext.getCtx(), group2, RelationshipTypeEnum.JBOSS_IDENTITY_MEMBERSHIP, false, null).size());
+ assertEquals(0, testContext.getStore().findIdentityObject(testContext.getCtx(), group2, RelationshipTypeEnum.JBOSS_IDENTITY_MEMBERSHIP, true, null).size());
+
+ testContext.commit();
+
+ }
+
+ public void testPasswordCredential() throws Exception
+ {
+ testContext.begin();
+
+ IdentityObject user1 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Adam", IdentityTypeEnum.IDENTITY);
+ IdentityObject user2 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Eva", IdentityTypeEnum.IDENTITY);
+
+ IdentityObjectCredential passwordCredential1 = new PasswordCredential("SamplePasswordOne");
+ IdentityObjectCredential passwordCredential2 = new PasswordCredential("SamplePasswordTwo");
+
+ // If PASSWORD is supported
+ assertTrue(testContext.getStore().getSupportedFeatures().isCredentialSupported(IdentityTypeEnum.IDENTITY, passwordCredential1.getType()));
+
+ testContext.getStore().updateCredential(testContext.getCtx(), user1, passwordCredential1);
+ testContext.getStore().updateCredential(testContext.getCtx(), user2, passwordCredential2);
+
+ assertTrue(testContext.getStore().validateCredential(testContext.getCtx(), user1, passwordCredential1));
+ assertTrue(testContext.getStore().validateCredential(testContext.getCtx(), user2, passwordCredential2));
+ assertFalse(testContext.getStore().validateCredential(testContext.getCtx(), user1, passwordCredential2));
+ assertFalse(testContext.getStore().validateCredential(testContext.getCtx(), user2, passwordCredential1));
+
+ testContext.commit();
+ }
+
+ public void testBinaryCredential() throws Exception
+ {
+ testContext.begin();
+
+ IdentityObject user1 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Adam2", IdentityTypeEnum.IDENTITY);
+ IdentityObject user2 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Eva2", IdentityTypeEnum.IDENTITY);
+
+ Random random = new Random();
+
+ byte[] data1 = new byte[5120];
+ random.nextBytes(data1);
+ byte[] data2 = new byte[1024];
+ random.nextBytes(data2);
+
+ IdentityObjectCredential binaryCredential1 = new BinaryCredential(data1);
+ IdentityObjectCredential binaryCredential2 = new BinaryCredential(data2);
+
+
+ // If BINARY is supported
+ assertTrue(testContext.getStore().getSupportedFeatures().isCredentialSupported(IdentityTypeEnum.IDENTITY, binaryCredential1.getType()));
+
+ testContext.getStore().updateCredential(testContext.getCtx(), user1, binaryCredential1);
+ testContext.getStore().updateCredential(testContext.getCtx(), user2, binaryCredential2);
+
+ assertTrue(testContext.getStore().validateCredential(testContext.getCtx(), user1, binaryCredential1));
+ assertTrue(testContext.getStore().validateCredential(testContext.getCtx(), user2, binaryCredential2));
+ assertFalse(testContext.getStore().validateCredential(testContext.getCtx(), user1, binaryCredential2));
+ assertFalse(testContext.getStore().validateCredential(testContext.getCtx(), user2, binaryCredential1));
+
+ testContext.commit();
+ }
+
+
+
+
+ public void testControls() throws Exception
+ {
+ testContext.begin();
+
+ IdentityObject group1 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Division1", IdentityTypeEnum.IDENTITY);
+ IdentityObject group2 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Division2", IdentityTypeEnum.IDENTITY);
+ IdentityObject group3 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Division3", IdentityTypeEnum.IDENTITY);
+ IdentityObject group4 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Company1", IdentityTypeEnum.IDENTITY);
+ IdentityObject group5 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Company2", IdentityTypeEnum.IDENTITY);
+ IdentityObject group6 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Entity1", IdentityTypeEnum.IDENTITY);
+ IdentityObject group7 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Entity2", IdentityTypeEnum.IDENTITY);
+ IdentityObject group8 = testContext.getStore().createIdentityObject(testContext.getCtx(), "Entity3", IdentityTypeEnum.IDENTITY);
+
+ Collection<IdentityObject> results = null;
+ IdentityObjectSearchControl control = null;
+
+ // TODO: by RelationshipType
+
+ if (testContext.getStore().getSupportedFeatures().isControlSupported(IdentityTypeEnum.IDENTITY, NameFilterSearchControl.class))
+ {
+ control = new NameFilterSearchControl("*");
+
+ results = testContext.getStore().
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new IdentityObjectSearchControl[]{control});
+
+ assertEquals(8, results.size());
+
+ control = new NameFilterSearchControl("D*");
+
+ results = testContext.getStore().
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new IdentityObjectSearchControl[]{control});
+
+ assertEquals(3, results.size());
+
+ control = new NameFilterSearchControl("*2");
+
+ results = testContext.getStore().
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new IdentityObjectSearchControl[]{control});
+
+ assertEquals(3, results.size());
+
+ control = new NameFilterSearchControl("*3");
+
+ results = testContext.getStore().
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new IdentityObjectSearchControl[]{control});
+
+ assertEquals(2, results.size());
+
+ control = new NameFilterSearchControl("Company1");
+
+ results = testContext.getStore().
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new IdentityObjectSearchControl[]{control});
+
+ assertEquals(1, results.size());
+
+ control = new NameFilterSearchControl("Totoro");
+
+ results = testContext.getStore().
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new IdentityObjectSearchControl[]{control});
+
+ assertEquals(0, results.size());
+ }
+
+
+ if (testContext.getStore().getSupportedFeatures().isControlSupported(IdentityTypeEnum.IDENTITY, PageSearchControl.class))
+ {
+
+ control = new PageSearchControl(0, 3);
+
+ results = testContext.getStore().
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new IdentityObjectSearchControl[]{control});
+
+ assertEquals(3, results.size());
+
+ control = new PageSearchControl(2, 2);
+
+ results = testContext.getStore().
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new IdentityObjectSearchControl[]{control});
+
+ assertEquals(2, results.size());
+
+ }
+ if (testContext.getStore().getSupportedFeatures().isControlSupported(IdentityTypeEnum.IDENTITY, SortByNameSearchControl.class))
+ {
+
+
+ control = new SortByNameSearchControl(true);
+
+ results = testContext.getStore().
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new IdentityObjectSearchControl[]{control});
+
+ assertEquals(8, results.size());
+
+ // Just check the first and the last one
+ assertEquals("Company1", ((List<IdentityObject>)results).get(0).getName());
+ assertEquals("Entity3", ((List<IdentityObject>)results).get(7).getName());
+
+
+ // And reverse order
+ control = new SortByNameSearchControl(false);
+
+ results = testContext.getStore().
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new IdentityObjectSearchControl[]{control});
+
+ assertEquals(8, results.size());
+
+ // Just check the first and the last one
+ assertEquals("Company1", ((List<IdentityObject>)results).get(7).getName());
+ assertEquals("Entity3", ((List<IdentityObject>)results).get(0).getName());
+
+
+
+
+
+ // Combine controls to check that the results are diffrent for pagination
+ if (testContext.getStore().getSupportedFeatures().isControlSupported(IdentityTypeEnum.IDENTITY, PageSearchControl.class))
+ {
+ control = new SortByNameSearchControl(true);
+ IdentityObjectSearchControl control2 = new PageSearchControl(0, 3);
+
+ results = testContext.getStore().
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new IdentityObjectSearchControl[]{control, control2});
+
+ assertEquals(3, results.size());
+ assertEquals("Company1", ((List<IdentityObject>)results).get(0).getName());
+ assertEquals("Division1", ((List<IdentityObject>)results).get(2).getName());
+
+ control2 = new PageSearchControl(3, 1);
+
+ results = testContext.getStore().
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new IdentityObjectSearchControl[]{control, control2});
+
+ assertEquals(1, results.size());
+
+ assertEquals(1, results.size());
+ assertEquals("Division2", ((List<IdentityObject>)results).get(0).getName());
+
+ }
+
+ }
+
+ if (testContext.getStore().getSupportedFeatures().isControlSupported(IdentityTypeEnum.IDENTITY, AttributeFilterSearchControl.class))
+ {
+ Map<String, String[]> attrs = new HashMap<String, String[]>();
+ attrs.put("phone", new String[] {"777 777 777"});
+ attrs.put("description", new String[] {"sample desc"});
+
+ IdentityObjectAttribute phone = new SimpleAttribute("phone", new String[] {"777 777 777"});
+ IdentityObjectAttribute description = new SimpleAttribute("description", new String[] {"sample desc"});
+
+ testContext.getStore().addAttributes(testContext.getCtx(), group1, new IdentityObjectAttribute[]{phone, description});
+
+ control = new AttributeFilterSearchControl(attrs);
+
+ results = testContext.getStore().
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY, new IdentityObjectSearchControl[]{control});
+
+ assertEquals(1, results.size());
+
+ }
+
+ testContext.commit();
+
+ }
+
+
+}
\ No newline at end of file
Modified: trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/store/IdentityStoreTestContext.java
===================================================================
--- trunk/identity-impl/src/test/java/org/jboss/identity/impl/store/IdentityStoreTestContext.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/store/IdentityStoreTestContext.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,12 +20,10 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.store;
+package org.jboss.identity.idm.impl.store;
-import org.jboss.identity.spi.store.IdentityStore;
-import org.jboss.identity.spi.store.IdentityStoreInvocationContext;
-import junit.framework.TestCase;
-import junit.framework.Assert;
+import org.jboss.identity.idm.spi.store.IdentityStore;
+import org.jboss.identity.idm.spi.store.IdentityStoreInvocationContext;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Modified: trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/store/IdentityTypeEnum.java
===================================================================
--- trunk/identity-impl/src/test/java/org/jboss/identity/impl/store/IdentityTypeEnum.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/store/IdentityTypeEnum.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,9 +20,9 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.store;
+package org.jboss.identity.idm.impl.store;
-import org.jboss.identity.spi.model.IdentityObjectType;
+import org.jboss.identity.idm.spi.model.IdentityObjectType;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Modified: trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/store/RelationshipTypeEnum.java
===================================================================
--- trunk/identity-impl/src/test/java/org/jboss/identity/impl/store/RelationshipTypeEnum.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/store/RelationshipTypeEnum.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -21,9 +21,9 @@
*/
-package org.jboss.identity.impl.store;
+package org.jboss.identity.idm.impl.store;
-import org.jboss.identity.spi.model.IdentityObjectRelationshipType;
+import org.jboss.identity.idm.spi.model.IdentityObjectRelationshipType;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Deleted: trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreTestCase.java
===================================================================
--- trunk/identity-impl/src/test/java/org/jboss/identity/impl/store/hibernate/HibernateIdentityStoreTestCase.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreTestCase.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,277 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.store.hibernate;
-
-import org.jboss.identity.spi.model.IdentityObject;
-import org.jboss.identity.spi.model.IdentityObjectAttribute;
-import org.jboss.identity.spi.store.IdentityStoreInvocationContext;
-import org.jboss.identity.spi.store.IdentityStore;
-import org.jboss.identity.spi.store.IdentityStoreSession;
-import org.jboss.identity.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
-import org.jboss.identity.spi.configuration.metadata.IdentityConfigurationMetaData;
-import org.jboss.identity.impl.store.hibernate.HibernateIdentityStoreImpl;
-import org.jboss.identity.impl.store.hibernate.HibernateTestBase;
-import org.jboss.identity.impl.store.IdentityTypeEnum;
-import org.jboss.identity.impl.store.CommonIdentityStoreTest;
-import org.jboss.identity.impl.store.IdentityStoreTestContext;
-import org.jboss.identity.impl.configuration.jaxb2.JAXB2IdentityConfiguration;
-import org.jboss.identity.impl.api.SimpleAttributeImpl;
-import org.jboss.identity.exception.IdentityException;
-import org.hibernate.ejb.HibernateEntityManager;
-
-import java.util.Map;
-import java.util.HashMap;
-import java.io.File;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class HibernateIdentityStoreTestCase extends HibernateTestBase implements IdentityStoreTestContext
-{
-
- protected HibernateIdentityStoreImpl store;
-
- protected IdentityStoreInvocationContext ctx;
-
- protected CommonIdentityStoreTest commonTest;
-
- public HibernateIdentityStoreTestCase(String testName)
- {
- super(testName);
- commonTest = new CommonIdentityStoreTest(this);
- }
-
-
-
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
-
- IdentityConfigurationMetaData configurationMD = JAXB2IdentityConfiguration
- .createConfigurationMetaData(new File("src/test/resources/store-test-config.xml"));
-
- IdentityStoreConfigurationMetaData storeMD = null;
-
- for (IdentityStoreConfigurationMetaData metaData : configurationMD.getIdentityStores())
- {
- if (metaData.getId().equals("HibernateTestStore"))
- {
- storeMD = metaData;
- break;
- }
- }
-
- store = new HibernateIdentityStoreImpl("HibernateTestStore")
- {
-
- protected HibernateEntityManager getHibernateEntityManager(IdentityStoreInvocationContext ctx)
- {
- return em;
- }
-
- @Override
- protected HibernateEntityManager bootstrapHibernateEntityManager(String persistenceUnit) throws IdentityException
- {
- return em;
- }
-
- };
-
- store.bootstrap(storeMD);
-
-
- ctx = new IdentityStoreInvocationContext()
- {
- public IdentityStoreSession getIdentityStoreSession()
- {
- return null;
- }
-
- public String getRealmId()
- {
- return "testRealm";
- }
- };
-
-
- }
-
- public void begin() throws Exception
- {
- em.getTransaction().begin();
-
- }
-
- public void commit() throws Exception
- {
- em.getTransaction().commit();
- }
-
- public void flush() throws Exception
- {
- em.flush();
- }
-
- public IdentityStore getStore()
- {
- return store;
- }
-
- public IdentityStoreInvocationContext getCtx()
- {
- return ctx;
- }
-
- // Tests
-
- public void testStorePersistence() throws Exception
- {
-
- commonTest.testStorePersistence();
-
- }
-
- public void testFindMethods() throws Exception
- {
-
- commonTest.testFindMethods();
-
- }
-
- public void testAttributes() throws Exception
- {
-
- em.getTransaction().begin();
-
- IdentityObject user1 = store.createIdentityObject(ctx, "Adam", IdentityTypeEnum.IDENTITY);
- IdentityObject user2 = store.createIdentityObject(ctx, "Eva", IdentityTypeEnum.IDENTITY);
-
- em.flush();
-
- IdentityObjectAttribute[] attrs = new IdentityObjectAttribute[]{
- new SimpleAttributeImpl("key1", new String[]{"val1", "val2", "val3"}),
- new SimpleAttributeImpl("key2", new String[]{"val1", "val2", "val3", "val4"})
- };
-
- store.addAttributes(ctx, user1, attrs);
-
- em.flush();
-
- Map<String, IdentityObjectAttribute> persistedAttrs = store.getAttributes(ctx, user1);
-
- assertEquals(2, persistedAttrs.keySet().size());
-
- assertTrue(persistedAttrs.containsKey("key1"));
- assertEquals(3, persistedAttrs.get("key1").getSize());
-
- assertTrue(persistedAttrs.containsKey("key2"));
- assertEquals(4, persistedAttrs.get("key2").getSize());
-
- em.flush();
-
- attrs = new IdentityObjectAttribute[]{
- new SimpleAttributeImpl("key3", new String[]{"val1"})
- };
-
-
- store.addAttributes(ctx, user1, attrs);
-
- em.flush();
-
- persistedAttrs = store.getAttributes(ctx, user1);
-
- assertEquals(3, persistedAttrs.keySet().size());
-
- assertTrue(persistedAttrs.containsKey("key1"));
- assertEquals(3, persistedAttrs.get("key1").getSize());
-
- assertTrue(persistedAttrs.containsKey("key2"));
- assertEquals(4, persistedAttrs.get("key2").getSize());
-
- assertTrue(persistedAttrs.containsKey("key3"));
- assertEquals(1, persistedAttrs.get("key3").getSize());
-
- em.flush();
-
- attrs = new IdentityObjectAttribute[]{
- new SimpleAttributeImpl("key3", new String[]{"val2"})
- };
-
- store.addAttributes(ctx, user1, attrs);
-
- em.flush();
-
- persistedAttrs = store.getAttributes(ctx, user1);
-
- assertEquals(3, persistedAttrs.keySet().size());
-
- assertTrue(persistedAttrs.containsKey("key3"));
- assertEquals(2, persistedAttrs.get("key3").getSize());
-
- em.flush();
-
- store.updateAttributes(ctx, user1, attrs);
-
- em.flush();
-
- persistedAttrs = store.getAttributes(ctx, user1);
-
- assertEquals(3, persistedAttrs.keySet().size());
-
- assertTrue(persistedAttrs.containsKey("key3"));
- assertEquals(1, persistedAttrs.get("key3").getSize());
-
- em.flush();
-
- store.removeAttributes(ctx, user1, new String[] {"key3"});
-
- em.flush();
-
- persistedAttrs = store.getAttributes(ctx, user1);
-
- assertEquals(2, persistedAttrs.keySet().size());
-
-
- em.getTransaction().commit();
-
- }
-
- public void testRelationships() throws Exception
- {
- commonTest.testRelationships();
- }
-
- public void testCredentials() throws Exception
- {
- commonTest.testPasswordCredential();
- commonTest.testBinaryCredential();
- }
-
- public void testControls() throws Exception
- {
- commonTest.testControls();
- }
-
-}
Copied: trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreTestCase.java (from rev 211, trunk/identity-impl/src/test/java/org/jboss/identity/impl/store/hibernate/HibernateIdentityStoreTestCase.java)
===================================================================
--- trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreTestCase.java (rev 0)
+++ trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreTestCase.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,276 @@
+/*
+* 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.store.hibernate;
+
+import org.jboss.identity.idm.spi.model.IdentityObject;
+import org.jboss.identity.idm.spi.model.IdentityObjectAttribute;
+import org.jboss.identity.idm.spi.store.IdentityStoreInvocationContext;
+import org.jboss.identity.idm.spi.store.IdentityStore;
+import org.jboss.identity.idm.spi.store.IdentityStoreSession;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityConfigurationMetaData;
+import org.jboss.identity.idm.impl.store.hibernate.HibernateIdentityStoreImpl;
+import org.jboss.identity.idm.impl.store.hibernate.HibernateTestBase;
+import org.jboss.identity.idm.impl.store.IdentityTypeEnum;
+import org.jboss.identity.idm.impl.store.CommonIdentityStoreTest;
+import org.jboss.identity.idm.impl.store.IdentityStoreTestContext;
+import org.jboss.identity.idm.impl.configuration.jaxb2.JAXB2IdentityConfiguration;
+import org.jboss.identity.idm.impl.api.SimpleAttribute;
+import org.jboss.identity.idm.exception.IdentityException;
+import org.hibernate.ejb.HibernateEntityManager;
+
+import java.util.Map;
+import java.io.File;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class HibernateIdentityStoreTestCase extends HibernateTestBase implements IdentityStoreTestContext
+{
+
+ protected HibernateIdentityStoreImpl store;
+
+ protected IdentityStoreInvocationContext ctx;
+
+ protected CommonIdentityStoreTest commonTest;
+
+ public HibernateIdentityStoreTestCase(String testName)
+ {
+ super(testName);
+ commonTest = new CommonIdentityStoreTest(this);
+ }
+
+
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ IdentityConfigurationMetaData configurationMD = JAXB2IdentityConfiguration
+ .createConfigurationMetaData(new File("src/test/resources/store-test-config.xml"));
+
+ IdentityStoreConfigurationMetaData storeMD = null;
+
+ for (IdentityStoreConfigurationMetaData metaData : configurationMD.getIdentityStores())
+ {
+ if (metaData.getId().equals("HibernateTestStore"))
+ {
+ storeMD = metaData;
+ break;
+ }
+ }
+
+ store = new HibernateIdentityStoreImpl("HibernateTestStore")
+ {
+
+ protected HibernateEntityManager getHibernateEntityManager(IdentityStoreInvocationContext ctx)
+ {
+ return em;
+ }
+
+ @Override
+ protected HibernateEntityManager bootstrapHibernateEntityManager(String persistenceUnit) throws IdentityException
+ {
+ return em;
+ }
+
+ };
+
+ store.bootstrap(storeMD);
+
+
+ ctx = new IdentityStoreInvocationContext()
+ {
+ public IdentityStoreSession getIdentityStoreSession()
+ {
+ return null;
+ }
+
+ public String getRealmId()
+ {
+ return "testRealm";
+ }
+ };
+
+
+ }
+
+ public void begin() throws Exception
+ {
+ em.getTransaction().begin();
+
+ }
+
+ public void commit() throws Exception
+ {
+ em.getTransaction().commit();
+ }
+
+ public void flush() throws Exception
+ {
+ em.flush();
+ }
+
+ public IdentityStore getStore()
+ {
+ return store;
+ }
+
+ public IdentityStoreInvocationContext getCtx()
+ {
+ return ctx;
+ }
+
+ // Tests
+
+ public void testStorePersistence() throws Exception
+ {
+
+ commonTest.testStorePersistence();
+
+ }
+
+ public void testFindMethods() throws Exception
+ {
+
+ commonTest.testFindMethods();
+
+ }
+
+ public void testAttributes() throws Exception
+ {
+
+ em.getTransaction().begin();
+
+ IdentityObject user1 = store.createIdentityObject(ctx, "Adam", IdentityTypeEnum.IDENTITY);
+ IdentityObject user2 = store.createIdentityObject(ctx, "Eva", IdentityTypeEnum.IDENTITY);
+
+ em.flush();
+
+ IdentityObjectAttribute[] attrs = new IdentityObjectAttribute[]{
+ new SimpleAttribute("key1", new String[]{"val1", "val2", "val3"}),
+ new SimpleAttribute("key2", new String[]{"val1", "val2", "val3", "val4"})
+ };
+
+ store.addAttributes(ctx, user1, attrs);
+
+ em.flush();
+
+ Map<String, IdentityObjectAttribute> persistedAttrs = store.getAttributes(ctx, user1);
+
+ assertEquals(2, persistedAttrs.keySet().size());
+
+ assertTrue(persistedAttrs.containsKey("key1"));
+ assertEquals(3, persistedAttrs.get("key1").getSize());
+
+ assertTrue(persistedAttrs.containsKey("key2"));
+ assertEquals(4, persistedAttrs.get("key2").getSize());
+
+ em.flush();
+
+ attrs = new IdentityObjectAttribute[]{
+ new SimpleAttribute("key3", new String[]{"val1"})
+ };
+
+
+ store.addAttributes(ctx, user1, attrs);
+
+ em.flush();
+
+ persistedAttrs = store.getAttributes(ctx, user1);
+
+ assertEquals(3, persistedAttrs.keySet().size());
+
+ assertTrue(persistedAttrs.containsKey("key1"));
+ assertEquals(3, persistedAttrs.get("key1").getSize());
+
+ assertTrue(persistedAttrs.containsKey("key2"));
+ assertEquals(4, persistedAttrs.get("key2").getSize());
+
+ assertTrue(persistedAttrs.containsKey("key3"));
+ assertEquals(1, persistedAttrs.get("key3").getSize());
+
+ em.flush();
+
+ attrs = new IdentityObjectAttribute[]{
+ new SimpleAttribute("key3", new String[]{"val2"})
+ };
+
+ store.addAttributes(ctx, user1, attrs);
+
+ em.flush();
+
+ persistedAttrs = store.getAttributes(ctx, user1);
+
+ assertEquals(3, persistedAttrs.keySet().size());
+
+ assertTrue(persistedAttrs.containsKey("key3"));
+ assertEquals(2, persistedAttrs.get("key3").getSize());
+
+ em.flush();
+
+ store.updateAttributes(ctx, user1, attrs);
+
+ em.flush();
+
+ persistedAttrs = store.getAttributes(ctx, user1);
+
+ assertEquals(3, persistedAttrs.keySet().size());
+
+ assertTrue(persistedAttrs.containsKey("key3"));
+ assertEquals(1, persistedAttrs.get("key3").getSize());
+
+ em.flush();
+
+ store.removeAttributes(ctx, user1, new String[] {"key3"});
+
+ em.flush();
+
+ persistedAttrs = store.getAttributes(ctx, user1);
+
+ assertEquals(2, persistedAttrs.keySet().size());
+
+
+ em.getTransaction().commit();
+
+ }
+
+ public void testRelationships() throws Exception
+ {
+ commonTest.testRelationships();
+ }
+
+ public void testCredentials() throws Exception
+ {
+ commonTest.testPasswordCredential();
+ commonTest.testBinaryCredential();
+ }
+
+ public void testControls() throws Exception
+ {
+ commonTest.testControls();
+ }
+
+}
Modified: trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelTestCase.java
===================================================================
--- trunk/identity-impl/src/test/java/org/jboss/identity/impl/store/hibernate/HibernateModelTestCase.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateModelTestCase.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,20 +20,17 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.store.hibernate;
+package org.jboss.identity.idm.impl.store.hibernate;
-import java.util.Set;
-import java.util.HashSet;
-
import javax.persistence.Query;
-import org.jboss.identity.impl.store.hibernate.HibernateTestBase;
-import org.jboss.identity.impl.model.hibernate.HibernateIdentityObjectRelationshipType;
-import org.jboss.identity.impl.model.hibernate.HibernateIdentityObject;
-import org.jboss.identity.impl.model.hibernate.HibernateIdentityObjectType;
-import org.jboss.identity.impl.model.hibernate.HibernateIdentityObjectRelationship;
-import org.jboss.identity.impl.model.hibernate.HibernateRealm;
-import org.jboss.identity.impl.model.hibernate.HibernateIdentityObjectTextAttribute;
+import org.jboss.identity.idm.impl.store.hibernate.HibernateTestBase;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipType;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObject;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectType;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationship;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateRealm;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectTextAttribute;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Modified: trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateTestBase.java
===================================================================
--- trunk/identity-impl/src/test/java/org/jboss/identity/impl/store/hibernate/HibernateTestBase.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateTestBase.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,19 +20,15 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.impl.store.hibernate;
+package org.jboss.identity.idm.impl.store.hibernate;
import junit.framework.TestCase;
-import javax.persistence.Persistence;
import java.util.logging.Logger;
-import java.sql.Connection;
-import java.sql.DriverManager;
import org.hibernate.ejb.HibernateEntityManager;
-import org.hibernate.ejb.HibernateEntityManagerFactory;
-import org.jboss.identity.impl.store.hibernate.HibernateModelTestCase;
-import org.jboss.identity.impl.HibernateTestSupport;
+import org.jboss.identity.idm.impl.store.hibernate.HibernateModelTestCase;
+import org.jboss.identity.idm.impl.HibernateTestSupport;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Deleted: trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreTestCase.java
===================================================================
--- trunk/identity-impl/src/test/java/org/jboss/identity/impl/store/ldap/LDAPIdentityStoreTestCase.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreTestCase.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,524 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.impl.store.ldap;
-
-import junit.framework.TestCase;
-import org.jboss.identity.opends.OpenDSService;
-import org.jboss.identity.spi.store.IdentityStore;
-import org.jboss.identity.spi.store.IdentityStoreInvocationContext;
-import org.jboss.identity.spi.store.IdentityStoreSession;
-import org.jboss.identity.spi.model.IdentityObject;
-import org.jboss.identity.spi.model.IdentityObjectAttribute;
-import org.jboss.identity.spi.configuration.metadata.IdentityConfigurationMetaData;
-import org.jboss.identity.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
-import org.jboss.identity.impl.store.IdentityTypeEnum;
-import org.jboss.identity.impl.store.CommonIdentityStoreTest;
-import org.jboss.identity.impl.store.IdentityStoreTestContext;
-import org.jboss.identity.impl.configuration.jaxb2.JAXB2IdentityConfiguration;
-import org.jboss.identity.impl.api.SimpleAttributeImpl;
-import org.jboss.identity.exception.IdentityException;
-import org.opends.server.tools.LDAPModify;
-
-import javax.naming.Context;
-import javax.naming.NamingException;
-import javax.naming.NamingEnumeration;
-import javax.naming.Binding;
-import javax.naming.directory.DirContext;
-import javax.naming.ldap.LdapContext;
-import javax.naming.ldap.InitialLdapContext;
-import java.net.URL;
-import java.util.Hashtable;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.logging.Logger;
-import java.util.logging.Level;
-import java.io.File;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class
- LDAPIdentityStoreTestCase extends TestCase implements IdentityStoreTestContext
-{
-
- public static final String LDAP_HOST = "localhost";
-
- public static final String LDAP_PORT = "10389";
-
- public static final String LDAP_PROVIDER_URL = "ldap://" + LDAP_HOST + ":" + LDAP_PORT;
-
- public static final String LDAP_PRINCIPAL = "cn=Directory Manager";
-
- public static final String LDAP_CREDENTIALS = "password";
-
- OpenDSService openDSService = new OpenDSService("target/test-classes/opends");
-
- IdentityStore store;
-
- CommonIdentityStoreTest commonTest;
-
- IdentityStoreInvocationContext ctx;
-
- public LDAPIdentityStoreTestCase(String s)
- {
- super(s);
- commonTest = new CommonIdentityStoreTest(this);
- }
-
- protected void setUp() throws Exception
- {
- super.setUp();
-
- openDSService.start();
-
- IdentityConfigurationMetaData configurationMD = JAXB2IdentityConfiguration
- .createConfigurationMetaData(new File("src/test/resources/store-test-config.xml"));
-
- IdentityStoreConfigurationMetaData storeMD = null;
-
- for (IdentityStoreConfigurationMetaData metaData : configurationMD.getIdentityStores())
- {
- if (metaData.getId().equals("LDAPTestStore"))
- {
- storeMD = metaData;
- break;
- }
- }
-
- ctx = new IdentityStoreInvocationContext()
- {
- public IdentityStoreSession getIdentityStoreSession()
- {
- return new IdentityStoreSession(){
-
- public Object getSessionContext() throws IdentityException
- {
- try
- {
- return getLdapContext();
- }
- catch (Exception e)
- {
- throw new IdentityException("Failed to obtain LDAP connection: ", e);
- }
- }
-
- public void close() throws IdentityException
- {
-
- }
-
- public void save() throws IdentityException
- {
-
- }
-
- public void clear() throws IdentityException
- {
-
- }
-
- public boolean isOpen()
- {
- return false;
- }
-
- public boolean isTransactionSupported()
- {
- return false;
- }
-
- public void startTransaction()
- {
-
- }
-
- public void commitTransaction()
- {
-
- }
-
- public void rollbackTransaction()
- {
-
- }
-
- public boolean isTransactionActive()
- {
- return false;
- }
- };
- }
-
- public String getRealmId()
- {
- return "testRealm";
- }
- };
-
- //populate();
-
- store = new LDAPIdentityStoreImpl("LDAPTestStore");
-
- store.bootstrap(storeMD);
- }
-
- protected void tearDown() throws Exception
- {
- super.tearDown();
-
- cleanUp();
-
- openDSService.stop();
- }
-
- public void begin() throws Exception
- {
- //nothing
- }
-
- public void commit() throws Exception
- {
- //nothing
- }
-
- public void flush() throws Exception
- {
- //nothing
- }
-
- public IdentityStore getStore()
- {
- return store;
- }
-
- public IdentityStoreInvocationContext getCtx()
- {
- return ctx;
- }
-
-
- public LdapContext getLdapContext() throws Exception
- {
- Hashtable<String,String> env = new Hashtable<String,String>();
- env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
- env.put(Context.PROVIDER_URL, LDAP_PROVIDER_URL);
- env.put(Context.SECURITY_AUTHENTICATION, "simple");
- env.put(Context.SECURITY_PRINCIPAL, LDAP_PRINCIPAL);
- env.put(Context.SECURITY_CREDENTIALS, LDAP_CREDENTIALS);
-
- return new InitialLdapContext(env, null);
- }
-
-
-
- public void populate() throws Exception
- {
- populateLDIF("target/test-classes/ldap/initial-opends.ldif");
- }
-
- public void populateClean() throws Exception
- {
- populateLDIF("target/test-classes/ldap/initial-empty-opends.ldif");
- }
-
- public void populateLDIF(String ldifRelativePath) throws Exception
- {
- File ldif = new File(ldifRelativePath);
-
- System.out.println("LDIF: " + ldif.getAbsolutePath());
-
- String[] cmd = new String[] {"-h", LDAP_HOST,
- "-p", LDAP_PORT,
- "-D", LDAP_PRINCIPAL,
- "-w", LDAP_CREDENTIALS,
- "-a", "-f", ldif.getPath()};
-
- System.out.println("Populate success: " + (LDAPModify.mainModify(cmd, false, System.out, System.err) == 0));
-
- }
-
- protected void cleanUp() throws Exception
- {
- DirContext ldapCtx = getLdapContext();
-
- try
- {
-
-
- String dn = "dc=portal,dc=example,dc=com";
-
- System.out.println("Removing: " + dn);
-
- removeContext(ldapCtx, dn);
- }
- catch (Exception e)
- {
- //
- }
- finally
- {
- ldapCtx.close();
- }
- }
-
- //subsequent remove of javax.naming.Context
- protected void removeContext(Context mainCtx, String name) throws Exception
- {
- Context deleteCtx = (Context)mainCtx.lookup(name);
- NamingEnumeration subDirs = mainCtx.listBindings(name);
-
- while (subDirs.hasMoreElements())
- {
- Binding binding = (Binding)subDirs.nextElement();
- String subName = binding.getName();
-
- removeContext(deleteCtx, subName);
- }
-
- mainCtx.unbind(name);
- }
-
- // Tests
-
-// Just test if OpenDS is running and was populated...
- public void testSimple() throws Exception
- {
- populate();
-
- Hashtable<String,String> env = new Hashtable<String,String>();
- env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
- env.put(Context.PROVIDER_URL, LDAP_PROVIDER_URL);
- env.put(Context.SECURITY_AUTHENTICATION, "simple");
- env.put(Context.SECURITY_PRINCIPAL, LDAP_PRINCIPAL);
- env.put(Context.SECURITY_CREDENTIALS, LDAP_CREDENTIALS);
-
- LdapContext ldapCtx = null;
- try
- {
- ldapCtx = new InitialLdapContext(env, null);
-
-// Do something ...
- System.out.println("Attributes: " + ldapCtx.getAttributes("o=test,dc=portal,dc=example,dc=com"));
-
- }
- catch (NamingException e)
- {
- e.printStackTrace();
- }
- finally
- {
- try
- {
- if (ldapCtx != null)
- {
- ldapCtx.close();
- }
- }
- catch (NamingException e)
- {
- e.printStackTrace();
- }
- }
- }
-
- public void testIdentityObjectCount() throws Exception
- {
- populate();
-
- assertEquals(7, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.IDENTITY));
- assertEquals(5, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.ROLE));
- assertEquals(2, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.GROUP));
- }
-
- public void testFindCreateRemove() throws Exception
- {
- populate();
-
- assertEquals(7, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.IDENTITY));
-
- IdentityObject io = store.findIdentityObject(ctx, "admin", IdentityTypeEnum.IDENTITY);
- assertEquals("admin", io.getName());
- assertEquals("uid=admin,ou=People,o=test,dc=portal,dc=example,dc=com", io.getId().toString());
-
- //
-
- store.removeIdentityObject(ctx, io);
-
- assertEquals(6, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.IDENTITY));
-
- store.createIdentityObject(ctx, "newUserA", IdentityTypeEnum.IDENTITY);
-
- assertEquals(7, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.IDENTITY));
-
- //
-
- assertEquals(2, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.GROUP));
-
- store.createIdentityObject(ctx, "newGroupA", IdentityTypeEnum.GROUP);
-
- assertEquals(3, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.GROUP));
-
- //
-
- io = store.findIdentityObject(ctx, "cn=newGroupA,ou=Groups,o=test,dc=portal,dc=example,dc=com");
- assertEquals("newGroupA", io.getName());
-
- }
-
- public void testAttributes() throws Exception{
-
- populate();
-
- IdentityObject user1 = store.createIdentityObject(ctx, "Adam", IdentityTypeEnum.IDENTITY);
- IdentityObject user2 = store.createIdentityObject(ctx, "Eva", IdentityTypeEnum.IDENTITY);
-
- //
-
- IdentityObjectAttribute[] attrs = new IdentityObjectAttribute[]{
- new SimpleAttributeImpl("phone", new String[]{"val1", "val2", "val3"}),
- new SimpleAttributeImpl("description", new String[]{"val1", "val2", "val3", "val4"}),
-
- };
-
- store.addAttributes(ctx, user1, attrs);
-
- //
-
- Map<String, IdentityObjectAttribute> persistedAttrs = store.getAttributes(ctx, user1);
-
- assertEquals(2, persistedAttrs.keySet().size());
-
- assertTrue(persistedAttrs.containsKey("phone"));
- assertEquals(3, persistedAttrs.get("phone").getSize());
-
- assertTrue(persistedAttrs.containsKey("description"));
- assertEquals(4, persistedAttrs.get("description").getSize());
-
- //
-
- attrs = new IdentityObjectAttribute[]{
- new SimpleAttributeImpl("carLicense", new String[]{"val1"})
- };
-
- store.addAttributes(ctx, user1, attrs);
-
- //
-
- persistedAttrs = store.getAttributes(ctx, user1);
-
- assertEquals(3, persistedAttrs.keySet().size());
-
- assertTrue(persistedAttrs.containsKey("phone"));
- assertEquals(3, persistedAttrs.get("phone").getSize());
-
- assertTrue(persistedAttrs.containsKey("description"));
- assertEquals(4, persistedAttrs.get("description").getSize());
-
- assertTrue(persistedAttrs.containsKey("carLicense"));
- assertEquals(1, persistedAttrs.get("carLicense").getSize());
-
- attrs = new IdentityObjectAttribute[]{
- new SimpleAttributeImpl("carLicense", new String[]{"val2"})
- };
-
- store.addAttributes(ctx, user1, attrs);
-
- //
-
- persistedAttrs = store.getAttributes(ctx, user1);
-
- assertEquals(3, persistedAttrs.keySet().size());
-
- assertTrue(persistedAttrs.containsKey("carLicense"));
- assertEquals(2, persistedAttrs.get("carLicense").getSize());
-
- //
-
- store.updateAttributes(ctx, user1, attrs);
-
- //
-
- persistedAttrs = store.getAttributes(ctx, user1);
-
- assertEquals(3, persistedAttrs.keySet().size());
-
- assertTrue(persistedAttrs.containsKey("carLicense"));
- assertEquals(1, persistedAttrs.get("carLicense").getSize());
-
- //
-
- String[] names = new String[]{"carLicense"};
- store.removeAttributes(ctx, user1, names);
-
- //
-
- persistedAttrs = store.getAttributes(ctx, user1);
-
- assertEquals(2, persistedAttrs.keySet().size());
-
- }
-
- public void testRelationships() throws Exception
- {
- populateClean();
-
- commonTest.testRelationships();
-
- }
-
- public void testStorePersistence() throws Exception
- {
- populateClean();
-
- commonTest.testStorePersistence();
-
- }
-
- public void testFindMethods() throws Exception
- {
- populateClean();
-
- commonTest.testFindMethods();
-
- }
-
- public void testControls() throws Exception
- {
- populateClean();
-
- commonTest.testControls();
- }
-
-
- public void testCredentials() throws Exception
- {
- populateClean();
-
- commonTest.testPasswordCredential();
- }
-
-}
Copied: trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreTestCase.java (from rev 211, trunk/identity-impl/src/test/java/org/jboss/identity/impl/store/ldap/LDAPIdentityStoreTestCase.java)
===================================================================
--- trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreTestCase.java (rev 0)
+++ trunk/identity-impl/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreTestCase.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,518 @@
+/*
+* 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.store.ldap;
+
+import junit.framework.TestCase;
+import org.jboss.identity.idm.opends.OpenDSService;
+import org.jboss.identity.idm.spi.store.IdentityStore;
+import org.jboss.identity.idm.spi.store.IdentityStoreInvocationContext;
+import org.jboss.identity.idm.spi.store.IdentityStoreSession;
+import org.jboss.identity.idm.spi.model.IdentityObject;
+import org.jboss.identity.idm.spi.model.IdentityObjectAttribute;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
+import org.jboss.identity.idm.impl.store.IdentityTypeEnum;
+import org.jboss.identity.idm.impl.store.CommonIdentityStoreTest;
+import org.jboss.identity.idm.impl.store.IdentityStoreTestContext;
+import org.jboss.identity.idm.impl.configuration.jaxb2.JAXB2IdentityConfiguration;
+import org.jboss.identity.idm.impl.api.SimpleAttribute;
+import org.jboss.identity.idm.exception.IdentityException;
+import org.opends.server.tools.LDAPModify;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.NamingEnumeration;
+import javax.naming.Binding;
+import javax.naming.directory.DirContext;
+import javax.naming.ldap.LdapContext;
+import javax.naming.ldap.InitialLdapContext;
+import java.util.Hashtable;
+import java.util.Map;
+import java.io.File;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class
+ LDAPIdentityStoreTestCase extends TestCase implements IdentityStoreTestContext
+{
+
+ public static final String LDAP_HOST = "localhost";
+
+ public static final String LDAP_PORT = "10389";
+
+ public static final String LDAP_PROVIDER_URL = "ldap://" + LDAP_HOST + ":" + LDAP_PORT;
+
+ public static final String LDAP_PRINCIPAL = "cn=Directory Manager";
+
+ public static final String LDAP_CREDENTIALS = "password";
+
+ OpenDSService openDSService = new OpenDSService("target/test-classes/opends");
+
+ IdentityStore store;
+
+ CommonIdentityStoreTest commonTest;
+
+ IdentityStoreInvocationContext ctx;
+
+ public LDAPIdentityStoreTestCase(String s)
+ {
+ super(s);
+ commonTest = new CommonIdentityStoreTest(this);
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ openDSService.start();
+
+ IdentityConfigurationMetaData configurationMD = JAXB2IdentityConfiguration
+ .createConfigurationMetaData(new File("src/test/resources/store-test-config.xml"));
+
+ IdentityStoreConfigurationMetaData storeMD = null;
+
+ for (IdentityStoreConfigurationMetaData metaData : configurationMD.getIdentityStores())
+ {
+ if (metaData.getId().equals("LDAPTestStore"))
+ {
+ storeMD = metaData;
+ break;
+ }
+ }
+
+ ctx = new IdentityStoreInvocationContext()
+ {
+ public IdentityStoreSession getIdentityStoreSession()
+ {
+ return new IdentityStoreSession(){
+
+ public Object getSessionContext() throws IdentityException
+ {
+ try
+ {
+ return getLdapContext();
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Failed to obtain LDAP connection: ", e);
+ }
+ }
+
+ public void close() throws IdentityException
+ {
+
+ }
+
+ public void save() throws IdentityException
+ {
+
+ }
+
+ public void clear() throws IdentityException
+ {
+
+ }
+
+ public boolean isOpen()
+ {
+ return false;
+ }
+
+ public boolean isTransactionSupported()
+ {
+ return false;
+ }
+
+ public void startTransaction()
+ {
+
+ }
+
+ public void commitTransaction()
+ {
+
+ }
+
+ public void rollbackTransaction()
+ {
+
+ }
+
+ public boolean isTransactionActive()
+ {
+ return false;
+ }
+ };
+ }
+
+ public String getRealmId()
+ {
+ return "testRealm";
+ }
+ };
+
+ //populate();
+
+ store = new LDAPIdentityStoreImpl("LDAPTestStore");
+
+ store.bootstrap(storeMD);
+ }
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+
+ cleanUp();
+
+ openDSService.stop();
+ }
+
+ public void begin() throws Exception
+ {
+ //nothing
+ }
+
+ public void commit() throws Exception
+ {
+ //nothing
+ }
+
+ public void flush() throws Exception
+ {
+ //nothing
+ }
+
+ public IdentityStore getStore()
+ {
+ return store;
+ }
+
+ public IdentityStoreInvocationContext getCtx()
+ {
+ return ctx;
+ }
+
+
+ public LdapContext getLdapContext() throws Exception
+ {
+ Hashtable<String,String> env = new Hashtable<String,String>();
+ env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
+ env.put(Context.PROVIDER_URL, LDAP_PROVIDER_URL);
+ env.put(Context.SECURITY_AUTHENTICATION, "simple");
+ env.put(Context.SECURITY_PRINCIPAL, LDAP_PRINCIPAL);
+ env.put(Context.SECURITY_CREDENTIALS, LDAP_CREDENTIALS);
+
+ return new InitialLdapContext(env, null);
+ }
+
+
+
+ public void populate() throws Exception
+ {
+ populateLDIF("target/test-classes/ldap/initial-opends.ldif");
+ }
+
+ public void populateClean() throws Exception
+ {
+ populateLDIF("target/test-classes/ldap/initial-empty-opends.ldif");
+ }
+
+ public void populateLDIF(String ldifRelativePath) throws Exception
+ {
+ File ldif = new File(ldifRelativePath);
+
+ System.out.println("LDIF: " + ldif.getAbsolutePath());
+
+ String[] cmd = new String[] {"-h", LDAP_HOST,
+ "-p", LDAP_PORT,
+ "-D", LDAP_PRINCIPAL,
+ "-w", LDAP_CREDENTIALS,
+ "-a", "-f", ldif.getPath()};
+
+ System.out.println("Populate success: " + (LDAPModify.mainModify(cmd, false, System.out, System.err) == 0));
+
+ }
+
+ protected void cleanUp() throws Exception
+ {
+ DirContext ldapCtx = getLdapContext();
+
+ try
+ {
+
+
+ String dn = "dc=portal,dc=example,dc=com";
+
+ System.out.println("Removing: " + dn);
+
+ removeContext(ldapCtx, dn);
+ }
+ catch (Exception e)
+ {
+ //
+ }
+ finally
+ {
+ ldapCtx.close();
+ }
+ }
+
+ //subsequent remove of javax.naming.Context
+ protected void removeContext(Context mainCtx, String name) throws Exception
+ {
+ Context deleteCtx = (Context)mainCtx.lookup(name);
+ NamingEnumeration subDirs = mainCtx.listBindings(name);
+
+ while (subDirs.hasMoreElements())
+ {
+ Binding binding = (Binding)subDirs.nextElement();
+ String subName = binding.getName();
+
+ removeContext(deleteCtx, subName);
+ }
+
+ mainCtx.unbind(name);
+ }
+
+ // Tests
+
+// Just test if OpenDS is running and was populated...
+ public void testSimple() throws Exception
+ {
+ populate();
+
+ Hashtable<String,String> env = new Hashtable<String,String>();
+ env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
+ env.put(Context.PROVIDER_URL, LDAP_PROVIDER_URL);
+ env.put(Context.SECURITY_AUTHENTICATION, "simple");
+ env.put(Context.SECURITY_PRINCIPAL, LDAP_PRINCIPAL);
+ env.put(Context.SECURITY_CREDENTIALS, LDAP_CREDENTIALS);
+
+ LdapContext ldapCtx = null;
+ try
+ {
+ ldapCtx = new InitialLdapContext(env, null);
+
+// Do something ...
+ System.out.println("Attributes: " + ldapCtx.getAttributes("o=test,dc=portal,dc=example,dc=com"));
+
+ }
+ catch (NamingException e)
+ {
+ e.printStackTrace();
+ }
+ finally
+ {
+ try
+ {
+ if (ldapCtx != null)
+ {
+ ldapCtx.close();
+ }
+ }
+ catch (NamingException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public void testIdentityObjectCount() throws Exception
+ {
+ populate();
+
+ assertEquals(7, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.IDENTITY));
+ assertEquals(5, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.ROLE));
+ assertEquals(2, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.GROUP));
+ }
+
+ public void testFindCreateRemove() throws Exception
+ {
+ populate();
+
+ assertEquals(7, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.IDENTITY));
+
+ IdentityObject io = store.findIdentityObject(ctx, "admin", IdentityTypeEnum.IDENTITY);
+ assertEquals("admin", io.getName());
+ assertEquals("uid=admin,ou=People,o=test,dc=portal,dc=example,dc=com", io.getId().toString());
+
+ //
+
+ store.removeIdentityObject(ctx, io);
+
+ assertEquals(6, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.IDENTITY));
+
+ store.createIdentityObject(ctx, "newUserA", IdentityTypeEnum.IDENTITY);
+
+ assertEquals(7, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.IDENTITY));
+
+ //
+
+ assertEquals(2, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.GROUP));
+
+ store.createIdentityObject(ctx, "newGroupA", IdentityTypeEnum.GROUP);
+
+ assertEquals(3, store.getIdentityObjectsCount(ctx, IdentityTypeEnum.GROUP));
+
+ //
+
+ io = store.findIdentityObject(ctx, "cn=newGroupA,ou=Groups,o=test,dc=portal,dc=example,dc=com");
+ assertEquals("newGroupA", io.getName());
+
+ }
+
+ public void testAttributes() throws Exception{
+
+ populate();
+
+ IdentityObject user1 = store.createIdentityObject(ctx, "Adam", IdentityTypeEnum.IDENTITY);
+ IdentityObject user2 = store.createIdentityObject(ctx, "Eva", IdentityTypeEnum.IDENTITY);
+
+ //
+
+ IdentityObjectAttribute[] attrs = new IdentityObjectAttribute[]{
+ new SimpleAttribute("phone", new String[]{"val1", "val2", "val3"}),
+ new SimpleAttribute("description", new String[]{"val1", "val2", "val3", "val4"}),
+
+ };
+
+ store.addAttributes(ctx, user1, attrs);
+
+ //
+
+ Map<String, IdentityObjectAttribute> persistedAttrs = store.getAttributes(ctx, user1);
+
+ assertEquals(2, persistedAttrs.keySet().size());
+
+ assertTrue(persistedAttrs.containsKey("phone"));
+ assertEquals(3, persistedAttrs.get("phone").getSize());
+
+ assertTrue(persistedAttrs.containsKey("description"));
+ assertEquals(4, persistedAttrs.get("description").getSize());
+
+ //
+
+ attrs = new IdentityObjectAttribute[]{
+ new SimpleAttribute("carLicense", new String[]{"val1"})
+ };
+
+ store.addAttributes(ctx, user1, attrs);
+
+ //
+
+ persistedAttrs = store.getAttributes(ctx, user1);
+
+ assertEquals(3, persistedAttrs.keySet().size());
+
+ assertTrue(persistedAttrs.containsKey("phone"));
+ assertEquals(3, persistedAttrs.get("phone").getSize());
+
+ assertTrue(persistedAttrs.containsKey("description"));
+ assertEquals(4, persistedAttrs.get("description").getSize());
+
+ assertTrue(persistedAttrs.containsKey("carLicense"));
+ assertEquals(1, persistedAttrs.get("carLicense").getSize());
+
+ attrs = new IdentityObjectAttribute[]{
+ new SimpleAttribute("carLicense", new String[]{"val2"})
+ };
+
+ store.addAttributes(ctx, user1, attrs);
+
+ //
+
+ persistedAttrs = store.getAttributes(ctx, user1);
+
+ assertEquals(3, persistedAttrs.keySet().size());
+
+ assertTrue(persistedAttrs.containsKey("carLicense"));
+ assertEquals(2, persistedAttrs.get("carLicense").getSize());
+
+ //
+
+ store.updateAttributes(ctx, user1, attrs);
+
+ //
+
+ persistedAttrs = store.getAttributes(ctx, user1);
+
+ assertEquals(3, persistedAttrs.keySet().size());
+
+ assertTrue(persistedAttrs.containsKey("carLicense"));
+ assertEquals(1, persistedAttrs.get("carLicense").getSize());
+
+ //
+
+ String[] names = new String[]{"carLicense"};
+ store.removeAttributes(ctx, user1, names);
+
+ //
+
+ persistedAttrs = store.getAttributes(ctx, user1);
+
+ assertEquals(2, persistedAttrs.keySet().size());
+
+ }
+
+ public void testRelationships() throws Exception
+ {
+ populateClean();
+
+ commonTest.testRelationships();
+
+ }
+
+ public void testStorePersistence() throws Exception
+ {
+ populateClean();
+
+ commonTest.testStorePersistence();
+
+ }
+
+ public void testFindMethods() throws Exception
+ {
+ populateClean();
+
+ commonTest.testFindMethods();
+
+ }
+
+ public void testControls() throws Exception
+ {
+ populateClean();
+
+ commonTest.testControls();
+ }
+
+
+ public void testCredentials() throws Exception
+ {
+ populateClean();
+
+ commonTest.testPasswordCredential();
+ }
+
+}
Copied: trunk/identity-impl/src/test/java/org/jboss/identity/idm/opends (from rev 198, trunk/identity-impl/src/test/java/org/jboss/identity/opends)
Deleted: trunk/identity-impl/src/test/java/org/jboss/identity/idm/opends/OpenDSService.java
===================================================================
--- trunk/identity-impl/src/test/java/org/jboss/identity/opends/OpenDSService.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-impl/src/test/java/org/jboss/identity/idm/opends/OpenDSService.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,107 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.opends;
-
-import java.io.File;
-
-import org.opends.server.util.EmbeddedUtils;
-import org.opends.server.types.DirectoryEnvironmentConfig;
-import org.opends.server.types.InitializationException;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class OpenDSService
-{
- private String serverRoot = "";
-
- public OpenDSService(String serverRoot)
- {
- this.serverRoot = serverRoot;
- }
-
- public DirectoryEnvironmentConfig getConfig()
- {
- DirectoryEnvironmentConfig config = new DirectoryEnvironmentConfig();
-
- try
- {
- File root = new File(getServerRoot());
-
- if (root == null || !root.exists())
- {
- throw new IllegalStateException("opends root doesn't exist: " + getServerRoot());
- }
- if (!root.isDirectory())
- {
- throw new IllegalStateException("opends root is not a directory: " + getServerRoot());
- }
-
- // Server root points to the directory with opends configuration
- config.setServerRoot(new File(getServerRoot()));
- config.setForceDaemonThreads(true);
-
- }
- catch (InitializationException e)
- {
- e.printStackTrace();
- }
-
- return config;
- }
-
-
- public void start()
- {
- if (!EmbeddedUtils.isRunning())
- {
- try
- {
- EmbeddedUtils.startServer(getConfig());
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- }
-
- public void stop()
- {
- if (EmbeddedUtils.isRunning())
- {
- EmbeddedUtils.stopServer(this.getClass().getName(), null);
- }
- }
-
- public String getServerRoot()
- {
- return serverRoot;
- }
-
- public void setServerRoot(String serverRoot)
- {
- this.serverRoot = serverRoot;
- }
-}
Copied: trunk/identity-impl/src/test/java/org/jboss/identity/idm/opends/OpenDSService.java (from rev 211, trunk/identity-impl/src/test/java/org/jboss/identity/opends/OpenDSService.java)
===================================================================
--- trunk/identity-impl/src/test/java/org/jboss/identity/idm/opends/OpenDSService.java (rev 0)
+++ trunk/identity-impl/src/test/java/org/jboss/identity/idm/opends/OpenDSService.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,109 @@
+/*
+* 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.opends;
+
+import java.io.File;
+
+import org.opends.server.util.EmbeddedUtils;
+import org.opends.server.types.DirectoryEnvironmentConfig;
+import org.opends.server.types.InitializationException;
+
+/**
+ * Simple service class that enables to bootstrap OpenDS LDAP server and to manage its lifecycle
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class OpenDSService
+{
+ private String serverRoot = "";
+
+ public OpenDSService(String serverRoot)
+ {
+ this.serverRoot = serverRoot;
+ }
+
+ public DirectoryEnvironmentConfig getConfig()
+ {
+ DirectoryEnvironmentConfig config = new DirectoryEnvironmentConfig();
+
+ try
+ {
+ File root = new File(getServerRoot());
+
+ if (root == null || !root.exists())
+ {
+ throw new IllegalStateException("opends root doesn't exist: " + getServerRoot());
+ }
+ if (!root.isDirectory())
+ {
+ throw new IllegalStateException("opends root is not a directory: " + getServerRoot());
+ }
+
+ // Server root points to the directory with opends configuration
+ config.setServerRoot(new File(getServerRoot()));
+ config.setForceDaemonThreads(true);
+
+ }
+ catch (InitializationException e)
+ {
+ e.printStackTrace();
+ }
+
+ return config;
+ }
+
+
+ public void start()
+ {
+ if (!EmbeddedUtils.isRunning())
+ {
+ try
+ {
+ EmbeddedUtils.startServer(getConfig());
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public void stop()
+ {
+ if (EmbeddedUtils.isRunning())
+ {
+ EmbeddedUtils.stopServer(this.getClass().getName(), null);
+ }
+ }
+
+ public String getServerRoot()
+ {
+ return serverRoot;
+ }
+
+ public void setServerRoot(String serverRoot)
+ {
+ this.serverRoot = serverRoot;
+ }
+}
Modified: trunk/identity-impl/src/test/resources/META-INF/persistence.xml
===================================================================
--- trunk/identity-impl/src/test/resources/META-INF/persistence.xml 2009-01-13 15:18:42 UTC (rev 211)
+++ trunk/identity-impl/src/test/resources/META-INF/persistence.xml 2009-01-13 15:39:59 UTC (rev 212)
@@ -9,15 +9,15 @@
<provider>org.hibernate.ejb.HibernatePersistence</provider>
- <class>org.jboss.identity.impl.model.hibernate.HibernateRealm</class>
- <class>org.jboss.identity.impl.model.hibernate.HibernateIdentityObject</class>
- <class>org.jboss.identity.impl.model.hibernate.HibernateIdentityObjectCredential</class>
- <class>org.jboss.identity.impl.model.hibernate.HibernateIdentityObjectCredentialType</class>
- <class>org.jboss.identity.impl.model.hibernate.HibernateIdentityObjectAttribute</class>
- <class>org.jboss.identity.impl.model.hibernate.HibernateIdentityObjectType</class>
- <class>org.jboss.identity.impl.model.hibernate.HibernateIdentityObjectRelationship</class>
- <class>org.jboss.identity.impl.model.hibernate.HibernateIdentityObjectRelationshipType</class>
- <class>org.jboss.identity.impl.model.hibernate.HibernateIdentityObjectRelationshipName</class>
+ <class>org.jboss.identity.idm.impl.model.hibernate.HibernateRealm</class>
+ <class>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObject</class>
+ <class>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredential</class>
+ <class>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredentialType</class>
+ <class>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectAttribute</class>
+ <class>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectType</class>
+ <class>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationship</class>
+ <class>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipType</class>
+ <class>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipName</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
@@ -37,15 +37,15 @@
<provider>org.hibernate.ejb.HibernatePersistence</provider>
- <class>org.jboss.identity.impl.model.hibernate.HibernateRealm</class>
- <class>org.jboss.identity.impl.model.hibernate.HibernateIdentityObject</class>
- <class>org.jboss.identity.impl.model.hibernate.HibernateIdentityObjectCredential</class>
- <class>org.jboss.identity.impl.model.hibernate.HibernateIdentityObjectCredentialType</class>
- <class>org.jboss.identity.impl.model.hibernate.HibernateIdentityObjectAttribute</class>
- <class>org.jboss.identity.impl.model.hibernate.HibernateIdentityObjectType</class>
- <class>org.jboss.identity.impl.model.hibernate.HibernateIdentityObjectRelationship</class>
- <class>org.jboss.identity.impl.model.hibernate.HibernateIdentityObjectRelationshipType</class>
- <class>org.jboss.identity.impl.model.hibernate.HibernateIdentityObjectRelationshipName</class>
+ <class>org.jboss.identity.idm.impl.model.hibernate.HibernateRealm</class>
+ <class>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObject</class>
+ <class>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredential</class>
+ <class>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredentialType</class>
+ <class>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectAttribute</class>
+ <class>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectType</class>
+ <class>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationship</class>
+ <class>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipType</class>
+ <class>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipName</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
Modified: trunk/identity-impl/src/test/resources/organization-test-config.xml
===================================================================
--- trunk/identity-impl/src/test/resources/organization-test-config.xml 2009-01-13 15:18:42 UTC (rev 211)
+++ trunk/identity-impl/src/test/resources/organization-test-config.xml 2009-01-13 15:39:59 UTC (rev 212)
@@ -36,7 +36,7 @@
<repositories>
<repository>
<id>RedHat Repository DB</id>
- <class>org.jboss.identity.impl.repository.FallbackIdentityStoreRepository</class>
+ <class>org.jboss.identity.idm.impl.repository.FallbackIdentityStoreRepository</class>
<external-config/>
<default-identity-store-id>Hibernate Identity Store</default-identity-store-id>
<default-attribute-store-id>Hibernate Identity Store</default-attribute-store-id>
@@ -64,7 +64,7 @@
</repository>
<repository>
<id>Sample Portal Repository DB</id>
- <class>org.jboss.identity.impl.repository.FallbackIdentityStoreRepository</class>
+ <class>org.jboss.identity.idm.impl.repository.FallbackIdentityStoreRepository</class>
<external-config/>
<default-identity-store-id>Hibernate Identity Store</default-identity-store-id>
<default-attribute-store-id>Hibernate Identity Store</default-attribute-store-id>
@@ -96,7 +96,7 @@
</repository>
<repository>
<id>RedHat Repository DB+LDAP</id>
- <class>org.jboss.identity.impl.repository.FallbackIdentityStoreRepository</class>
+ <class>org.jboss.identity.idm.impl.repository.FallbackIdentityStoreRepository</class>
<external-config/>
<default-identity-store-id>Hibernate Identity Store</default-identity-store-id>
<default-attribute-store-id>Hibernate Identity Store</default-attribute-store-id>
@@ -133,7 +133,7 @@
</repository>
<repository>
<id>Sample Portal Repository DB+LDAP</id>
- <class>org.jboss.identity.impl.repository.FallbackIdentityStoreRepository</class>
+ <class>org.jboss.identity.idm.impl.repository.FallbackIdentityStoreRepository</class>
<external-config/>
<default-identity-store-id>Hibernate Identity Store</default-identity-store-id>
<default-attribute-store-id>Hibernate Identity Store</default-attribute-store-id>
@@ -179,7 +179,7 @@
<identity-stores>
<identity-store>
<id>Hibernate Identity Store</id>
- <class>org.jboss.identity.impl.store.hibernate.HibernateIdentityStoreImpl</class>
+ <class>org.jboss.identity.idm.impl.store.hibernate.HibernateIdentityStoreImpl</class>
<external-config/>
<supported-relationship-types>
<relationship-type>JBOSS_IDENTITY_MEMBERSHIP</relationship-type>
@@ -311,7 +311,7 @@
</identity-store>
<identity-store>
<id>LDAP Identity Store</id>
- <class>org.jboss.identity.impl.store.ldap.LDAPIdentityStoreImpl</class>
+ <class>org.jboss.identity.idm.impl.store.ldap.LDAPIdentityStoreImpl</class>
<external-config/>
<supported-relationship-types>
<relationship-type>JBOSS_IDENTITY_MEMBERSHIP</relationship-type>
Modified: trunk/identity-impl/src/test/resources/store-test-config.xml
===================================================================
--- trunk/identity-impl/src/test/resources/store-test-config.xml 2009-01-13 15:18:42 UTC (rev 211)
+++ trunk/identity-impl/src/test/resources/store-test-config.xml 2009-01-13 15:39:59 UTC (rev 212)
@@ -32,7 +32,7 @@
<identity-stores>
<identity-store>
<id>HibernateTestStore</id>
- <class>org.jboss.identity.impl.store.hibernate.HibernateIdentityStoreImpl</class>
+ <class>org.jboss.identity.idm.impl.store.hibernate.HibernateIdentityStoreImpl</class>
<external-config/>
<supported-relationship-types>
<relationship-type>JBOSS_IDENTITY_MEMBERSHIP</relationship-type>
@@ -159,7 +159,7 @@
</identity-store>
<identity-store>
<id>LDAPTestStore</id>
- <class>org.jboss.identity.impl.store.ldap.LDAPIdentityStoreImpl</class>
+ <class>org.jboss.identity.idm.impl.store.ldap.LDAPIdentityStoreImpl</class>
<external-config/>
<supported-relationship-types>
<relationship-type>JBOSS_IDENTITY_MEMBERSHIP</relationship-type>
Modified: trunk/identity-impl/src/test/resources/test-config.xml
===================================================================
--- trunk/identity-impl/src/test/resources/test-config.xml 2009-01-13 15:18:42 UTC (rev 211)
+++ trunk/identity-impl/src/test/resources/test-config.xml 2009-01-13 15:39:59 UTC (rev 212)
@@ -25,7 +25,7 @@
<repositories>
<repository>
<id>Fallback Repository - ACME</id>
- <class>org.jboss.identity.impl.repository.FallbackIdentityStoreRepository</class>
+ <class>org.jboss.identity.idm.impl.repository.FallbackIdentityStoreRepository</class>
<external-config override="false">path/to/file.xml</external-config>
<default-identity-store-id>Hibernate Identity Store</default-identity-store-id>
<default-attribute-store-id>Hibernate Identity Store</default-attribute-store-id>
@@ -69,7 +69,7 @@
<identity-stores>
<identity-store>
<id>Hibernate Identity Store</id>
- <class>org.jboss.identity.impl.store.hibernate.HibernateIdentityStoreImpl</class>
+ <class>org.jboss.identity.idm.impl.store.hibernate.HibernateIdentityStoreImpl</class>
<external-config/>
<supported-relationship-types>
<relationship-type>JBOSS_IDENTITY_RELATIONSHIP_MEMBERSHIP</relationship-type>
@@ -99,7 +99,7 @@
</identity-store>
<identity-store>
<id>LDAP Identity Store</id>
- <class>org.jboss.identity.impl.store.hibernate.HibernateIdentityStoreImpl</class>
+ <class>org.jboss.identity.idm.impl.store.hibernate.HibernateIdentityStoreImpl</class>
<external-config override="false">path/to/file.xml</external-config>
<supported-relationship-types>
<relationship-type>JBOSS_IDENTITY_RELATIONSHIP_MEMBERSHIP</relationship-type>
Copied: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi (from rev 198, trunk/identity-spi/src/main/java/org/jboss/identity/spi)
Deleted: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/attribute/IdentityObjectAttributeMetaData.java
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/spi/attribute/IdentityObjectAttributeMetaData.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/attribute/IdentityObjectAttributeMetaData.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,64 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.spi.attribute;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public interface IdentityObjectAttributeMetaData
-{
- public static final String TEXT_TYPE = "text";
-
- public static final String BINARY_TYPE = "binary";
-
- /**
- * @return
- */
- String getName();
-
- /**
- * @return
- */
- String getStoreMapping();
-
- /**
- * @return
- */
- String getType();
-
- /**
- * @return
- */
- boolean isReadonly();
-
- /**
- * @return
- */
- boolean isMultivalued();
-
- /**
- * @return
- */
- boolean isRequired();
-}
Deleted: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/ConfigurationService.java
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/spi/configuration/ConfigurationService.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/ConfigurationService.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,38 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.spi.configuration;
-
-import java.util.Collection;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public interface ConfigurationService
-{
-
-
-
-
-
-}
Deleted: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityConfigurationMetaData.java
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/spi/configuration/metadata/IdentityConfigurationMetaData.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityConfigurationMetaData.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,41 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.spi.configuration.metadata;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public interface IdentityConfigurationMetaData
-{
- List<RealmConfigurationMetaData> getRealms();
-
- List<IdentityRepositoryConfigurationMetaData> getRepositories();
-
- List<IdentityStoreConfigurationMetaData> getIdentityStores();
-
- Map<String, List<String>> getOptions();
-}
Copied: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityConfigurationMetaData.java (from rev 211, trunk/identity-spi/src/main/java/org/jboss/identity/spi/configuration/metadata/IdentityConfigurationMetaData.java)
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityConfigurationMetaData.java (rev 0)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityConfigurationMetaData.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,56 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.spi.configuration.metadata;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Main interface describing configuration of identity realms, repositories and global options
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface IdentityConfigurationMetaData
+{
+
+ /**
+ * @return realms configuration
+ */
+ List<RealmConfigurationMetaData> getRealms();
+
+ /**
+ * @return repositories configuration
+ */
+ List<IdentityRepositoryConfigurationMetaData> getRepositories();
+
+ /**
+ * @return identity stores configuration
+ */
+ List<IdentityStoreConfigurationMetaData> getIdentityStores();
+
+ /**
+ * @return options map
+ */
+ Map<String, List<String>> getOptions();
+}
Copied: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityObjectAttributeMetaData.java (from rev 211, trunk/identity-spi/src/main/java/org/jboss/identity/spi/configuration/metadata/IdentityObjectAttributeMetaData.java)
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityObjectAttributeMetaData.java (rev 0)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityObjectAttributeMetaData.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,64 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.spi.configuration.metadata;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface IdentityObjectAttributeMetaData
+{
+ public static final String TEXT_TYPE = "text";
+
+ public static final String BINARY_TYPE = "binary";
+
+ /**
+ * @return
+ */
+ String getName();
+
+ /**
+ * @return
+ */
+ String getStoreMapping();
+
+ /**
+ * @return
+ */
+ String getType();
+
+ /**
+ * @return
+ */
+ boolean isReadonly();
+
+ /**
+ * @return
+ */
+ boolean isMultivalued();
+
+ /**
+ * @return
+ */
+ boolean isRequired();
+}
Deleted: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityObjectTypeMetaData.java
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/spi/configuration/metadata/IdentityObjectTypeMetaData.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityObjectTypeMetaData.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,49 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.spi.configuration.metadata;
-
-import org.jboss.identity.spi.attribute.IdentityObjectAttributeMetaData;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public interface IdentityObjectTypeMetaData
-{
- String getName();
-
- List<RelationshipMetaData> getRelationships();
-
- List<IdentityObjectAttributeMetaData> getAttributes();
-
- List<String> getCredentials();
-
- Map<String, List<String>> getOptions();
-
- List<String> getOption(String optionName);
-
- String getOptionSingleValue(String optionName);
-}
Copied: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityObjectTypeMetaData.java (from rev 211, trunk/identity-spi/src/main/java/org/jboss/identity/spi/configuration/metadata/IdentityObjectTypeMetaData.java)
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityObjectTypeMetaData.java (rev 0)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityObjectTypeMetaData.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,74 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.spi.configuration.metadata;
+
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityObjectAttributeMetaData;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Configuration of IdentityObjectType within IdentityStore
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface IdentityObjectTypeMetaData
+{
+ /**
+ * @return name
+ */
+ String getName();
+
+ /**
+ * @return allowed relationships meta data
+ */
+ List<RelationshipMetaData> getRelationships();
+
+ /**
+ * @return allowed attributes meta data
+ */
+ List<IdentityObjectAttributeMetaData> getAttributes();
+
+ /**
+ * @return list of supported CredentialType names
+ */
+ List<String> getCredentials();
+
+ /**
+ * @return options
+ */
+ Map<String, List<String>> getOptions();
+
+ /**
+ * @param optionName
+ * @return option values
+ */
+ List<String> getOption(String optionName);
+
+ /**
+ * @param optionName
+ * @return single (first) value of a given option
+ */
+ String getOptionSingleValue(String optionName);
+}
Deleted: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityRepositoryConfigurationMetaData.java
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/spi/configuration/metadata/IdentityRepositoryConfigurationMetaData.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityRepositoryConfigurationMetaData.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,51 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.spi.configuration.metadata;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public interface IdentityRepositoryConfigurationMetaData
-{
- String getId();
-
- String getClassName();
-
- String getExternalConfig();
-
- String getDefaultIdentityStoreId();
-
- String getDefaultAttributeStroeId();
-
- List<IdentityStoreMappingMetaData> getIdentityStoreToIdentityObjectTypeMappings();
-
- Map<String, List<String>> getOptions();
-
- List<String> getOption(String optionName);
-
- String getOptionSingleValue(String optionName);
-}
Copied: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityRepositoryConfigurationMetaData.java (from rev 211, trunk/identity-spi/src/main/java/org/jboss/identity/spi/configuration/metadata/IdentityRepositoryConfigurationMetaData.java)
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityRepositoryConfigurationMetaData.java (rev 0)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityRepositoryConfigurationMetaData.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,82 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.spi.configuration.metadata;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Configuration of IdentityRepository
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface IdentityRepositoryConfigurationMetaData
+{
+ /**
+ * @return id
+ */
+ String getId();
+
+ /**
+ * @return class name of IdentityStoreRepository implementation
+ */
+ String getClassName();
+
+ /**
+ * @return extenal configuration file
+ */
+ String getExternalConfig();
+
+ /**
+ * @return id of the default IdentityStore
+ */
+ String getDefaultIdentityStoreId();
+
+ /**
+ * @return id of the default AttributeStore
+ */
+ String getDefaultAttributeStroeId();
+
+ /**
+ * @return configuration meta data of IdentityStore mappings
+ */
+ List<IdentityStoreMappingMetaData> getIdentityStoreToIdentityObjectTypeMappings();
+
+ /**
+ * @return options
+ */
+ Map<String, List<String>> getOptions();
+
+ /**
+ * @param optionName
+ * @return values of a given option
+ */
+ List<String> getOption(String optionName);
+
+ /**
+ * @param optionName
+ * @return single (first) value of a given option
+ */
+ String getOptionSingleValue(String optionName);
+}
Deleted: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityStoreConfigurationMetaData.java
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/spi/configuration/metadata/IdentityStoreConfigurationMetaData.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityStoreConfigurationMetaData.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,49 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.spi.configuration.metadata;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public interface IdentityStoreConfigurationMetaData
-{
- String getId();
-
- String getClassName();
-
- String getExternalConfig();
-
- List<String> getSupportedRelationshipTypes();
-
- List<IdentityObjectTypeMetaData> getSupportedIdentityTypes();
-
- Map<String, List<String>> getOptions();
-
- List<String> getOption(String optionName);
-
- String getOptionSingleValue(String optionName);
-}
Copied: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityStoreConfigurationMetaData.java (from rev 211, trunk/identity-spi/src/main/java/org/jboss/identity/spi/configuration/metadata/IdentityStoreConfigurationMetaData.java)
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityStoreConfigurationMetaData.java (rev 0)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityStoreConfigurationMetaData.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,77 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.spi.configuration.metadata;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Configuration of IdentityStore
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface IdentityStoreConfigurationMetaData
+{
+ /**
+ * @return id
+ */
+ String getId();
+
+ /**
+ * @return class name of an IdentityStore implementation
+ */
+ String getClassName();
+
+ /**
+ * @return external configuration file
+ */
+ String getExternalConfig();
+
+ /**
+ * @return list of supported RelationshipType names
+ */
+ List<String> getSupportedRelationshipTypes();
+
+ /**
+ * @return IdentityTypes configurations
+ */
+ List<IdentityObjectTypeMetaData> getSupportedIdentityTypes();
+
+ /**
+ * @return options
+ */
+ Map<String, List<String>> getOptions();
+
+ /**
+ * @param optionName
+ * @return option values
+ */
+ List<String> getOption(String optionName);
+
+ /**
+ * @param optionName
+ * @return single (first) value of a given option
+ */
+ String getOptionSingleValue(String optionName);
+}
Deleted: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityStoreMappingMetaData.java
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/spi/configuration/metadata/IdentityStoreMappingMetaData.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityStoreMappingMetaData.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,43 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.spi.configuration.metadata;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public interface IdentityStoreMappingMetaData
-{
- String getIdentityStoreId();
-
- List<String> getIdentityObjectTypeMappings();
-
- Map<String, List<String>> getOptions();
-
- List<String> getOption(String optionName);
-
- String getOptionSingleValue(String optionName);
-}
Copied: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityStoreMappingMetaData.java (from rev 211, trunk/identity-spi/src/main/java/org/jboss/identity/spi/configuration/metadata/IdentityStoreMappingMetaData.java)
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityStoreMappingMetaData.java (rev 0)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/IdentityStoreMappingMetaData.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,62 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.spi.configuration.metadata;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Configuration of IdentityStore mappings within IdentityStoreRepository
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface IdentityStoreMappingMetaData
+{
+ /**
+ * @return IdentityStore id
+ */
+ String getIdentityStoreId();
+
+ /**
+ * @return list of mapped IdentityObjectType names
+ */
+ List<String> getIdentityObjectTypeMappings();
+
+ /**
+ * @return options
+ */
+ Map<String, List<String>> getOptions();
+
+ /**
+ * @param optionName
+ * @return values of a given option
+ */
+ List<String> getOption(String optionName);
+
+ /**
+ * @param optionName
+ * @return single (first) value of a given option
+ */
+ String getOptionSingleValue(String optionName);
+}
Deleted: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/RealmConfigurationMetaData.java
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/spi/configuration/metadata/RealmConfigurationMetaData.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/RealmConfigurationMetaData.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,43 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.spi.configuration.metadata;
-
-import java.util.Map;
-import java.util.List;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public interface RealmConfigurationMetaData
-{
- String getId();
-
- String getIdentityRepositoryIdRef();
-
- String getIdentityMapping();
-
- Map<String, String> getGroupTypeMappings();
-
- Map<String, List<String>> getOptions();
-}
Copied: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/RealmConfigurationMetaData.java (from rev 211, trunk/identity-spi/src/main/java/org/jboss/identity/spi/configuration/metadata/RealmConfigurationMetaData.java)
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/RealmConfigurationMetaData.java (rev 0)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/RealmConfigurationMetaData.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,59 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.spi.configuration.metadata;
+
+import java.util.Map;
+import java.util.List;
+
+/**
+ * Configuration of a single realm
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface RealmConfigurationMetaData
+{
+ /**
+ * @return realm id
+ */
+ String getId();
+
+ /**
+ * @return id of IdentityRepository
+ */
+ String getIdentityRepositoryIdRef();
+
+ /**
+ * @return name of IdentityObjectType that represents Identity object
+ */
+ String getIdentityMapping();
+
+ /**
+ *@return mappings between GroupType and IdentityObjectType names
+ */
+ Map<String, String> getGroupTypeMappings();
+
+ /**
+ * @return options
+ */
+ Map<String, List<String>> getOptions();
+}
Deleted: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/RelationshipMetaData.java
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/spi/configuration/metadata/RelationshipMetaData.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/RelationshipMetaData.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,34 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.spi.configuration.metadata;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public interface RelationshipMetaData
-{
- String getRelationshipTypeRef();
-
- String getIdentityObjectTypeRef();
-}
Copied: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/RelationshipMetaData.java (from rev 211, trunk/identity-spi/src/main/java/org/jboss/identity/spi/configuration/metadata/RelationshipMetaData.java)
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/RelationshipMetaData.java (rev 0)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/configuration/metadata/RelationshipMetaData.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,42 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.spi.configuration.metadata;
+
+/**
+ * Relationship meta data
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface RelationshipMetaData
+{
+ /**
+ * @return RelationshipType name
+ */
+ String getRelationshipTypeRef();
+
+ /**
+ * @return IdentityObjectType name
+ */
+ String getIdentityObjectTypeRef();
+}
Modified: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/exception/IdentityConfigurationException.java
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/spi/exception/IdentityConfigurationException.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/exception/IdentityConfigurationException.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,9 +20,9 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.spi.exception;
+package org.jboss.identity.idm.spi.exception;
-import org.jboss.identity.exception.IdentityException;
+import org.jboss.identity.idm.exception.IdentityException;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Modified: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/exception/IdentityTypeNotSupportedException.java
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/spi/exception/IdentityTypeNotSupportedException.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/exception/IdentityTypeNotSupportedException.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -19,9 +19,9 @@
* 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.spi.exception;
+package org.jboss.identity.idm.spi.exception;
-import org.jboss.identity.exception.IdentityException;
+import org.jboss.identity.idm.exception.IdentityException;
/**
* <p>Represents an exception that
Modified: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/exception/OperationNotSupportedException.java
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/spi/exception/OperationNotSupportedException.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/exception/OperationNotSupportedException.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,7 +20,7 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.spi.exception;
+package org.jboss.identity.idm.spi.exception;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Modified: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/fedid/PseudonymGenerator.java
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/spi/fedid/PseudonymGenerator.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/fedid/PseudonymGenerator.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -19,7 +19,7 @@
* 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.spi.fedid;
+package org.jboss.identity.idm.spi.fedid;
/**
* Generator for Pseudonyms
Deleted: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObject.java
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/spi/model/IdentityObject.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObject.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,67 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.spi.model;
-
-import java.util.Map;
-import java.util.Set;
-
-import org.jboss.identity.exception.PolicyValidationException;
-
-/**
- * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot com">Boleslaw Dawidowicz</a>
- * @author Anil.Saldhana at redhat.com
- * @version : 0.1 $
- */
-public interface IdentityObject
-{
-
- /**
- * @return id of this identity object
- */
- String getId();
-
- /**
- * FQDN identifies the context of this object - realm, identity store in which it is persisted and object id in this store
- *
- * @return full qualified domain name for this identity
- */
- String getFQDN();
-
- /**
- * <p>Return the name of the identity</p>
- * @return
- */
- String getName();
-
- /**
- * <p>Return type of this identity object</p>
- * @return
- */
- IdentityObjectType getIdentityType();
-
- /**
- * Validate configured Policies
- * @throws org.jboss.identity.exception.PolicyValidationException
- */
- void validatePolicy() throws PolicyValidationException;
-}
Copied: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObject.java (from rev 211, trunk/identity-spi/src/main/java/org/jboss/identity/spi/model/IdentityObject.java)
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObject.java (rev 0)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObject.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,57 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.spi.model;
+
+import org.jboss.identity.idm.exception.PolicyValidationException;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot com">Boleslaw Dawidowicz</a>
+ * @author Anil.Saldhana at redhat.com
+ * @version : 0.1 $
+ */
+public interface IdentityObject
+{
+
+ /**
+ * @return id of this identity object
+ */
+ String getId();
+
+ /**
+ * <p>Return the name of the identity</p>
+ * @return
+ */
+ String getName();
+
+ /**
+ * <p>Return type of this identity object</p>
+ * @return
+ */
+ IdentityObjectType getIdentityType();
+
+ /**
+ * Validate configured Policies
+ * @throws org.jboss.identity.idm.exception.PolicyValidationException
+ */
+ void validatePolicy() throws PolicyValidationException;
+}
Deleted: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectAttribute.java
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/spi/model/IdentityObjectAttribute.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectAttribute.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,47 +0,0 @@
-/*
- * 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.spi.model;
-
-import org.jboss.identity.spi.attribute.IdentityObjectAttributeMetaData;
-
-import java.util.Collection;
-
-/**
- * An attribute of an identity
- * @author Anil.Saldhana at redhat.com
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @since Jun 30, 2008
- */
-public interface IdentityObjectAttribute
-{
-
- String getName();
-
- Object getValue();
-
- void addValue(Object value);
-
- Collection getValues();
-
- int getSize();
-
-}
\ No newline at end of file
Copied: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectAttribute.java (from rev 211, trunk/identity-spi/src/main/java/org/jboss/identity/spi/model/IdentityObjectAttribute.java)
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectAttribute.java (rev 0)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectAttribute.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,63 @@
+/*
+ * 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.idm.spi.model;
+
+import java.util.Collection;
+
+/**
+ * Abstract representation of attribute related to IdentityObject object. Can have many values
+ *
+ * @author Anil.Saldhana at redhat.com
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @since Jun 30, 2008
+ */
+public interface IdentityObjectAttribute
+{
+
+ /**
+ * @return name
+ */
+ String getName();
+
+ /**
+ * @return attribute value. If attribute has many values it may be any one of them.
+ */
+ Object getValue();
+
+ /**
+ * Add attribute value. It will be appended.
+ *
+ * @param value
+ */
+ void addValue(Object value);
+
+ /**
+ * @return attribute values
+ */
+ Collection getValues();
+
+ /**
+ * @return number of attribute values
+ */
+ int getSize();
+
+}
\ No newline at end of file
Deleted: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectCredential.java
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/spi/model/IdentityObjectCredential.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectCredential.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,51 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.spi.model;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public interface IdentityObjectCredential
-{
-
- /**
- *
- * @return
- */
- IdentityObjectCredentialType getType();
-
- /**
- * @return Should return either String for text based credentials or byte[] for binary
- */
- Object getValue();
-
-
- /**
- * @return encoded value. For example hash from a string password.
- * Should return either String for text based credentials or byte[] for binary.
- * May return null if credential implementaion doesn't provide encoding mechanism.
- * IdentityStore is not obligated to use encoded value.
- */
- Object getEncodedValue();
-}
Copied: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectCredential.java (from rev 211, trunk/identity-spi/src/main/java/org/jboss/identity/spi/model/IdentityObjectCredential.java)
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectCredential.java (rev 0)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectCredential.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -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.idm.spi.model;
+
+/**
+ * Represents credential related to IdentityObject
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface IdentityObjectCredential
+{
+
+ /**
+ *
+ * @return
+ */
+ IdentityObjectCredentialType getType();
+
+ /**
+ * @return Should return either String for text based credentials or byte[] for binary
+ */
+ Object getValue();
+
+
+ /**
+ * @return encoded value. For example hash from a string password.
+ * Should return either String for text based credentials or byte[] for binary.
+ * May return null if credential implementaion doesn't provide encoding mechanism.
+ * IdentityStore is not obligated to use encoded value.
+ */
+ Object getEncodedValue();
+}
Deleted: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectCredentialType.java
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/spi/model/IdentityObjectCredentialType.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectCredentialType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,37 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.spi.model;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public interface IdentityObjectCredentialType
-{
-
- /**
- *
- * @return
- */
- String getName();
-}
Copied: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectCredentialType.java (from rev 211, trunk/identity-spi/src/main/java/org/jboss/identity/spi/model/IdentityObjectCredentialType.java)
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectCredentialType.java (rev 0)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectCredentialType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,38 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.spi.model;
+
+/**
+ * Type of Credential
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface IdentityObjectCredentialType
+{
+
+ /**
+ * @return name
+ */
+ String getName();
+}
Deleted: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectRelationship.java
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/spi/model/IdentityObjectRelationship.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectRelationship.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,48 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.spi.model;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public interface IdentityObjectRelationship
-{
-
- /**
- * @return Relationship name or null if this relationship is not named
- */
- String getName();
-
- /**
- *
- * @return
- */
- IdentityObjectRelationshipType getType();
-
- IdentityObject getFromIdentityObject();
-
- IdentityObject getToIdentityObject();
-
-
-}
Copied: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectRelationship.java (from rev 211, trunk/identity-spi/src/main/java/org/jboss/identity/spi/model/IdentityObjectRelationship.java)
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectRelationship.java (rev 0)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectRelationship.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,57 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.spi.model;
+
+/**
+ * Relationship between two IdentityObject objects
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface IdentityObjectRelationship
+{
+
+ /**
+ * @return relationship name or null if this relationship is not named
+ */
+ String getName();
+
+ /**
+ *
+ * @return relationship type
+ */
+ IdentityObjectRelationshipType getType();
+
+ /**
+ *
+ * @return IdentityObject from which this relationship starts
+ */
+ IdentityObject getFromIdentityObject();
+
+ /**
+ * @return IdentityObject on which this relationship ends
+ */
+ IdentityObject getToIdentityObject();
+
+
+}
Deleted: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectRelationshipType.java
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/spi/model/IdentityObjectRelationshipType.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectRelationshipType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,32 +0,0 @@
-/*
- * 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.spi.model;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @author Anil.Saldhana at redhat.com
- * @since Jul 9, 2008
- */
-public interface IdentityObjectRelationshipType
-{
- String getName();
-}
\ No newline at end of file
Copied: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectRelationshipType.java (from rev 211, trunk/identity-spi/src/main/java/org/jboss/identity/spi/model/IdentityObjectRelationshipType.java)
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectRelationshipType.java (rev 0)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectRelationshipType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,38 @@
+/*
+ * 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.idm.spi.model;
+
+/**
+ * Type of Relationship
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @author Anil.Saldhana at redhat.com
+ * @since Jul 9, 2008
+ */
+public interface IdentityObjectRelationshipType
+{
+
+ /**
+ * @return name
+ */
+ String getName();
+}
\ No newline at end of file
Modified: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectType.java
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/spi/model/IdentityObjectType.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/model/IdentityObjectType.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -19,7 +19,7 @@
* 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.spi.model;
+package org.jboss.identity.idm.spi.model;
/**
* @author Anil.Saldhana at redhat.com
Deleted: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/policy/IdentityTypePolicy.java
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/spi/policy/IdentityTypePolicy.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/policy/IdentityTypePolicy.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,32 +0,0 @@
-/*
- * 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.spi.policy;
-
-/**
- * Marker Interface to indicate a policy
- * that governs one or more IdentityType(s)
- * @author Anil.Saldhana at redhat.com
- * @since Jul 13, 2008
- */
-public interface IdentityTypePolicy
-{
-}
\ No newline at end of file
Copied: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/policy/IdentityTypePolicy.java (from rev 211, trunk/identity-spi/src/main/java/org/jboss/identity/spi/policy/IdentityTypePolicy.java)
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/policy/IdentityTypePolicy.java (rev 0)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/policy/IdentityTypePolicy.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,32 @@
+///*
+// * 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.spi.policy;
+//
+///**
+// * Marker Interface to indicate a policy
+// * that governs one or more IdentityType(s)
+// * @author Anil.Saldhana at redhat.com
+// * @since Jul 13, 2008
+// */
+//public interface IdentityTypePolicy
+//{
+//}
\ No newline at end of file
Deleted: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/policy/PasswordExpirationPolicy.java
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/spi/policy/PasswordExpirationPolicy.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/policy/PasswordExpirationPolicy.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,34 +0,0 @@
-/*
- * 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.spi.policy;
-
-import org.jboss.identity.spi.model.IdentityObjectType;
-
-/**
- * Policy to govern Passwords
- * @author Anil.Saldhana at redhat.com
- * @since Jul 13, 2008
- */
-public interface PasswordExpirationPolicy<P extends IdentityObjectType>
-extends IdentityTypePolicy
-{
-}
\ No newline at end of file
Copied: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/policy/PasswordExpirationPolicy.java (from rev 211, trunk/identity-spi/src/main/java/org/jboss/identity/spi/policy/PasswordExpirationPolicy.java)
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/policy/PasswordExpirationPolicy.java (rev 0)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/policy/PasswordExpirationPolicy.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,34 @@
+///*
+// * 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.spi.policy;
+//
+//import org.jboss.identity.spi.model.IdentityObjectType;
+//
+///**
+// * Policy to govern Passwords
+// * @author Anil.Saldhana at redhat.com
+// * @since Jul 13, 2008
+// */
+//public interface PasswordExpirationPolicy<P extends IdentityObjectType>
+//extends IdentityTypePolicy
+//{
+//}
\ No newline at end of file
Deleted: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/policy/RelationshipPolicy.java
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/spi/policy/RelationshipPolicy.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/policy/RelationshipPolicy.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,50 +0,0 @@
-/*
- * 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.spi.policy;
-
-import org.jboss.identity.spi.model.IdentityObjectType;
-import org.jboss.identity.exception.PolicyValidationException;
-
-/**
- * A Policy that governs the Relationships
- * @author Anil.Saldhana at redhat.com
- * @since Jul 13, 2008
- */
-public interface RelationshipPolicy<P extends IdentityObjectType, Q extends IdentityObjectType>
-extends IdentityTypePolicy
-{
- /**
- * Define a relationship
- * @param pIdentityType
- * @param qIdentityType
- */
- void definePolicy(P pIdentityType, Q qIdentityType);
-
- /**
- * Validate a relationship
- * @param typeA first type
- * @param typeB second type
- * @throws PolicyValidationException
- */
- void validate(P typeA, Q typeB)
- throws PolicyValidationException;
-}
\ No newline at end of file
Copied: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/policy/RelationshipPolicy.java (from rev 211, trunk/identity-spi/src/main/java/org/jboss/identity/spi/policy/RelationshipPolicy.java)
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/policy/RelationshipPolicy.java (rev 0)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/policy/RelationshipPolicy.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,50 @@
+///*
+// * 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.spi.policy;
+//
+//import org.jboss.identity.spi.model.IdentityObjectType;
+//import org.jboss.identity.exception.PolicyValidationException;
+//
+///**
+// * A Policy that governs the Relationships
+// * @author Anil.Saldhana at redhat.com
+// * @since Jul 13, 2008
+// */
+//public interface RelationshipPolicy<P extends IdentityObjectType, Q extends IdentityObjectType>
+//extends IdentityTypePolicy
+//{
+// /**
+// * Define a relationship
+// * @param pIdentityType
+// * @param qIdentityType
+// */
+// void definePolicy(P pIdentityType, Q qIdentityType);
+//
+// /**
+// * Validate a relationship
+// * @param typeA first type
+// * @param typeB second type
+// * @throws PolicyValidationException
+// */
+// void validate(P typeA, Q typeB)
+// throws PolicyValidationException;
+//}
\ No newline at end of file
Modified: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/repository/IdentityStoreRepository.java
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/spi/repository/IdentityStoreRepository.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/repository/IdentityStoreRepository.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -19,16 +19,16 @@
* 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.spi.repository;
+package org.jboss.identity.idm.spi.repository;
import java.util.Map;
import java.util.Set;
-import org.jboss.identity.spi.model.IdentityObjectType;
-import org.jboss.identity.spi.store.IdentityStore;
-import org.jboss.identity.spi.store.AttributeStore;
-import org.jboss.identity.spi.configuration.metadata.IdentityRepositoryConfigurationMetaData;
-import org.jboss.identity.exception.IdentityException;
+import org.jboss.identity.idm.spi.model.IdentityObjectType;
+import org.jboss.identity.idm.spi.store.IdentityStore;
+import org.jboss.identity.idm.spi.store.AttributeStore;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityRepositoryConfigurationMetaData;
+import org.jboss.identity.idm.exception.IdentityException;
/**
* IdentityStoreRepository exposes identity object management
Modified: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/searchcontrol/IdentityObjectSearchControl.java
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/spi/searchcontrol/IdentityObjectSearchControl.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/searchcontrol/IdentityObjectSearchControl.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,7 +20,7 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.spi.searchcontrol;
+package org.jboss.identity.idm.spi.searchcontrol;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Deleted: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/store/AttributeStore.java
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/spi/store/AttributeStore.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/store/AttributeStore.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,112 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.spi.store;
-
-import org.jboss.identity.spi.model.IdentityObjectType;
-import org.jboss.identity.spi.model.IdentityObject;
-import org.jboss.identity.spi.model.IdentityObjectAttribute;
-import org.jboss.identity.spi.attribute.IdentityObjectAttributeMetaData;
-import org.jboss.identity.exception.IdentityException;
-
-import java.util.Set;
-import java.util.Map;
-
-/**
- * Store for identity related attributes. Its separate interface as there is possible need to store profiles in a
- * distributted way (part in LDAP part in DB).
- *
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public interface AttributeStore extends IdentityStoreSessionFactory
-{
-
- /**
- * @return id of this identity store
- */
- String getId();
-
- /**
- * @param invocationContext
- * @param identityType @return names of supported attributes
- * @return
- * @throws org.jboss.identity.exception.IdentityException
- */
- Set<String> getSupportedAttributeNames(IdentityStoreInvocationContext invocationContext, IdentityObjectType identityType)
- throws IdentityException;
-
- /**
- *
- * @return
- */
- Map<String, IdentityObjectAttributeMetaData> getAttributesMetaData(IdentityStoreInvocationContext invocationContext, IdentityObjectType identityType);
-
- //TODO: isNotConfiguredAttributeSupported - if store can handle attribute not mentioned in method above
-
- /**
- * Get attributes for the given identity
- *
- * @param invocationContext
- *@param identity @return @throws IdentityException
- */
- Map<String, IdentityObjectAttribute> getAttributes(IdentityStoreInvocationContext invocationContext, IdentityObject identity) throws IdentityException;
-
- /**
- * Get attribute for the given identity
- *
- * @param invocationContext
- *@param identity @return @throws IdentityException
- */
- IdentityObjectAttribute getAttribute(IdentityStoreInvocationContext invocationContext, IdentityObject identity, String name) throws IdentityException;
-
- /**
- * Update attributes with new values - previous values will be overwritten. Attributes not specified in the map are not changed.
- * @param invocationCtx
- * @param identity
- * @param attributes @throws IdentityException
- */
- void updateAttributes(IdentityStoreInvocationContext invocationCtx, IdentityObject identity, IdentityObjectAttribute[] attributes)
- throws IdentityException;
-
- /**
- * Add new attributes - if attribute with given name already exists the values
- * will be appended
- *
- * @param invocationCtx
- * @param identity
- * @param attributes @throws IdentityException
- */
- void addAttributes(IdentityStoreInvocationContext invocationCtx, IdentityObject identity, IdentityObjectAttribute[] attributes)
- throws IdentityException;
-
- /**
- * Remove attributes
- *
- * @param invocationCtx
- * @param identity
- * @param attributeNames
- */
- void removeAttributes(IdentityStoreInvocationContext invocationCtx, IdentityObject identity, String[] attributeNames)
- throws IdentityException;
-
-}
Copied: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/store/AttributeStore.java (from rev 211, trunk/identity-spi/src/main/java/org/jboss/identity/spi/store/AttributeStore.java)
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/store/AttributeStore.java (rev 0)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/store/AttributeStore.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,110 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.spi.store;
+
+import org.jboss.identity.idm.spi.model.IdentityObjectType;
+import org.jboss.identity.idm.spi.model.IdentityObject;
+import org.jboss.identity.idm.spi.model.IdentityObjectAttribute;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityObjectAttributeMetaData;
+import org.jboss.identity.idm.exception.IdentityException;
+
+import java.util.Set;
+import java.util.Map;
+
+/**
+ * Store for identity related attributes. Its separate interface as there is possible need to store profiles in a
+ * distributted way (part in LDAP part in DB).
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface AttributeStore extends IdentityStoreSessionFactory
+{
+
+ /**
+ * @return id of this identity store
+ */
+ String getId();
+
+ /**
+ * @param invocationContext
+ * @param identityType @return names of supported attributes
+ * @return
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ Set<String> getSupportedAttributeNames(IdentityStoreInvocationContext invocationContext, IdentityObjectType identityType)
+ throws IdentityException;
+
+ /**
+ *
+ * @return
+ */
+ Map<String, IdentityObjectAttributeMetaData> getAttributesMetaData(IdentityStoreInvocationContext invocationContext, IdentityObjectType identityType);
+
+ /**
+ * Get attributes for the given identity
+ *
+ * @param invocationContext
+ *@param identity @return @throws IdentityException
+ */
+ Map<String, IdentityObjectAttribute> getAttributes(IdentityStoreInvocationContext invocationContext, IdentityObject identity) throws IdentityException;
+
+ /**
+ * Get attribute for the given identity
+ *
+ * @param invocationContext
+ *@param identity @return @throws IdentityException
+ */
+ IdentityObjectAttribute getAttribute(IdentityStoreInvocationContext invocationContext, IdentityObject identity, String name) throws IdentityException;
+
+ /**
+ * Update attributes with new values - previous values will be overwritten. Attributes not specified in the map are not changed.
+ * @param invocationCtx
+ * @param identity
+ * @param attributes @throws IdentityException
+ */
+ void updateAttributes(IdentityStoreInvocationContext invocationCtx, IdentityObject identity, IdentityObjectAttribute[] attributes)
+ throws IdentityException;
+
+ /**
+ * Add new attributes - if attribute with given name already exists the values
+ * will be appended
+ *
+ * @param invocationCtx
+ * @param identity
+ * @param attributes @throws IdentityException
+ */
+ void addAttributes(IdentityStoreInvocationContext invocationCtx, IdentityObject identity, IdentityObjectAttribute[] attributes)
+ throws IdentityException;
+
+ /**
+ * Remove attributes
+ *
+ * @param invocationCtx
+ * @param identity
+ * @param attributeNames
+ */
+ void removeAttributes(IdentityStoreInvocationContext invocationCtx, IdentityObject identity, String[] attributeNames)
+ throws IdentityException;
+
+}
Deleted: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/store/FeaturesMetaData.java
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/spi/store/FeaturesMetaData.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/store/FeaturesMetaData.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,101 +0,0 @@
-/*
- * 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.spi.store;
-
-import java.util.Set;
-
-import org.jboss.identity.spi.model.IdentityObjectType;
-import org.jboss.identity.spi.model.IdentityObjectRelationshipType;
-import org.jboss.identity.spi.model.IdentityObjectCredentialType;
-import org.jboss.identity.spi.searchcontrol.IdentityObjectSearchControl;
-import org.jboss.identity.exception.IdentityException;
-
-/**
- * Describe the features supported by an Identity Store
- * @author boleslaw dot dawidowicz at redhat anotherdot com
- * @author Anil.Saldhana at redhat.com
- * @since Jul 10, 2008
- */
-public interface FeaturesMetaData
-{
- /**
- *
- * @param identityObjectType
- * @param control
- * @return
- */
- boolean isControlSupported(IdentityObjectType identityObjectType, IdentityObjectSearchControl control);
-
- /**
- *
- * @param identityObjectType
- * @param controlClazz
- * @return
- */
- boolean isControlSupported(IdentityObjectType identityObjectType, Class controlClazz);
-
- //TODO: isControlSupported per RelationshipType
-
-
- /**
- * @return set of identity types that can be persisted
- */
- Set<String> getSupportedIdentityObjectTypes();
-
- /**
- * @param identityObjectType
- * @return boolean describing if given identity type can be persisted or retrieved using this identity store
- */
- boolean isIdentityObjectTypeSupported(IdentityObjectType identityObjectType);
-
- /**
- * @param fromType
- * @param toType
- * @param relationshipType
- * @return true is given relationship can be persisted or retrieved
- * @throws org.jboss.identity.exception.IdentityException
- */
- boolean isRelationshipTypeSupported(IdentityObjectType fromType, IdentityObjectType toType,
- IdentityObjectRelationshipType relationshipType)
- throws IdentityException;
-
- /**
- *
- * @return
- */
- boolean isNamedRelationshipsSupported();
-
-
- /**
- * @return Set of relationship type names supported in this store
- */
- Set<String> getSupportedRelationshipTypes();
-
- /**
- *
- * @param identityObjectType
- * @param credentialType
- * @return
- */
- boolean isCredentialSupported(IdentityObjectType identityObjectType, IdentityObjectCredentialType credentialType);
-
-}
\ No newline at end of file
Copied: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/store/FeaturesMetaData.java (from rev 211, trunk/identity-spi/src/main/java/org/jboss/identity/spi/store/FeaturesMetaData.java)
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/store/FeaturesMetaData.java (rev 0)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/store/FeaturesMetaData.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,98 @@
+/*
+ * 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.idm.spi.store;
+
+import java.util.Set;
+
+import org.jboss.identity.idm.spi.model.IdentityObjectType;
+import org.jboss.identity.idm.spi.model.IdentityObjectRelationshipType;
+import org.jboss.identity.idm.spi.model.IdentityObjectCredentialType;
+import org.jboss.identity.idm.spi.searchcontrol.IdentityObjectSearchControl;
+import org.jboss.identity.idm.exception.IdentityException;
+
+/**
+ * Describe the features supported by an Identity Store
+ * @author boleslaw dot dawidowicz at redhat anotherdot com
+ * @author Anil.Saldhana at redhat.com
+ * @since Jul 10, 2008
+ */
+public interface FeaturesMetaData
+{
+ /**
+ *
+ * @param identityObjectType
+ * @param control
+ * @return
+ */
+ boolean isControlSupported(IdentityObjectType identityObjectType, IdentityObjectSearchControl control);
+
+ /**
+ *
+ * @param identityObjectType
+ * @param controlClazz
+ * @return
+ */
+ boolean isControlSupported(IdentityObjectType identityObjectType, Class controlClazz);
+
+ /**
+ * @return set of identity types that can be persisted
+ */
+ Set<String> getSupportedIdentityObjectTypes();
+
+ /**
+ * @param identityObjectType
+ * @return boolean describing if given identity type can be persisted or retrieved using this identity store
+ */
+ boolean isIdentityObjectTypeSupported(IdentityObjectType identityObjectType);
+
+ /**
+ * @param fromType
+ * @param toType
+ * @param relationshipType
+ * @return true is given relationship can be persisted or retrieved
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ boolean isRelationshipTypeSupported(IdentityObjectType fromType, IdentityObjectType toType,
+ IdentityObjectRelationshipType relationshipType)
+ throws IdentityException;
+
+ /**
+ *
+ * @return
+ */
+ boolean isNamedRelationshipsSupported();
+
+
+ /**
+ * @return Set of relationship type names supported in this store
+ */
+ Set<String> getSupportedRelationshipTypes();
+
+ /**
+ *
+ * @param identityObjectType
+ * @param credentialType
+ * @return
+ */
+ boolean isCredentialSupported(IdentityObjectType identityObjectType, IdentityObjectCredentialType credentialType);
+
+}
\ No newline at end of file
Modified: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityStore.java
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/spi/store/IdentityStore.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityStore.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -19,22 +19,22 @@
* 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.spi.store;
+package org.jboss.identity.idm.spi.store;
import java.io.IOException;
import java.util.Collection;
import java.util.Set;
import java.util.Map;
-import org.jboss.identity.spi.model.IdentityObject;
-import org.jboss.identity.spi.model.IdentityObjectType;
-import org.jboss.identity.spi.model.IdentityObjectRelationshipType;
-import org.jboss.identity.spi.model.IdentityObjectRelationship;
-import org.jboss.identity.spi.exception.OperationNotSupportedException;
-import org.jboss.identity.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
-import org.jboss.identity.spi.model.IdentityObjectCredential;
-import org.jboss.identity.spi.searchcontrol.IdentityObjectSearchControl;
-import org.jboss.identity.exception.IdentityException;
+import org.jboss.identity.idm.spi.model.IdentityObject;
+import org.jboss.identity.idm.spi.model.IdentityObjectType;
+import org.jboss.identity.idm.spi.model.IdentityObjectRelationshipType;
+import org.jboss.identity.idm.spi.model.IdentityObjectRelationship;
+import org.jboss.identity.idm.spi.exception.OperationNotSupportedException;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
+import org.jboss.identity.idm.spi.model.IdentityObjectCredential;
+import org.jboss.identity.idm.spi.searchcontrol.IdentityObjectSearchControl;
+import org.jboss.identity.idm.exception.IdentityException;
/**
* Represents an Identity Store. Implementation of this interface perform operations on real identity storage like DB or LDAP
Deleted: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityStoreContext.java
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/spi/store/IdentityStoreContext.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityStoreContext.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,31 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.spi.store;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public interface IdentityStoreContext
-{
-}
Modified: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityStoreInvocationContext.java
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/spi/store/IdentityStoreInvocationContext.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityStoreInvocationContext.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,7 +20,7 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.spi.store;
+package org.jboss.identity.idm.spi.store;
/**
* IdentityStoreInvocationContext is passed to the IdentityStore methods. It enables IdentityStore to not be aware
Deleted: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityStoreSession.java
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/spi/store/IdentityStoreSession.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityStoreSession.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -1,87 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.identity.spi.store;
-
-import org.jboss.identity.exception.IdentityException;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public interface IdentityStoreSession
-{
-
- /**
- * Session Context
- * @return
- */
- Object getSessionContext() throws IdentityException;
-
- /**
- * Close this session
- * @throws org.jboss.identity.exception.IdentityException
- */
- void close() throws IdentityException;
-
- /**
- * Save all pending changes
- * @throws org.jboss.identity.exception.IdentityException
- */
- void save() throws IdentityException;
-
- /**
- * Clear this session
- * @throws org.jboss.identity.exception.IdentityException
- */
- void clear() throws IdentityException;
-
- /**
- * Check if this session is open
- * @return
- */
- boolean isOpen();
-
-
- boolean isTransactionSupported();
-
- /**
- * Begin new transaction
- */
- void startTransaction();
-
- /**
- * Commit transaction - flush associated session
- */
- void commitTransaction();
-
- /**
- * Rollback transaction
- */
- void rollbackTransaction();
-
- /**
- *
- * @return
- */
- boolean isTransactionActive();
-}
Copied: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityStoreSession.java (from rev 211, trunk/identity-spi/src/main/java/org/jboss/identity/spi/store/IdentityStoreSession.java)
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityStoreSession.java (rev 0)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityStoreSession.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -0,0 +1,89 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.spi.store;
+
+import org.jboss.identity.idm.exception.IdentityException;
+
+/**
+ * Session related to the identity persistence store. Created by IdentityStoreSessionFactory
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface IdentityStoreSession
+{
+
+ /**
+ * Session Context
+ * @return
+ */
+ Object getSessionContext() throws IdentityException;
+
+ /**
+ * Close this session
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ void close() throws IdentityException;
+
+ /**
+ * Save all pending changes
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ void save() throws IdentityException;
+
+ /**
+ * Clear this session
+ * @throws org.jboss.identity.idm.exception.IdentityException
+ */
+ void clear() throws IdentityException;
+
+ /**
+ * Check if this session is open
+ * @return
+ */
+ boolean isOpen();
+
+
+ boolean isTransactionSupported();
+
+ /**
+ * Begin new transaction
+ */
+ void startTransaction();
+
+ /**
+ * Commit transaction - flush associated session
+ */
+ void commitTransaction();
+
+ /**
+ * Rollback transaction
+ */
+ void rollbackTransaction();
+
+ /**
+ *
+ * @return
+ */
+ boolean isTransactionActive();
+}
Modified: trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityStoreSessionFactory.java
===================================================================
--- trunk/identity-spi/src/main/java/org/jboss/identity/spi/store/IdentityStoreSessionFactory.java 2009-01-07 17:49:52 UTC (rev 198)
+++ trunk/identity-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityStoreSessionFactory.java 2009-01-13 15:39:59 UTC (rev 212)
@@ -20,9 +20,9 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.identity.spi.store;
+package org.jboss.identity.idm.spi.store;
-import org.jboss.identity.exception.IdentityException;
+import org.jboss.identity.idm.exception.IdentityException;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-01-13 15:18:42 UTC (rev 211)
+++ trunk/pom.xml 2009-01-13 15:39:59 UTC (rev 212)
@@ -30,7 +30,7 @@
<configuration>
<aggregate>true</aggregate>
- <excludePackageNames>org.jboss.identity.impl</excludePackageNames>
+ <excludePackageNames>org.jboss.identity.idm.impl</excludePackageNames>
</configuration>
</plugin>
</plugins>
More information about the jboss-identity-commits
mailing list