Example usage for javax.servlet.http HttpServletRequest logout

List of usage examples for javax.servlet.http HttpServletRequest logout

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest logout.

Prototype

public void logout() throws ServletException;

Source Link

Document

Establish null as the value returned when getUserPrincipal, getRemoteUser, and getAuthType is called on the request.

Usage

From source file:org.wte4j.ui.auth.server.AuthController.java

@RequestMapping(value = "logout", method = RequestMethod.POST, produces = "application/json")
public void logout(HttpServletRequest request) throws Exception {
    request.logout();
}

From source file:io.smalldata.ohmageomh.dsu.controller.AccountController.java

@RequestMapping(value = "/signout", method = RequestMethod.GET)
@ResponseBody/*from  ww  w .j a  va  2  s .c  o  m*/
public RedirectView signOut(HttpServletRequest request) throws ServletException {
    request.logout();
    return new RedirectView(""); // Redirect back to home
}

From source file:com.github.sshw.controller.LogoutController.java

@Override
@RequestMapping//from  w w w .  j a  va2  s .c o m
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {

    request.logout();
    return new ModelAndView("redirect:login");

}

From source file:ispok.pres.bb.Navigation.java

public void logout() {
    System.out.println("********************** LOGOUT");
    //        SecurityContextHolder.clearContext();
    ServletRequestAttributes sra = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
    HttpServletRequest req = sra.getRequest();
    try {//from   www. java2 s .co  m
        req.logout();
    } catch (ServletException ex) {
        Logger.getLogger(Navigation.class.getName()).log(Level.SEVERE, null, ex);
    }
    //        SecurityContextHolder.getContext().getAuthentication().setAuthenticated(false);
    //        SecurityContextHolder.createEmptyContext();
    //        return "/ispok/index.xhtml";
}

From source file:org.smigo.user.UserController.java

@RequestMapping(value = { "/rest/logout" }, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody//from   w w w.j a va2  s  .  c om
public void logout(HttpServletRequest request) throws ServletException {
    request.logout();
}

From source file:be.fedict.hsm.admin.webapp.security.AuthenticationController.java

public String logout() {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExternalContext externalContext = facesContext.getExternalContext();
    HttpServletRequest httpServletRequest = (HttpServletRequest) externalContext.getRequest();
    try {/*from w  w w.j  ava  2 s .com*/
        httpServletRequest.logout();
    } catch (ServletException e) {
        LOG.error("logout error: " + e.getMessage(), e);
    }
    return "/index.xhtml";
}

From source file:com.redhat.developers.msa.ola.OlaController.java

@CrossOrigin
@RequestMapping(method = RequestMethod.GET, value = "/logout", produces = "text/plain")
@ApiOperation("Logout")
public String logout() throws ServletException {
    HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes())
            .getRequest();//from w ww  .  j ava2s. c  o  m
    request.logout();
    return "Logged out";
}

From source file:com.deepsky.spring_security.samples.ServletApiController.java

/**
 * Demonstrates that invoking {@link javax.servlet.http.HttpServletRequest#logout()} will log the user out. Note that the response does
 * not get processed, so you need to write something to the response.
 * @param request//from  w  ww  .  j  a v a 2 s. c o  m
 * @param response
 * @param redirect
 * @return
 * @throws javax.servlet.ServletException
 */
@RequestMapping("/logout")
public String logout(HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirect)
        throws ServletException {
    request.logout();
    return "redirect:/";
}

From source file:de.hska.ld.core.controller.HomeController.java

@RequestMapping("/logout")
public String logout(HttpServletRequest request, HttpServletResponse response, Principal p)
        throws ServletException {
    request.logout();
    javax.servlet.http.Cookie cookie = new Cookie("sessionID", "");
    cookie.setPath("/");
    if (!"localhost".equals(env.getProperty("module.core.oidc.server.endpoint.main.domain"))) {
        cookie.setDomain(env.getProperty("module.core.oidc.server.endpoint.main.domain"));
    }/*from  w ww  . ja  v  a 2  s  . c  om*/
    cookie.setMaxAge(0);
    response.addCookie(cookie);
    return "redirect:";
}

From source file:org.smigo.config.ErrorViewExceptionResolver.java

@Override
public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler,
        Exception ex) {/*from   w w  w.  ja  v a  2 s .  c om*/
    log.info("Invalidating session and removing persistent token:" + request.getUserPrincipal());
    try {
        request.logout();
    } catch (ServletException e) {
        log.error("Could not logout user " + request.getUserPrincipal(), e);
    }
    return new ModelAndView("error.jsp", "statusCode", response.getStatus());
}