private void clear() { username = null; userAuthenticated = false; closeContext(); }
@Override public boolean commit() throws LoginException { boolean result = userAuthenticated; Set<UserPrincipal> authenticatedUsers = subject.getPrincipals(UserPrincipal.class); Set<Principal> principals = subject.getPrincipals(); if (result) { principals.add(new UserPrincipal(username)); } // assign roles to any other UserPrincipal for (UserPrincipal authenticatedUser : authenticatedUsers) { List<String> roles = new ArrayList<>(); try { String dn = resolveDN(authenticatedUser.getName(), roles); resolveRolesForDN(context, dn, authenticatedUser.getName(), roles); } catch (NamingException e) { closeContext(); FailedLoginException ex = new FailedLoginException("Error contacting LDAP"); ex.initCause(e); throw ex; } } for (RolePrincipal gp : groups) { principals.add(gp); } clear(); return result; }
protected boolean authenticate(String username, String password) throws LoginException { List<String> roles = new ArrayList<>(); try { String dn = resolveDN(username, roles); // check the credentials by binding to server if (bindUser(context, dn, password)) { // if authenticated add more roles resolveRolesForDN(context, dn, username, roles); } else { throw new FailedLoginException("Password does not match for user: " + username); } } catch (CommunicationException e) { closeContext(); FailedLoginException ex = new FailedLoginException("Error contacting LDAP"); ex.initCause(e); throw ex; } catch (NamingException e) { closeContext(); FailedLoginException ex = new FailedLoginException("Error contacting LDAP"); ex.initCause(e); throw ex; } return true; }
closeContext(); ActiveMQServerLogger.LOGGER.failedToOpenContext(e); throw e;
closeContext(); FailedLoginException ex = new FailedLoginException("Error parsing absolute name as URI."); ex.initCause(e); closeContext(); FailedLoginException ex = new FailedLoginException("Error contacting LDAP"); ex.initCause(e); throw ex; } catch (NamingException e) { closeContext(); FailedLoginException ex = new FailedLoginException("Error contacting LDAP"); ex.initCause(e);