portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r502834 - in /portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/spi/impl/ldap: AbstractLdapDao.java LdapBindingConfig.java
Date Sat, 03 Feb 2007 01:41:46 GMT
Author: ate
Date: Fri Feb  2 17:41:46 2007
New Revision: 502834

URL: http://svn.apache.org/viewvc?view=rev&rev=502834
Log:
Provide a more flexible way of binding to a LDAP server, especially for when a secured connection
is required.
Also adding a default constructor for LdapBindingConfig so it can be configured through simply
setting properties
instead of having to create one big ugly constructor call.

Patch provided by Berry van Halderen from Hippo.

Modified:
    portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/spi/impl/ldap/AbstractLdapDao.java
    portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/spi/impl/ldap/LdapBindingConfig.java

Modified: portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/spi/impl/ldap/AbstractLdapDao.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/spi/impl/ldap/AbstractLdapDao.java?view=diff&rev=502834&r1=502833&r2=502834
==============================================================================
--- portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/spi/impl/ldap/AbstractLdapDao.java
(original)
+++ portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/spi/impl/ldap/AbstractLdapDao.java
Fri Feb  2 17:41:46 2007
@@ -96,11 +96,19 @@
         {
             Properties env = new Properties();
             env.put(Context.INITIAL_CONTEXT_FACTORY, this.ldapBindingConfig.getInitialContextFactory());
-            env.put(Context.PROVIDER_URL, "ldap://" + this.ldapBindingConfig.getLdapServerName()
+ ":"
+            env.put(Context.PROVIDER_URL, this.ldapBindingConfig.getLdapScheme() + "://"
+ this.ldapBindingConfig.getLdapServerName() + ":"
                     + this.ldapBindingConfig.getLdapServerPort() + "/" + this.ldapBindingConfig.getRootContext());
             env.put(Context.SECURITY_PRINCIPAL, rootDn);
             env.put(Context.SECURITY_CREDENTIALS, rootPassword);
-            env.put(Context.SECURITY_AUTHENTICATION, "simple");
+            env.put(Context.SECURITY_AUTHENTICATION, this.ldapBindingConfig.getLdapSecurityLevel());
+            if ( !StringUtils.isEmpty(this.ldapBindingConfig.getLdapSecurityProtocol()) )
+            {
+                env.put(Context.SECURITY_PROTOCOL, this.ldapBindingConfig.getLdapSecurityProtocol());
+            }
+            if ( !StringUtils.isEmpty(this.ldapBindingConfig.getLdapSocketFactory()) )
+            {
+                env.put("java.naming.ldap.factory.socket", this.ldapBindingConfig.getLdapSocketFactory());
+            }
             ctx = new InitialLdapContext(env, null);
         }
         catch (NamingException ne)

Modified: portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/spi/impl/ldap/LdapBindingConfig.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/spi/impl/ldap/LdapBindingConfig.java?view=diff&rev=502834&r1=502833&r2=502834
==============================================================================
--- portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/spi/impl/ldap/LdapBindingConfig.java
(original)
+++ portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/spi/impl/ldap/LdapBindingConfig.java
Fri Feb  2 17:41:46 2007
@@ -33,8 +33,12 @@
     private static final Log logger = LogFactory.getLog(LdapBindingConfig.class);
 
     private String initialContextFactory;
+    private String ldapSocketFactory;
+    private String ldapScheme = "ldap";
     private String ldapServerName;
     private String ldapServerPort;
+    private String ldapSecurityLevel = "simple";
+    private String ldapSecurityProtocol;
     private String rootDn;
     private String rootPassword;
     private String rootContext;
@@ -88,17 +92,11 @@
 
 	private String[] knownAttributes;
 
-    /**
-     * @param factory The initial context factory.
-     * @param name The ldap server name.
-     * @param port The ldap server port.
-     * @param suffix The default dn suffix.
-     * @param context The root context.
-     * @param dn The root dn.
-     * @param password The root password.
-     * @param uou The users organization unit.
-     * @param gou The groups organization unit.
-     */
+    public LdapBindingConfig()
+    {
+        // allow for properties setting configuration instead of through one big ugly constructor
call or external properties file
+    }
+    
     public LdapBindingConfig(String factory, 
     		String name, 
     		String port, 
@@ -275,6 +273,38 @@
     {
         this.initialContextFactory = initialContextFactory;
     }
+    
+    /**
+     * @return the ldapScheme
+     */
+    public String getLdapScheme()
+    {
+        return ldapScheme;
+    }
+
+    /**
+     * @param ldapScheme the ldapScheme to set
+     */
+    public void setLdapScheme(String ldapScheme)
+    {
+        this.ldapScheme = ldapScheme;
+    }
+
+    /**
+     * @return the ldapSocketFactory
+     */
+    public String getLdapSocketFactory()
+    {
+        return ldapSocketFactory;
+    }
+
+    /**
+     * @param ldapSocketFactory the ldapSocketFactory to set
+     */
+    public void setLdapSocketFactory(String ldapSocketFactory)
+    {
+        this.ldapSocketFactory = ldapSocketFactory;
+    }
 
     /**
      * @return Returns the ldapServerName.
@@ -306,6 +336,38 @@
     public void setLdapServerPort(String ldapServerPort)
     {
         this.ldapServerPort = ldapServerPort;
+    }
+
+    /**
+     * @return the ldapSecurityLevel
+     */
+    public String getLdapSecurityLevel()
+    {
+        return ldapSecurityLevel;
+    }
+
+    /**
+     * @param ldapSecurityLevel the ldapSecurityLevel to set
+     */
+    public void setLdapSecurityLevel(String ldapSecurityLevel)
+    {
+        this.ldapSecurityLevel = ldapSecurityLevel;
+    }
+
+    /**
+     * @return the ldapSecurityProtocol
+     */
+    public String getLdapSecurityProtocol()
+    {
+        return ldapSecurityProtocol;
+    }
+
+    /**
+     * @param ldapSecurityProtocol the ldapSecurityProtocol to set
+     */
+    public void setLdapSecurityProtocol(String ldapSecurityProtocol)
+    {
+        this.ldapSecurityProtocol = ldapSecurityProtocol;
     }
 
     /**



---------------------------------------------------------------------
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