/** * Check if the credential is valid * * @return boolean */ public boolean isValid() { return credential.getStatus().equals(Credentials.Status.VALID); }
this.credentials.setStatus(creds.getStatus()); this.credentials.setValidatedAccount(creds.getValidatedAccount()); if (Credentials.Status.VALID.equals(creds.getStatus())) { setStatus(AuthenticationStatus.SUCCESS); setAccount(creds.getValidatedAccount()); } else if (Credentials.Status.ACCOUNT_DISABLED.equals(creds.getStatus())) { throw new LockedAccountException("Account [" + this.credentials.getUserId() + "] is disabled."); } else if (Credentials.Status.EXPIRED.equals(creds.getStatus())) { throw new CredentialExpiredException("Credential is expired for Account [" + this.credentials.getUserId() + "].");
this.credentials.setStatus(creds.getStatus()); this.credentials.setValidatedAccount(creds.getValidatedAccount()); if (Credentials.Status.VALID.equals(creds.getStatus())) { setStatus(AuthenticationStatus.SUCCESS); setAccount(creds.getValidatedAccount()); } else if (Credentials.Status.ACCOUNT_DISABLED.equals(creds.getStatus())) { throw new LockedAccountException("Account [" + this.credentials.getUserId() + "] is disabled."); } else if (Credentials.Status.EXPIRED.equals(creds.getStatus())) { throw new CredentialExpiredException("Credential is expired for Account [" + this.credentials.getUserId() + "].");
this.credentials.setStatus(creds.getStatus()); this.credentials.setValidatedAccount(creds.getValidatedAccount()); if (Credentials.Status.VALID.equals(creds.getStatus())) { setStatus(AuthenticationStatus.SUCCESS); setAccount(creds.getValidatedAccount()); } else if (Credentials.Status.ACCOUNT_DISABLED.equals(creds.getStatus())) { throw new LockedAccountException("Account [" + this.credentials.getUserId() + "] is disabled."); } else if (Credentials.Status.EXPIRED.equals(creds.getStatus())) { throw new CredentialExpiredException("Credential is expired for Account [" + this.credentials.getUserId() + "].");
/** * Check if the credential has already expired * * @return boolean */ public boolean hasExpired() { return credential.getStatus().equals(Credentials.Status.EXPIRED); }
@Override protected PicketBoxPrincipal doHTTPAuthentication(HttpServletCredential credential) { HTTPBasicCredential basicCredential = (HTTPBasicCredential) credential; if (basicCredential.getCredential() != null) { String username = basicCredential.getUserName(); User user = getIdentityManager().getUser(username); Credentials userCredential = basicCredential.getCredential(); getIdentityManager().validateCredentials(userCredential); if (user != null && userCredential.getStatus().equals(Status.VALID)) { return new PicketBoxPrincipal(username); } } return null; }
@Override protected Principal doAuthenticate(UserCredential credential, AuthenticationResult result) throws AuthenticationException { UsernamePasswordCredential userCredential = (UsernamePasswordCredential) credential; // try to retrieve the user from the configured identity store User user = getIdentityManager().getUser(userCredential.getUserName()); Credentials passwordCredential = userCredential.getCredential(); getIdentityManager().validateCredentials(passwordCredential); if (user != null && passwordCredential.getStatus().equals(Status.VALID)) { return new PicketBoxPrincipal(userCredential.getUserName()); } return null; } }
@Override protected Principal doHTTPAuthentication(HttpServletCredential credential) { HTTPFormCredential formCredential = (HTTPFormCredential) credential; if (formCredential.getCredential() != null) { User user = getIdentityManager().getUser(formCredential.getUserName()); Credentials passwordCredential = formCredential.getCredential(); getIdentityManager().validateCredentials(passwordCredential); if (user != null && passwordCredential.getStatus().equals(Status.VALID)) { return new PicketBoxPrincipal(formCredential.getUserName()); } } return null; }