Example usage for org.springframework.security.authentication AuthenticationCredentialsNotFoundException getMessage

List of usage examples for org.springframework.security.authentication AuthenticationCredentialsNotFoundException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.ngrinder.home.controller.HomeController.java

/**
 * Return nGrinder index page.//from   w w w.  j  a  v a2s  . co  m
 *
 * @param user      user
 * @param exception exception if it's redirected from exception handler
 * @param region    region. where this access comes from. it's optional
 * @param model     model
 * @param response  response
 * @param request   request
 * @return "index" if already logged in. Otherwise "login".
 */
@RequestMapping(value = { "/home", "/" })
public String home(User user, @RequestParam(value = "exception", defaultValue = "") String exception,
        @RequestParam(value = "region", defaultValue = "") String region, ModelMap model,
        HttpServletResponse response, HttpServletRequest request) {
    try {
        Role role;
        try {
            recordReferrer(region);
            // set local language
            setLanguage(getCurrentUser().getUserLanguage(), response, request);
            setLoginPageDate(model);
            role = user.getRole();
        } catch (AuthenticationCredentialsNotFoundException e) {
            return "login";
        }
        setPanelEntries(model);
        model.addAttribute("handlers", scriptHandlerFactory.getVisibleHandlers());

        if (StringUtils.isNotBlank(exception)) {
            model.addAttribute("exception", exception);
        }
        if (role == Role.ADMIN || role == Role.SUPER_USER || role == Role.USER) {
            return "index";
        } else {
            LOG.info("Invalid user role:{}", role.getFullName());
            return "login";
        }
    } catch (Exception e) {
        // Make the home reliable...
        model.addAttribute("exception", e.getMessage());
        return "index";
    }
}