Source:
public void handleMessage(Message message) throws Fault { AssertionInfoMap aim = message.get(AssertionInfoMap.class); if (aim == null) { return; } Collection<AssertionInfo> ais = getAllAssertionsByLocalname(aim, SPConstants.ISSUED_TOKEN); if (ais == null) { return; } IssuedToken itok = (IssuedToken) ais.iterator().next().getAssertion(); SecurityToken token = (SecurityToken) message.getContextualProperty(SecurityConstants.TOKEN); boolean shouldRequestNewToken = false; if (token == null && itok == null) { return; } SecurityAssertion securityAssertion = new SecurityAssertionImpl(token); Element requestSecurityTokenTemplate = itok.getRequestSecurityTokenTemplate(); List<AttributeStatement> attributeStatements = securityAssertion.getAttributeStatements(); XMLStreamReader xmlStreamReader = StaxUtils.createXMLStreamReader(requestSecurityTokenTemplate); try { while (xmlStreamReader.hasNext()) { int event = xmlStreamReader.next(); switch (event) { case XMLStreamConstants.START_ELEMENT: { String localName = xmlStreamReader.getLocalName(); String elementText; switch (localName) { case "TokenType": elementText = xmlStreamReader.getElementText(); shouldRequestNewToken = shouldRequestNewTokenFromTokenType(securityAssertion, elementText); break; case "KeyType": elementText = xmlStreamReader.getElementText(); shouldRequestNewToken = shouldRequestNewTokenFromKeyType(securityAssertion, elementText); break; case "ClaimType": int attributeCount = xmlStreamReader.getAttributeCount(); shouldRequestNewToken = shouldRequestNewTokenFromClaimType( attributeStatements, xmlStreamReader, attributeCount); break; } } } } } catch (XMLStreamException e) { throw new Fault(e); } if (shouldRequestNewToken) { message.put(SecurityConstants.TOKEN, null); message.put(SecurityConstants.STS_TOKEN_ON_BEHALF_OF, token.getToken()); } }

Target:
public void handleMessage(Message message) throws Fault { AssertionInfoMap aim = message.get(AssertionInfoMap.class); if (aim == null) { return; } Collection<AssertionInfo> ais = getAllAssertionsByLocalname(aim, SPConstants.ISSUED_TOKEN); if (ais == null) { return; } IssuedToken itok = (IssuedToken) ais.iterator().next().getAssertion(); SecurityToken token = (SecurityToken) message.getContextualProperty(SecurityConstants.TOKEN); boolean shouldRequestNewToken = false; if (token == null || itok == null) { return; } SecurityAssertion securityAssertion = new SecurityAssertionImpl(token); Element requestSecurityTokenTemplate = itok.getRequestSecurityTokenTemplate(); List<AttributeStatement> attributeStatements = securityAssertion.getAttributeStatements(); XMLStreamReader xmlStreamReader = StaxUtils.createXMLStreamReader(requestSecurityTokenTemplate); try { while (xmlStreamReader.hasNext()) { int event = xmlStreamReader.next(); switch (event) { case XMLStreamConstants.START_ELEMENT: { String localName = xmlStreamReader.getLocalName(); String elementText; switch (localName) { case "TokenType": elementText = xmlStreamReader.getElementText(); shouldRequestNewToken = shouldRequestNewTokenFromTokenType(securityAssertion, elementText); break; case "KeyType": elementText = xmlStreamReader.getElementText(); shouldRequestNewToken = shouldRequestNewTokenFromKeyType(securityAssertion, elementText); break; case "ClaimType": int attributeCount = xmlStreamReader.getAttributeCount(); shouldRequestNewToken = shouldRequestNewTokenFromClaimType( attributeStatements, xmlStreamReader, attributeCount); break; } } } } } catch (XMLStreamException e) { throw new Fault(e); } if (shouldRequestNewToken) { message.put(SecurityConstants.TOKEN, null); message.put(SecurityConstants.STS_TOKEN_ON_BEHALF_OF, token.getToken()); } }