@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public boolean authenticate(HttpSession session, String user, String password) { if (session==null || user==null) return false; checkCanLoad(); Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, ldapUrl); env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.SECURITY_PRINCIPAL, getUserDN(user)); env.put(Context.SECURITY_CREDENTIALS, password); boolean authenticated = false; try { new InitialDirContext(env); authenticated = true; } catch (NamingException e) { LOG.warn("Failed to authenticate user: " + user); } if (session != null) session.setAttribute(AUTHENTICATED_SESSION_TOKEN_NAME, authenticated); return authenticated; }
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public boolean authenticate(HttpSession session, String user, String password) { if (session==null || user==null) return false; checkCanLoad(); Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, ldapUrl); env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.SECURITY_PRINCIPAL, getUserDN(user)); env.put(Context.SECURITY_CREDENTIALS, password); boolean authenticated = false; try { new InitialDirContext(env); authenticated = true; } catch (NamingException e) { LOG.warn("Failed to authenticate user: " + user); } if (session != null) session.setAttribute(AUTHENTICATED_SESSION_TOKEN_NAME, authenticated); return authenticated; }