Example usage for org.springframework.security.core.userdetails UsernameNotFoundException getCause

List of usage examples for org.springframework.security.core.userdetails UsernameNotFoundException getCause

Introduction

In this page you can find the example usage for org.springframework.security.core.userdetails UsernameNotFoundException getCause.

Prototype

public synchronized Throwable getCause() 

Source Link

Document

Returns the cause of this throwable or null if the cause is nonexistent or unknown.

Usage

From source file:org.musicrecital.webapp.pages.PasswordRecoveryToken.java

Object onActivate(EventContext ctx) {
    // ensure that the username has been set
    if (ctx == null || ctx.getCount() == 0) {
        logger.warn("Username not specified, notifying user that it's a required field.");
        alertManager.alert(Duration.TRANSIENT, Severity.ERROR,
                messages.format("errors.required", messages.get("user.username")));

        return Login.class;
    }/*www  . j  av a2 s . co  m*/

    // Expect username is the first item in the context
    int userIdx = 0;
    this.username = ctx.get(String.class, userIdx).trim();

    logger.debug("Sending recovery token for username: " + username);

    try {
        userManager.sendPasswordRecoveryEmail(username, RequestUtil.getAppURL(request) + getLink());
    } catch (final UsernameNotFoundException ignored) {
        // lets ignore this
        Throwable exceptionToLog = ignored.getCause() != null ? ignored.getCause() : ignored;
        logger.error(exceptionToLog.getLocalizedMessage());
    }

    alertManager.alert(Duration.TRANSIENT, Severity.INFO, messages.get("updatePassword.recoveryToken.sent"));

    return Login.class;
}