src/main/java/org/apache/hadoop/hdfs/server/namenode/analytics/security/SecurityContext.java
public void logout(HttpServletRequest request, HttpServletResponse response) throws IOException {
    boolean authenticationEnabled = isAuthenticationEnabled();
    ProfileManager<CommonProfile> manager = new ProfileManager<>(new J2EContext(request, response));
    Optional<CommonProfile> profile = manager.get(false);
    if (authenticationEnabled && profile.isPresent()) {
      manager.logout();
      HttpSession session = request.getSession();
      if (session != null) {
        session.invalidate();
      }
      Cookie cookie = new Cookie("nna-jwt-token", "");
      cookie.setMaxAge(0);
      response.addCookie(cookie);
      response.addHeader("Cache-Control", "no-cache, no-store, must-revalidate");
      response.addHeader("Pragma", "no-cache");
      response.addHeader("Expires", "0");
      response.setStatus(HttpStatus.SC_OK);
      try (Writer writer = response.getWriter()) {
        writer.write("You have been logged out.");
      }
    } else {
      response.setStatus(HttpStatus.SC_BAD_REQUEST);
      try (Writer writer = response.getWriter()) {
        writer.write("No login session.");
      }
    }
  }
/**
   * Perform logout of authenticated web session.
   *
   * @param request - The HTTP request.
   * @param response - The HTTP response.
   */
Perform logout of authenticated web session.
@param request - The HTTP request.
@param response - The HTTP response.
Perform logout of authenticated web session . @param request - The HTTP request . @param response - The HTTP response .
public void logout(HttpServletRequest request, HttpServletResponse response) throws IOException {
    boolean authenticationEnabled = isAuthenticationEnabled();
    ProfileManager<CommonProfile> manager = new ProfileManager<>(new J2EContext(request, response));
    Optional<CommonProfile> profile = manager.get(false);
    if (authenticationEnabled && profile.isPresent()) {
      manager.logout();
      HttpSession session = request.getSession();
      if (session != null) {
        session.invalidate();
      }
      Cookie cookie = new Cookie("nna-jwt-token", "");
      cookie.setMaxAge(0);
      response.addCookie(cookie);
      response.addHeader("Cache-Control", "no-cache, no-store, must-revalidate");
      response.addHeader("Pragma", "no-cache");
      response.addHeader("Expires", "0");
      response.setStatus(HttpStatus.SC_OK);
      try (Writer writer = response.getWriter()) {
        writer.write("You have been logged out.");
      }
    } else {
      response.setStatus(HttpStatus.SC_BAD_REQUEST);
      try (Writer writer = response.getWriter()) {
        writer.write("No login session.");
      }
    }
  }
public void logout ( HttpServletRequest request , HttpServletResponse response ) throws IOException { boolean authenticationEnabled = isAuthenticationEnabled ( ) ; ProfileManager < CommonProfile > manager = new ProfileManager < > ( new J2EContext ( request , response ) ) ; Optional < CommonProfile > profile = manager . get ( false ) ; if ( authenticationEnabled && profile . isPresent ( ) ) { manager . logout ( ) ; HttpSession session = request . getSession ( ) ; if ( session != null ) { session . invalidate ( ) ; } Cookie cookie = new Cookie ( "nna-jwt-token" , "" ) ; cookie . setMaxAge ( 0 ) ; response . addCookie ( cookie ) ; response . addHeader ( "Cache-Control" , "no-cache, no-store, must-revalidate" ) ; response . addHeader ( "Pragma" , "no-cache" ) ; response . addHeader ( "Expires" , "0" ) ; response . setStatus ( HttpStatus . SC_OK ) ; try ( Writer writer = response . getWriter ( ) ) { writer . write ( "You have been logged out." ) ; } } else { response . setStatus ( HttpStatus . SC_BAD_REQUEST ) ; try ( Writer writer = response . getWriter ( ) ) { writer . write ( "No login session." ) ; } } }
Perform logout of authenticated web session.
Perform logout of authenticated web session .