throw new FailedLoginException("user name is null"); throw new FailedLoginException("User does exist"); throw new FailedLoginException("Password does not match");
/** * Overriding to allow for certificate-based login. Standard JAAS. */ @Override public boolean login() throws LoginException { Callback[] callbacks = new Callback[1]; callbacks[0] = new CertificateCallback(); try { callbackHandler.handle(callbacks); } catch (IOException ioe) { throw new LoginException(ioe.getMessage()); } catch (UnsupportedCallbackException uce) { throw new LoginException(uce.getMessage() + " Unable to obtain client certificates."); } X509Certificate[] certificates = ((CertificateCallback)callbacks[0]).getCertificates(); username = getUserNameForCertificates(certificates); if (username == null) { throw new FailedLoginException("No user for client certificate: " + getDistinguishedName(certificates)); } if (debug) { LOG.debug("Certificate for user: " + username); } succeeded = true; return true; }
context = open(); } catch (NamingException ne) { FailedLoginException ex = new FailedLoginException("Error opening LDAP connection"); ex.initCause(ne); throw ex; throw new FailedLoginException("User " + username + " not found in LDAP."); close(context); FailedLoginException ex = new FailedLoginException("Error parsing absolute name as URI."); ex.initCause(e); throw ex; throw new FailedLoginException("User found, but LDAP entry malformed: " + username); throw new FailedLoginException("Password does not match for user: " + username); FailedLoginException ex = new FailedLoginException("Error contacting LDAP"); ex.initCause(e); throw ex; close(context); FailedLoginException ex = new FailedLoginException("Error contacting LDAP"); ex.initCause(e); throw ex;
private static void checkSuccess(boolean success, String msg) throws LoginException { if (!success) { throw new FailedLoginException(msg); } }
@Override public final FailedLoginException noMatchingUsernameFoundInRoles() { final FailedLoginException result = new FailedLoginException(String.format(noMatchingUsernameFoundInRoles$str())); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String failedToLookupDataSourceMessage = "PBOX00064: Error looking up DataSource from %s";
@Override public final FailedLoginException invalidPassword() { final FailedLoginException result = new FailedLoginException(String.format(invalidPassword$str())); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String failedToInstantiateClassMessage = "PBOX00071: Failed to instantiate %s class";
@Override public final FailedLoginException noMatchingUsernameFoundInPrincipals() { final FailedLoginException result = new FailedLoginException(String.format(noMatchingUsernameFoundInPrincipals$str())); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String noMatchingUsernameFoundInRoles = "PBOX00063: No matching username found in roles";
@Override public final FailedLoginException failedToMatchCredential(final String alias) { final FailedLoginException result = new FailedLoginException(String.format(failedToMatchCredential$str(), alias)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String noCallbackHandlerAvailable = "PBOX00053: No CallbackHandler available to collect authentication information";
@Override public final FailedLoginException noMatchingUsernameFoundInRoles() { final FailedLoginException result = new FailedLoginException(String.format(noMatchingUsernameFoundInRoles$str())); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String failedToLookupDataSourceMessage = "PBOX00064: Error looking up DataSource from %s";
public static void handle(final AuthenticationStatus status, final String userId) throws LoginException { switch (status) { case FAILED: throw new FailedLoginException("Wrong username or password."); case CREDENTIAL_EXPIRED: throw new CredentialExpiredException("User: '" + userId + "'"); case ACCOUNT_EXPIRED: throw new AccountExpiredException("User: '" + userId + "'"); } }
@Override public final FailedLoginException invalidPassword() { final FailedLoginException result = new FailedLoginException(String.format(invalidPassword$str())); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String failedToInstantiateClassMessage = "PBOX00071: Failed to instantiate %s class";
@Override public final FailedLoginException failedToMatchCredential(final String alias) { final FailedLoginException result = new FailedLoginException(String.format(failedToMatchCredential$str(), alias)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String noCallbackHandlerAvailable = "PBOX00053: No CallbackHandler available to collect authentication information";
@Override public final FailedLoginException noMatchingUsernameFoundInPrincipals() { final FailedLoginException result = new FailedLoginException(String.format(noMatchingUsernameFoundInPrincipals$str())); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String noMatchingUsernameFoundInRoles = "PBOX00063: No matching username found in roles";
@Override public final FailedLoginException noMatchingUsernameFoundInRoles() { final FailedLoginException result = new FailedLoginException(String.format(noMatchingUsernameFoundInRoles$str())); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String failedToLookupDataSourceMessage = "PBOX00064: Error looking up DataSource from %s";
@Override public final FailedLoginException invalidPassword() { final FailedLoginException result = new FailedLoginException(String.format(invalidPassword$str())); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String failedToInstantiateClassMessage = "PBOX00071: Failed to instantiate %s class";
@Override protected AuthenticationHandlerExecutionResult authenticateUsernamePasswordInternal(final UsernamePasswordCredential credential, final String originalPassword) throws GeneralSecurityException { val username = credential.getUsername(); if (this.users.contains(username)) { throw new FailedLoginException(); } return createHandlerResult(credential, this.principalFactory.createPrincipal(username), new ArrayList<>(0)); } }
@Override public boolean commit() throws LoginException { if (this.id == null) { final String message = ExceptionManager.getInstance().getFullMessage("bi_PLM_6"); throw new FailedLoginException(message); } final Set<Principal> principals = this.subject.getPrincipals(); principals.add(new BonitaPrincipal(this.id)); principals.add(new BonitaPrincipalRole(role)); return true; }
@Override public AuthenticationHandlerExecutionResult authenticate(final Credential credential) throws GeneralSecurityException, PreventedException { if (!preAuthenticate(credential)) { throw new FailedLoginException(); } return postAuthenticate(credential, doAuthentication(credential)); }
@Override protected AuthenticationHandlerExecutionResult doAuthentication(final Credential credential) throws GeneralSecurityException { val wsFederationCredentials = (WsFederationCredential) credential; if (wsFederationCredentials != null) { val attributes = wsFederationCredentials.getAttributes(); val principal = this.principalFactory.createPrincipal(wsFederationCredentials.getId(), (Map) attributes); return this.createHandlerResult(wsFederationCredentials, principal, new ArrayList<>()); } throw new FailedLoginException(); }
/** * {@inheritDoc} **/ @Override public final HandlerResult authenticate(final Credential credential) throws GeneralSecurityException, PreventedException { if (!preAuthenticate(credential)) { throw new FailedLoginException(); } return postAuthenticate(credential, doAuthentication(credential)); }