View Javadoc

1   package com.atlassian.user.impl.ldap.repository;
2   
3   import com.atlassian.user.impl.RepositoryException;
4   
5   import javax.naming.directory.DirContext;
6   import javax.naming.directory.InitialDirContext;
7   import java.util.Hashtable;
8   
9   /**
10   * This interface hold all information needed for the Atlassian user implementation to connect
11   * to different LDAP systems.
12   *
13   * Accessors in the class can be divided into two groups - accessors for serving out connection properties
14   * or accessors for serving mappings properties.
15   *
16   * Connection properties are used, obviously, for a connection.
17   *
18   * Any implementation of this interface should ensure that the behaviours return meaningful information,
19   * whether for mapping or for connection. The global constants are there for use in a configuration file,
20   * for example a properties file could be used holding connection properties, such as port=389.
21   */
22  public interface LdapContextFactory
23  {
24  
25      //global constants for connection properties.
26      public static final String HOST                         = "host";
27      public static final String PORT                         = "port";
28      public static final String SECURITY_PRINCIPAL           = "securityPrincipal";
29      public static final String SECURITY_CREDENTIAL          = "securityCredential";
30      public static final String SECURITY_AUTHENTICATION      = "securityAuthentication";
31      public static final String PROVIDER_URL                 = "providerURL";
32      public static final String JNDI_INITIAL_CONTEXT_FACTORY = "initialContextFactory";
33      public static final String BATCH_SIZE                   = "batchSize";
34      public static final String SECURITY_PROTOCOL            = "securityProtocol";
35      public static final String TIME_TO_LIVE                 = "timeToLive";
36  
37      //global constants for mapping the User and Group objects to different LDAP schemata
38      public static final String BASE_USER_NAMESPACE      = "baseUserNamespace";
39      public static final String BASE_GROUP_NAMESPACE     = "baseGroupNamespace";
40      public static final String USERNAME_ATTRIBUTE       = "usernameAttribute";
41      public static final String GROUPNAME_ATTRIBUTE      = "groupnameAttribute";
42      public static final String FIRSTNAME_ATTRIBUTE      = "firstnameAttribute";
43      public static final String PASSWORD_ATTRIBUTE       = "passwordAttribute";
44      public static final String SURNAME_ATTRIBUTE        = "surnameAttribute";
45      public static final String EMAIL_ATTRIBUTE          = "emailAttribute";
46      public static final String MEMBERSHIP_ATTRIBUTE     = "membershipAttribute";
47      public static final String USER_SEARCH_ALL_DEPTHS   = "userSearchAllDepths";
48      public static final String GROUP_SEARCH_ALL_DEPTHS  = "groupSearchAllDepths";
49      public static final String GROUP_SEARCH_FILTER      = "groupSearchFilter";
50      public static final String USER_SEARCH_FILTER       = "userSearchFilter";
51      public static final String USE_UNQUALIFIED_USER_NAME_FOR_MEMBERSHIP_COMPARISON = "useUnqualifiedUsernameForMembershipComparison";
52  
53      /**
54       * Returns a JNDI environment suitable for passing to {@link InitialDirContext#InitialDirContext(Hashtable)}.
55       * The environment is suitable for a connection using all the configuration specified in the other properties
56       * on this object.
57       */
58      Hashtable getJNDIEnv();
59  
60      /**
61       * Returns a JNDI environment suitable for passing to {@link InitialDirContext#InitialContext(Hashtable)}.
62       * The environment is suitable for a connection for authenticating the username and password provided.
63       */
64      Hashtable getAuthenticationJndiEnvironment(String userDN, String password);
65  
66      /**
67       * Opens a new connection to the LDAP server.
68       *
69       * @return an LDAP directory context suitable for interacting with the LDAP server
70       * @throws RepositoryException if there was a problem opening the connection
71       */
72      DirContext getLDAPContext() throws RepositoryException;
73  }