portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r702186 - in /portals/jetspeed-2/portal/branches/security-refactoring: components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/ components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping...
Date Mon, 06 Oct 2008 16:13:32 GMT
Author: ddam
Date: Mon Oct  6 09:13:28 2008
New Revision: 702186

URL: http://svn.apache.org/viewvc?rev=702186&view=rev
Log:
- set objectClasses hierarchy as CSV value
- add sanity check on LDAP configuration

Modified:
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/LDAPEntityDAOConfiguration.java
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/impl/SpringLDAPEntityDAO.java
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-portal-resources/src/main/resources/assembly/security-ldap.xml

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/LDAPEntityDAOConfiguration.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/LDAPEntityDAOConfiguration.java?rev=702186&r1=702185&r2=702186&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/LDAPEntityDAOConfiguration.java
(original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/LDAPEntityDAOConfiguration.java
Mon Oct  6 09:13:28 2008
@@ -18,9 +18,9 @@
 
 import java.util.Set;
 
-import org.springframework.ldap.filter.Filter;
-
+import org.apache.jetspeed.exception.JetspeedException;
 import org.apache.jetspeed.security.mapping.model.AttributeDef;
+import org.springframework.ldap.filter.Filter;
 
 /**
  * @author <a href="mailto:ddam@apache.org">Dennis Dam</a>
@@ -41,7 +41,22 @@
 
     private String entityType;
     
-    private String objectClass;
+    private String[] objectClassesArr;
+
+    public void initialize() throws JetspeedException {
+        checkNotEmpty("entityType", entityType);
+        checkNotNull("baseDN", baseDN);
+        checkNotEmpty("ldapIdAttribute", ldapIdAttribute);
+        checkNotNull("attributeDefinitions", attributeDefinitions);
+    }
+    
+    private void checkNotNull(String fieldName, Object fieldValue ) throws JetspeedException
{
+        if (fieldValue == null) throw new JetspeedException(getClass().getName()+": property
'"+fieldName+"' cannot be null.");
+    }
+
+    private void checkNotEmpty(String fieldName, String fieldValue ) throws JetspeedException
{
+        if (fieldValue == null) throw new JetspeedException(getClass().getName()+": property
'"+fieldName+"' cannot be null or empty.");
+    }
 
     public String getBaseDN()
     {
@@ -103,14 +118,16 @@
         this.entityType = entityType;
     }
 
-    public String getObjectClass()
+    public String[] getObjectClassesArray()
     {
-        return objectClass;
+        return objectClassesArr;
     }
     
-    public void setObjectClass(String objectClass)
+    public void setObjectClasses(String objectClasses)
     {
-        this.objectClass = objectClass;
+        if (objectClasses != null){
+            this.objectClassesArr=objectClasses.split(",");
+        }
     }
     
 }

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/impl/SpringLDAPEntityDAO.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/impl/SpringLDAPEntityDAO.java?rev=702186&r1=702185&r2=702186&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/impl/SpringLDAPEntityDAO.java
(original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/impl/SpringLDAPEntityDAO.java
Mon Oct  6 09:13:28 2008
@@ -321,7 +321,11 @@
                     context.setAttribute(basicAttr);
                 }
             }
-            BasicAttribute attr = new BasicAttribute("objectClass", configuration.getObjectClass());
+            BasicAttribute attr = new BasicAttribute("objectClass");
+            for (String objClass : configuration.getObjectClassesArray())
+            {
+                attr.add(objClass);
+            }
             context.setAttribute(attr);
             ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
             try

Modified: portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-portal-resources/src/main/resources/assembly/security-ldap.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-portal-resources/src/main/resources/assembly/security-ldap.xml?rev=702186&r1=702185&r2=702186&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-portal-resources/src/main/resources/assembly/security-ldap.xml
(original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-portal-resources/src/main/resources/assembly/security-ldap.xml
Mon Oct  6 09:13:28 2008
@@ -100,7 +100,7 @@
     </property>
   </bean>
   
-  <bean id="UserDaoConfiguration" class="org.apache.jetspeed.security.mapping.ldap.dao.LDAPEntityDAOConfiguration">
+  <bean id="UserDaoConfiguration" class="org.apache.jetspeed.security.mapping.ldap.dao.LDAPEntityDAOConfiguration"
init-method="initialize">
     <meta key="j2:cat" value="ldap" />
     <property name="baseDN" value="${ldap.base}" />
     <property name="searchDN" value="" />
@@ -110,7 +110,7 @@
       </bean>
     </property>
     <property name="ldapIdAttribute" value="uid" />
-    <property name="objectClass" value="inetOrgPerson"/>
+    <property name="objectClasses" value="inetOrgPerson,organizationalPerson,person,top"/>
     <property name="attributeDefinitions">
       <set>
         <bean class="org.apache.jetspeed.security.mapping.model.impl.AttributeDefImpl">
@@ -144,7 +144,7 @@
     </property>
     <property name="entityType" value="user" />
   </bean>
-  <bean id="RoleDaoConfiguration" class="org.apache.jetspeed.security.mapping.ldap.dao.LDAPEntityDAOConfiguration">
+  <bean id="RoleDaoConfiguration" class="org.apache.jetspeed.security.mapping.ldap.dao.LDAPEntityDAOConfiguration"
init-method="initialize">
     <meta key="j2:cat" value="ldap" />
     <property name="baseDN" value="${ldap.base}" />
     <property name="searchDN" value="${ldap.role.searchBase}" />
@@ -154,7 +154,7 @@
       </bean>
     </property>
     <property name="ldapIdAttribute" value="cn" />
-    <property name="objectClass" value="groupOfUniqueNames"/>
+    <property name="objectClasses" value="groupOfUniqueNames"/>
     <property name="attributeDefinitions">
       <set>
         <bean class="org.apache.jetspeed.security.mapping.model.impl.AttributeDefImpl">
@@ -189,7 +189,7 @@
     <property name="entityType" value="role" />
   </bean>
   
-  <bean id="GroupDaoConfiguration" class="org.apache.jetspeed.security.mapping.ldap.dao.LDAPEntityDAOConfiguration">
+  <bean id="GroupDaoConfiguration" class="org.apache.jetspeed.security.mapping.ldap.dao.LDAPEntityDAOConfiguration"
init-method="initialize">
     <meta key="j2:cat" value="ldap" />
     <property name="baseDN" value="${ldap.base}" />
     <property name="searchDN" value="${ldap.group.searchBase}" />
@@ -199,7 +199,7 @@
       </bean>
     </property>
     <property name="ldapIdAttribute" value="cn" />
-    <property name="objectClass" value="groupOfUniqueNames"/>
+    <property name="objectClasses" value="groupOfUniqueNames"/>
     <property name="attributeDefinitions">
       <set>
         <bean class="org.apache.jetspeed.security.mapping.model.impl.AttributeDefImpl">



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message