You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by no...@apache.org on 2010/10/26 12:04:01 UTC

svn commit: r1027441 - in /james/server/trunk: core-api/src/main/java/org/apache/james/lifecycle/ core-api/src/main/java/org/apache/james/services/ mail-api/src/main/java/org/apache/james/mailrepository/api/ user-ldap/src/main/java/org/apache/james/use...

Author: norman
Date: Tue Oct 26 10:04:00 2010
New Revision: 1027441

URL: http://svn.apache.org/viewvc?rev=1027441&view=rev
Log:
Only a bit cleanup

Modified:
    james/server/trunk/core-api/src/main/java/org/apache/james/lifecycle/Disposable.java
    james/server/trunk/core-api/src/main/java/org/apache/james/lifecycle/LifecycleUtil.java
    james/server/trunk/core-api/src/main/java/org/apache/james/services/FileSystem.java
    james/server/trunk/core-api/src/main/java/org/apache/james/services/InstanceFactory.java
    james/server/trunk/core-api/src/main/java/org/apache/james/services/MailServer.java
    james/server/trunk/core-api/src/main/java/org/apache/james/services/SpoolManager.java
    james/server/trunk/mail-api/src/main/java/org/apache/james/mailrepository/api/MailRepository.java
    james/server/trunk/user-ldap/src/main/java/org/apache/james/user/ldap/ReadOnlyLDAPGroupRestriction.java
    james/server/trunk/user-ldap/src/main/java/org/apache/james/user/ldap/ReadOnlyLDAPUser.java
    james/server/trunk/user-ldap/src/main/java/org/apache/james/user/ldap/SimpleLDAPConnection.java

Modified: james/server/trunk/core-api/src/main/java/org/apache/james/lifecycle/Disposable.java
URL: http://svn.apache.org/viewvc/james/server/trunk/core-api/src/main/java/org/apache/james/lifecycle/Disposable.java?rev=1027441&r1=1027440&r2=1027441&view=diff
==============================================================================
--- james/server/trunk/core-api/src/main/java/org/apache/james/lifecycle/Disposable.java (original)
+++ james/server/trunk/core-api/src/main/java/org/apache/james/lifecycle/Disposable.java Tue Oct 26 10:04:00 2010
@@ -19,7 +19,16 @@
 
 package org.apache.james.lifecycle;
 
+/**
+ * Classes which implement this interface need some special handling on destroy.
+ * So the {@link #dispose()} method need to get called
+ * 
+ *
+ */
 public interface Disposable {
 
+    /**
+     * Dispose the object
+     */
     public void dispose();
 }

Modified: james/server/trunk/core-api/src/main/java/org/apache/james/lifecycle/LifecycleUtil.java
URL: http://svn.apache.org/viewvc/james/server/trunk/core-api/src/main/java/org/apache/james/lifecycle/LifecycleUtil.java?rev=1027441&r1=1027440&r2=1027441&view=diff
==============================================================================
--- james/server/trunk/core-api/src/main/java/org/apache/james/lifecycle/LifecycleUtil.java (original)
+++ james/server/trunk/core-api/src/main/java/org/apache/james/lifecycle/LifecycleUtil.java Tue Oct 26 10:04:00 2010
@@ -21,6 +21,11 @@ package org.apache.james.lifecycle;
 
 public class LifecycleUtil {
 
+    /**
+     * Dispose the given object if its an instanceof {@link Disposable}
+     * 
+     * @param obj
+     */
     public static void dispose(Object obj) {
         if (obj instanceof Disposable && obj != null) {
             ((Disposable) obj).dispose();

Modified: james/server/trunk/core-api/src/main/java/org/apache/james/services/FileSystem.java
URL: http://svn.apache.org/viewvc/james/server/trunk/core-api/src/main/java/org/apache/james/services/FileSystem.java?rev=1027441&r1=1027440&r2=1027441&view=diff
==============================================================================
--- james/server/trunk/core-api/src/main/java/org/apache/james/services/FileSystem.java (original)
+++ james/server/trunk/core-api/src/main/java/org/apache/james/services/FileSystem.java Tue Oct 26 10:04:00 2010
@@ -32,8 +32,6 @@ import java.io.IOException;
  */
 public interface FileSystem {
 
-    String ROLE = "org.apache.james.services.FileSystem";
-
 
     /**
      * Prefix for loading of a filesystem based on the current directory

Modified: james/server/trunk/core-api/src/main/java/org/apache/james/services/InstanceFactory.java
URL: http://svn.apache.org/viewvc/james/server/trunk/core-api/src/main/java/org/apache/james/services/InstanceFactory.java?rev=1027441&r1=1027440&r2=1027441&view=diff
==============================================================================
--- james/server/trunk/core-api/src/main/java/org/apache/james/services/InstanceFactory.java (original)
+++ james/server/trunk/core-api/src/main/java/org/apache/james/services/InstanceFactory.java Tue Oct 26 10:04:00 2010
@@ -36,6 +36,17 @@ public interface InstanceFactory {
      */
     public <T> T newInstance(Class<T> clazz) throws InstanceException;
     
+
+    /**
+     * Create an instance of the given class and inject the log and config 
+     * 
+     * Instances should - where appropriate - have dependencies injected.
+     * @param <T> 
+     * @param log
+     * @param config
+     * @param type may be interface or concrete, not null
+     * @return an instance of the type
+     */
     public <T> T newInstance(Class<T> clazz, Log log, HierarchicalConfiguration config) throws InstanceException;
 
     

Modified: james/server/trunk/core-api/src/main/java/org/apache/james/services/MailServer.java
URL: http://svn.apache.org/viewvc/james/server/trunk/core-api/src/main/java/org/apache/james/services/MailServer.java?rev=1027441&r1=1027440&r2=1027441&view=diff
==============================================================================
--- james/server/trunk/core-api/src/main/java/org/apache/james/services/MailServer.java (original)
+++ james/server/trunk/core-api/src/main/java/org/apache/james/services/MailServer.java Tue Oct 26 10:04:00 2010
@@ -32,22 +32,7 @@ import org.apache.mailet.MailAddress;
  *
  * @version This is $Revision$
  */
-public interface MailServer
-{
-    /**
-     * The component role used by components implementing this service
-     */
-    String ROLE = "org.apache.james.services.MailServer";
-
-    /**
-     * Reserved user name for the mail delivery agent for multi-user mailboxes
-     */
-    String MDA = "JamesMDA";
-
-    /**
-     * Reserved user name meaning all users for multi-user mailboxes
-     */
-    String ALL = "AllMailUsers";
+public interface MailServer{
 
     /**
      *  Pass a Mail to this MailServer for processing

Modified: james/server/trunk/core-api/src/main/java/org/apache/james/services/SpoolManager.java
URL: http://svn.apache.org/viewvc/james/server/trunk/core-api/src/main/java/org/apache/james/services/SpoolManager.java?rev=1027441&r1=1027440&r2=1027441&view=diff
==============================================================================
--- james/server/trunk/core-api/src/main/java/org/apache/james/services/SpoolManager.java (original)
+++ james/server/trunk/core-api/src/main/java/org/apache/james/services/SpoolManager.java Tue Oct 26 10:04:00 2010
@@ -27,7 +27,6 @@ import org.apache.mailet.Matcher;
  * provide all the data needed to manage spool processors, mailets and matchers
  */
 public interface SpoolManager {
-    String ROLE = "org.apache.james.services.SpoolManager";
 
     /**
      * @return names of all configured processors

Modified: james/server/trunk/mail-api/src/main/java/org/apache/james/mailrepository/api/MailRepository.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mail-api/src/main/java/org/apache/james/mailrepository/api/MailRepository.java?rev=1027441&r1=1027440&r2=1027441&view=diff
==============================================================================
--- james/server/trunk/mail-api/src/main/java/org/apache/james/mailrepository/api/MailRepository.java (original)
+++ james/server/trunk/mail-api/src/main/java/org/apache/james/mailrepository/api/MailRepository.java Tue Oct 26 10:04:00 2010
@@ -35,18 +35,6 @@ import java.util.Iterator;
 public interface MailRepository {
 
     /**
-     * The component role used by components implementing this service
-     */
-    String ROLE = "org.apache.james.services.MailRepository";
-    
-    /**
-     * Define a MAIL repository. MAILS are stored in the specified
-     * destination.
-     */
-    String MAIL = "MAIL";
-
-
-    /**
      * Stores a message in this repository. Shouldn't this return the key
      * under which it is stored?
      *

Modified: james/server/trunk/user-ldap/src/main/java/org/apache/james/user/ldap/ReadOnlyLDAPGroupRestriction.java
URL: http://svn.apache.org/viewvc/james/server/trunk/user-ldap/src/main/java/org/apache/james/user/ldap/ReadOnlyLDAPGroupRestriction.java?rev=1027441&r1=1027440&r2=1027441&view=diff
==============================================================================
--- james/server/trunk/user-ldap/src/main/java/org/apache/james/user/ldap/ReadOnlyLDAPGroupRestriction.java (original)
+++ james/server/trunk/user-ldap/src/main/java/org/apache/james/user/ldap/ReadOnlyLDAPGroupRestriction.java Tue Oct 26 10:04:00 2010
@@ -44,17 +44,16 @@ import org.apache.commons.configuration.
  * 
  */
 
-public class ReadOnlyLDAPGroupRestriction
-{   
-	/**
-	 * <p>
-	 * The name of the LDAP attribute name which holds the unique names 
-	 * (distinguished-names/DNs) of the members of the group/role.
-	 * 
-	 * </p>  
-	 */
+public class ReadOnlyLDAPGroupRestriction{
+    /**
+     * <p>
+     * The name of the LDAP attribute name which holds the unique names
+     * (distinguished-names/DNs) of the members of the group/role.
+     * 
+     * </p>
+     */
     private String memberAttribute;
-    
+
     /**
      * <p>
      * The distinguished-names of the LDAP groups/roles to which James users must 
@@ -83,19 +82,18 @@ public class ReadOnlyLDAPGroupRestrictio
     public ReadOnlyLDAPGroupRestriction(HierarchicalConfiguration configuration) {
         groupDNs = new ArrayList<String>();
 
-		if (configuration != null) {
-			memberAttribute = configuration.getString("[@memberAttribute]");
+        if (configuration != null) {
+            memberAttribute = configuration.getString("[@memberAttribute]");
+
+            if (configuration.getKeys("group").hasNext()) {
+                List<String> groupNames = configuration.getList("group");
 
-			if (configuration.getKeys("group").hasNext()) {
-			List<String> groupNames = configuration
-					.getList("group");
-
-				for (int i = 0; i < groupNames.size(); i++) {
-					groupDNs.add(groupNames.get(i));
-				}
-			}
-		}
-	}
+                for (int i = 0; i < groupNames.size(); i++) {
+                    groupDNs.add(groupNames.get(i));
+                }
+            }
+        }
+    }
 
     /**
      * <p>
@@ -105,73 +103,74 @@ public class ReadOnlyLDAPGroupRestrictio
      * @return <code>True</code> If there list of group/role distinguished 
      * names is not empty, and <code>false</code> otherwise.
      */
-	protected boolean isActivated() {
-		return !groupDNs.isEmpty();
-	}
-
-	/**
-	 * <p>
-	 * Converts an instance of this type to a string.
-	 * </p>
-	 * @return A string representation of the instance. 
-	 */
-	public String toString() {
-		return "Activated=" + isActivated() + "; Groups=" + groupDNs;
-	}
-
-	/**
-	 * <p>
-	 * Returns the distinguished-names (DNs) of all the members of the 
-	 * groups specified in the restriction list. The information is 
-	 * organised as a list of <code>&quot;&lt;groupDN&gt;=&lt;
-	 * [userDN1,userDN2,...,userDNn]&gt;&quot;</code>. Put differently,
-	 * each <code>groupDN</code> is associated to a list of <code>userDNs</code>.   
-	 * </p>
-	 * 
-	 * @param connection	The connection to the LDAP directory server.
-	 * @return	Returns a map of groupDNs to userDN lists.
-	 * @throws NamingException	Propagated from underlying 
-	 * LDAP communication layer. 
-	 */
-	protected Map<String,Collection<String>> getGroupMembershipLists(SimpleLDAPConnection connection)
-			throws NamingException {
-		Map<String,Collection<String>> result = new HashMap<String,Collection<String>>();
-
-		Iterator<String> groupDNsIterator = groupDNs.iterator();
-
-		Attributes groupAttributes;
-		while (groupDNsIterator.hasNext()) {
-			String groupDN = (String) groupDNsIterator.next();
-			groupAttributes = connection.getLdapContext()
-					.getAttributes(groupDN);
-			result.put(groupDN, extractMembers(groupAttributes));
-		}
-
-		return result;
-	}
-
-	/**
-	 * <p>
-	 * Extracts the DNs for members of the group with the given 
-	 * LDAP context attributes. This is achieved by extracting all the values
-	 * of the LDAP attribute, with name equivalent to the field value
-	 * {@link #memberAttribute}, from the attributes collection.
-	 * </p>
-	 * 
-	 * @param groupAttributes	The attributes taken from the group's LDAP context.
-	 * @return	A collection of distinguished-names for the users belonging to 
-	 * the group with the specified attributes.
-	 * @throws NamingException	Propagated from underlying LDAP communication layer.
-	 */
-	private Collection<String> extractMembers(Attributes groupAttributes)
-			throws NamingException {
-		Collection<String> result = new ArrayList<String>();
-		Attribute members = groupAttributes.get(memberAttribute);
-		NamingEnumeration<?> memberDNs = members.getAll();
+    protected boolean isActivated() {
+        return !groupDNs.isEmpty();
+    }
+
+    /**
+     * <p>
+     * Converts an instance of this type to a string.
+     * </p>
+     * 
+     * @return A string representation of the instance.
+     */
+    public String toString() {
+        return "Activated=" + isActivated() + "; Groups=" + groupDNs;
+    }
+
+    /**
+     * <p>
+     * Returns the distinguished-names (DNs) of all the members of the groups
+     * specified in the restriction list. The information is organised as a list
+     * of <code>&quot;&lt;groupDN&gt;=&lt;
+     * [userDN1,userDN2,...,userDNn]&gt;&quot;</code>. Put differently, each
+     * <code>groupDN</code> is associated to a list of <code>userDNs</code>.
+     * </p>
+     * 
+     * @param connection
+     *            The connection to the LDAP directory server.
+     * @return Returns a map of groupDNs to userDN lists.
+     * @throws NamingException
+     *             Propagated from underlying LDAP communication layer.
+     */
+    protected Map<String, Collection<String>> getGroupMembershipLists(SimpleLDAPConnection connection) throws NamingException {
+        Map<String, Collection<String>> result = new HashMap<String, Collection<String>>();
+
+        Iterator<String> groupDNsIterator = groupDNs.iterator();
+
+        Attributes groupAttributes;
+        while (groupDNsIterator.hasNext()) {
+            String groupDN = (String) groupDNsIterator.next();
+            groupAttributes = connection.getLdapContext().getAttributes(groupDN);
+            result.put(groupDN, extractMembers(groupAttributes));
+        }
+
+        return result;
+    }
+
+    /**
+     * <p>
+     * Extracts the DNs for members of the group with the given LDAP context
+     * attributes. This is achieved by extracting all the values of the LDAP
+     * attribute, with name equivalent to the field value
+     * {@link #memberAttribute}, from the attributes collection.
+     * </p>
+     * 
+     * @param groupAttributes
+     *            The attributes taken from the group's LDAP context.
+     * @return A collection of distinguished-names for the users belonging to
+     *         the group with the specified attributes.
+     * @throws NamingException
+     *             Propagated from underlying LDAP communication layer.
+     */
+    private Collection<String> extractMembers(Attributes groupAttributes) throws NamingException {
+        Collection<String> result = new ArrayList<String>();
+        Attribute members = groupAttributes.get(memberAttribute);
+        NamingEnumeration<?> memberDNs = members.getAll();
 
-		while (memberDNs.hasMore())
-			result.add(memberDNs.next().toString());
+        while (memberDNs.hasMore())
+            result.add(memberDNs.next().toString());
 
-		return result;
-	}
+        return result;
+    }
 }

Modified: james/server/trunk/user-ldap/src/main/java/org/apache/james/user/ldap/ReadOnlyLDAPUser.java
URL: http://svn.apache.org/viewvc/james/server/trunk/user-ldap/src/main/java/org/apache/james/user/ldap/ReadOnlyLDAPUser.java?rev=1027441&r1=1027440&r2=1027441&view=diff
==============================================================================
--- james/server/trunk/user-ldap/src/main/java/org/apache/james/user/ldap/ReadOnlyLDAPUser.java (original)
+++ james/server/trunk/user-ldap/src/main/java/org/apache/james/user/ldap/ReadOnlyLDAPUser.java Tue Oct 26 10:04:00 2010
@@ -43,7 +43,7 @@ import org.apache.james.user.api.User;
  * 
  */
 public class ReadOnlyLDAPUser implements User, Serializable {
-	private static final long serialVersionUID = -6712066073820393235L;
+    private static final long serialVersionUID = -6712066073820393235L;
     
     /**
      * <p>
@@ -92,10 +92,10 @@ public class ReadOnlyLDAPUser implements
      * is invoked. 
      */
     public ReadOnlyLDAPUser(String userName, String userDN, String ldapURL) {
-		this.userName = userName;
-		this.userDN = userDN;
-		this.ldapURL = ldapURL;
-	}
+        this.userName = userName;
+        this.userDN = userDN;
+        this.ldapURL = ldapURL;
+    }
 
     /**
      * <p>
@@ -108,8 +108,8 @@ public class ReadOnlyLDAPUser implements
      * @return The user's identifier or name.
      */
     public String getUserName() {
-		return userName;
-	}
+        return userName;
+    }
 
     /**
      * <p>
@@ -122,9 +122,8 @@ public class ReadOnlyLDAPUser implements
      * @return <code>False</code>
      */
     public boolean setPassword(String newPass) {
-		return false;
-	}
-
+        return false;
+    }
 
     /**
      * <p>
@@ -140,14 +139,14 @@ public class ReadOnlyLDAPUser implements
      * the result will still be <code>false</code>.
      */
     public boolean verifyPassword(String password) {
-		boolean result;
-		try {
-			SimpleLDAPConnection.openLDAPConnection(userDN, password, ldapURL);
-			result = true;
-		} catch (NamingException exception) {
-			result = false;
-		}
-		return result;
-	}
+        boolean result;
+        try {
+            SimpleLDAPConnection.openLDAPConnection(userDN, password, ldapURL);
+            result = true;
+        } catch (NamingException exception) {
+            result = false;
+        }
+        return result;
+    }
 
 }

Modified: james/server/trunk/user-ldap/src/main/java/org/apache/james/user/ldap/SimpleLDAPConnection.java
URL: http://svn.apache.org/viewvc/james/server/trunk/user-ldap/src/main/java/org/apache/james/user/ldap/SimpleLDAPConnection.java?rev=1027441&r1=1027440&r2=1027441&view=diff
==============================================================================
--- james/server/trunk/user-ldap/src/main/java/org/apache/james/user/ldap/SimpleLDAPConnection.java (original)
+++ james/server/trunk/user-ldap/src/main/java/org/apache/james/user/ldap/SimpleLDAPConnection.java Tue Oct 26 10:04:00 2010
@@ -36,105 +36,112 @@ import javax.naming.directory.InitialDir
  */
 public class SimpleLDAPConnection {
 
-	/**
-	 * <p>
-	 * The distinguished-name/DN of the principal to authenticate
-	 * against the LDAP server.
-	 * </p>
-	 */
-	private String principal;
-	
-	/**
-	 * <p>
-	 * The credentials with which to authenticate against the LDAP server.
-	 * </p>
-	 */
-	private String credentials;
-	
-	/**
-	 * <p>The URL of the LDAP server.</p>
-	 */
-	private String ldapURL;
-	
-	/**
-	 * <p>
-	 * The root directory context that is visible to the 
-	 * authenticated user. 
-	 * </p>
-	 */
-	private DirContext ldapContext;
-	
-	/**
-	 * <p>
-	 * Creates an instance with the given login details.
-	 * </p>
-	 * @param principal		The distinguished-name (DN) of the user
-	 * to authenticate against the server.
-	 * @param credentials	The credentials with which to authenticate 
-	 * the user e.g. the user's password.
-	 * @param ldapURL		The URL of the LDAP server against which to 
-	 * authenticate the user. 
-	 */
-	private SimpleLDAPConnection(String principal, String credentials,
-			String ldapURL) {
-		super();
-		this.principal = principal;
-		this.credentials = credentials;
-		this.ldapURL = ldapURL;
-	}	
-	
-	/**
-	 * <p>
-	 * Opens a connection to the specified LDAP server using 
-	 * the specified user details.  
-	 * </p>
-	 * @param principal		The distinguished-name (DN) of the user
-	 * to authenticate against the server.
-	 * @param credentials	The credentials with which to authenticate 
-	 * the user e.g. the user's password.
-	 * @param ldapURL		The URL of the LDAP server against which to 
-	 * authenticate the user. 
-	 * @return	A connection to the LDAP host.
-	 * @throws NamingException	Propagated from the underlying LDAP connection.
-	 */
-	public static SimpleLDAPConnection openLDAPConnection(String principal,
-			String credentials, String ldapURL) throws NamingException {
-		SimpleLDAPConnection result = new SimpleLDAPConnection(principal,
-				credentials, ldapURL);
-		result.initializeContext();
-		return result;
-	}
-
-	/**
-	 * <p>
-	 * Returns the root directory context that is visible to the 
-	 * authenticated user.
-	 * </p>  
-	 * @return	The directory context that is visible to the 
-	 * authenticated user. 
-	 */
-	public DirContext getLdapContext() {
-		return ldapContext;
-	}
- 
-	/**
-	 * <p>
-	 * Internal helper method which creates an LDAP/JNDI context using the 
-	 * specified user credentials.  
-	 * </p>
-	 * @throws NamingException	Propagated from underlying 
-	 * LDAP communication API.
-	 */
-	private void initializeContext() throws NamingException {
-		Properties props = new Properties();
-		props.put(Context.INITIAL_CONTEXT_FACTORY,
-				"com.sun.jndi.ldap.LdapCtxFactory");
-		props.put(Context.PROVIDER_URL, ldapURL);
-
-		props.put(Context.SECURITY_AUTHENTICATION, "simple");
-		props.put(Context.SECURITY_PRINCIPAL, principal);
-		props.put(Context.SECURITY_CREDENTIALS, credentials);
+    /**
+     * <p>
+     * The distinguished-name/DN of the principal to authenticate against the
+     * LDAP server.
+     * </p>
+     */
+    private String principal;
 
-		ldapContext = new InitialDirContext(props);
-	}
+    /**
+     * <p>
+     * The credentials with which to authenticate against the LDAP server.
+     * </p>
+     */
+    private String credentials;
+
+    /**
+     * <p>
+     * The URL of the LDAP server.
+     * </p>
+     */
+    private String ldapURL;
+
+    /**
+     * <p>
+     * The root directory context that is visible to the authenticated user.
+     * </p>
+     */
+    private DirContext ldapContext;
+
+    /**
+     * <p>
+     * Creates an instance with the given login details.
+     * </p>
+     * 
+     * @param principal
+     *            The distinguished-name (DN) of the user to authenticate
+     *            against the server.
+     * @param credentials
+     *            The credentials with which to authenticate the user e.g. the
+     *            user's password.
+     * @param ldapURL
+     *            The URL of the LDAP server against which to authenticate the
+     *            user.
+     */
+    private SimpleLDAPConnection(String principal, String credentials, String ldapURL) {
+        super();
+        this.principal = principal;
+        this.credentials = credentials;
+        this.ldapURL = ldapURL;
+    }
+
+    /**
+     * <p>
+     * Opens a connection to the specified LDAP server using the specified user
+     * details.
+     * </p>
+     * 
+     * @param principal
+     *            The distinguished-name (DN) of the user to authenticate
+     *            against the server.
+     * @param credentials
+     *            The credentials with which to authenticate the user e.g. the
+     *            user's password.
+     * @param ldapURL
+     *            The URL of the LDAP server against which to authenticate the
+     *            user.
+     * @return A connection to the LDAP host.
+     * @throws NamingException
+     *             Propagated from the underlying LDAP connection.
+     */
+    public static SimpleLDAPConnection openLDAPConnection(String principal, String credentials, String ldapURL) throws NamingException {
+        SimpleLDAPConnection result = new SimpleLDAPConnection(principal, credentials, ldapURL);
+        result.initializeContext();
+        return result;
+    }
+
+    /**
+     * <p>
+     * Returns the root directory context that is visible to the authenticated
+     * user.
+     * </p>
+     * 
+     * @return The directory context that is visible to the authenticated user.
+     */
+    public DirContext getLdapContext() {
+        return ldapContext;
+    }
+
+    /**
+     * <p>
+     * Internal helper method which creates an LDAP/JNDI context using the
+     * specified user credentials.
+     * </p>
+     * 
+     * @throws NamingException
+     *             Propagated from underlying LDAP communication API.
+     */
+    private void initializeContext() throws NamingException {
+        Properties props = new Properties();
+        props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
+        props.put(Context.PROVIDER_URL, ldapURL);
+
+        props.put(Context.SECURITY_AUTHENTICATION, "simple");
+        props.put(Context.SECURITY_PRINCIPAL, principal);
+        props.put(Context.SECURITY_CREDENTIALS, credentials);
+
+        ldapContext = new InitialDirContext(props);
+    }
 }



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