@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; }
public static Object directAuthentication(final String securityRealm, final String username, final String password, final ServerMetaData server) throws FailedLoginException { // authenticate final AuthenticationRequest authReq = new AuthenticationRequest(securityRealm, username, password); final AuthenticationResponse authRes; try { authRes = (AuthenticationResponse) Client.request(authReq, new AuthenticationResponse(), server); } catch (final RemoteException e) { throw (FailedLoginException) new FailedLoginException("Unable to authenticate with server " + server).initCause(e); } // check the response if (authRes.getResponseCode() != ResponseCodes.AUTH_GRANTED) { throw (FailedLoginException) new FailedLoginException("This principal is not authenticated.").initCause(authRes.getDeniedCause()); } // return the response object return authRes.getIdentity().getClientIdentity(); }
public static Object directAuthentication(String securityRealm, String username, String password, ServerMetaData server) throws FailedLoginException { // authenticate AuthenticationRequest authReq = new AuthenticationRequest(securityRealm, username, password); AuthenticationResponse authRes; try { authRes = (AuthenticationResponse) Client.request(authReq, new AuthenticationResponse(), server); } catch (RemoteException e) { throw (FailedLoginException) new FailedLoginException("Unable to authenticate with server " + server).initCause(e); } // check the response if (authRes.getResponseCode() != ResponseCodes.AUTH_GRANTED) { throw (FailedLoginException) new FailedLoginException("This principal is not authenticated.").initCause(authRes.getDeniedCause()); } // return the response object Object clientIdentity = authRes.getIdentity().getClientIdentity(); return clientIdentity; }
e.printStackTrace(); FailedLoginException ex = new FailedLoginException("Error contacting LDAP using GSSAPI in JAAS loginConfigScope: " + configScope); ex.initCause(e); throw ex;
} catch (Exception ne) { FailedLoginException ex = new FailedLoginException("Error opening LDAP connection"); ex.initCause(ne); throw ex; Exception cause = e.getException(); FailedLoginException ex = new FailedLoginException("Error executing search query to resolve DN"); ex.initCause(cause); throw ex; closeContext(); FailedLoginException ex = new FailedLoginException("Error parsing absolute name as URI."); ex.initCause(e); throw ex; 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;
PicketBoxLogger.LOGGER.debugBadPasswordForUsername(username); if( ex != null && this.throwValidateError) fle.initCause(ex); throw fle;