Author: bdaw
Date: 2008-12-02 13:51:34 -0500 (Tue, 02 Dec 2008)
New Revision: 124
Added:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/AbstractCredential.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/BinaryCredential.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/NameFilterSearchControl.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/PasswordCredential.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SimpleCredentialTypeImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/CredentialsType.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateIdentityObjectCredential.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateIdentityObjectCredentialType.java
trunk/identity-impl/src/test/resources/store-test-config.xml
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/AttributeFilterSearchControl.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/PageSearchControl.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SortByNameSearchControl.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/JAXB2IdentityConfiguration.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/AttributeType.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/AttributesType.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/ExternalConfigType.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/GroupTypeMappingType.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/IdentityObjectTypeType.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/IdentityObjectTypesType.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/IdentityStoreMappingType.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/IdentityStoreMappingsType.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/IdentityStoreType.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/IdentityStoresType.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/IdentityTypeMappingsType.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/JbossIdentityType.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/ObjectFactory.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/OptionType.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/OptionsType.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/RealmType.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/RealmsType.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/RelationshipType.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/RelationshipsType.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/RepositoriesType.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/RepositoryType.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/StoresType.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/SupportedIdentityObjectTypesType.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/SupportedRelationshipTypesType.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/package-info.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/metadata/IdentityObjectTypeMetaDataImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateIdentityObject.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateIdentityObjectAttribute.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateIdentityObjectRelationshipName.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateRealm.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/repository/WrapperIdentityStoreRepository.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/FeaturesMetaDataImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/hibernate/HibernateIdentityStoreImpl.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/ldap/LDAPIdentityStoreImpl.java
trunk/identity-impl/src/test/java/org/jboss/identity/impl/store/CommonIdentityStoreTest.java
trunk/identity-impl/src/test/java/org/jboss/identity/impl/store/RelationshipTypeEnum.java
trunk/identity-impl/src/test/java/org/jboss/identity/impl/store/hibernate/HibernateIdentityStoreTestCase.java
trunk/identity-impl/src/test/java/org/jboss/identity/impl/store/hibernate/HibernateModelTestCase.java
trunk/identity-impl/src/test/resources/META-INF/persistence.xml
trunk/identity-impl/src/test/resources/identity-config.xml
trunk/identity-impl/src/test/resources/identity-config.xsd
trunk/identity-impl/src/test/resources/organization-test-config.xml
trunk/identity-spi/src/main/java/org/jboss/identity/spi/configuration/metadata/IdentityObjectTypeMetaData.java
trunk/identity-spi/src/main/java/org/jboss/identity/spi/credential/IdentityObjectCredential.java
trunk/identity-spi/src/main/java/org/jboss/identity/spi/store/FeaturesMetaData.java
Log:
Nearly feature complete Hibernate store
Added:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/AbstractCredential.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/AbstractCredential.java
(rev 0)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/AbstractCredential.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -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.impl.api;
+
+import org.jboss.identity.spi.credential.IdentityObjectCredential;
+import org.jboss.identity.api.Credential;
+import org.jboss.identity.api.CredentialType;
+
+/**
+ * @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)
+ {
+ this.type = type;
+ }
+
+ public SimpleCredentialTypeImpl getType()
+ {
+ return type;
+ }
+}
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/AttributeFilterSearchControl.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/AttributeFilterSearchControl.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/AttributeFilterSearchControl.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -25,11 +25,27 @@
import org.jboss.identity.api.IdentitySearchControl;
import org.jboss.identity.spi.searchcontrol.IdentityObjectSearchControl;
+import java.util.Map;
+
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
* @version : 0.1 $
*/
public class AttributeFilterSearchControl implements IdentitySearchControl,
IdentityObjectSearchControl
{
-
+ private final Map<String, String[]> attributes;
+
+ public AttributeFilterSearchControl(Map<String, String[]> attributes)
+ {
+ if (attributes == null)
+ {
+ throw new IllegalArgumentException("attributes is null");
+ }
+ this.attributes = attributes;
+ }
+
+ public Map<String, String[]> getValues()
+ {
+ return attributes;
+ }
}
Added:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/BinaryCredential.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/BinaryCredential.java
(rev 0)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/BinaryCredential.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -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.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 BinaryCredential(byte[] value)
+ {
+ super(new SimpleCredentialTypeImpl("BINARY"));
+ this.value = value;
+ }
+
+ public byte[] getValue()
+ {
+ return value;
+ }
+
+ public Object getEncodedValue()
+ {
+ return null;
+ }
+}
\ No newline at end of file
Added:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/NameFilterSearchControl.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/NameFilterSearchControl.java
(rev 0)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/NameFilterSearchControl.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -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.impl.api;
+
+import org.jboss.identity.api.IdentitySearchControl;
+import org.jboss.identity.spi.searchcontrol.IdentityObjectSearchControl;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class NameFilterSearchControl implements IdentitySearchControl,
IdentityObjectSearchControl
+{
+
+ private final String filter;
+
+ public NameFilterSearchControl(String filter)
+ {
+ this.filter = filter;
+ }
+
+ public String getFilter()
+ {
+ return filter;
+ }
+}
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/PageSearchControl.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/PageSearchControl.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/PageSearchControl.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -31,9 +31,9 @@
*/
public class PageSearchControl implements IdentitySearchControl,
IdentityObjectSearchControl
{
- private int offset;
+ private final int offset;
- private int limit;
+ private final int limit;
public PageSearchControl(int offset, int limit)
{
@@ -46,18 +46,8 @@
return offset;
}
- public void setOffset(int offset)
- {
- this.offset = offset;
- }
-
public int getLimit()
{
return limit;
}
-
- public void setLimit(int limit)
- {
- this.limit = limit;
- }
}
Added:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/PasswordCredential.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/PasswordCredential.java
(rev 0)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/PasswordCredential.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -0,0 +1,120 @@
+/*
+* 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 PasswordCredential(String value)
+ {
+ super(new SimpleCredentialTypeImpl("PASSWORD"));
+ 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();
+ }
+
+
+
+}
Added:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SimpleCredentialTypeImpl.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SimpleCredentialTypeImpl.java
(rev 0)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SimpleCredentialTypeImpl.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -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.impl.api;
+
+import org.jboss.identity.api.CredentialType;
+import org.jboss.identity.spi.credential.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;
+ }
+}
+
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SortByNameSearchControl.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SortByNameSearchControl.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/api/SortByNameSearchControl.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -31,7 +31,7 @@
*/
public class SortByNameSearchControl implements IdentitySearchControl,
IdentityObjectSearchControl
{
- private boolean ascending;
+ private final boolean ascending;
public SortByNameSearchControl(boolean ascending)
{
@@ -42,9 +42,4 @@
{
return ascending;
}
-
- public void setAscending(boolean ascending)
- {
- this.ascending = ascending;
- }
}
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/JAXB2IdentityConfiguration.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/JAXB2IdentityConfiguration.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/JAXB2IdentityConfiguration.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -141,7 +141,8 @@
Map<String, String> groupMappings = new HashMap<String, String>();
- if (realmType.getIdentityTypeMappings() != null)
+ if (realmType.getIdentityTypeMappings() != null
+ && realmType.getIdentityTypeMappings().getGroupTypeMapping() != null)
{
for (GroupTypeMappingType groupTypeMappingType :
realmType.getIdentityTypeMappings().getGroupTypeMapping())
{
@@ -173,15 +174,20 @@
List<IdentityStoreMappingMetaData> storeMappings = new
LinkedList<IdentityStoreMappingMetaData>();
- for (IdentityStoreMappingType identityStoreMappingType :
repositoryType.getIdentityStoreMappings().getIdentityStoreMapping())
+ if (repositoryType.getIdentityStoreMappings() != null &&
+ repositoryType.getIdentityStoreMappings().getIdentityStoreMapping() != null)
{
- IdentityStoreMappingMetaDataImpl mapping = new
IdentityStoreMappingMetaDataImpl();
- mapping.setIdentityStoreId(identityStoreMappingType.getIdentityStoreId());
-
mapping.setIdentityObjectTypeMappings(identityStoreMappingType.getIdentityObjectTypes().getIdentityObjectType());
- mapping.setOptions(createOptions(identityStoreMappingType.getOptions()));
+ for (IdentityStoreMappingType identityStoreMappingType :
repositoryType.getIdentityStoreMappings().getIdentityStoreMapping())
+ {
+ IdentityStoreMappingMetaDataImpl mapping = new
IdentityStoreMappingMetaDataImpl();
- storeMappings.add(mapping);
+ mapping.setIdentityStoreId(identityStoreMappingType.getIdentityStoreId());
+
mapping.setIdentityObjectTypeMappings(identityStoreMappingType.getIdentityObjectTypes().getIdentityObjectType());
+ mapping.setOptions(createOptions(identityStoreMappingType.getOptions()));
+
+ storeMappings.add(mapping);
+ }
}
repoMD.setIdentityStoreToIdentityObjectTypeMappings(storeMappings);
@@ -206,66 +212,98 @@
storeMD.setSupportedRelationshipTypes(identityStoreType.getSupportedRelationshipTypes().getRelationshipType());
- for (IdentityObjectTypeType identityObjectTypeType :
identityStoreType.getSupportedIdentityObjectTypes().getIdentityObjectType())
+ if (identityStoreType.getSupportedIdentityObjectTypes() != null &&
+ identityStoreType.getSupportedIdentityObjectTypes().getIdentityObjectType() !=
null)
+
{
- IdentityObjectTypeMetaDataImpl identityObjectTypeMD = new
IdentityObjectTypeMetaDataImpl();
- identityObjectTypeMD.setName(identityObjectTypeType.getName());
+ for (IdentityObjectTypeType identityObjectTypeType :
identityStoreType.getSupportedIdentityObjectTypes().getIdentityObjectType())
+ {
+ IdentityObjectTypeMetaDataImpl identityObjectTypeMD = new
IdentityObjectTypeMetaDataImpl();
- List<AttributeMetaData> attributes = new
LinkedList<AttributeMetaData>();
+ identityObjectTypeMD.setName(identityObjectTypeType.getName());
- for (AttributeType attributeType :
identityObjectTypeType.getAttributes().getAttribute())
- {
- AttributeMetaDataImpl attributeMD = new AttributeMetaDataImpl();
+ List<AttributeMetaData> attributes = new
LinkedList<AttributeMetaData>();
- attributeMD.setName(attributeType.getName());
- attributeMD.setStoreMapping(attributeType.getMapping());
-
- String readonly = attributeType.getIsReadOnly();
- if (readonly != null && readonly.equalsIgnoreCase("true"))
+ if (identityObjectTypeType.getAttributes() != null &&
+ identityObjectTypeType.getAttributes().getAttribute() != null)
{
- attributeMD.setReadonly(true);
- }
- String multivalued = attributeType.getIsMultivalued();
- if (multivalued != null &&
multivalued.equalsIgnoreCase("true"))
- {
- attributeMD.setMultivalued(true);
+ for (AttributeType attributeType :
identityObjectTypeType.getAttributes().getAttribute())
+ {
+ AttributeMetaDataImpl attributeMD = new AttributeMetaDataImpl();
+
+ attributeMD.setName(attributeType.getName());
+ attributeMD.setStoreMapping(attributeType.getMapping());
+
+ String readonly = attributeType.getIsReadOnly();
+ if (readonly != null &&
readonly.equalsIgnoreCase("true"))
+ {
+ attributeMD.setReadonly(true);
+ }
+
+ String multivalued = attributeType.getIsMultivalued();
+ if (multivalued != null &&
multivalued.equalsIgnoreCase("true"))
+ {
+ attributeMD.setMultivalued(true);
+ }
+
+ String required = attributeType.getIsRequired();
+ if (required != null &&
required.equalsIgnoreCase("true"))
+ {
+ attributeMD.setRequired(true);
+ }
+
+ attributes.add(attributeMD);
+ }
}
- String required = attributeType.getIsRequired();
- if (required != null && required.equalsIgnoreCase("true"))
+ identityObjectTypeMD.setAttributes(attributes);
+
+ List<String> credentials = new LinkedList<String>();
+
+ if (identityObjectTypeType.getCredentials() != null &&
+ identityObjectTypeType.getCredentials().getCredentialType() != null)
{
- attributeMD.setRequired(true);
+ for (String credentialType :
identityObjectTypeType.getCredentials().getCredentialType())
+ {
+ credentials.add(credentialType);
+ }
}
- attributes.add(attributeMD);
- }
+ identityObjectTypeMD.setCredentials(credentials);
- identityObjectTypeMD.setAttributes(attributes);
+ Map<String, List<String>> options = new HashMap<String,
List<String>>();
+ if (identityObjectTypeType.getOptions() != null &&
+ identityObjectTypeType.getOptions().getOption() != null)
+ {
- Map<String, List<String>> options = new HashMap<String,
List<String>>();
+ for (OptionType optionType :
identityObjectTypeType.getOptions().getOption())
+ {
+ options.put(optionType.getName(), optionType.getValue());
+ }
+ }
+
+ identityObjectTypeMD.setOptions(options);
- for (OptionType optionType : identityObjectTypeType.getOptions().getOption())
- {
- options.put(optionType.getName(), optionType.getValue());
+ storeMD.getSupportedIdentityTypes().add(identityObjectTypeMD);
}
-
- identityObjectTypeMD.setOptions(options);
-
- storeMD.getSupportedIdentityTypes().add(identityObjectTypeMD);
}
-
Map<String, List<String>> options = new HashMap<String,
List<String>>();
- for (OptionType optionType : identityStoreType.getOptions().getOption())
+ if (identityStoreType.getOptions() != null &&
+ identityStoreType.getOptions().getOption() != null)
{
- options.put(optionType.getName(), optionType.getValue());
+
+ for (OptionType optionType : identityStoreType.getOptions().getOption())
+ {
+ options.put(optionType.getName(), optionType.getValue());
+ }
}
-
+
storeMD.setOptions(options);
return storeMD;
@@ -275,7 +313,8 @@
{
Map<String, List<String>> options = new HashMap<String,
List<String>>();
- if (optionsType != null)
+ if (optionsType != null &&
+ optionsType.getOption() != null)
{
for (OptionType optionType : optionsType.getOption())
{
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/AttributeType.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/AttributeType.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/AttributeType.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference
Implementation, vJAXB 2.1.3 in JDK
// See <a
href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/...
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2008.11.12 at 03:13:41 PM CET
+// Generated on: 2008.11.24 at 10:17:31 PM CET
//
@@ -26,8 +26,24 @@
* <sequence>
* <element name="name"
type="{http://www.w3.org/2001/XMLSchema}string"/>
* <element name="mapping"
type="{http://www.w3.org/2001/XMLSchema}string"/>
- * <element name="isRequired"
type="{http://www.w3.org/2001/XMLSchema}string"/>
- * <element name="isMultivalued"
type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * <element name="isRequired">
+ * <simpleType>
+ * <restriction
base="{http://www.w3.org/2001/XMLSchema}string">
+ * <enumeration value=""/>
+ * <enumeration value="true"/>
+ * <enumeration value="false"/>
+ * </restriction>
+ * </simpleType>
+ * </element>
+ * <element name="isMultivalued">
+ * <simpleType>
+ * <restriction
base="{http://www.w3.org/2001/XMLSchema}string">
+ * <enumeration value=""/>
+ * <enumeration value="true"/>
+ * <enumeration value="false"/>
+ * </restriction>
+ * </simpleType>
+ * </element>
* <element name="isReadOnly"
type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* </sequence>
* </restriction>
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/AttributesType.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/AttributesType.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/AttributesType.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference
Implementation, vJAXB 2.1.3 in JDK
// See <a
href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/...
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2008.11.12 at 03:13:41 PM CET
+// Generated on: 2008.11.24 at 10:17:31 PM CET
//
Added:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/CredentialsType.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/CredentialsType.java
(rev 0)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/CredentialsType.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -0,0 +1,76 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference
Implementation, vJAXB 2.1.3 in JDK
+// See <a
href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/...
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2008.11.24 at 10:17:31 PM CET
+//
+
+
+package org.jboss.identity.impl.configuration.jaxb2.generated;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for credentialsType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within
this class.
+ *
+ * <pre>
+ * <complexType name="credentialsType">
+ * <complexContent>
+ * <restriction
base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="credential-type"
type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded"
minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+(a)XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "credentialsType", propOrder = {
+ "credentialType"
+})
+public class CredentialsType {
+
+ @XmlElement(name = "credential-type")
+ protected List<String> credentialType;
+
+ /**
+ * Gets the value of the credentialType property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the
credentialType property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getCredentialType().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link String }
+ *
+ *
+ */
+ public List<String> getCredentialType() {
+ if (credentialType == null) {
+ credentialType = new ArrayList<String>();
+ }
+ return this.credentialType;
+ }
+
+}
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/ExternalConfigType.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/ExternalConfigType.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/ExternalConfigType.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference
Implementation, vJAXB 2.1.3 in JDK
// See <a
href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/...
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2008.11.12 at 03:13:41 PM CET
+// Generated on: 2008.11.24 at 10:17:31 PM CET
//
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/GroupTypeMappingType.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/GroupTypeMappingType.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/GroupTypeMappingType.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference
Implementation, vJAXB 2.1.3 in JDK
// See <a
href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/...
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2008.11.12 at 03:13:41 PM CET
+// Generated on: 2008.11.24 at 10:17:31 PM CET
//
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/IdentityObjectTypeType.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/IdentityObjectTypeType.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/IdentityObjectTypeType.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference
Implementation, vJAXB 2.1.3 in JDK
// See <a
href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/...
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2008.11.12 at 03:13:41 PM CET
+// Generated on: 2008.11.24 at 10:17:31 PM CET
//
@@ -38,6 +38,17 @@
* </complexContent>
* </complexType>
* </element>
+ * <element name="credentials">
+ * <complexType>
+ * <complexContent>
+ * <restriction
base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="credential-type"
type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded"
minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </element>
* <element name="attributes">
* <complexType>
* <complexContent>
@@ -72,6 +83,7 @@
@XmlType(name = "identity-object-typeType", propOrder = {
"name",
"relationships",
+ "credentials",
"attributes",
"options"
})
@@ -82,6 +94,8 @@
@XmlElement(required = true)
protected IdentityObjectTypeType.Relationships relationships;
@XmlElement(required = true)
+ protected IdentityObjectTypeType.Credentials credentials;
+ @XmlElement(required = true)
protected IdentityObjectTypeType.Attributes attributes;
@XmlElement(required = true)
protected IdentityObjectTypeType.Options options;
@@ -135,6 +149,30 @@
}
/**
+ * Gets the value of the credentials property.
+ *
+ * @return
+ * possible object is
+ * {@link IdentityObjectTypeType.Credentials }
+ *
+ */
+ public IdentityObjectTypeType.Credentials getCredentials() {
+ return credentials;
+ }
+
+ /**
+ * Sets the value of the credentials property.
+ *
+ * @param value
+ * allowed object is
+ * {@link IdentityObjectTypeType.Credentials }
+ *
+ */
+ public void setCredentials(IdentityObjectTypeType.Credentials value) {
+ this.credentials = value;
+ }
+
+ /**
* Gets the value of the attributes property.
*
* @return
@@ -252,6 +290,66 @@
* <complexContent>
* <restriction
base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
+ * <element name="credential-type"
type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded"
minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+ @XmlAccessorType(XmlAccessType.FIELD)
+ @XmlType(name = "", propOrder = {
+ "credentialType"
+ })
+ public static class Credentials {
+
+ @XmlElement(name = "credential-type")
+ protected List<String> credentialType;
+
+ /**
+ * Gets the value of the credentialType property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the
credentialType property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getCredentialType().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link String }
+ *
+ *
+ */
+ public List<String> getCredentialType() {
+ if (credentialType == null) {
+ credentialType = new ArrayList<String>();
+ }
+ return this.credentialType;
+ }
+
+ }
+
+
+ /**
+ * <p>Java class for anonymous complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained
within this class.
+ *
+ * <pre>
+ * <complexType>
+ * <complexContent>
+ * <restriction
base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
* <element name="option"
type="{urn:jboss:identity:config:v0_1}optionType"
maxOccurs="unbounded" minOccurs="0"/>
* </sequence>
* </restriction>
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/IdentityObjectTypesType.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/IdentityObjectTypesType.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/IdentityObjectTypesType.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference
Implementation, vJAXB 2.1.3 in JDK
// See <a
href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/...
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2008.11.12 at 03:13:41 PM CET
+// Generated on: 2008.11.24 at 10:17:31 PM CET
//
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/IdentityStoreMappingType.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/IdentityStoreMappingType.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/IdentityStoreMappingType.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference
Implementation, vJAXB 2.1.3 in JDK
// See <a
href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/...
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2008.11.12 at 03:13:41 PM CET
+// Generated on: 2008.11.24 at 10:17:31 PM CET
//
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/IdentityStoreMappingsType.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/IdentityStoreMappingsType.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/IdentityStoreMappingsType.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference
Implementation, vJAXB 2.1.3 in JDK
// See <a
href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/...
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2008.11.12 at 03:13:41 PM CET
+// Generated on: 2008.11.24 at 10:17:31 PM CET
//
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/IdentityStoreType.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/IdentityStoreType.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/IdentityStoreType.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference
Implementation, vJAXB 2.1.3 in JDK
// See <a
href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/...
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2008.11.12 at 03:13:41 PM CET
+// Generated on: 2008.11.24 at 10:17:31 PM CET
//
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/IdentityStoresType.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/IdentityStoresType.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/IdentityStoresType.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference
Implementation, vJAXB 2.1.3 in JDK
// See <a
href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/...
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2008.11.12 at 03:13:41 PM CET
+// Generated on: 2008.11.24 at 10:17:31 PM CET
//
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/IdentityTypeMappingsType.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/IdentityTypeMappingsType.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/IdentityTypeMappingsType.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference
Implementation, vJAXB 2.1.3 in JDK
// See <a
href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/...
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2008.11.12 at 03:13:41 PM CET
+// Generated on: 2008.11.24 at 10:17:31 PM CET
//
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/JbossIdentityType.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/JbossIdentityType.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/JbossIdentityType.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference
Implementation, vJAXB 2.1.3 in JDK
// See <a
href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/...
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2008.11.12 at 03:13:41 PM CET
+// Generated on: 2008.11.24 at 10:17:31 PM CET
//
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/ObjectFactory.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/ObjectFactory.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/ObjectFactory.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference
Implementation, vJAXB 2.1.3 in JDK
// See <a
href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/...
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2008.11.12 at 03:13:41 PM CET
+// Generated on: 2008.11.24 at 10:17:31 PM CET
//
@@ -41,14 +41,6 @@
}
/**
- * Create an instance of {@link RelationshipsType }
- *
- */
- public RelationshipsType createRelationshipsType() {
- return new RelationshipsType();
- }
-
- /**
* Create an instance of {@link IdentityObjectTypeType }
*
*/
@@ -57,131 +49,131 @@
}
/**
- * Create an instance of {@link IdentityTypeMappingsType }
+ * Create an instance of {@link IdentityObjectTypesType }
*
*/
- public IdentityTypeMappingsType createIdentityTypeMappingsType() {
- return new IdentityTypeMappingsType();
+ public IdentityObjectTypesType createIdentityObjectTypesType() {
+ return new IdentityObjectTypesType();
}
/**
- * Create an instance of {@link OptionsType }
+ * Create an instance of {@link IdentityStoresType }
*
*/
- public OptionsType createOptionsType() {
- return new OptionsType();
+ public IdentityStoresType createIdentityStoresType() {
+ return new IdentityStoresType();
}
/**
- * Create an instance of {@link IdentityObjectTypeType.Options }
+ * Create an instance of {@link IdentityStoreType.Options }
*
*/
- public IdentityObjectTypeType.Options createIdentityObjectTypeTypeOptions() {
- return new IdentityObjectTypeType.Options();
+ public IdentityStoreType.Options createIdentityStoreTypeOptions() {
+ return new IdentityStoreType.Options();
}
/**
- * Create an instance of {@link RepositoriesType }
+ * Create an instance of {@link SupportedRelationshipTypesType }
*
*/
- public RepositoriesType createRepositoriesType() {
- return new RepositoriesType();
+ public SupportedRelationshipTypesType createSupportedRelationshipTypesType() {
+ return new SupportedRelationshipTypesType();
}
/**
- * Create an instance of {@link IdentityObjectTypesType }
+ * Create an instance of {@link CredentialsType }
*
*/
- public IdentityObjectTypesType createIdentityObjectTypesType() {
- return new IdentityObjectTypesType();
+ public CredentialsType createCredentialsType() {
+ return new CredentialsType();
}
/**
- * Create an instance of {@link SupportedRelationshipTypesType }
+ * Create an instance of {@link RealmsType }
*
*/
- public SupportedRelationshipTypesType createSupportedRelationshipTypesType() {
- return new SupportedRelationshipTypesType();
+ public RealmsType createRealmsType() {
+ return new RealmsType();
}
/**
- * Create an instance of {@link ExternalConfigType }
+ * Create an instance of {@link StoresType }
*
*/
- public ExternalConfigType createExternalConfigType() {
- return new ExternalConfigType();
+ public StoresType createStoresType() {
+ return new StoresType();
}
/**
- * Create an instance of {@link AttributeType }
+ * Create an instance of {@link IdentityStoreMappingType }
*
*/
- public AttributeType createAttributeType() {
- return new AttributeType();
+ public IdentityStoreMappingType createIdentityStoreMappingType() {
+ return new IdentityStoreMappingType();
}
/**
- * Create an instance of {@link RealmsType }
+ * Create an instance of {@link IdentityObjectTypeType.Options }
*
*/
- public RealmsType createRealmsType() {
- return new RealmsType();
+ public IdentityObjectTypeType.Options createIdentityObjectTypeTypeOptions() {
+ return new IdentityObjectTypeType.Options();
}
/**
- * Create an instance of {@link AttributesType }
+ * Create an instance of {@link RepositoriesType }
*
*/
- public AttributesType createAttributesType() {
- return new AttributesType();
+ public RepositoriesType createRepositoriesType() {
+ return new RepositoriesType();
}
/**
- * Create an instance of {@link IdentityObjectTypeType.Attributes }
+ * Create an instance of {@link GroupTypeMappingType }
*
*/
- public IdentityObjectTypeType.Attributes createIdentityObjectTypeTypeAttributes() {
- return new IdentityObjectTypeType.Attributes();
+ public GroupTypeMappingType createGroupTypeMappingType() {
+ return new GroupTypeMappingType();
}
/**
- * Create an instance of {@link RelationshipType }
+ * Create an instance of {@link IdentityStoreMappingsType }
*
*/
- public RelationshipType createRelationshipType() {
- return new RelationshipType();
+ public IdentityStoreMappingsType createIdentityStoreMappingsType() {
+ return new IdentityStoreMappingsType();
}
/**
- * Create an instance of {@link IdentityStoreType.Options }
+ * Create an instance of {@link IdentityStoreType }
*
*/
- public IdentityStoreType.Options createIdentityStoreTypeOptions() {
- return new IdentityStoreType.Options();
+ public IdentityStoreType createIdentityStoreType() {
+ return new IdentityStoreType();
}
/**
- * Create an instance of {@link IdentityStoreType }
+ * Create an instance of {@link RealmType }
*
*/
- public IdentityStoreType createIdentityStoreType() {
- return new IdentityStoreType();
+ public RealmType createRealmType() {
+ return new RealmType();
}
/**
- * Create an instance of {@link StoresType }
+ * Create an instance of {@link OptionType }
*
*/
- public StoresType createStoresType() {
- return new StoresType();
+ public OptionType createOptionType() {
+ return new OptionType();
}
/**
- * Create an instance of {@link IdentityStoreMappingType }
+ * Create an instance of {@link ExternalConfigType }
*
*/
- public IdentityStoreMappingType createIdentityStoreMappingType() {
- return new IdentityStoreMappingType();
+ public ExternalConfigType createExternalConfigType() {
+ return new ExternalConfigType();
}
/**
@@ -193,38 +185,62 @@
}
/**
- * Create an instance of {@link OptionType }
+ * Create an instance of {@link RepositoryType }
*
*/
- public OptionType createOptionType() {
- return new OptionType();
+ public RepositoryType createRepositoryType() {
+ return new RepositoryType();
}
/**
- * Create an instance of {@link IdentityStoresType }
+ * Create an instance of {@link OptionsType }
*
*/
- public IdentityStoresType createIdentityStoresType() {
- return new IdentityStoresType();
+ public OptionsType createOptionsType() {
+ return new OptionsType();
}
/**
- * Create an instance of {@link GroupTypeMappingType }
+ * Create an instance of {@link SupportedIdentityObjectTypesType }
*
*/
- public GroupTypeMappingType createGroupTypeMappingType() {
- return new GroupTypeMappingType();
+ public SupportedIdentityObjectTypesType createSupportedIdentityObjectTypesType() {
+ return new SupportedIdentityObjectTypesType();
}
/**
- * Create an instance of {@link SupportedIdentityObjectTypesType }
+ * Create an instance of {@link IdentityTypeMappingsType }
*
*/
- public SupportedIdentityObjectTypesType createSupportedIdentityObjectTypesType() {
- return new SupportedIdentityObjectTypesType();
+ public IdentityTypeMappingsType createIdentityTypeMappingsType() {
+ return new IdentityTypeMappingsType();
}
/**
+ * Create an instance of {@link AttributesType }
+ *
+ */
+ public AttributesType createAttributesType() {
+ return new AttributesType();
+ }
+
+ /**
+ * Create an instance of {@link IdentityObjectTypeType.Credentials }
+ *
+ */
+ public IdentityObjectTypeType.Credentials createIdentityObjectTypeTypeCredentials()
{
+ return new IdentityObjectTypeType.Credentials();
+ }
+
+ /**
+ * Create an instance of {@link RelationshipType }
+ *
+ */
+ public RelationshipType createRelationshipType() {
+ return new RelationshipType();
+ }
+
+ /**
* Create an instance of {@link JbossIdentityType }
*
*/
@@ -233,27 +249,27 @@
}
/**
- * Create an instance of {@link RealmType }
+ * Create an instance of {@link AttributeType }
*
*/
- public RealmType createRealmType() {
- return new RealmType();
+ public AttributeType createAttributeType() {
+ return new AttributeType();
}
/**
- * Create an instance of {@link IdentityStoreMappingsType }
+ * Create an instance of {@link IdentityObjectTypeType.Attributes }
*
*/
- public IdentityStoreMappingsType createIdentityStoreMappingsType() {
- return new IdentityStoreMappingsType();
+ public IdentityObjectTypeType.Attributes createIdentityObjectTypeTypeAttributes() {
+ return new IdentityObjectTypeType.Attributes();
}
/**
- * Create an instance of {@link RepositoryType }
+ * Create an instance of {@link RelationshipsType }
*
*/
- public RepositoryType createRepositoryType() {
- return new RepositoryType();
+ public RelationshipsType createRelationshipsType() {
+ return new RelationshipsType();
}
/**
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/OptionType.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/OptionType.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/OptionType.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference
Implementation, vJAXB 2.1.3 in JDK
// See <a
href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/...
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2008.11.12 at 03:13:41 PM CET
+// Generated on: 2008.11.24 at 10:17:31 PM CET
//
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/OptionsType.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/OptionsType.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/OptionsType.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference
Implementation, vJAXB 2.1.3 in JDK
// See <a
href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/...
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2008.11.12 at 03:13:41 PM CET
+// Generated on: 2008.11.24 at 10:17:31 PM CET
//
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/RealmType.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/RealmType.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/RealmType.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference
Implementation, vJAXB 2.1.3 in JDK
// See <a
href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/...
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2008.11.12 at 03:13:41 PM CET
+// Generated on: 2008.11.24 at 10:17:31 PM CET
//
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/RealmsType.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/RealmsType.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/RealmsType.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference
Implementation, vJAXB 2.1.3 in JDK
// See <a
href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/...
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2008.11.12 at 03:13:41 PM CET
+// Generated on: 2008.11.24 at 10:17:31 PM CET
//
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/RelationshipType.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/RelationshipType.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/RelationshipType.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference
Implementation, vJAXB 2.1.3 in JDK
// See <a
href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/...
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2008.11.12 at 03:13:41 PM CET
+// Generated on: 2008.11.24 at 10:17:31 PM CET
//
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/RelationshipsType.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/RelationshipsType.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/RelationshipsType.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference
Implementation, vJAXB 2.1.3 in JDK
// See <a
href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/...
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2008.11.12 at 03:13:41 PM CET
+// Generated on: 2008.11.24 at 10:17:31 PM CET
//
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/RepositoriesType.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/RepositoriesType.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/RepositoriesType.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference
Implementation, vJAXB 2.1.3 in JDK
// See <a
href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/...
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2008.11.12 at 03:13:41 PM CET
+// Generated on: 2008.11.24 at 10:17:31 PM CET
//
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/RepositoryType.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/RepositoryType.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/RepositoryType.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference
Implementation, vJAXB 2.1.3 in JDK
// See <a
href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/...
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2008.11.12 at 03:13:41 PM CET
+// Generated on: 2008.11.24 at 10:17:31 PM CET
//
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/StoresType.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/StoresType.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/StoresType.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference
Implementation, vJAXB 2.1.3 in JDK
// See <a
href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/...
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2008.11.12 at 03:13:41 PM CET
+// Generated on: 2008.11.24 at 10:17:31 PM CET
//
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/SupportedIdentityObjectTypesType.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/SupportedIdentityObjectTypesType.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/SupportedIdentityObjectTypesType.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference
Implementation, vJAXB 2.1.3 in JDK
// See <a
href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/...
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2008.11.12 at 03:13:41 PM CET
+// Generated on: 2008.11.24 at 10:17:31 PM CET
//
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/SupportedRelationshipTypesType.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/SupportedRelationshipTypesType.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/SupportedRelationshipTypesType.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference
Implementation, vJAXB 2.1.3 in JDK
// See <a
href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/...
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2008.11.12 at 03:13:41 PM CET
+// Generated on: 2008.11.24 at 10:17:31 PM CET
//
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/package-info.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/package-info.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/jaxb2/generated/package-info.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference
Implementation, vJAXB 2.1.3 in JDK
// See <a
href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/...
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2008.11.12 at 03:13:41 PM CET
+// Generated on: 2008.11.24 at 10:17:31 PM CET
//
@javax.xml.bind.annotation.XmlSchema(namespace =
"urn:jboss:identity:config:v0_1", elementFormDefault =
javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/metadata/IdentityObjectTypeMetaDataImpl.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/metadata/IdentityObjectTypeMetaDataImpl.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/configuration/metadata/IdentityObjectTypeMetaDataImpl.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -44,6 +44,8 @@
private Map<String, List<String>> options;
+ private List<String> credentials;
+
public IdentityObjectTypeMetaDataImpl()
{
}
@@ -78,6 +80,16 @@
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;
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateIdentityObject.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateIdentityObject.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateIdentityObject.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -29,6 +29,8 @@
import java.util.Collections;
import java.util.Arrays;
import java.util.List;
+import java.util.ArrayList;
+import java.util.LinkedList;
import javax.persistence.Column;
import javax.persistence.CascadeType;
@@ -43,9 +45,13 @@
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.spi.model.IdentityObject;
+import org.jboss.identity.spi.credential.IdentityObjectCredentialType;
+import org.hibernate.annotations.Cascade;
+import org.hibernate.annotations.CollectionOfElements;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
@@ -58,17 +64,17 @@
),
@NamedQuery(
name = "findIdentityObjectsByType",
- query = "select o from HibernateIdentityObject o where o.realm like :realm and
o.identityType.name like :typeName"
+ 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.realm like :realm and
o.identityType.name like :typeName " +
+ 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.realm like :realm and
o.identityType.name like :typeName " +
- "order by o.name desc"
+ 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",
@@ -96,8 +102,21 @@
@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})
- private Map<String, HibernateIdentityObjectAttribute> attributes = new
HashMap<String, HibernateIdentityObjectAttribute>();
+ @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")
@@ -149,20 +168,35 @@
return null;
}
+ public Set<HibernateIdentityObjectAttribute> getAttributes()
+ {
+ return attributes;
+ }
+
+ public void setAttributes(Set<HibernateIdentityObjectAttribute> attributes)
+ {
+ this.attributes = attributes;
+ }
+
public Set<String> getAttribute(String name)
{
- if (attributes.containsKey(name))
+ for (HibernateIdentityObjectAttribute attribute : attributes)
{
- return Collections.unmodifiableSet((attributes.get(name)).getValues());
+ if (attribute.getName().equals(name))
+ {
+ return Collections.unmodifiableSet(attribute.getValues());
+ }
}
+
+
return new HashSet<String>();
}
- public Map<String, String[]> getAttributes()
+ public Map<String, String[]> getAttributesAsMap()
{
Map<String, String[]> map = new HashMap<String, String[]>();
- for (HibernateIdentityObjectAttribute attribute : attributes.values())
+ for (HibernateIdentityObjectAttribute attribute : attributes)
{
Set<String> values = attribute.getValues();
map.put(attribute.getName(),values.toArray(new String[values.size()]));
@@ -171,48 +205,78 @@
return Collections.unmodifiableMap(map);
}
- public void setAttribute(String name, String[] values)
+ public void addAttribute(String name, String[] values)
{
-
- attributes.put(name, new HibernateIdentityObjectAttribute(name, values));
+ attributes.add(new HibernateIdentityObjectAttribute(this, name, values));
}
- public void setAttribute(String name, Set<String> values)
+ public void updateAttribute(String name, String[] values)
{
-
- attributes.put(name, new HibernateIdentityObjectAttribute(name, values));
+ for (HibernateIdentityObjectAttribute attribute : attributes)
+ {
+ if (attribute.getName().equals(name))
+ {
+ Set<String> v = new HashSet<String>();
+ for (String value : values)
+ {
+ v.add(value);
+ }
+ attribute.setValues(v);
+ break;
+ }
+ }
}
public void addAttributeValues(String name, String[] values)
{
- if (!attributes.containsKey(name))
+
+ for (HibernateIdentityObjectAttribute attribute : attributes)
{
- setAttribute(name, values);
+ 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;
+ }
}
- else
- {
- Set<String> mergedValues = new
HashSet<String>((attributes.get(name)).getValues());
- List<String> list = Arrays.asList(values);
- mergedValues.addAll(new HashSet<String>(list));
- setAttribute(name, mergedValues);
- }
+
+ addAttribute(name, values);
}
- public void setAttributes(Map<String, Set<String>> values)
+ public void updateAttributes(Map<String, Set<String>> values)
{
- Map<String, HibernateIdentityObjectAttribute> newAttrs= new
HashMap<String, HibernateIdentityObjectAttribute>();
+ Set<HibernateIdentityObjectAttribute> newAttrs= new
HashSet<HibernateIdentityObjectAttribute>();
for (String name : values.keySet())
{
-
- newAttrs.put(name, new HibernateIdentityObjectAttribute(name, new
HashSet<String>(values.get(name))));
+ newAttrs.add(new HibernateIdentityObjectAttribute(this, name, new
HashSet<String>(values.get(name))));
}
+
attributes = newAttrs;
}
+
+
public void removeAttribute(String name)
{
- attributes.remove(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()
@@ -257,6 +321,50 @@
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/impl/model/hibernate/HibernateIdentityObjectAttribute.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateIdentityObjectAttribute.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateIdentityObjectAttribute.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -31,6 +31,10 @@
import javax.persistence.Id;
import javax.persistence.GeneratedValue;
import javax.persistence.Embedded;
+import javax.persistence.Column;
+import javax.persistence.ManyToOne;
+import javax.persistence.JoinColumn;
+import javax.persistence.UniqueConstraint;
import java.util.Set;
import java.util.HashSet;
import java.util.List;
@@ -41,13 +45,18 @@
* @version : 0.1 $
*/
@Entity
-@Table(name = "identity_obj_attrs")
+@Table(name = "identity_obj_attrs", uniqueConstraints =
{@UniqueConstraint(columnNames = {"NAME", "IDENTITY_OBJECT_ID"})})
public class HibernateIdentityObjectAttribute implements IdentityObjectAttribute
{
@Id
@GeneratedValue
private Long id;
+ @ManyToOne
+ @JoinColumn(name="IDENTITY_OBJECT_ID", nullable = false)
+ private HibernateIdentityObject identityObject;
+
+ @Column(name = "NAME")
private String name;
@CollectionOfElements
@@ -57,19 +66,22 @@
{
}
- public HibernateIdentityObjectAttribute(String name)
+ public HibernateIdentityObjectAttribute(HibernateIdentityObject identityObject, String
name)
{
+ this.identityObject = identityObject;
this.name = name;
}
- public HibernateIdentityObjectAttribute(String name, Set<String> values)
+ public HibernateIdentityObjectAttribute(HibernateIdentityObject identityObject, String
name, Set<String> values)
{
+ this.identityObject = identityObject;
this.name = name;
this.values = values;
}
- public HibernateIdentityObjectAttribute(String name, String[] values)
+ public HibernateIdentityObjectAttribute(HibernateIdentityObject identityObject, String
name, String[] values)
{
+ this.identityObject = identityObject;
List<String> list = Arrays.asList(values);
this.name = name;
this.values = new HashSet<String>(list);
@@ -109,4 +121,15 @@
{
getValues().add(val);
}
+
+ public HibernateIdentityObject getIdentityObject()
+ {
+ return identityObject;
+ }
+
+ public void setIdentityObject(HibernateIdentityObject identityObject)
+ {
+ this.identityObject = identityObject;
+ }
+
}
Added:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateIdentityObjectCredential.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateIdentityObjectCredential.java
(rev 0)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateIdentityObjectCredential.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -0,0 +1,152 @@
+/*
+* 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 org.jboss.identity.spi.credential.IdentityObjectCredential;
+import org.hibernate.annotations.CollectionOfElements;
+
+import javax.persistence.Entity;
+import javax.persistence.Table;
+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.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.JoinTable;
+import javax.persistence.UniqueConstraint;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+@Entity
+@Table(name = "identity_obj_credential", uniqueConstraints =
{@UniqueConstraint(columnNames = {"IDENTITY_TYPE", "IDENTITY_ID"})})
+public class HibernateIdentityObjectCredential implements IdentityObjectCredential
+{
+
+ @Id
+ @GeneratedValue
+ private Long id;
+
+ @ManyToOne(fetch = FetchType.EAGER)
+ @JoinColumn(name = "IDENTITY_TYPE", nullable = false)
+ private HibernateIdentityObjectCredentialType type;
+
+ @ManyToOne(fetch = FetchType.EAGER)
+ @JoinColumn(name = "IDENTITY_ID", nullable = false)
+ private HibernateIdentityObject identityObject;
+
+ @Column(name= "TEXT", nullable = true)
+ private String textValue;
+
+ @Column(name= "BINARY", nullable = true)
+ private byte[] binaryValue;
+
+ @CollectionOfElements
+ @JoinTable(name = "identity_obj_credential_properties", joinColumns =
@JoinColumn(name = "CREDENTIAL_ID"))
+ @Column(name = "PROPERTY")
+ private Map<String, String> properties = new HashMap<String, String>();
+
+ public HibernateIdentityObjectCredential()
+ {
+ }
+
+ public Long getId()
+ {
+ return id;
+ }
+
+ public void setId(Long id)
+ {
+ this.id = id;
+ }
+
+ public String getTextValue()
+ {
+ return textValue;
+ }
+
+ public void setTextValue(String textValue)
+ {
+ this.textValue = textValue;
+ }
+
+ public byte[] getBinaryValue()
+ {
+ return binaryValue;
+ }
+
+ public void setBinaryValue(byte[] binaryValue)
+ {
+ this.binaryValue = binaryValue;
+ }
+
+ public Map<String, String> getProperties()
+ {
+ return properties;
+ }
+
+ public void setProperties(Map<String, String> properties)
+ {
+ this.properties = properties;
+ }
+
+ public HibernateIdentityObjectCredentialType getType()
+ {
+ return type;
+ }
+
+ public void setType(HibernateIdentityObjectCredentialType type)
+ {
+ this.type = type;
+ }
+
+ public HibernateIdentityObject getIdentityObject()
+ {
+ return identityObject;
+ }
+
+ public void setIdentityObject(HibernateIdentityObject identityObject)
+ {
+ this.identityObject = identityObject;
+ }
+
+ public Object getValue()
+ {
+ if (textValue != null)
+ {
+ return textValue;
+ }
+ return binaryValue;
+ }
+
+ public Object getEncodedValue()
+ {
+ return null;
+ }
+}
Added:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateIdentityObjectCredentialType.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateIdentityObjectCredentialType.java
(rev 0)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateIdentityObjectCredentialType.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -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.impl.model.hibernate;
+
+import org.jboss.identity.spi.credential.IdentityObjectCredential;
+import org.jboss.identity.spi.credential.IdentityObjectCredentialType;
+
+import javax.persistence.Entity;
+import javax.persistence.Table;
+import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Column;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+@Entity
+@Table(name = "identity_obj_credential_type")
+public class HibernateIdentityObjectCredentialType implements
IdentityObjectCredentialType
+{
+
+ @Id
+ @GeneratedValue
+ private Long id;
+
+ @Column(name = "NAME", unique = true)
+ private String name;
+
+ public HibernateIdentityObjectCredentialType()
+ {
+ }
+
+ public HibernateIdentityObjectCredentialType(String typeName)
+ {
+ this.name = typeName;
+ }
+
+ public Long getId()
+ {
+ return id;
+ }
+
+ public void setId(Long id)
+ {
+ this.id = id;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+
+}
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateIdentityObjectRelationshipName.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateIdentityObjectRelationshipName.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateIdentityObjectRelationshipName.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -46,16 +46,16 @@
),
@NamedQuery(
name = "findIdentityObjectRelationshipNames",
- query = "select rn.name from HibernateIdentityObjectRelationshipName rn where
rn.realm like :realm"
+ query = "select rn.name from HibernateIdentityObjectRelationshipName rn where
rn.name like :nameFilter and rn.realm like :realm"
),
@NamedQuery(
name = "findIdentityObjectRelationshipNamesOrderedByNameAsc",
- query = "select rn.name from HibernateIdentityObjectRelationshipName rn where
rn.realm like :realm " +
+ query = "select rn.name from HibernateIdentityObjectRelationshipName rn where
rn.name like :nameFilter and rn.realm like :realm " +
"order by rn.name asc"
),
@NamedQuery(
name = "findIdentityObjectRelationshipNamesOrderedByNameDesc",
- query = "select rn.name from HibernateIdentityObjectRelationshipName rn where
rn.realm like :realm " +
+ query = "select rn.name from HibernateIdentityObjectRelationshipName rn where
rn.name like :nameFilter and rn.realm like :realm " +
"order by rn.name desc"
),
@NamedQuery(
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateRealm.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateRealm.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/model/hibernate/HibernateRealm.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -22,6 +22,8 @@
package org.jboss.identity.impl.model.hibernate;
+import org.hibernate.annotations.CollectionOfElements;
+
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
@@ -33,6 +35,8 @@
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;
@@ -63,9 +67,11 @@
@Column(name = "NAME", nullable = false)
private String name;
- @OneToMany(fetch = FetchType.EAGER, cascade = {CascadeType.ALL})
- private Map<String, HibernateIdentityObjectAttribute> attributes = new
HashMap<String, HibernateIdentityObjectAttribute>();
-
+ @CollectionOfElements
+ @JoinTable(name = "identity_realm_properties", joinColumns =
@JoinColumn(name = "REALM_ID"))
+ @Column(name = "PROPERTY")
+ private Map<String, String> properties = new HashMap<String, String>();
+
public HibernateRealm()
{
}
@@ -95,70 +101,13 @@
this.name = name;
}
- public Set<String> getAttribute(String name) {
- if (attributes.containsKey(name))
- {
- return Collections.unmodifiableSet((attributes.get(name)).getValues());
- }
- return new HashSet<String>();
- }
-
- public Map<String, String[]> getAttributes()
+ public Map<String, String> getProperties()
{
- Map<String, String[]> map = new HashMap<String, String[]>();
-
- for (HibernateIdentityObjectAttribute attribute : attributes.values())
- {
- Set<String> values = attribute.getValues();
- map.put(attribute.getName(),values.toArray(new String[values.size()]));
- }
-
- return Collections.unmodifiableMap(map);
+ return properties;
}
- public void setAttribute(String name, String[] values)
+ public void setProperties(Map<String, String> properties)
{
-
- attributes.put(name, new HibernateIdentityObjectAttribute(name, values));
+ this.properties = properties;
}
-
- public void setAttribute(String name, Set<String> values)
- {
-
- attributes.put(name, new HibernateIdentityObjectAttribute(name, values));
- }
-
- public void addAttributeValues(String name, String[] values)
- {
- if (!attributes.containsKey(name))
- {
- setAttribute(name, values);
- }
- else
- {
- Set<String> mergedValues = new
HashSet<String>((attributes.get(name)).getValues());
- List<String> list = Arrays.asList(values);
- mergedValues.addAll(new HashSet<String>(list));
- setAttribute(name, mergedValues);
- }
- }
-
- public void setAttributes(Map<String, Set<String>> values)
- {
- Map<String, HibernateIdentityObjectAttribute> newAttrs= new
HashMap<String, HibernateIdentityObjectAttribute>();
-
- for (String name : values.keySet())
- {
-
- newAttrs.put(name, new HibernateIdentityObjectAttribute(name, new
HashSet<String>(values.get(name))));
- }
- attributes = newAttrs;
- }
-
- public void removeAttribute(String name)
- {
- attributes.remove(name);
- }
-
-
}
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/repository/WrapperIdentityStoreRepository.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/repository/WrapperIdentityStoreRepository.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/repository/WrapperIdentityStoreRepository.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -22,24 +22,6 @@
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.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.exception.IdentityException;
-
-import java.util.Map;
-import java.util.Collection;
-import java.util.Set;
-import java.io.IOException;
-
/**
* Simply wraps IdentityStore and AttributeStore and delegates all the calls
*
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/FeaturesMetaDataImpl.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/FeaturesMetaDataImpl.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/FeaturesMetaDataImpl.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -54,23 +54,33 @@
private Map<String, Map<String, Set<String>>>
supportedRelationshipMappings = new HashMap<String, Map<String,
Set<String>>>();
-
+
public FeaturesMetaDataImpl(IdentityStoreConfigurationMetaData configurationMD,
- Set<Class> supportedControls,
- Map<String, Set<String>>
supportedCredentials)
+ Set<Class> supportedControls)
{
+ 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);
- this.supportedCredentials = Collections.unmodifiableMap(supportedCredentials);
+
// Supported relationships
List<String> relationshipNames =
configurationMD.getSupportedRelationshipTypes();
@@ -78,7 +88,7 @@
for (IdentityObjectTypeMetaData identityObjectTypeMetaData :
configurationMD.getSupportedIdentityTypes())
{
String fromTypeName = identityObjectTypeMetaData.getName();
-
+
if (identityObjectTypeMetaData.getRelationships() == null)
{
continue;
@@ -122,10 +132,14 @@
}
}
+
+
}
+
+
}
public boolean isControlSupported(IdentityObjectType identityObjectType,
IdentityObjectSearchControl control)
@@ -181,7 +195,7 @@
public boolean isCredentialSupported(IdentityObjectType identityObjectType,
IdentityObjectCredentialType credentialType)
{
Set<String> types = supportedCredentials.get(identityObjectType.getName());
- if (types != null && types.contains(credentialType))
+ if (types != null && types.contains(credentialType.getName()))
{
return true;
}
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/hibernate/HibernateIdentityStoreImpl.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/hibernate/HibernateIdentityStoreImpl.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/hibernate/HibernateIdentityStoreImpl.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -35,6 +35,8 @@
import org.jboss.identity.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
import org.jboss.identity.spi.configuration.metadata.IdentityObjectTypeMetaData;
import org.jboss.identity.spi.credential.IdentityObjectCredential;
+import org.jboss.identity.spi.credential.IdentityObjectCredentialType;
+import org.jboss.identity.spi.attribute.AttributeMetaData;
import org.jboss.identity.exception.IdentityException;
import org.jboss.identity.impl.model.hibernate.HibernateIdentityObject;
import org.jboss.identity.impl.model.hibernate.HibernateIdentityObjectRelationship;
@@ -42,9 +44,12 @@
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.NotYetImplementedException;
+import org.jboss.identity.impl.model.hibernate.HibernateIdentityObjectCredentialType;
+import org.jboss.identity.impl.model.hibernate.HibernateIdentityObjectCredential;
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;
@@ -61,7 +66,9 @@
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>
@@ -97,8 +104,14 @@
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;
@@ -107,19 +120,36 @@
private boolean isRealmAware = false;
+ private boolean isAllowNotDefinedAttributes = false;
+
// TODO: rewrite this into some more handy object
private IdentityStoreConfigurationMetaData configurationMD;
- private static Set<Class> supportedSearchControls = new HashSet<Class>();
+ 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, AttributeMetaData>> attributesMetaData =
new HashMap<String, Map<String, AttributeMetaData>>();
+
+ // <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
- //TODO: attributefilter?
+ supportedIdentityObjectSearchControls.add(PageSearchControl.class);
+ supportedIdentityObjectSearchControls.add(SortByNameSearchControl.class);
+ supportedIdentityObjectSearchControls.add(AttributeFilterSearchControl.class);
+ supportedIdentityObjectSearchControls.add(NameFilterSearchControl.class);
- supportedSearchControls.add(PageSearchControl.class);
- supportedSearchControls.add(SortByNameSearchControl.class);
-
+ // credential types supported by this impl
+ supportedCredentialTypes.add(CREDENTIAL_TYPE_PASSWORD);
+ supportedCredentialTypes.add(CREDENTIAL_TYPE_BINARY);
+
}
public HibernateIdentityStoreImpl(String id)
@@ -131,22 +161,43 @@
{
this.configurationMD = configurationMD;
- supportedFeatures = new FeaturesMetaDataImpl(configurationMD,
supportedSearchControls, new HashMap<String, Set<String>>());
+ id = configurationMD.getId();
+ supportedFeatures = new FeaturesMetaDataImpl(configurationMD,
supportedIdentityObjectSearchControls);
+
String persistenceUnit = configurationMD.getOptionSingleValue(PERSISTENCE_UNIT);
- if (persistenceUnit == null)
+ 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())
{
- throw new IdentityException("Persistence Unit not defined for
IdentityStore: " + getId());
- }
+ Set<String> names = new HashSet<String>();
+ Map<String, AttributeMetaData> metadataMap = new HashMap<String,
AttributeMetaData>();
+ Map<String, String> reverseMap = new HashMap<String, String>();
+ for (AttributeMetaData attributeMetaData :
identityObjectTypeMetaData.getAttributes())
+ {
+ names.add(attributeMetaData.getName());
+ metadataMap.put(attributeMetaData.getName(), attributeMetaData);
+ if (attributeMetaData.getStoreMapping() != null)
+ {
+ reverseMap.put(attributeMetaData.getStoreMapping(),
attributeMetaData.getName());
+ }
+ }
- emFactory =
(HibernateEntityManagerFactory)Persistence.createEntityManagerFactory(persistenceUnit);
+ // Use unmodifiableSet as it'll be exposed directly
+ attributeMappings.put(identityObjectTypeMetaData.getName(),
Collections.unmodifiableSet(names));
- String populateMembershipTypes =
configurationMD.getOptionSingleValue(POPULATE_MEMBERSHIP_TYPES);
- String populateIdentityObjectTypes =
configurationMD.getOptionSingleValue(POPULATE_IDENTITY_OBJECT_TYPES);
+ attributesMetaData.put(identityObjectTypeMetaData.getName(), metadataMap);
- HibernateEntityManager em =
(HibernateEntityManager)emFactory.createEntityManager();
+ reverseAttributeMappings.put(identityObjectTypeMetaData.getName(), reverseMap);
+ }
+ attributeMappings = Collections.unmodifiableMap(attributeMappings);
if (populateMembershipTypes != null &&
populateMembershipTypes.equalsIgnoreCase("true"))
{
@@ -189,6 +240,18 @@
}
+ 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"))
@@ -196,6 +259,13 @@
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;
@@ -220,10 +290,24 @@
{
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
@@ -277,7 +361,8 @@
List results = em.createNamedQuery("findIdentityObjectByNameAndType")
.setParameter("realm", realm)
.setParameter("name", name)
- .setParameter("typeName",
identityObjectType.getName()).getResultList();
+ .setParameter("typeName", identityObjectType.getName())
+ .getResultList();
if (results.size() != 0)
{
@@ -294,7 +379,7 @@
{
for (Map.Entry<String, String[]> entry : attributes.entrySet())
{
- io.setAttribute(entry.getKey(), entry.getValue());
+ io.addAttribute(entry.getKey(), entry.getValue());
}
}
@@ -315,11 +400,28 @@
{
HibernateIdentityObject hibernateObject = safeGet(ctx, identity);
- //TODO: handle cleanup of present relationships
+ HibernateEntityManager hem = getHibernateEntityManager(ctx);
try
{
- getHibernateEntityManager(ctx).remove(hibernateObject);
+ // 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)
{
@@ -392,7 +494,7 @@
throw new IllegalArgumentException("id is null");
}
- HibernateIdentityObject hibernateObject = null;
+ HibernateIdentityObject hibernateObject;
try
{
@@ -418,6 +520,8 @@
PageSearchControl pageSearchControl = null;
SortByNameSearchControl sortSearchControl = null;
+ AttributeFilterSearchControl attributeFilterControl = null;
+ NameFilterSearchControl nameFilterSearchControl = null;
if (controls != null)
{
@@ -431,6 +535,14 @@
{
sortSearchControl = (SortByNameSearchControl)control;
}
+ else if (control instanceof AttributeFilterSearchControl)
+ {
+ attributeFilterControl = (AttributeFilterSearchControl)control;
+ }
+ else if (control instanceof NameFilterSearchControl)
+ {
+ nameFilterSearchControl = (NameFilterSearchControl)control;
+ }
}
}
@@ -461,19 +573,30 @@
q = em.createNamedQuery("findIdentityObjectsByType");
}
-
- q.setParameter("realm", getRealm(em, ctx))
- .setParameter("typeName", hibernateType.getName());
-
if (pageSearchControl != null)
{
- q.setFirstResult(pageSearchControl.getOffset());
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();
}
@@ -482,10 +605,16 @@
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);
@@ -498,10 +627,14 @@
HibernateIdentityObject hibernateObject = safeGet(ctx, identity);
- List<IdentityObject> results = null;
+ List<IdentityObject> results;
+ checkControls(controls);
+
PageSearchControl pageSearchControl = null;
SortByNameSearchControl sortSearchControl = null;
+ AttributeFilterSearchControl attributeFilterControl = null;
+ NameFilterSearchControl nameFilterSearchControl = null;
if (controls != null)
{
@@ -515,6 +648,14 @@
{
sortSearchControl = (SortByNameSearchControl)control;
}
+ else if (control instanceof AttributeFilterSearchControl)
+ {
+ attributeFilterControl = (AttributeFilterSearchControl)control;
+ }
+ else if (control instanceof NameFilterSearchControl)
+ {
+ nameFilterSearchControl = (NameFilterSearchControl)control;
+ }
}
}
@@ -544,7 +685,8 @@
if (parent)
{
- hqlString.append("select ior.toIdentityObject from
HibernateIdentityObjectRelationship ior where ior.type.name like :relType and
ior.fromIdentityObject like :identity");
+ 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)
{
@@ -557,7 +699,8 @@
}
else
{
- hqlString.append("select ior.fromIdentityObject from
HibernateIdentityObjectRelationship ior where ior.type.name like :relType and
ior.toIdentityObject like :identity");
+ 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)
@@ -570,9 +713,21 @@
}
}
+
+
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)
{
@@ -583,6 +738,8 @@
}
}
+
+
results = q.list();
@@ -592,20 +749,29 @@
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
+ 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
+ public IdentityObjectRelationship createRelationship(IdentityStoreInvocationContext
ctx,
+ IdentityObject fromIdentity,
+ IdentityObject toIdentity,
+ IdentityObjectRelationshipType
relationshipType,
+ String name, boolean createNames)
throws IdentityException
{
- //TODO: check name
if (relationshipType == null)
{
@@ -639,6 +805,11 @@
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
@@ -652,9 +823,10 @@
}
+
+
public void removeRelationship(IdentityStoreInvocationContext ctx, IdentityObject
fromIdentity, IdentityObject toIdentity, IdentityObjectRelationshipType relationshipType,
String name) throws IdentityException
{
- //TODO: check name
if (relationshipType == null)
{
@@ -678,6 +850,13 @@
}
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)
@@ -701,12 +880,8 @@
}
-
-
public void removeRelationships(IdentityStoreInvocationContext ctx, IdentityObject
identity1, IdentityObject identity2, boolean named) throws IdentityException
{
- //TODO: named
-
HibernateIdentityObject hio1 = safeGet(ctx, identity1);
HibernateIdentityObject hio2 = safeGet(ctx, identity2);
@@ -719,9 +894,14 @@
for (Iterator iterator = results.iterator(); iterator.hasNext();)
{
HibernateIdentityObjectRelationship relationship =
(HibernateIdentityObjectRelationship) iterator.next();
-
relationship.getFromIdentityObject().getFromRelationships().remove(relationship);
- relationship.getToIdentityObject().getToRelationships().remove(relationship);
- getHibernateEntityManager(ctx).remove(relationship);
+
+ if ((named && relationship.getName() != null) ||
+ (!named && relationship.getName() == null))
+ {
+
relationship.getFromIdentityObject().getFromRelationships().remove(relationship);
+
relationship.getToIdentityObject().getToRelationships().remove(relationship);
+ getHibernateEntityManager(ctx).remove(relationship);
+ }
}
}
@@ -813,8 +993,12 @@
HibernateEntityManager em = getHibernateEntityManager(ctx);
+ checkControls(controls);
+
PageSearchControl pageSearchControl = null;
SortByNameSearchControl sortSearchControl = null;
+ AttributeFilterSearchControl attributeFilterControl = null;
+ NameFilterSearchControl nameFilterSearchControl = null;
if (controls != null)
{
@@ -828,6 +1012,14 @@
{
sortSearchControl = (SortByNameSearchControl)control;
}
+ else if (control instanceof AttributeFilterSearchControl)
+ {
+ attributeFilterControl = (AttributeFilterSearchControl)control;
+ }
+ else if (control instanceof NameFilterSearchControl)
+ {
+ nameFilterSearchControl = (NameFilterSearchControl)control;
+ }
}
}
@@ -854,6 +1046,16 @@
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());
@@ -890,6 +1092,8 @@
HibernateEntityManager em = getHibernateEntityManager(ctx);
+ checkControls(controls);
+
PageSearchControl pageSearchControl = null;
SortByNameSearchControl sortSearchControl = null;
@@ -961,8 +1165,15 @@
public <T extends IdentityObjectType> Set<String>
getSupportedAttributeNames(IdentityStoreInvocationContext ctx, T identityType) throws
IdentityException
{
- //TODO: NYI
- throw new NotYetImplementedException();
+ checkIOType(identityType);
+
+ if (attributeMappings.containsKey(identityType.getName()))
+ {
+ return attributeMappings.get(identityType.getName());
+ }
+
+ return new HashSet<String>();
+
}
public Map<String, String[]> getAttributes(IdentityStoreInvocationContext ctx,
IdentityObject identity) throws IdentityException
@@ -970,8 +1181,21 @@
HibernateIdentityObject hibernateObject = safeGet(ctx, identity);
- return hibernateObject.getAttributes();
+ Map<String, String[]> storeAttributes =
hibernateObject.getAttributesAsMap();
+ Map<String, String[]> result = new HashMap<String, String[]>();
+
+ // Remap the names
+ for (Map.Entry<String, String[]> entry : storeAttributes.entrySet())
+ {
+ String name = resolveAttributeNameFromStoreMapping(identity.getIdentityType(),
entry.getKey());
+ if (name != null)
+ {
+ result.put(name, entry.getValue());
+ }
+ }
+ return result;
+
}
public void updateAttributes(IdentityStoreInvocationContext ctx, IdentityObject
identity, Map<String, String[]> attributes) throws IdentityException
@@ -982,11 +1206,30 @@
throw new IllegalArgumentException("attributes are null");
}
+ Map<String, String[]> mappedAttributes = new HashMap<String,
String[]>();
+
+ for (Map.Entry<String, String[]> entry : attributes.entrySet())
+ {
+ String name = resolveAttributeStoreMapping(identity.getIdentityType(),
entry.getKey());
+ mappedAttributes.put(name, entry.getValue());
+
+ Map<String, AttributeMetaData> mdMap =
attributesMetaData.get(identity.getIdentityType().getName());
+
+ if (mdMap != null)
+ {
+ AttributeMetaData amd = mdMap.get(entry.getKey());
+ if (amd != null && !amd.isMultivalued() &&
entry.getValue().length > 1)
+ {
+ throw new IdentityException("Cannot assigned multiply values to
single valued attribute: " + entry.getKey());
+ }
+ }
+ }
+
HibernateIdentityObject hibernateObject = safeGet(ctx, identity);
- for (String name : attributes.keySet())
+ for (String name : mappedAttributes.keySet())
{
- hibernateObject.setAttribute(name, attributes.get(name));
+ hibernateObject.updateAttribute(name, mappedAttributes.get(name));
}
}
@@ -999,11 +1242,30 @@
throw new IllegalArgumentException("attributes are null");
}
+ Map<String, String[]> mappedAttributes = new HashMap<String,
String[]>();
+
+ for (Map.Entry<String, String[]> entry : attributes.entrySet())
+ {
+ String name = resolveAttributeStoreMapping(identity.getIdentityType(),
entry.getKey());
+ mappedAttributes.put(name, entry.getValue());
+
+ Map<String, AttributeMetaData> mdMap =
attributesMetaData.get(identity.getIdentityType().getName());
+
+ if (mdMap != null)
+ {
+ AttributeMetaData amd = mdMap.get(entry.getKey());
+ if (amd != null && !amd.isMultivalued() &&
entry.getValue().length > 1)
+ {
+ throw new IdentityException("Cannot assigned multiply values to
single valued attribute: " + entry.getKey());
+ }
+ }
+ }
+
HibernateIdentityObject hibernateObject = safeGet(ctx, identity);
- for (String name : attributes.keySet())
+ for (String name : mappedAttributes.keySet())
{
- hibernateObject.addAttributeValues(name, attributes.get(name));
+ hibernateObject.addAttributeValues(name, mappedAttributes.get(name));
}
}
@@ -1015,9 +1277,29 @@
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, AttributeMetaData> mdMap =
attributesMetaData.get(identity.getIdentityType().getName());
+
+ if (mdMap != null)
+ {
+ AttributeMetaData amd = mdMap.get(attributes[i]);
+ if (amd != null && amd.isRequired())
+ {
+ throw new IdentityException("Cannot remove required attribute: "
+ attributes[i]);
+ }
+ }
+
+ }
+
HibernateIdentityObject hibernateObject = safeGet(ctx, identity);
- for (String attr : attributes)
+ for (String attr : mappedAttributes)
{
hibernateObject.removeAttribute(attr);
}
@@ -1025,16 +1307,123 @@
public boolean validateCredential(IdentityStoreInvocationContext ctx, IdentityObject
identityObject, IdentityObjectCredential credential) throws IdentityException
{
- //TODO: NYI
- throw new NotYetImplementedException();
+ 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
+ {
+ 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
{
- //TODO: NYI
- throw new NotYetImplementedException();
+
+ 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
+ {
+ 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
@@ -1167,6 +1556,26 @@
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
{
@@ -1213,6 +1622,30 @@
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
{
@@ -1258,6 +1691,15 @@
{
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;
+ }
}
@@ -1269,6 +1711,11 @@
{
return isRealmAware;
}
+
+ private boolean isAllowNotDefinedAttributes()
+ {
+ return isAllowNotDefinedAttributes;
+ }
private void checkControls(IdentityObjectSearchControl[] controls) throws
IdentityException
{
@@ -1276,7 +1723,7 @@
{
for (IdentityObjectSearchControl control : controls)
{
- if (!supportedSearchControls.contains(control.getClass()))
+ if (!supportedIdentityObjectSearchControls.contains(control.getClass()))
{
throw new IdentityException("IdentityObjectSearchControl not
supported by this IdentityStore: " + control.getClass());
}
@@ -1284,6 +1731,100 @@
}
}
+ /**
+ * 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()))
+ {
+ AttributeMetaData 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 on the hibernate query level
+ private void filterByAttributesValues(Collection<IdentityObject> objects,
Map<String, String[]> attrs)
+ {
+ Set<IdentityObject> toRemove = new HashSet<IdentityObject>();
+
+ for (IdentityObject object : objects)
+ {
+ boolean add = true;
+
+ Map<String, String[]> 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()));
+ Set<String> present = new
HashSet<String>(Arrays.asList(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);
+ }
+ }
+
+
+
}
Modified:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/ldap/LDAPIdentityStoreImpl.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/ldap/LDAPIdentityStoreImpl.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/ldap/LDAPIdentityStoreImpl.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -40,9 +40,15 @@
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 javax.naming.ldap.LdapContext;
import javax.naming.ldap.LdapName;
+import javax.naming.ldap.Control;
+import javax.naming.ldap.SortControl;
import javax.naming.directory.Attributes;
import javax.naming.directory.Attribute;
import javax.naming.directory.SearchControls;
@@ -88,7 +94,9 @@
// List all supported controls classes
//TODO:
- //supportedSearchControls.add()
+ supportedSearchControls.add(SortByNameSearchControl.class);
+ //supportedSearchControls.add(PageSearchControl.class);
+ //supportedSearchControls.add(AttributeFilterSearchControl.class);
}
public LDAPIdentityStoreImpl(String id)
@@ -100,7 +108,7 @@
{
configuration = new SimpleLDAPIdentityStoreConfiguration(configurationMD);
- supportedFeatures = new FeaturesMetaDataImpl(configurationMD,
supportedSearchControls, new HashMap<String, Set<String>>());
+ supportedFeatures = new FeaturesMetaDataImpl(configurationMD,
supportedSearchControls);
}
public IdentityStoreSession createIdentityStoreSession()
@@ -482,18 +490,92 @@
// );
// }
- //TODO: controls (name filter)
+ checkControls(controls);
+
+ //TODO: paged 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 = "*";
- //TODO: handle paged results and sort
+ //Filter by name
+ if (nameFilterSearchControl != null)
+ {
+ nameFilter = nameFilterSearchControl.getFilter();
+ }
- Context ctx = getLDAPContext(invocationCtx);
+
+ //TODO: handle paged results
+
+ LdapContext ctx = getLDAPContext(invocationCtx);
+
+
checkIOType(type);
List<IdentityObject> objects = new LinkedList<IdentityObject>();
+ LDAPIdentityObjectTypeConfiguration typeConfiguration =
getTypeConfiguration(invocationCtx, type);
+
try
{
+ // Sort control
+ if (sortSearchControl != null)
+ {
+ //TODO: make criticallity optional
+ ctx.setRequestControls(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;
@@ -501,23 +583,31 @@
{
Object[] filterArgs = {nameFilter};
- sr = searchIdentityObjects(invocationCtx, type, filter, filterArgs, new
String[]{getTypeConfiguration(invocationCtx, type).getIdAttributeName()});
+ sr = searchIdentityObjects(invocationCtx, type, "&(" + filter +
")" + af.toString(), filterArgs, new
String[]{typeConfiguration.getIdAttributeName()});
}
else
{
- filter = "(".concat(getTypeConfiguration(invocationCtx,
type).getIdAttributeName()).concat("=").concat(nameFilter).concat(")");
- sr = searchIdentityObjects(invocationCtx, type, filter, null, new
String[]{getTypeConfiguration(invocationCtx, type).getIdAttributeName()});
+ filter =
"(".concat(typeConfiguration.getIdAttributeName()).concat("=").concat(nameFilter).concat(")");
+ sr = searchIdentityObjects(invocationCtx, type, "&(" + filter +
")" + af.toString(), null, new
String[]{typeConfiguration.getIdAttributeName()});
}
for (SearchResult res : sr)
{
- ctx = (Context)res.getObject();
+ ctx = (LdapContext)res.getObject();
String dn = ctx.getNameInNamespace();
objects.add(createIdentityObjectInstance(invocationCtx, type,
res.getAttributes(), dn));
}
ctx.close();
+
+ // Post sort if the order was descending
+ if (sortSearchControl != null && !sortSearchControl.isAscending());
+ {
+ //TODO: rather sucks for the performance but I don't see how to do this
with JNDI SortControl
+ //TODO: check if result was sorted (if the control was NONCRITICAL) to save
some cycles
+ Collections.reverse(objects);
+ }
return objects;
}
@@ -525,7 +615,7 @@
{
//log.debug("No identity object found with name: " + name, e);
}
- catch (NamingException e)
+ catch (Exception e)
{
throw new IdentityException("IdentityObject search failed.", e);
}
@@ -665,6 +755,26 @@
//TODO: handle paged results and sort
+ 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;
+ }
+ }
+ }
+
Set<IdentityObjectRelationship> relationships = new
HashSet<IdentityObjectRelationship>();
LDAPIdentityObjectImpl ldapFromIO = getSafeLDAPIO(ctx, identity);
@@ -704,12 +814,15 @@
break;
}
}
+
+ //TODO: need to be sorted/paginated manually
}
- // if not parent all parent entries need to be found
+ // if not parent then all parent entries need to be found
else
{
//TODO:
+ //TODO: apply sort/pagination ldap control
throw new NotYetImplementedException();
}
@@ -767,8 +880,6 @@
LdapContext ldapContext = getLDAPContext(ctx);
// Check posibilities
- //TODO: Supported features should handle information from type configurations
-
if
(!getSupportedFeatures().isRelationshipTypeSupported(fromIdentity.getIdentityType(),
toIdentity.getIdentityType(), relationshipType))
{
throw new IdentityException("Relationship not supported");
@@ -776,7 +887,7 @@
try
{
- //construct new member attribute values
+ // Construct new member attribute values
Attributes attrs = new BasicAttributes(true);
Attribute member = new
BasicAttribute(fromTypeConfig.getMembershipAttributeName());
@@ -1504,5 +1615,18 @@
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());
+ }
+ }
+ }
+ }
}
Modified:
trunk/identity-impl/src/test/java/org/jboss/identity/impl/store/CommonIdentityStoreTest.java
===================================================================
---
trunk/identity-impl/src/test/java/org/jboss/identity/impl/store/CommonIdentityStoreTest.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/test/java/org/jboss/identity/impl/store/CommonIdentityStoreTest.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -23,12 +23,22 @@
package org.jboss.identity.impl.store;
import org.jboss.identity.spi.model.IdentityObject;
+import org.jboss.identity.spi.credential.IdentityObjectCredential;
+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.model.hibernate.HibernateIdentityObject;
+import org.opends.server.controls.PagedResultsControl;
import java.util.Collection;
-import java.util.Set;
import java.util.Map;
import java.util.HashMap;
-import java.util.HashSet;
+import java.util.Random;
+import java.util.List;
import junit.framework.Assert;
@@ -61,8 +71,8 @@
testContext.begin();
- IdentityObject user1 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Adam",
IdentityTypeEnum.USER);
- IdentityObject user2 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Eva",
IdentityTypeEnum.USER);
+ 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);
@@ -72,7 +82,7 @@
testContext.flush();
assertEquals(0,
testContext.getStore().getIdentityObjectsCount(testContext.getCtx(),
IdentityTypeEnum.ROLE));
- assertEquals(2,
testContext.getStore().getIdentityObjectsCount(testContext.getCtx(),
IdentityTypeEnum.USER));
+ assertEquals(2,
testContext.getStore().getIdentityObjectsCount(testContext.getCtx(),
IdentityTypeEnum.IDENTITY));
assertEquals(4,
testContext.getStore().getIdentityObjectsCount(testContext.getCtx(),
IdentityTypeEnum.ORGANIZATION));
testContext.flush();
@@ -81,14 +91,14 @@
testContext.getStore().removeIdentityObject(testContext.getCtx(), group1);
testContext.getStore().removeIdentityObject(testContext.getCtx(), group2);
- assertEquals(1,
testContext.getStore().getIdentityObjectsCount(testContext.getCtx(),
IdentityTypeEnum.USER));
+ 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.USER));
+ assertEquals(0,
testContext.getStore().getIdentityObjectsCount(testContext.getCtx(),
IdentityTypeEnum.IDENTITY));
assertEquals(0,
testContext.getStore().getIdentityObjectsCount(testContext.getCtx(),
IdentityTypeEnum.ORGANIZATION));
testContext.commit();
@@ -100,8 +110,8 @@
testContext.begin();
- IdentityObject user1 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Adam",
IdentityTypeEnum.USER);
- IdentityObject user2 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Eva",
IdentityTypeEnum.USER);
+ 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);
@@ -110,13 +120,13 @@
testContext.flush();
- IdentityObject xx = testContext.getStore().findIdentityObject(testContext.getCtx(),
"Adam", IdentityTypeEnum.USER);
+ 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.USER,
null);
+ Collection results =
testContext.getStore().findIdentityObject(testContext.getCtx(), IdentityTypeEnum.IDENTITY,
null);
assertEquals(2, results.size());
results = testContext.getStore().findIdentityObject(testContext.getCtx(),
IdentityTypeEnum.ORGANIZATION, null);
@@ -135,8 +145,8 @@
testContext.begin();
- IdentityObject user1 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Adam",
IdentityTypeEnum.USER);
- IdentityObject user2 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Eva",
IdentityTypeEnum.USER);
+ IdentityObject user1 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Adam",
IdentityTypeEnum.IDENTITY);
+ IdentityObject user2 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Eva",
IdentityTypeEnum.IDENTITY);
testContext.flush();
@@ -231,8 +241,8 @@
testContext.begin();
- IdentityObject user1 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Adam",
IdentityTypeEnum.USER);
- IdentityObject user2 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Eva",
IdentityTypeEnum.USER);
+ 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);
@@ -241,8 +251,8 @@
testContext.flush();
- testContext.getStore().createRelationship(testContext.getCtx(), group1, user1,
RelationshipTypeEnum.MEMBER, null, false);
- testContext.getStore().createRelationship(testContext.getCtx(), group2, user1,
RelationshipTypeEnum.MEMBER, null, false);
+ 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();
@@ -251,7 +261,7 @@
assertEquals(1, testContext.getStore().resolveRelationships(testContext.getCtx(),
group2, user1).size());
assertEquals(0, testContext.getStore().resolveRelationships(testContext.getCtx(),
user1, group2).size());
- testContext.getStore().removeRelationship(testContext.getCtx(), group2, user1,
RelationshipTypeEnum.MEMBER, null);
+ testContext.getStore().removeRelationship(testContext.getCtx(), group2, user1,
RelationshipTypeEnum.JBOSS_IDENTITY_MEMBERSHIP, null);
testContext.flush();
@@ -271,4 +281,228 @@
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"});
+
+ testContext.getStore().addAttributes(testContext.getCtx(), group1, attrs);
+
+ 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/impl/store/RelationshipTypeEnum.java
===================================================================
---
trunk/identity-impl/src/test/java/org/jboss/identity/impl/store/RelationshipTypeEnum.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/test/java/org/jboss/identity/impl/store/RelationshipTypeEnum.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -31,7 +31,8 @@
*/
public enum RelationshipTypeEnum implements IdentityObjectRelationshipType
{
- MEMBER;
+ JBOSS_IDENTITY_MEMBERSHIP,
+ JBOSS_IDENTITY_ROLE;
public String getName()
{
Modified:
trunk/identity-impl/src/test/java/org/jboss/identity/impl/store/hibernate/HibernateIdentityStoreTestCase.java
===================================================================
---
trunk/identity-impl/src/test/java/org/jboss/identity/impl/store/hibernate/HibernateIdentityStoreTestCase.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/test/java/org/jboss/identity/impl/store/hibernate/HibernateIdentityStoreTestCase.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -31,6 +31,8 @@
import org.jboss.identity.spi.store.IdentityStoreSession;
import org.jboss.identity.spi.searchcontrol.IdentityObjectSearchControl;
import org.jboss.identity.spi.credential.IdentityObjectCredentialType;
+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.RelationshipTypeEnum;
@@ -39,6 +41,10 @@
import org.jboss.identity.impl.store.IdentityStoreTestContext;
import org.jboss.identity.impl.store.FeaturesMetaDataImpl;
import org.jboss.identity.impl.model.hibernate.HibernateRealm;
+import
org.jboss.identity.impl.configuration.metadata.IdentityStoreConfigurationMetaDataImpl;
+import org.jboss.identity.impl.configuration.metadata.IdentityObjectTypeMetaDataImpl;
+import org.jboss.identity.impl.configuration.metadata.IdentityConfigurationMetaDataImpl;
+import org.jboss.identity.impl.configuration.jaxb2.JAXB2IdentityConfiguration;
import org.jboss.identity.exception.IdentityException;
import org.hibernate.ejb.HibernateEntityManager;
@@ -47,6 +53,11 @@
import java.util.Map;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.io.File;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
@@ -74,57 +85,39 @@
{
super.setUp();
- store = new HibernateIdentityStoreImpl("test-id")
+ 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
- public FeaturesMetaData getSupportedFeatures()
+ protected HibernateEntityManager bootstrapHibernateEntityManager(String
persistenceUnit) throws IdentityException
{
- return new FeaturesMetaData()
- {
- public boolean isControlSupported(IdentityObjectType identityObjectType,
IdentityObjectSearchControl control)
- {
- return true;
- }
+ return em;
+ }
- public boolean isControlSupported(IdentityObjectType identityObjectType,
Class controlClazz)
- {
- return true;
- }
+ };
- public Set<String> getSupportedIdentityObjectTypes()
- {
- return null;
- }
+ store.bootstrap(storeMD);
- public boolean isIdentityObjectTypeSupported(IdentityObjectType
identityObjectType)
- {
- return true;
- }
- public boolean isRelationshipTypeSupported(IdentityObjectType fromType,
IdentityObjectType toType, IdentityObjectRelationshipType relationshipType) throws
IdentityException
- {
- return true;
- }
-
- public Set<String> getSupportedRelationshipTypes()
- {
- return null;
- }
-
- public boolean isCredentialSupported(IdentityObjectType
identityObjectType, IdentityObjectCredentialType credentialType)
- {
- return true;
- }
- };
- }
- };
-
ctx = new IdentityStoreInvocationContext()
{
public IdentityStoreSession getIdentityStoreSession()
@@ -138,51 +131,9 @@
}
};
- populateIdentityTypes();
- populateRelationshipTypes();
- em.getTransaction().begin();
-
- HibernateRealm realm = new
HibernateRealm(HibernateIdentityStoreImpl.DEFAULT_REALM_NAME);
- em.persist(realm);
-
- em.getTransaction().commit();
-
-
}
- private void populateRelationshipTypes() throws Exception
- {
-
- em.getTransaction().begin();
-
- RelationshipTypeEnum types[] = RelationshipTypeEnum.values();
-
- for (int i = 0; i < types.length; i++)
- {
- RelationshipTypeEnum type = types[i];
- store.addIdentityObjectRelationshipType(ctx, type);
- }
-
- em.getTransaction().commit();
-
- }
-
- private void populateIdentityTypes() throws Exception
- {
- em.getTransaction().begin();
-
- IdentityTypeEnum types[] = IdentityTypeEnum.values();
-
- for (int i = 0; i < types.length; i++)
- {
- IdentityTypeEnum type = types[i];
- store.addIdentityObjectType(ctx, type);
- }
-
- em.getTransaction().commit();
- }
-
public void begin() throws Exception
{
em.getTransaction().begin();
@@ -230,8 +181,8 @@
em.getTransaction().begin();
- IdentityObject user1 = store.createIdentityObject(ctx, "Adam",
IdentityTypeEnum.USER);
- IdentityObject user2 = store.createIdentityObject(ctx, "Eva",
IdentityTypeEnum.USER);
+ IdentityObject user1 = store.createIdentityObject(ctx, "Adam",
IdentityTypeEnum.IDENTITY);
+ IdentityObject user2 = store.createIdentityObject(ctx, "Eva",
IdentityTypeEnum.IDENTITY);
em.flush();
@@ -307,8 +258,6 @@
em.flush();
- Set<String> names = new HashSet<String>();
- names.add("key3");
store.removeAttributes(ctx, user1, new String[] {"key3"});
em.flush();
@@ -324,10 +273,18 @@
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/impl/store/hibernate/HibernateModelTestCase.java
===================================================================
---
trunk/identity-impl/src/test/java/org/jboss/identity/impl/store/hibernate/HibernateModelTestCase.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-impl/src/test/java/org/jboss/identity/impl/store/hibernate/HibernateModelTestCase.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -268,8 +268,8 @@
values1.add("Val3");
- user1.setAttribute("simple1", values1);
- user1.setAttribute("simple2", values1);
+ user1.updateAttribute("simple1", new String[]{"Val1",
"Val2", "Val3"});
+ user1.updateAttribute("simple2", new String[]{"Val1",
"Val2", "Val3"});
em.getTransaction().commit();
@@ -277,10 +277,10 @@
em.getTransaction().begin();
- user1 = em.find(HibernateIdentityObject.class, new Long(user1.getId()));
- assertEquals(2, user1.getAttributes().entrySet().size() );
- assertNotNull(user1.getAttributes().get("simple1"));
- assertEquals(3, user1.getAttributes().get("simple1").length);
+// user1 = em.find(HibernateIdentityObject.class, new Long(user1.getId()));
+// assertEquals(2, user1.getProfileAttributes().entrySet().size() );
+// assertNotNull(user1.getProfileAttributes().get("simple1"));
+// assertEquals(3, user1.getProfileAttributes().get("simple1").length);
em.getTransaction().commit();
Modified: trunk/identity-impl/src/test/resources/META-INF/persistence.xml
===================================================================
--- trunk/identity-impl/src/test/resources/META-INF/persistence.xml 2008-11-18 21:49:18
UTC (rev 123)
+++ trunk/identity-impl/src/test/resources/META-INF/persistence.xml 2008-12-02 18:51:34
UTC (rev 124)
@@ -11,6 +11,8 @@
<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>
@@ -37,6 +39,8 @@
<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>
Modified: trunk/identity-impl/src/test/resources/identity-config.xml
===================================================================
--- trunk/identity-impl/src/test/resources/identity-config.xml 2008-11-18 21:49:18 UTC
(rev 123)
+++ trunk/identity-impl/src/test/resources/identity-config.xml 2008-12-02 18:51:34 UTC
(rev 124)
@@ -128,6 +128,7 @@
<identity-object-type>
<name></name>
<relationships/>
+ <credentials/>
<attributes/>
<options/>
</identity-object-type>
@@ -139,6 +140,7 @@
<identity-object-type-ref></identity-object-type-ref>
</relationship>
</relationships>
+ <credentials/>
<attributes/>
<options/>
</identity-object-type>
@@ -157,6 +159,11 @@
<identity-object-type>
<name></name>
<relationships/>
+ <credentials>
+ <credential-type></credential-type>
+ <credential-type></credential-type>
+ <credential-type></credential-type>
+ </credentials>
<attributes>
<attribute>
<name></name>
@@ -202,6 +209,7 @@
<identity-object-type-ref></identity-object-type-ref>
</relationship>
</relationships>
+ <credentials/>
<attributes>
<attribute>
<name></name>
Modified: trunk/identity-impl/src/test/resources/identity-config.xsd
===================================================================
--- trunk/identity-impl/src/test/resources/identity-config.xsd 2008-11-18 21:49:18 UTC
(rev 123)
+++ trunk/identity-impl/src/test/resources/identity-config.xsd 2008-12-02 18:51:34 UTC
(rev 124)
@@ -79,6 +79,11 @@
<xs:element type="xs:string"
name="identity-object-type-name"/>
</xs:sequence>
</xs:complexType>
+ <xs:complexType name="credentialsType">
+ <xs:sequence>
+ <xs:element type="xs:string" name="credential-type"
maxOccurs="unbounded" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
<xs:complexType name="repositoriesType">
<xs:sequence>
<xs:element type="urn:repositoryType" name="repository"
maxOccurs="unbounded" minOccurs="0"
xmlns:urn="urn:jboss:identity:config:v0_1"/>
@@ -151,6 +156,13 @@
</xs:sequence>
</xs:complexType>
</xs:element>
+ <xs:element name="credentials">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element type="xs:string" name="credential-type"
maxOccurs="unbounded" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
<xs:element name="attributes">
<xs:complexType>
<xs:sequence>
@@ -171,8 +183,24 @@
<xs:sequence>
<xs:element type="xs:string" name="name"/>
<xs:element type="xs:string" name="mapping"/>
- <xs:element type="xs:string" name="isRequired"/>
- <xs:element type="xs:string" name="isMultivalued"/>
+ <xs:element name="isRequired">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:enumeration value=""/>
+ <xs:enumeration value="true"/>
+ <xs:enumeration value="false"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+ <xs:element name="isMultivalued">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:enumeration value=""/>
+ <xs:enumeration value="true"/>
+ <xs:enumeration value="false"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
<xs:element type="xs:string" name="isReadOnly"
minOccurs="0"/>
</xs:sequence>
</xs:complexType>
Modified: trunk/identity-impl/src/test/resources/organization-test-config.xml
===================================================================
--- trunk/identity-impl/src/test/resources/organization-test-config.xml 2008-11-18
21:49:18 UTC (rev 123)
+++ trunk/identity-impl/src/test/resources/organization-test-config.xml 2008-12-02
18:51:34 UTC (rev 124)
@@ -157,72 +157,86 @@
<identity-object-type>
<name>IDENTITY</name>
<relationships/>
+ <credentials>
+ <credential-type>PASSWORD</credential-type>
+ </credentials>
<attributes/>
<options/>
</identity-object-type>
<identity-object-type>
<name>ORGANIZATION</name>
<relationships/>
+ <credentials/>
<attributes/>
<options/>
</identity-object-type>
<identity-object-type>
<name>ORGANIZATION_UNIT</name>
<relationships/>
+ <credentials/>
<attributes/>
<options/>
</identity-object-type>
<identity-object-type>
<name>DIVISION</name>
<relationships/>
+ <credentials/>
<attributes/>
<options/>
</identity-object-type>
<identity-object-type>
<name>DEPARTMENT</name>
<relationships/>
+ <credentials/>
<attributes/>
<options/>
</identity-object-type>
<identity-object-type>
<name>PROJECT</name>
<relationships/>
+ <credentials/>
<attributes/>
<options/>
</identity-object-type>
<identity-object-type>
<name>PEOPLE</name>
<relationships/>
+ <credentials/>
<attributes/>
<options/>
</identity-object-type>
<identity-object-type>
<name>ADMINISTRATION</name>
<relationships/>
+ <credentials/>
<attributes/>
<options/>
</identity-object-type>
<identity-object-type>
<name>COMMUNITY</name>
<relationships/>
+ <credentials/>
<attributes/>
<options/>
</identity-object-type>
<identity-object-type>
<name>OFFICE</name>
<relationships/>
+ <credentials/>
<attributes/>
<options/>
</identity-object-type>
<identity-object-type>
<name>SECURITY</name>
<relationships/>
+ <credentials/>
<attributes/>
<options/>
</identity-object-type>
<identity-object-type>
<name>SYSTEM</name>
<relationships/>
+ <credentials/>
<attributes/>
<options/>
</identity-object-type>
@@ -240,6 +254,14 @@
<name>populateIdentityObjectTypes</name>
<value>true</value>
</option>
+ <option>
+ <name>allowNotDefinedAttributes</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>isRealmAware</name>
+ <value>true</value>
+ </option>
</options>
</identity-store>
<identity-store>
@@ -251,6 +273,9 @@
<identity-object-type>
<name>IDENTITY</name>
<relationships/>
+ <credentials>
+ <credential-type>PASSWORD</credential-type>
+ </credentials>
<attributes>
<attribute>
<name>phone</name>
@@ -312,6 +337,7 @@
<identity-object-type-ref>GROUP</identity-object-type-ref>
</relationship>
</relationships>
+ <credentials/>
<attributes/>
<options>
<option>
@@ -357,6 +383,7 @@
<identity-object-type-ref>IDENTITY</identity-object-type-ref>
</relationship>
</relationships>
+ <credentials/>
<attributes/>
<options>
<option>
Copied: trunk/identity-impl/src/test/resources/store-test-config.xml (from rev 122,
trunk/identity-impl/src/test/resources/organization-test-config.xml)
===================================================================
--- trunk/identity-impl/src/test/resources/store-test-config.xml
(rev 0)
+++ trunk/identity-impl/src/test/resources/store-test-config.xml 2008-12-02 18:51:34 UTC
(rev 124)
@@ -0,0 +1,339 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jboss-identity xmlns="urn:jboss:identity:config:v0_1"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:identity:config:v0_1
identity-config.xsd">
+ <realms>
+ <realm>
+ <id>realm://Dymmy</id>
+ <repository-id-ref>X</repository-id-ref>
+ <identity-type-mappings>
+ <identity-mapping>IDENTITY</identity-mapping>
+ </identity-type-mappings>
+ </realm>
+ </realms>
+ <repositories>
+ <repository>
+ <id>X</id>
+ <class>X</class>
+ <external-config/>
+
<default-identity-store-id>HibernateTestStore</default-identity-store-id>
+
<default-attribute-store-id>HibernateTestStore</default-attribute-store-id>
+ <identity-store-mappings>
+ <identity-store-mapping>
+
<identity-store-id>HibernateTestStore</identity-store-id>
+ <identity-object-types/>
+ <options/>
+ </identity-store-mapping>
+ </identity-store-mappings>
+ </repository>
+ </repositories>
+ <stores>
+ <attribute-stores/>
+ <identity-stores>
+ <identity-store>
+ <id>HibernateTestStore</id>
+
<class>org.jboss.identity.impl.store.hibernate.HibernateIdentityStoreImpl</class>
+ <external-config/>
+ <supported-relationship-types>
+
<relationship-type>JBOSS_IDENTITY_MEMBERSHIP</relationship-type>
+
<relationship-type>JBOSS_IDENTITY_ROLE</relationship-type>
+ </supported-relationship-types>
+ <supported-identity-object-types>
+ <identity-object-type>
+ <name>IDENTITY</name>
+ <relationships/>
+ <credentials>
+ <credential-type>PASSWORD</credential-type>
+ <credential-type>BINARY</credential-type>
+ </credentials>
+ <attributes/>
+ <options/>
+ </identity-object-type>
+ <identity-object-type>
+ <name>ORGANIZATION</name>
+ <relationships/>
+ <credentials/>
+ <attributes/>
+ <options/>
+ </identity-object-type>
+ <identity-object-type>
+ <name>ORGANIZATION_UNIT</name>
+ <relationships/>
+ <credentials/>
+ <attributes/>
+ <options/>
+ </identity-object-type>
+ <identity-object-type>
+ <name>DIVISION</name>
+ <relationships/>
+ <credentials/>
+ <attributes/>
+ <options/>
+ </identity-object-type>
+ <identity-object-type>
+ <name>DEPARTMENT</name>
+ <relationships/>
+ <credentials/>
+ <attributes/>
+ <options/>
+ </identity-object-type>
+ <identity-object-type>
+ <name>PROJECT</name>
+ <relationships/>
+ <credentials/>
+ <attributes/>
+ <options/>
+ </identity-object-type>
+ <identity-object-type>
+ <name>PEOPLE</name>
+ <relationships/>
+ <credentials/>
+ <attributes/>
+ <options/>
+ </identity-object-type>
+ <identity-object-type>
+ <name>ADMINISTRATION</name>
+ <relationships/>
+ <credentials/>
+ <attributes/>
+ <options/>
+ </identity-object-type>
+ <identity-object-type>
+ <name>COMMUNITY</name>
+ <relationships/>
+ <credentials/>
+ <attributes/>
+ <options/>
+ </identity-object-type>
+ <identity-object-type>
+ <name>OFFICE</name>
+ <relationships/>
+ <credentials/>
+ <attributes/>
+ <options/>
+ </identity-object-type>
+ <identity-object-type>
+ <name>SECURITY</name>
+ <relationships/>
+ <credentials/>
+ <attributes/>
+ <options/>
+ </identity-object-type>
+ <identity-object-type>
+ <name>ROLE</name>
+ <relationships/>
+ <credentials/>
+ <attributes/>
+ <options/>
+ </identity-object-type>
+ <identity-object-type>
+ <name>SYSTEM</name>
+ <relationships/>
+ <credentials/>
+ <attributes/>
+ <options/>
+ </identity-object-type>
+ </supported-identity-object-types>
+ <options>
+ <option>
+ <name>persistenceUnit</name>
+ <value>jboss-identity-model1</value>
+ </option>
+ <option>
+ <name>populateRelationshipTypes</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>populateIdentityObjectTypes</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>isRealmAware</name>
+ <value>false</value>
+ </option>
+ <option>
+ <name>allowNotDefinedAttributes</name>
+ <value>true</value>
+ </option>
+ </options>
+ </identity-store>
+ <identity-store>
+ <id>LDAPTestStore</id>
+
<class>org.jboss.identity.impl.store.ldap.LDAPIdentityStoreImpl</class>
+ <external-config/>
+ <supported-relationship-types/>
+ <supported-identity-object-types>
+ <identity-object-type>
+ <name>IDENTITY</name>
+ <relationships/>
+ <credentials>
+ <credential-type>PASSWORD</credential-type>
+ </credentials>
+ <attributes>
+ <attribute>
+ <name>phone</name>
+ <mapping>telephoneNumber</mapping>
+ <isRequired/>
+ <isMultivalued/>
+ <isReadOnly/>
+ </attribute>
+ <attribute>
+ <name>description</name>
+ <mapping>description</mapping>
+ <isRequired/>
+ <isMultivalued/>
+ <isReadOnly/>
+ </attribute>
+ <attribute>
+ <name>carLicense</name>
+ <mapping>carLicense</mapping>
+ <isRequired/>
+ <isMultivalued/>
+ <isReadOnly/>
+ </attribute>
+ </attributes>
+ <options>
+ <option>
+ <name>idAttributeName</name>
+ <value>uid</value>
+ </option>
+ <option>
+ <name>ctxDNs</name>
+
<value>ou=People,o=test,dc=portal,dc=example,dc=com</value>
+ </option>
+ <option>
+ <name>allowCreateEntry</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>createEntryAttributeValues</name>
+ <value>objectClass=top</value>
+ <value>objectClass=inetOrgPerson</value>
+ <value>sn= </value>
+ <value>cn= </value>
+ </option>
+ </options>
+ </identity-object-type>
+ <identity-object-type>
+ <name>GROUP</name>
+ <relationships>
+ <relationship>
+ <relationship-type-ref/>
+
<identity-object-type-ref>IDENTITY</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref/>
+
<identity-object-type-ref>ROLE</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref/>
+
<identity-object-type-ref>GROUP</identity-object-type-ref>
+ </relationship>
+ </relationships>
+ <credentials/>
+ <attributes/>
+ <options>
+ <option>
+ <name>idAttributeName</name>
+ <value>cn</value>
+ </option>
+ <option>
+ <name>ctxDNs</name>
+
<value>ou=Roles,o=test,dc=portal,dc=example,dc=com</value>
+ </option>
+ <!--<option>-->
+ <!--<name>entrySearchFilter</name>-->
+ <!--<value></value>-->
+ <!--</option>-->
+ <option>
+ <name>allowCreateEntry</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>membershipAttributeName</name>
+ <value>member</value>
+ </option>
+ <option>
+ <name>isMembershipAttributeDN</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>allowEmptyMemberships</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>createEntryAttributeValues</name>
+ <value>objectClass=top</value>
+ <value>objectClass=groupOfNames</value>
+ </option>
+ </options>
+ </identity-object-type>
+ <identity-object-type>
+ <name>ROLE</name>
+ <relationships>
+ <relationship>
+ <relationship-type-ref/>
+
<identity-object-type-ref>IDENTITY</identity-object-type-ref>
+ </relationship>
+ </relationships>
+ <credentials/>
+ <attributes/>
+ <options>
+ <option>
+ <name>idAttributeName</name>
+ <value>cn</value>
+ </option>
+ <option>
+ <name>ctxDNs</name>
+
<value>ou=Roles,o=test,dc=portal,dc=example,dc=com</value>
+ </option>
+ <!--<option>-->
+ <!--<name>entrySearchFilter</name>-->
+ <!--<value></value>-->
+ <!--</option>-->
+ <option>
+ <name>allowCreateEntry</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>membershipAttributeName</name>
+ <value>member</value>
+ </option>
+ <option>
+ <name>isMembershipAttributeDN</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>allowEmptyMemberships</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>createEntryAttributeValues</name>
+ <value>objectClass=top</value>
+ <value>objectClass=groupOfNames</value>
+ </option>
+ </options>
+ </identity-object-type>
+ </supported-identity-object-types>
+ <options>
+ <option>
+ <name>providerURL</name>
+ <value>ldap://localhost:10389</value>
+ </option>
+ <option>
+ <name>adminDN</name>
+ <value>cn=Directory Manager</value>
+ </option>
+ <option>
+ <name>adminPassword</name>
+ <value>password</value>
+ </option>
+ <option>
+ <name>searchTimeLimit</name>
+ <value>10000</value>
+ </option>
+ </options>
+ </identity-store>
+ </identity-stores>
+ </stores>
+</jboss-identity>
\ No newline at end of file
Property changes on: trunk/identity-impl/src/test/resources/store-test-config.xml
___________________________________________________________________
Name: svn:mergeinfo
+
Modified:
trunk/identity-spi/src/main/java/org/jboss/identity/spi/configuration/metadata/IdentityObjectTypeMetaData.java
===================================================================
---
trunk/identity-spi/src/main/java/org/jboss/identity/spi/configuration/metadata/IdentityObjectTypeMetaData.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-spi/src/main/java/org/jboss/identity/spi/configuration/metadata/IdentityObjectTypeMetaData.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -39,6 +39,8 @@
List<AttributeMetaData> getAttributes();
+ List<String> getCredentials();
+
Map<String, List<String>> getOptions();
List<String> getOption(String optionName);
Modified:
trunk/identity-spi/src/main/java/org/jboss/identity/spi/credential/IdentityObjectCredential.java
===================================================================
---
trunk/identity-spi/src/main/java/org/jboss/identity/spi/credential/IdentityObjectCredential.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-spi/src/main/java/org/jboss/identity/spi/credential/IdentityObjectCredential.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -34,5 +34,18 @@
* @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();
}
Modified:
trunk/identity-spi/src/main/java/org/jboss/identity/spi/store/FeaturesMetaData.java
===================================================================
---
trunk/identity-spi/src/main/java/org/jboss/identity/spi/store/FeaturesMetaData.java 2008-11-18
21:49:18 UTC (rev 123)
+++
trunk/identity-spi/src/main/java/org/jboss/identity/spi/store/FeaturesMetaData.java 2008-12-02
18:51:34 UTC (rev 124)
@@ -55,7 +55,9 @@
*/
boolean isControlSupported(IdentityObjectType identityObjectType, Class
controlClazz);
+ //TODO: isControlSupported per RelationshipType
+
/**
* @return set of identity types that can be persisted
*/