List of usage examples for org.springframework.security.authentication AccountExpiredException AccountExpiredException
public AccountExpiredException(String msg, Throwable t)
AccountExpiredException
with the specified message and root cause. From source file:org.codehaus.groovy.grails.plugins.springsecurity.DefaultPreAuthenticationChecks.java
public void check(UserDetails user) { if (!user.isAccountNonLocked()) { log.debug("User account is locked"); throw new LockedException(messages.getMessage("AbstractUserDetailsAuthenticationProvider.locked", "User account is locked"), user); }//from www .j a v a 2 s. c o m if (!user.isEnabled()) { log.debug("User account is disabled"); throw new DisabledException( messages.getMessage("AbstractUserDetailsAuthenticationProvider.disabled", "User is disabled"), user); } if (!user.isAccountNonExpired()) { log.debug("User account is expired"); throw new AccountExpiredException(messages.getMessage( "AbstractUserDetailsAuthenticationProvider.expired", "User account has expired"), user); } }
From source file:de.theit.jenkins.crowd.CrowdAuthenticationManager.java
/** * {@inheritDoc}/*from w w w .j a v a2 s . c o m*/ * * @see org.springframework.security.AuthenticationManager#authenticate(org.springframework.security.Authentication) */ @Override public Authentication authenticate(Authentication authentication) throws AuthenticationException { String username = authentication.getPrincipal().toString(); // checking whether there's already a SSO token if (null == authentication.getCredentials() && authentication instanceof CrowdAuthenticationToken && null != ((CrowdAuthenticationToken) authentication).getSSOToken()) { // SSO token available => user already authenticated if (LOG.isLoggable(Level.FINER)) { LOG.finer("User '" + username + "' already authenticated"); } return authentication; } String password = authentication.getCredentials().toString(); // ensure that the group is available, active and that the user // is a member of it if (!this.configuration.isGroupMember(username)) { throw new InsufficientAuthenticationException( userNotValid(username, this.configuration.allowedGroupNames)); } String displayName = null; try { // authenticate user if (LOG.isLoggable(Level.FINE)) { LOG.fine("Authenticating user: " + username); } User user = this.configuration.crowdClient.authenticateUser(username, password); displayName = user.getDisplayName(); } catch (UserNotFoundException ex) { if (LOG.isLoggable(Level.INFO)) { LOG.info(userNotFound(username)); } throw new BadCredentialsException(userNotFound(username), ex); } catch (ExpiredCredentialException ex) { LOG.warning(expiredCredentials(username)); throw new CredentialsExpiredException(expiredCredentials(username), ex); } catch (InactiveAccountException ex) { LOG.warning(accountExpired(username)); throw new AccountExpiredException(accountExpired(username), ex); } catch (ApplicationPermissionException ex) { LOG.warning(applicationPermission()); throw new AuthenticationServiceException(applicationPermission(), ex); } catch (InvalidAuthenticationException ex) { LOG.warning(invalidAuthentication()); throw new AuthenticationServiceException(invalidAuthentication(), ex); } catch (OperationFailedException ex) { LOG.log(Level.SEVERE, operationFailed(), ex); throw new AuthenticationServiceException(operationFailed(), ex); } // user successfully authenticated // => retrieve the list of groups the user is a member of List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>(); // add the "authenticated" authority to the list of granted // authorities... authorities.add(SecurityRealm.AUTHENTICATED_AUTHORITY); // ..and finally all authorities retrieved from the Crowd server authorities.addAll(this.configuration.getAuthoritiesForUser(username)); // user successfully authenticated => create authentication token if (LOG.isLoggable(Level.FINE)) { LOG.fine("User successfully authenticated; creating authentication token"); } return new CrowdAuthenticationToken(username, password, authorities, null, displayName); }
From source file:iplatform.admin.ui.server.auth.ad.ActiveDirectoryLdapAuthenticationProvider.java
void raiseExceptionForErrorCode(int code, NamingException exception) { //String hexString = Integer.toHexString(code); //Throwable cause = new ActiveDirectoryAuthenticationException(hexString, exception.getMessage(), exception); Throwable cause = new Exception(exception.getMessage()); switch (code) { case PASSWORD_EXPIRED: throw new CredentialsExpiredException(messages.getMessage( "LdapAuthenticationProvider.credentialsExpired", "User credentials have expired"), cause); case ACCOUNT_DISABLED: throw new DisabledException( messages.getMessage("LdapAuthenticationProvider.disabled", "User is disabled"), cause); case ACCOUNT_EXPIRED: throw new AccountExpiredException( messages.getMessage("LdapAuthenticationProvider.expired", "User account has expired"), cause); case ACCOUNT_LOCKED: throw new LockedException( messages.getMessage("LdapAuthenticationProvider.locked", "User account is locked"), cause); default:/*from w w w . jav a 2 s . c o m*/ throw badCredentials(cause); } }