| | |
| | | String pwd, int timeout, Hashtable<String, String> env) |
| | | throws NamingException |
| | | { |
| | | if (env != null) |
| | | { // We clone 'env' so that we can modify it freely |
| | | env = new Hashtable<String, String>(env); |
| | | } else |
| | | { |
| | | env = new Hashtable<String, String>(); |
| | | } |
| | | env = copy(env); |
| | | env.put(Context.INITIAL_CONTEXT_FACTORY, |
| | | "com.sun.jndi.ldap.LdapCtxFactory"); |
| | | env.put("java.naming.ldap.attributes.binary", |
| | |
| | | public static InitialLdapContext createLdapsContext(String ldapsURL, |
| | | String dn, String pwd, int timeout, Hashtable<String, String> env, |
| | | TrustManager trustManager, KeyManager keyManager) throws NamingException { |
| | | if (env != null) |
| | | { // We clone 'env' so that we can modify it freely |
| | | env = new Hashtable<String, String>(env); |
| | | } else |
| | | { |
| | | env = new Hashtable<String, String>(); |
| | | } |
| | | env = copy(env); |
| | | env.put(Context.INITIAL_CONTEXT_FACTORY, |
| | | "com.sun.jndi.ldap.LdapCtxFactory"); |
| | | env.put("java.naming.ldap.attributes.binary", |
| | |
| | | verifier = new BlindHostnameVerifier(); |
| | | } |
| | | |
| | | if (env != null) |
| | | { // We clone 'env' to modify it freely |
| | | env = new Hashtable<String, String>(env); |
| | | } |
| | | else |
| | | { |
| | | env = new Hashtable<String, String>(); |
| | | } |
| | | env = copy(env); |
| | | env.put(Context.INITIAL_CONTEXT_FACTORY, |
| | | "com.sun.jndi.ldap.LdapCtxFactory"); |
| | | env.put("java.naming.ldap.attributes.binary", |
| | |
| | | return getInitialLdapContext(t, pair, timeout); |
| | | } |
| | | |
| | | private static Hashtable<String, String> copy(Hashtable<String, String> env) { |
| | | return env != null ? new Hashtable<>(env) : new Hashtable<String, String>(); |
| | | } |
| | | |
| | | /** |
| | | * Returns the LDAP URL used in the provided InitialLdapContext. |
| | | * @param ctx the context to analyze. |
| | |
| | | public static Set<String> getValues(SearchResult entry, String attrName) |
| | | throws NamingException |
| | | { |
| | | Set<String> values = new HashSet<String>(); |
| | | Set<String> values = new HashSet<>(); |
| | | Attributes attrs = entry.getAttributes(); |
| | | if (attrs != null) |
| | | { |