Example usage for org.springframework.security.authentication LockedException LockedException

List of usage examples for org.springframework.security.authentication LockedException LockedException

Introduction

In this page you can find the example usage for org.springframework.security.authentication LockedException LockedException.

Prototype

public LockedException(String msg, Throwable t) 

Source Link

Document

Constructs a LockedException with the specified message and root cause.

Usage

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);
    }/*ww  w. j a  v  a  2s. com*/

    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: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://ww w.  j a va 2  s  .  c om
        throw badCredentials(cause);
    }
}