1 package com.atlassian.user.util;
2
3
4
5
6
7 import org.apache.log4j.Logger;
8
9 import java.util.Properties;
10
11 public class LDAPConnectionPoolUtils
12 {
13 private static final Logger log = Logger.getLogger(LDAPConnectionPoolUtils.class);
14
15 private static boolean initialized;
16 public final static String POOL_MAX = "com.sun.jndi.ldap.connect.pool.maxsize";
17 public final static String POOL_INITSIZE = "com.sun.jndi.ldap.connect.pool.initsize";
18 public final static String POOL_PREFSIZE = "com.sun.jndi.ldap.connect.pool.prefsize";
19 public final static String POOL_DEBUG = "com.sun.jndi.ldap.connect.pool.debug";
20 public final static String POOL_PROTOCOL = "com.sun.jndi.ldap.connect.pool.protocol";
21 public final static String POOL_AUTH = "com.sun.jndi.ldap.connect.pool.authentication";
22 public final static String POOL_TIMEOUT = "com.sun.jndi.ldap.connect.pool.timeout";
23
24 private static Properties connectionPoolProperties = null;
25
26 public static Properties getConnectionPoolProperties()
27 {
28 if (connectionPoolProperties == null)
29 connectionPoolProperties = new Properties();
30 else
31 return connectionPoolProperties;
32
33 if (connectionPoolProperties.getProperty(POOL_MAX) == null)
34 connectionPoolProperties.setProperty(POOL_MAX, "10");
35
36 if (connectionPoolProperties.getProperty(POOL_INITSIZE) == null)
37 connectionPoolProperties.setProperty(POOL_INITSIZE, "10");
38
39 if (connectionPoolProperties.getProperty(POOL_PREFSIZE) == null)
40 connectionPoolProperties.setProperty(POOL_PREFSIZE, "10");
41
42 if (connectionPoolProperties.getProperty(POOL_DEBUG) == null)
43 connectionPoolProperties.setProperty(POOL_DEBUG, "fine");
44
45 if (connectionPoolProperties.getProperty(POOL_PROTOCOL) == null)
46 connectionPoolProperties.setProperty(POOL_PROTOCOL, "plain ssl");
47
48 if (connectionPoolProperties.getProperty(POOL_AUTH) == null)
49 connectionPoolProperties.setProperty(POOL_AUTH, "none simple DIGEST-MD5");
50
51 if (connectionPoolProperties.getProperty(POOL_TIMEOUT) == null)
52 connectionPoolProperties.setProperty(POOL_TIMEOUT, "3000000");
53
54 return connectionPoolProperties;
55 }
56 }