Example usage for org.springframework.security.web.authentication.logout SecurityContextLogoutHandler SecurityContextLogoutHandler

List of usage examples for org.springframework.security.web.authentication.logout SecurityContextLogoutHandler SecurityContextLogoutHandler

Introduction

In this page you can find the example usage for org.springframework.security.web.authentication.logout SecurityContextLogoutHandler SecurityContextLogoutHandler.

Prototype

SecurityContextLogoutHandler

Source Link

Usage

From source file:com.naveen.demo.config.Saml2SSOConfig.java

@Bean
public SecurityContextLogoutHandler logoutHandler() {
    SecurityContextLogoutHandler logoutHandler = new SecurityContextLogoutHandler();
    logoutHandler.setInvalidateHttpSession(true);
    logoutHandler.setClearAuthentication(true);
    return logoutHandler;
}

From source file:ch.astina.hesperid.web.services.SecurityModule.java

/**
 * Configuration for LogoutService created in {@link #bind(ServiceBinder)}
 *//*from w  w  w.  j a v a2  s  . c  om*/
public static void contributeLogoutService(final OrderedConfiguration<LogoutHandler> cfg,
        @Inject RequestGlobals globals,
        @InjectService("RememberMeLogoutHandler") final LogoutHandler rememberMeLogoutHandler) {
    cfg.add("securityContextLogoutHandler", new SecurityContextLogoutHandler());
    cfg.add("rememberMeLogoutHandler", rememberMeLogoutHandler);
    cfg.add("tapestryLogoutHandler", new TapestryLogoutHandler(globals), new String[0]);
}

From source file:com.netflix.genie.web.security.saml.SAMLConfig.java

/**
 * Logout handler terminating local session.
 *
 * @return The security context logout handler
 * @see SecurityContextLogoutHandler/*w ww  .ja v  a2s. c o  m*/
 */
@Bean
public SecurityContextLogoutHandler logoutHandler() {
    final SecurityContextLogoutHandler logoutHandler = new SecurityContextLogoutHandler();
    logoutHandler.setInvalidateHttpSession(true);
    logoutHandler.setClearAuthentication(true);
    return logoutHandler;
}

From source file:it.infn.mw.iam.config.saml.SamlConfig.java

@Bean
public SecurityContextLogoutHandler logoutHandler() {

    SecurityContextLogoutHandler logoutHandler = new SecurityContextLogoutHandler();
    logoutHandler.setInvalidateHttpSession(true);
    logoutHandler.setClearAuthentication(true);
    return logoutHandler;
}

From source file:at.fh.swenga.firefighters.controller.FireFighterController.java

@RequestMapping(value = "editProfile", method = RequestMethod.POST)
public String editProfile(Model model, @RequestParam String firstname, @RequestParam String lastname,
        @RequestParam String email, HttpServletRequest request) {
    User currentUser = userRepository.findById(getSessionUser().getId());
    currentUser.setName(firstname);//from   w  ww. ja va2 s.c o  m
    currentUser.setSurname(lastname);
    currentUser.setEmail(email);
    userRepository.save(currentUser);
    new SecurityContextLogoutHandler().logout(request, null, null);
    return "redirect:login";
}

From source file:org.ambraproject.wombat.config.SpringSecurityConfiguration.java

private LogoutFilter requestLogoutFilter() {
    // This filter redirects to the CAS Server to signal Single Logout should be performed
    SecurityContextLogoutHandler logoutHandler = new SecurityContextLogoutHandler();
    logoutHandler.setClearAuthentication(true);
    logoutHandler.setInvalidateHttpSession(true);
    LogoutFilter logoutFilter = new LogoutFilter(getLogoutSuccessHandler(), logoutHandler);
    logoutFilter.setFilterProcessesUrl(CAS_LOGOUT_URI);
    return logoutFilter;
}

From source file:org.orcid.frontend.web.controllers.BaseController.java

protected void logoutCurrentUser(HttpServletRequest request, HttpServletResponse response) {
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    if (internalSSOManager.enableCookie()) {
        Cookie[] cookies = request.getCookies();
        // Delete cookie and token associated with that cookie
        if (cookies != null) {
            for (Cookie cookie : cookies) {
                if (InternalSSOManager.COOKIE_NAME.equals(cookie.getName())) {
                    try {
                        // If it is a valid cookie, extract the orcid value
                        // and
                        // remove the token and the cookie
                        @SuppressWarnings("unchecked")
                        HashMap<String, String> cookieValues = JsonUtils
                                .readObjectFromJsonString(cookie.getValue(), HashMap.class);
                        if (cookieValues.containsKey(InternalSSOManager.COOKIE_KEY_ORCID)
                                && !PojoUtil.isEmpty(cookieValues.get(InternalSSOManager.COOKIE_KEY_ORCID))) {
                            internalSSOManager.deleteToken(
                                    cookieValues.get(InternalSSOManager.COOKIE_KEY_ORCID), request, response);
                        } else {
                            // If it is not valid, just remove the cookie
                            cookie.setValue(StringUtils.EMPTY);
                            cookie.setMaxAge(0);
                            response.addCookie(cookie);
                        }/*w ww . j a v  a  2 s . c  om*/
                    } catch (RuntimeException re) {
                        // If any exception happens, but, the cookie exists,
                        // remove the cookie
                        cookie.setValue(StringUtils.EMPTY);
                        cookie.setMaxAge(0);
                        response.addCookie(cookie);
                    }
                    break;
                }
            }
        }
        // Delete token if exists
        if (authentication != null && !PojoUtil.isEmpty(authentication.getName())) {
            internalSSOManager.deleteToken(authentication.getName());
        }
    }
    if (authentication != null && authentication.isAuthenticated()) {
        new SecurityContextLogoutHandler().logout(request, response, authentication);
    }
    CsrfToken token = csrfTokenRepository.generateToken(request);
    csrfTokenRepository.saveToken(token, request, response);
    request.setAttribute("_csrf", token);
}