[jboss-identity-commits] JBoss Identity SVN: r255 - in idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl: store/ldap and 1 other directory.

jboss-identity-commits at lists.jboss.org jboss-identity-commits at lists.jboss.org
Tue Jan 27 10:28:46 EST 2009


Author: bdaw
Date: 2009-01-27 10:28:46 -0500 (Tue, 27 Jan 2009)
New Revision: 255

Modified:
   idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/BinaryCredential.java
   idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreImpl.java
   idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/ldap/SimpleLDAPIdentityObjectTypeConfiguration.java
Log:
few minor code fixes

Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/BinaryCredential.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/BinaryCredential.java	2009-01-27 06:05:23 UTC (rev 254)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/BinaryCredential.java	2009-01-27 15:28:46 UTC (rev 255)
@@ -35,7 +35,7 @@
    public BinaryCredential(byte[] value)
    {
       super(TYPE);
-      this.value = value;
+      this.value = value.clone();
    }
 
    public byte[] getValue()

Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreImpl.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreImpl.java	2009-01-27 06:05:23 UTC (rev 254)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreImpl.java	2009-01-27 15:28:46 UTC (rev 255)
@@ -2054,14 +2054,24 @@
 
    private LdapContext getLDAPContext(IdentityStoreInvocationContext ctx) throws IdentityException
    {
+
+      LdapContext ldapContext = null;
+
       try
       {
-         return (LdapContext)ctx.getIdentityStoreSession().getSessionContext();
+         ldapContext = (LdapContext)ctx.getIdentityStoreSession().getSessionContext();
       }
       catch (Exception e)
       {
          throw new IdentityException("Could not obtain LDAP connection: ", e);
       }
+      
+      if (ldapContext == null)
+      {
+         throw new IdentityException("IllegalState: - Could not obtain LDAP connection");
+      }
+
+      return ldapContext;
    }
 
    private LDAPIdentityStoreConfiguration getConfiguration(IdentityStoreInvocationContext ctx) throws IdentityException

Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/ldap/SimpleLDAPIdentityObjectTypeConfiguration.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/ldap/SimpleLDAPIdentityObjectTypeConfiguration.java	2009-01-27 06:05:23 UTC (rev 254)
+++ idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/ldap/SimpleLDAPIdentityObjectTypeConfiguration.java	2009-01-27 15:28:46 UTC (rev 255)
@@ -132,13 +132,15 @@
 
       allowedMembershipTypes = relationships.toArray(new String[relationships.size()]);
       
-      attributeNames = new HashMap<String, String>();
+      Map<String, String> attrsNames = new HashMap<String, String>();
 
       for (IdentityObjectAttributeMetaData attributeMetaData : objectTypeMD.getAttributes())
       {
-         attributeNames.put(attributeMetaData.getName(), attributeMetaData.getStoreMapping());
+         attrsNames.put(attributeMetaData.getName(), attributeMetaData.getStoreMapping());
       }
 
+      attributeNames = Collections.unmodifiableMap(attrsNames);
+
       List<String> dns = objectTypeMD.getOption(CTX_DNS);
       if (dns != null)
       {
@@ -151,8 +153,6 @@
 
       Map<String, List<String>> createEntryAttributesMap = new HashMap<String, List<String>>();
 
-
-
       List<String> createAttributes = objectTypeMD.getOption(CREATE_ENTRY_ATTRIBUTE_VALUES);
 
       if (createAttributes != null && createAttributes.size() > 0 )
@@ -187,11 +187,11 @@
             createEntryAttributesArray.put(entry.getKey(), entry.getValue().toArray(new String[entry.getValue().size()]));
          }
 
-         this.createEntryAttributeValues = createEntryAttributesArray;
+         this.createEntryAttributeValues = Collections.unmodifiableMap(createEntryAttributesArray);
       }
       else
       {
-         this.createEntryAttributeValues = new HashMap<String, String[]>();
+         this.createEntryAttributeValues = Collections.unmodifiableMap(new HashMap<String, String[]>());
       }
 
       //TODO: validate all required options - throw exception for missing ones and set defaults for others
@@ -214,15 +214,15 @@
    {
       this.idAttributeName = idAttributeName;
       this.passwordAttributeName = passwordAttributeName;
-      this.ctxDNs = ctxDNs;
+      this.ctxDNs = ctxDNs.clone();
       this.entrySearchFilter = entrySearchFilter;
       this.allowCreateEntry = allowCreateEntry;
-      this.createEntryAttributeValues = createEntryAttributeValues;
-      this.allowedMembershipTypes = allowedMembershipTypes;
+      this.createEntryAttributeValues = Collections.unmodifiableMap(createEntryAttributeValues);
+      this.allowedMembershipTypes = allowedMembershipTypes.clone();
       this.membershipAttributeName = membershipAttributeName;
       isMembershipAttributeDN = membershipAttributeDN;
       this.allowEmptyMemberships = allowEmptyMemberships;
-      this.attributeNames = attributeNames;
+      this.attributeNames = Collections.unmodifiableMap(attributeNames);
    }
 
 
@@ -234,7 +234,7 @@
 
    public String[] getCtxDNs()
    {
-      return ctxDNs;
+      return ctxDNs.clone();
    }
 
    public String getEntrySearchFilter()
@@ -254,7 +254,7 @@
 
    public String[] getAllowedMembershipTypes()
    {
-      return allowedMembershipTypes;
+      return allowedMembershipTypes.clone();
    }
 
    public String getMembershipAttributeName()




More information about the jboss-identity-commits mailing list