core/src/main/java/org/springframework/security/authentication/jaas/AbstractJaasAuthenticationProvider.java
protected void handleLogout(SessionDestroyedEvent event) {
		List<SecurityContext> contexts = event.getSecurityContexts();

		if (contexts.isEmpty()) {
			this.log.debug("The destroyed session has no SecurityContexts");

			return;
		}

		for (SecurityContext context : contexts) {
			Authentication auth = context.getAuthentication();

			if ((auth != null) && (auth instanceof JaasAuthenticationToken)) {
				JaasAuthenticationToken token = (JaasAuthenticationToken) auth;

				try {
					LoginContext loginContext = token.getLoginContext();
					boolean debug = this.log.isDebugEnabled();
					if (loginContext != null) {
						if (debug) {
							this.log.debug("Logging principal: [" + token.getPrincipal()
									+ "] out of LoginContext");
						}
						loginContext.logout();
					}
					else if (debug) {
						this.log.debug("Cannot logout principal: [" + token.getPrincipal()
								+ "] from LoginContext. "
								+ "The LoginContext is unavailable");
					}
				}
				catch (LoginException e) {
					this.log.warn("Error error logging out of LoginContext", e);
				}
			}
		}
	}
protected void handleLogout(SessionDestroyedEvent event) {
		List<SecurityContext> contexts = event.getSecurityContexts();

		if (contexts.isEmpty()) {
			this.log.debug("The destroyed session has no SecurityContexts");

			return;
		}

		for (SecurityContext context : contexts) {
			Authentication auth = context.getAuthentication();

			if ((auth != null) && (auth instanceof JaasAuthenticationToken)) {
				JaasAuthenticationToken token = (JaasAuthenticationToken) auth;

				try {
					LoginContext loginContext = token.getLoginContext();
					boolean debug = this.log.isDebugEnabled();
					if (loginContext != null) {
						if (debug) {
							this.log.debug("Logging principal: [" + token.getPrincipal()
									+ "] out of LoginContext");
						}
						loginContext.logout();
					}
					else if (debug) {
						this.log.debug("Cannot logout principal: [" + token.getPrincipal()
								+ "] from LoginContext. "
								+ "The LoginContext is unavailable");
					}
				}
				catch (LoginException e) {
					this.log.warn("Error error logging out of LoginContext", e);
				}
			}
		}
	}
protected void handleLogout ( SessionDestroyedEvent event ) { List < SecurityContext > contexts = event . getSecurityContexts ( ) ; if ( contexts . isEmpty ( ) ) { this . log . debug ( "The destroyed session has no SecurityContexts" ) ; return ; } for ( SecurityContext context : contexts ) { Authentication auth = context . getAuthentication ( ) ; if ( ( auth != null ) && ( auth instanceof JaasAuthenticationToken ) ) { JaasAuthenticationToken token = ( JaasAuthenticationToken ) auth ; try { LoginContext loginContext = token . getLoginContext ( ) ; boolean debug = this . log . isDebugEnabled ( ) ; if ( loginContext != null ) { if ( debug ) { this . log . debug ( "Logging principal: [" + token . getPrincipal ( ) + "] out of LoginContext" ) ; } loginContext . logout ( ) ; } else if ( debug ) { this . log . debug ( "Cannot logout principal: [" + token . getPrincipal ( ) + "] from LoginContext. " + "The LoginContext is unavailable" ) ; } } catch ( LoginException e ) { this . log . warn ( "Error error logging out of LoginContext" , e ) ; } } } }
Handles the logout by getting the security contexts for the destroyed session and
invoking {@code LoginContext.logout()} for any which contain a
{@code JaasAuthenticationToken}.


@param event the session event which contains the current session
Handles the logout by getting the security contexts for the destroyed session and invoking { @code LoginContext . logout () } for any which contain a { @code JaasAuthenticationToken } .