Check for logout request.

@param request    HttpServletRequest
@param form
@return null for continue, forwardLoggedOut to end session.
@throws Throwable
966157
protected String checkLogOut(final HttpServletRequest request,
                               final UtilActionForm form)
               throws Throwable {
    final String reqUser = request.getRemoteUser();

    final boolean forceLogout =
            !Util.equalsString(reqUser, form.getCurrentUser());

    final String temp = request.getParameter(requestLogout);


    if (forceLogout || (temp != null)) {
      final HttpSession sess = request.getSession(false);

      if ((sess != null) && logOutCleanup(request, form)) {
        sess.invalidate();
      }
      return forwardLoggedOut;
    }

    return null;
  }
424534
public static DeleteRequest checkRequest(final HttpServletRequest request,
			final DeleteResponse deleteResponse) {
		final DeleteRequestType type = checkType(request, deleteResponse);
		if (type != null) {
			return new DeleteRequest(type);
		}

		return null;
	}
462441
public static boolean isStepOnRequest(final Request request) {
		String val = request.getParameter(Environment.STEP_VARIABLE);
		return val != null;
	}
707731
public void deleteRouteRule(DeleteRouteRequest deleteRouteRequest) {
        checkNotNull(deleteRouteRequest, "request should not be null.");
        checkNotNull(deleteRouteRequest.getRouteRuleId(), "request routeRuleId should not be null.");
        if (Strings.isNullOrEmpty(deleteRouteRequest.getClientToken())) {
            deleteRouteRequest.setClientToken(this.generateClientToken());
        }
        InternalRequest internalRequest = this.createRequest(
                deleteRouteRequest, HttpMethodName.DELETE, ROUTE_PREFIX, ROUTE_RULE,
                deleteRouteRequest.getRouteRuleId());
        internalRequest.addParameter("clientToken", deleteRouteRequest.getClientToken());
        this.invokeHttpClient(internalRequest, AbstractBceResponse.class);
    }
880904
protected boolean isLoggingOut(final Request request, final Response response)
    {
        return this.isInterceptingLogout()
                && this.getLogoutPath().equals(request.getResourceRef().getRemainingPart(false, false))
                && (Method.GET.equals(request.getMethod()) || Method.POST.equals(request.getMethod()));
    }
853030
@Override
	public void serviceRequest(final Request request) {
		// Get the expected session token
		UIContext uic = UIContextHolder.getCurrent();
		String expected = uic.getEnvironment().getSessionToken();

		// Get the session token from the request
		String got = request.getParameter(Environment.SESSION_TOKEN_VARIABLE);

		// Check tokens match (Both null if new session)
		// or processing a GET and no token
		if (Util.equals(expected, got) || (got == null && "GET".equals(request.getMethod()))) {
			// Process request
			getBackingComponent().serviceRequest(request);
		} else {  // Invalid token
			String msg;
			if (expected == null && got != null) {
				msg = "Session for token [" + got + "] is no longer valid or timed out.";
			} else {
				msg = "Wrong session token detected for servlet request. Expected token [" + expected
						+ "] but got token [" + got + "].";
			}
			LOG.error(msg);
			String message = I18nUtilities.format(uic.getLocale(),
					InternalMessages.DEFAULT_SESSION_TOKEN_ERROR);
			throw new SystemException(message);
		}

	}
1308110
protected boolean sendSingleLogoutMessage(final SingleLogoutRequest request, final SingleLogoutMessage logoutMessage) {
        val logoutService = request.getService();
        LOGGER.trace("Preparing logout request for [{}] to [{}]", logoutService.getId(), request.getLogoutUrl());
        val msg = getLogoutHttpMessageToSend(request, logoutMessage);
        LOGGER.debug("Prepared logout message to send is [{}]. Sending...", msg);
        val result = sendMessageToEndpoint(msg, request, logoutMessage);
        logoutService.setLoggedOutAlready(result);
        return result;
    }
903257
public void logout() throws IOException {

        String loggedInUserName = getRequestContext().getCurrentUser().getName();
        HttpSession session = getRequest().getSession(false);
        if (session != null) {
            session.invalidate();
            /* we need this because a new session might be created after this method,
             but before the session info is updated in OpenCmsCore.showResource. */
            getCmsObject().getRequestContext().setUpdateSessionEnabled(false);
        }
        // logout was successful
        if (LOG.isInfoEnabled()) {
            LOG.info(
                Messages.get().getBundle().key(
                    Messages.LOG_LOGOUT_SUCCESFUL_3,
                    loggedInUserName,
                    getRequestContext().addSiteRoot(getRequestContext().getUri()),
                    getRequestContext().getRemoteAddress()));
        }
        getResponse().sendRedirect(getFormLink());
    }
317329
public boolean removeNewSessionRequest(RequestHandler request) {
    lock.writeLock().lock();
    try {
      return newSessionRequests.remove(request);
    } finally {
      lock.writeLock().unlock();
    }
  }
694657
public void service(ConnectionProtocol request)
  {
    RequestBaratine req = (RequestBaratine) request;
    
    Thread thread = Thread.currentThread();
    ClassLoader oldLoader = thread.getContextClassLoader();
    
    try {
      if (_webApp != null) {
        thread.setContextClassLoader(_webApp.classLoader());
      }
      
      for (RouteBaratine route : _routes) {
        if (route.service(req)) {
          return;
        }
      }
      
      if (_routes.length > 0) {
        req.halt(HttpStatus.METHOD_NOT_ALLOWED);
      }
      else {
        req.halt(HttpStatus.NOT_FOUND);
        
      }
    } finally {
      thread.setContextClassLoader(oldLoader);
    }
  }
326487
protected void processRequest(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {

        //get user's credentials from the request
        String uname = request.getParameter("j_username");
        String pass = request.getParameter("j_password");

        try {
            //validate given user using container's login mechanism
            request.login(uname, pass);

            ServletContext context = getServletConfig().getServletContext();
            
            //put user's credentials in the servlet context
            context.setAttribute("uname", uname);
            context.setAttribute("password", pass);
            
            //forward request to the initial page
            response.sendRedirect(request.getContextPath() + "/Console.html");
        } catch (ServletException e) {
            //login failed to forward user to the login form
            response.sendRedirect(request.getContextPath() + "/loginform.html");
        }
    }
1265906
final public function autoLogin(Request $request): ?TokenInterface
    {
        if (null === $cookie = $request->cookies->get($this->options['name'])) {
            return null;
        }

        if (null !== $this->logger) {
            $this->logger->debug('Remember-me cookie detected.');
        }

        $cookieParts = $this->decodeCookie($cookie);

        try {
            $user = $this->processAutoLoginCookie($cookieParts, $request);

            if (!$user instanceof UserInterface) {
                throw new \RuntimeException('processAutoLoginCookie() must return a UserInterface implementation.');
            }

            if (null !== $this->logger) {
                $this->logger->info('Remember-me cookie accepted.');
            }

            return new RememberMeToken($user, $this->providerKey, $this->secret);
        } catch (CookieTheftException $e) {
            $this->loginFail($request, $e);

            throw $e;
        } catch (UsernameNotFoundException $e) {
            if (null !== $this->logger) {
                $this->logger->info('User for remember-me cookie not found.', ['exception' => $e]);
            }

            $this->loginFail($request, $e);
        } catch (UnsupportedUserException $e) {
            if (null !== $this->logger) {
                $this->logger->warning('User class for remember-me cookie not supported.', ['exception' => $e]);
            }

            $this->loginFail($request, $e);
        } catch (AuthenticationException $e) {
            if (null !== $this->logger) {
                $this->logger->debug('Remember-Me authentication failed.', ['exception' => $e]);
            }

            $this->loginFail($request, $e);
        } catch (\Exception $e) {
            $this->loginFail($request, $e);

            throw $e;
        }

        return null;
    }
1371645
@Subscribe
    public void onLogout(LogoutRequestEvent event) {
        Subject subject = ThreadContext.getSubject();
        if (subject != null) {
            subject.logout();
        }
    }
786524
public PauseSessionResponse pauseSession(PauseSessionRequest request) {
        checkNotNull(request, "The parameter request should NOT be null.");
        checkStringNotEmpty(request.getSessionId(), "The parameter sessionId should NOT be null or empty string.");
        InternalRequest internalRequest = createRequest(HttpMethodName.PUT, request, LIVE_SESSION,
                request.getSessionId());
        internalRequest.addParameter(PAUSE, null);
        return invokeHttpClient(internalRequest, PauseSessionResponse.class);
    }
1263987
protected void validateLogoutRequest(final LogoutRequest logoutRequest, final SAML2MessageContext context,
                                               final SignatureTrustEngine engine) {

        validateSignatureIfItExists(logoutRequest.getSignature(), context, engine);

        // don't check because of CAS v5
        //validateIssueInstant(logoutRequest.getIssueInstant());

        validateIssuerIfItExists(logoutRequest.getIssuer(), context);

        NameID nameId = logoutRequest.getNameID();
        final EncryptedID encryptedID = logoutRequest.getEncryptedID();
        if (encryptedID != null) {
            nameId = decryptEncryptedId(encryptedID, decrypter);
        }

        String sessionIndex = null;
        final List<SessionIndex> sessionIndexes = logoutRequest.getSessionIndexes();
        if (sessionIndexes != null && !sessionIndexes.isEmpty()) {
            final SessionIndex sessionIndexObject = sessionIndexes.get(0);
            if (sessionIndexObject != null) {
                sessionIndex = sessionIndexObject.getSessionIndex();
            }
        }

        final String sloKey = computeSloKey(sessionIndex, nameId);
        if (sloKey != null) {
            final String bindingUri = context.getSAMLBindingContext().getBindingUri();
            if (SAMLConstants.SAML2_SOAP11_BINDING_URI.equals(bindingUri)) {
                logoutHandler.destroySessionBack(context.getWebContext(), sloKey);
            } else {
                logoutHandler.destroySessionFront(context.getWebContext(), sloKey);
            }
        }
    }
192078
public void persistInSession( HttpServletRequest request, HttpServletResponse response )
    {
        PageFlowController currentPageFlow = PageFlowUtils.getCurrentPageFlow( request, getServletContext() );

        //
        // This code implicitly destroys the current page flow.  In order to prevent multiple threads
        // from executing inside the JPF at once, synchronize on it in order to complete the "destroy"
        // atomically.
        //
        if ( currentPageFlow != null && ! currentPageFlow.isOnNestingStack() )
        {
            synchronized ( currentPageFlow )
            {
                InternalUtils.setCurrentPageFlow( this, request, getServletContext() );
            }
        }
        //
        // Here, there is no previous page flow to syncyronize upon before destruction
        //
        else
        {
            InternalUtils.setCurrentPageFlow( this, request, getServletContext() );
        }
    }
908143
def logout(request):
    
    # Dispatch the signal before the user is logged out so the receivers have a
    # chance to find out *who* logged out.
    user = getattr(request, 'user', None)
    if hasattr(user, 'is_authenticated') and not user.is_authenticated:
        user = None
    user_logged_out.send(sender=user.__class__, request=request, user=user)

    # remember language choice saved to session
    language = request.session.get(LANGUAGE_SESSION_KEY)

    request.session.flush()

    if language is not None:
        request.session[LANGUAGE_SESSION_KEY] = language

    if hasattr(request, 'user'):
        request.user = MojAnonymousUser()