Logs the user out and optionally invalidates their login token.<p>

@param invalidateToken true if the token should be invalidated

@throws IOException if something goes wrong
540586
public void logout(boolean invalidateToken) throws IOException {

        if (isLoggedIn() && invalidateToken) {
            CmsUser user = getCmsObject().getRequestContext().getCurrentUser();
            CmsPersistentLoginTokenHandler tokenHandler = new CmsPersistentLoginTokenHandler();
            try {
                Cookie cookie = new Cookie(CmsPersistentLoginAuthorizationHandler.COOKIE_NAME, "");
                cookie.setMaxAge(0);
                cookie.setPath(getCookiePath(true));
                getResponse().addCookie(cookie);
                tokenHandler.invalidateToken(
                    user,
                    CmsRequestUtil.getCookieValue(
                        getRequest().getCookies(),
                        CmsPersistentLoginAuthorizationHandler.COOKIE_NAME));
            } catch (Exception e) {
                LOG.error("Could not invalidate tokens for user " + user, e);
            }

        }
        super.logout();

    }
281848
private void disconnect(FTPClient client) throws IOException {
    if (client != null) {
      if (!client.isConnected()) {
        throw new FTPException("Client not connected");
      }
      boolean logoutSuccess = client.logout();
      client.disconnect();
      if (!logoutSuccess) {
        LOG.warn("Logout failed while disconnecting, error code - "
            + client.getReplyCode());
      }
    }
  }
391318
public boolean nextValidToken() throws IOException {
        while (tokeniser.nextToken()) {
            if (tokeniser.getTokenType() == PRTokeniser.TK_COMMENT)
                continue;
            return true;
        }
        return false;
    }
1167973
public void login(String username, String password) throws IOException {
        String requestUrl = RESOURCE + "/login";
        Credentials creds = new Credentials();

        creds.setPassword(password);
        creds.setUsername(username);

        ArgusResponse response = getClient().executeHttpRequest(ArgusHttpClient.RequestType.POST, requestUrl, creds);

        try {
		assertValidResponse(response, requestUrl);
	} catch (TokenExpiredException e) {
		//This should never happen
		throw new RuntimeException("This should never happen. login() method should never throw a TokenExpiredException", e);
	}
        
        Map<String, String> tokens = fromJson(response.getResult(), new TypeReference<Map<String, String>>() {});
        getClient().accessToken = tokens.get("accessToken");
        getClient().refreshToken = tokens.get("refreshToken");
    }
727481
public function invalidateToken( $service ) {
        unset( $this->tokens[$service] );

        $cacheKey = $this->getTokenCacheKey( $service );
        $this->client->cache->delete( $cacheKey );

        $this->client->logger->notice( 'Invalidated token for ' . ucfirst( $service ) . 'Service' );
    }
565342
public synchronized void refreshWithToken(String clientToken, String accessToken) throws AuthenticationException {
		authResult = authenticationService.refresh(Objects.requireNonNull(clientToken), Objects.requireNonNull(accessToken));
	}
618857
public void invalidate() {
		this.appToken = null;
		this.appDBID = null;
		this.authorizer = null;
		this.intuitServiceType = null;
		this.realmID = null;
	}
93081
public static boolean isValidKillSessionsToken(String token) {
    if (token == null || token.isEmpty()) {
      return false;
    }
    
    for (String validToken:VALID_TOKENS) {
      if (token.equals (validToken)) {
        return true;
      }
    }
    
    return false;
  }
1339532
public function invalidateRefreshToken(AccessToken $token)
    {
        $this->getAuthorizationServer()->getAuthenticatedRequest('DELETE',
            $this->authorizationServerUri . '/v2/auth/token', $token, [
                'json' => [
                    'token' => $token->getRefreshToken(),
                ],
            ]);

        $user = $this->getFrameworkBridge()->getUser($token->getResourceOwnerId());
        $user->clearOAuthToken();
    }
59464
private void destroySessionByToken(String id) {
		System.out.println(new LogEntry("destroying session " + id));
		synchronized (sessions) {
			synchronized (sessionsMirror) {
				StandardSession session = (StandardSession) sessions.get(id);
				if (session != null) {
					session.onDestruction();
					sessions.remove(id);
					sessionsMirror.remove(id);
				}
			}
		}
	}
442469
public void deleteToken(String token, DeleteTokenHandler handler) {
        HMSAgentLog.i("deleteToken:token:" + StrUtils.objDesc(token) + " handler=" + StrUtils.objDesc(handler));
        this.token = token;
        this.handler = handler;
        connect();
    }
1021155
public void invalidate(String sessionId) {
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
            StringBuffer sb = new StringBuffer("for app ").append(_sap.getAppName()).append(" id ").append(sessionId);
            LoggingUtil.SESSION_LOGGER_CORE.entering(methodClassName, methodNames[INVALIDATE], sb.toString());
        }
        ISession iSess = _coreHttpSessionManager.getISession(sessionId);

        if (iSess != null) {
            IStore iStore = _coreHttpSessionManager.getIStore();
            try {
                iStore.setThreadContext();
                synchronized (iSess) { // START PM47941
                    if (iSess.isValid()) {
                        iSess.invalidate();
                    }
                } // END PM47941
            } finally {
                iStore.unsetThreadContext();
            }
        }
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
            LoggingUtil.SESSION_LOGGER_CORE.exiting(methodClassName, methodNames[INVALIDATE]);
        }
    }
57771
public void doLogout( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
        String user = getAuthentication().getName();
        securityRealm.doLogout(req, rsp);
        SecurityListener.fireLoggedOut(user);
    }
6652
protected function validateIdToken($idToken) {
        $segments = explode('.', $idToken);
        if (count($segments) != 3) {
            throw new InvalidIdTokenException('Invalid Token');
        }
        $header = json_decode($this->decodeBase64Url($segments[0]), true);
        if (empty($header)) {
            throw new InvalidIdTokenException('Invalid Token');
        }
        $payload = json_decode($this->decodeBase64Url($segments[1]), true);
        if (empty($payload)) {
            throw new InvalidIdTokenException('Invalid Token');
        }
        $signature = $this->decodeBase64Url($segments[2]);

        $signingInput = implode('.', array($segments[0], $segments[1]));
        $kid = isset($header['kid']) ? $header['kid'] : null;
        switch ($header['alg']) {
            case 'RS256':
            case 'RS384':
            case 'RS512':
                // 署名検証用に公開鍵を取得する
                $publicKey = $this->getPublicKey($kid);

                $algo = 'sha' . substr($header['alg'], 2);
                if (openssl_verify($signingInput, $signature, $publicKey, $algo) != 1) {
                    openssl_free_key($publicKey);
                    throw new InvalidIdTokenException('Signature Mismatch');
                }
                openssl_free_key($publicKey);
                break;
            default:
                throw new InvalidIdTokenException('Unsupported Algorithm: ' . $header['alg']);
        }

        // Check Issuer
        if ($payload['iss'] != 'minecraft.jp') {
            throw new InvalidIdTokenException('Invalid Issuer.');
        }

        // Check Client Id
        if ($payload['aud'] != $this->getClientId()) {
            throw new InvalidIdTokenException('Client ID Mismatch.');
        }

        // Check expired
        $now = time();
        if ($payload['exp'] < $now || $payload['iat'] < $now - 600) {
            throw new InvalidIdTokenException('ID Token expired.');
        }

        // Check nonce
        if ($payload['nonce'] != $this->sessionStorage->read('nonce')) {
            throw new InvalidIdTokenException('Nonce Mismatch.');
        }

        $this->sessionStorage->remove('nonce');

        return $payload;
    }
869513
public function logout($authToken)
    {
        // get user from firewall
        $this->security($this->fwName)->getToken()->setTokenString($authToken);
        $user = $this->security($this->fwName)->getUser();
        if (!$user->isAuthenticated()) {
            throw new LoginException('User is not authenticated', 6);
        }

        // extract username
        $this->username = $user->getUsername();

        // logout on firewall
        $this->security($this->fwName)->processLogout();

        // delete the session
        $this->revokeSessions($this->username, $authToken);
    }
463172
public synchronized void invalidate(boolean appInvoked) {
        if (com.ibm.websphere.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINE)) {
            LoggingUtil.SESSION_LOGGER_WAS.entering(methodClassName, methodNames[INVALIDATE], appInvoked);
        }
        getSwappableListeners(BackedSession.HTTP_SESSION_BINDING_LISTENER);
        if (appInvoked && (!invalInProgress) && isValid())
            _storeCallback.sessionCacheDiscard(this);
        super.invalidate();
        //The session will be invalid, but do we need to worry about these in case we are already processing this session somewhere else?
        if (this.appDataChanges != null)
            this.appDataChanges.clear();
        if (this.appDataRemovals != null)
            this.appDataRemovals.clear();
        this.update = null;
        this.userWriteHit = false;
        this.maxInactWriteHit = false;
        this.listenCntHit = false;
        setSwappableData(null);
        this.mNonswappableData = null;
        if (com.ibm.websphere.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINE)) {
            LoggingUtil.SESSION_LOGGER_WAS.exiting(methodClassName, methodNames[INVALIDATE]);
        }
    }
807792
public boolean isSessionValid( final String token, long validityPeriod ) {

		boolean valid = false;
		Long loginTime = null;
		if( token != null )
			loginTime = this.tokenToLoginTime.get( token );

		if( validityPeriod < 0 ) {
			valid = loginTime != null;

		} else if( loginTime != null ) {
			long now = new Date().getTime();
			valid = (now - loginTime) <= validityPeriod * 1000;

			// Invalid sessions should be deleted
			if( ! valid )
				logout( token );
		}

		return valid;
	}