Example usage for org.springframework.security.web.authentication.rememberme RememberMeAuthenticationException getMessage

List of usage examples for org.springframework.security.web.authentication.rememberme RememberMeAuthenticationException getMessage

Introduction

In this page you can find the example usage for org.springframework.security.web.authentication.rememberme RememberMeAuthenticationException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.springframework.security.web.authentication.rememberme.AbstractRememberMeServices.java

/**
 * Template implementation which locates the Spring Security cookie, decodes it into a
 * delimited array of tokens and submits it to subclasses for processing via the
 * <tt>processAutoLoginCookie</tt> method.
 * <p>//from  w ww . ja  v  a  2  s.c o m
 * The returned username is then used to load the UserDetails object for the user,
 * which in turn is used to create a valid authentication token.
 */
@Override
public final Authentication autoLogin(HttpServletRequest request, HttpServletResponse response) {
    String rememberMeCookie = extractRememberMeCookie(request);

    if (rememberMeCookie == null) {
        return null;
    }

    logger.debug("Remember-me cookie detected");

    if (rememberMeCookie.length() == 0) {
        logger.debug("Cookie was empty");
        cancelCookie(request, response);
        return null;
    }

    UserDetails user = null;

    try {
        String[] cookieTokens = decodeCookie(rememberMeCookie);
        user = processAutoLoginCookie(cookieTokens, request, response);
        userDetailsChecker.check(user);

        logger.debug("Remember-me cookie accepted");

        return createSuccessfulAuthentication(request, user);
    } catch (CookieTheftException cte) {
        cancelCookie(request, response);
        throw cte;
    } catch (UsernameNotFoundException noUser) {
        logger.debug("Remember-me login was valid but corresponding user not found.", noUser);
    } catch (InvalidCookieException invalidCookie) {
        logger.debug("Invalid remember-me cookie: " + invalidCookie.getMessage());
    } catch (AccountStatusException statusInvalid) {
        logger.debug("Invalid UserDetails: " + statusInvalid.getMessage());
    } catch (RememberMeAuthenticationException e) {
        logger.debug(e.getMessage());
    }

    cancelCookie(request, response);
    return null;
}