Source:
private SAMLAuthenticationToken renewSecurityToken( HttpSession session, SAMLAuthenticationToken savedToken) throws ServletException, WSSecurityException { if (session != null) { SecurityAssertion savedAssertion = new SecurityAssertionImpl(((SecurityToken) savedToken.getCredentials())); if (savedAssertion.getIssuer() != null && !savedAssertion.getIssuer().equals(SystemBaseUrl.EXTERNAL.getHost())) { return null; } if (savedAssertion.getNotOnOrAfter() == null) { return null; } long afterMil = savedAssertion.getNotOnOrAfter().getTime(); long timeoutMillis = (afterMil - System.currentTimeMillis()); if (timeoutMillis <= 0) { throw new InvalidSAMLReceivedException("SAML assertion has expired."); } if (timeoutMillis <= 60000) { try { LOGGER.debug("Attempting to refresh user's SAML assertion."); Subject subject = securityManager.getSubject(savedToken); LOGGER.debug("Refresh of user assertion successful"); for (Object principal : subject.getPrincipals()) { if (principal instanceof SecurityAssertion) { SecurityToken token = ((SecurityAssertion) principal).getSecurityToken(); SAMLAuthenticationToken samlAuthenticationToken = new SAMLAuthenticationToken( (java.security.Principal) savedToken.getPrincipal(), token, savedToken.getRealm()); if (LOGGER.isTraceEnabled()) { LOGGER.trace( "Setting session token - class: classloader: {}", token.getClass().getName(), token.getClass().getClassLoader()); } ((SecurityTokenHolder) session.getAttribute(SecurityConstants.SAML_ASSERTION)) .addSecurityToken(savedToken.getRealm(), token); LOGGER.debug("Saved new user assertion to session."); return samlAuthenticationToken; } } } catch (SecurityServiceException e) { LOGGER.debug( "Unable to refresh user's SAML assertion. User will log out prematurely.", e); session.invalidate(); } catch (Exception e) { LOGGER.info("Unhandled exception occurred.", e); session.invalidate(); } } } return null; }

Target:
private SAMLAuthenticationToken renewSecurityToken( HttpSession session, SAMLAuthenticationToken savedToken) throws ServletException, WSSecurityException { if (session != null) { SecurityAssertion savedAssertion = new SecurityAssertionImpl(((SecurityToken) savedToken.getCredentials())); if (savedAssertion.getIssuer() != null && !savedAssertion.getIssuer().equals(SystemBaseUrl.INTERNAL.getHost())) { return null; } if (savedAssertion.getNotOnOrAfter() == null) { return null; } long afterMil = savedAssertion.getNotOnOrAfter().getTime(); long timeoutMillis = (afterMil - System.currentTimeMillis()); if (timeoutMillis <= 0) { throw new InvalidSAMLReceivedException("SAML assertion has expired."); } if (timeoutMillis <= 60000) { try { LOGGER.debug("Attempting to refresh user's SAML assertion."); Subject subject = securityManager.getSubject(savedToken); LOGGER.debug("Refresh of user assertion successful"); for (Object principal : subject.getPrincipals()) { if (principal instanceof SecurityAssertion) { SecurityToken token = ((SecurityAssertion) principal).getSecurityToken(); SAMLAuthenticationToken samlAuthenticationToken = new SAMLAuthenticationToken( (java.security.Principal) savedToken.getPrincipal(), token, savedToken.getRealm()); if (LOGGER.isTraceEnabled()) { LOGGER.trace( "Setting session token - class: classloader: {}", token.getClass().getName(), token.getClass().getClassLoader()); } ((SecurityTokenHolder) session.getAttribute(SecurityConstants.SAML_ASSERTION)) .addSecurityToken(savedToken.getRealm(), token); LOGGER.debug("Saved new user assertion to session."); return samlAuthenticationToken; } } } catch (SecurityServiceException e) { LOGGER.debug( "Unable to refresh user's SAML assertion. User will log out prematurely.", e); session.invalidate(); } catch (Exception e) { LOGGER.info("Unhandled exception occurred.", e); session.invalidate(); } } } return null; }