DirContext createContext(Hashtable<?, ?> env) throws NamingException { return new InitialLdapContext(env, null); } }
/** * Creates and returns a new {@link javax.naming.ldap.InitialLdapContext} instance. This method exists primarily * to support testing where a mock LdapContext can be returned instead of actually creating a connection, but * subclasses are free to provide a different implementation if necessary. * * @param env the JNDI environment settings used to create the LDAP connection * @return an LdapConnection * @throws NamingException if a problem occurs creating the connection */ protected LdapContext createLdapContext(Hashtable env) throws NamingException { return new InitialLdapContext(env, null); }
/** * Creates and returns a new {@link javax.naming.ldap.InitialLdapContext} instance. This method exists primarily * to support testing where a mock LdapContext can be returned instead of actually creating a connection, but * subclasses are free to provide a different implementation if necessary. * * @param env the JNDI environment settings used to create the LDAP connection * @return an LdapConnection * @throws NamingException if a problem occurs creating the connection */ protected LdapContext createLdapContext(Hashtable env) throws NamingException { return new InitialLdapContext(env, null); }
protected InitialLdapContext createLdapContext( Hashtable<String, String> env ) throws NamingException { return new InitialLdapContext( env, null ); }
public LdapContext newInitialLdapContext(Hashtable<?,?> environment, Control[] connCtls) throws NamingException { ClassLoader previous = setSocketFactory(); try { return new InitialLdapContext(environment, null); } finally { unsetSocketFactory(previous); } }
private LdapContext buildLdapContext() throws NamingException { config.putIfAbsent(Context.INITIAL_CONTEXT_FACTORY, DEFAULT_INITIAL_CONTEXT_FACTORY); config.putIfAbsent(Context.SECURITY_AUTHENTICATION, DEFAULT_SECURITY_AUTHENTICATION); String protocol = config.getProperty(Context.SECURITY_PROTOCOL); config.putIfAbsent(Context.PROVIDER_URL, createDefaultProviderUrl(protocol)); if (log.isDebugEnabled()) { log.debug("Using following InitialLdapContext properties:"); log.debug("Initial Context Factory: {}", config.getProperty(Context.INITIAL_CONTEXT_FACTORY)); log.debug("Authentication Type: {}", config.getProperty(Context.SECURITY_AUTHENTICATION)); log.debug("Protocol: {}", config.getProperty(Context.SECURITY_PROTOCOL)); log.debug("Provider URL: {}", config.getProperty(Context.PROVIDER_URL)); log.debug("User DN: {}", config.getProperty(Context.SECURITY_PRINCIPAL)); log.debug("Password: {}", config.getProperty(Context.SECURITY_CREDENTIALS)); } return new InitialLdapContext(config, null); }
initialContext = new InitialLdapContext(env, null); } catch (NamingException ne) { log.debugf(ne, "Could not create [%s]. Failed to connect to LDAP server.", InitialLdapContext.class);
userContext = ((DelegatingLdapContext) dirContext).newInitialLdapContext(props, null); } else { userContext = new InitialLdapContext(props, null);
/** * Creates and returns a new {@link javax.naming.ldap.InitialLdapContext} instance. This method exists primarily * to support testing where a mock LdapContext can be returned instead of actually creating a connection, but * subclasses are free to provide a different implementation if necessary. * * @param env the JNDI environment settings used to create the LDAP connection * @return an LdapConnection * @throws NamingException if a problem occurs creating the connection */ protected LdapContext createLdapContext(Hashtable env) throws NamingException { return new InitialLdapContext(env, null); }
/** * Creates and returns a new {@link javax.naming.ldap.InitialLdapContext} instance. This method exists primarily * to support testing where a mock LdapContext can be returned instead of actually creating a connection, but * subclasses are free to provide a different implementation if necessary. * * @param env the JNDI environment settings used to create the LDAP connection * @return an LdapConnection * @throws NamingException if a problem occurs creating the connection */ protected LdapContext createLdapContext(Hashtable env) throws NamingException { return new InitialLdapContext(env, null); }
private LdapContext createInitialDirContext(final String principal, final String password, final String providerUrl, final boolean isSystemContext, Long domainId) throws NamingException, IOException { Hashtable<String, String> environment = getEnvironment(principal, password, providerUrl, isSystemContext, domainId); s_logger.debug("initializing ldap with provider url: " + environment.get(Context.PROVIDER_URL)); return new InitialLdapContext(environment, null); }
protected InitialLdapContext openContext(String userDn, String password) { Hashtable<String, String> env = new Hashtable<>(); env.put(Context.INITIAL_CONTEXT_FACTORY, ldapConfiguration.getInitialContextFactory()); env.put(Context.SECURITY_AUTHENTICATION, ldapConfiguration.getSecurityAuthentication()); env.put(Context.PROVIDER_URL, ldapConfiguration.getServerUrl()); env.put(Context.SECURITY_PRINCIPAL, userDn); env.put(Context.SECURITY_CREDENTIALS, password); // for anonymous login if(ldapConfiguration.isAllowAnonymousLogin() && password.isEmpty()) { env.put(Context.SECURITY_AUTHENTICATION, "none"); } if(ldapConfiguration.isUseSsl()) { env.put(Context.SECURITY_PROTOCOL, "ssl"); } // add additional properties Map<String, String> contextProperties = ldapConfiguration.getContextProperties(); if(contextProperties != null) { env.putAll(contextProperties); } try { return new InitialLdapContext(env, null); } catch(AuthenticationException e) { throw new LdapAuthenticationException("Could not authenticate with LDAP server", e); } catch(NamingException e) { throw new IdentityProviderException("Could not connect to LDAP server", e); } }
/** * Creates and returns a new {@link javax.naming.ldap.InitialLdapContext} instance. This method exists primarily * to support testing where a mock LdapContext can be returned instead of actually creating a connection, but * subclasses are free to provide a different implementation if necessary. * * @param env the JNDI environment settings used to create the LDAP connection * @return an LdapConnection * @throws NamingException if a problem occurs creating the connection */ protected LdapContext createLdapContext(Hashtable env) throws NamingException { return new InitialLdapContext(env, null); }
protected DirContext getDirContextInstance(Hashtable<String, Object> environment) throws NamingException { return new InitialLdapContext(environment, null); } }
private InitialDirContext createInitialContext() throws NamingException { Hashtable<String, String> env = new Hashtable<>(5); env.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(javax.naming.Context.PROVIDER_URL, ldapuri.toString()); env.put(javax.naming.Context.SECURITY_AUTHENTICATION, SECURITY_AUTHENTICATION); env.put(javax.naming.Context.SECURITY_PRINCIPAL, bindDN); env.put(javax.naming.Context.SECURITY_CREDENTIALS, bindPassword); return new InitialLdapContext(env, null); } //CHECKSTYLE:ON
LdapContext ctx = new InitialLdapContext(); try { /* Use the context... */ } finally { ctx.close(); }
private InitialLdapContext constructInitialLdapContext(String dn, Object credential) throws NamingException { String protocol = (String)options.get(Context.SECURITY_PROTOCOL); String providerURL = (String) options.get(Context.PROVIDER_URL); if (providerURL == null) providerURL = "ldap://localhost:" + ((protocol != null && protocol.equals("ssl")) ? "636" : "389"); Properties env = constructLdapContextEnvironment(providerURL, dn, credential); return new InitialLdapContext(env, null); }
public LdapContext newInitialLdapContext(Hashtable<?,?> environment, Control[] connCtls) throws NamingException { if (socketFactory != null) ThreadLocalSSLSocketFactory.set(socketFactory); try { return new InitialLdapContext(environment, null); } finally { if (socketFactory != null) ThreadLocalSSLSocketFactory.unset(); } }
public synchronized InitialLdapContext getConnection() throws BackendException { Hashtable env = new Hashtable(); setupEnvironment(env, getUsername(), getPassword()); try { InitialLdapContext iCtx = new InitialLdapContext(env, null); return iCtx; } catch (NamingException e) { throw new BackendException(e); } } }
InitialLdapContext ldapContext = new InitialLdapContext(); ldapContext.addToEnvironment(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); ldapContext.addToEnvironment(Context.SECURITY_AUTHENTICATION, "simple"); ldapContext.addToEnvironment(Context.SECURITY_PRINCIPAL, userId + "@mydomain.com"); ldapContext.addToEnvironment(Context.SECURITY_CREDENTIALS, password); ldapContext.addToEnvironment(Context.PROVIDER_URL, "ldap://" + ldapHost + ":" + ldapPort);