@Override
public void handle(final InputProcessorChain inputProcessorChain, final XMLSecurityProperties securityProperties,
Deque<XMLSecEvent> eventQueue, Integer index) throws XMLSecurityException {
@SuppressWarnings("unchecked")
final SecurityTokenReferenceType securityTokenReferenceType =
((JAXBElement<SecurityTokenReferenceType>) parseStructure(eventQueue, index, securityProperties)).getValue();
QName attributeName = null;
String attributeValue = null;
final KeyIdentifierType keyIdentifierType = XMLSecurityUtils.getQNameType(
securityTokenReferenceType.getAny(), WSSConstants.TAG_wsse_KeyIdentifier);
if (keyIdentifierType != null) {
attributeValue = keyIdentifierType.getValue().trim();
if (WSSConstants.NS_SAML10_TYPE.equals(keyIdentifierType.getValueType())) {
attributeName = WSSConstants.ATT_NULL_AssertionID;
} else if (WSSConstants.NS_SAML20_TYPE.equals(keyIdentifierType.getValueType())) {
attributeName = WSSConstants.ATT_NULL_ID;
}
}
final ReferenceType referenceType = XMLSecurityUtils.getQNameType(
securityTokenReferenceType.getAny(), WSSConstants.TAG_wsse_Reference);
if (referenceType != null) {
attributeValue = WSSUtils.dropReferenceMarker(referenceType.getURI());
if (WSSConstants.NS_SAML10_TYPE.equals(referenceType.getValueType())) {
attributeName = WSSConstants.ATT_NULL_AssertionID;
} else if (WSSConstants.NS_SAML20_TYPE.equals(referenceType.getValueType())) {
attributeName = WSSConstants.ATT_NULL_ID;
}
}
if (attributeName != null) {
InternalSecurityTokenReferenceInputProcessor internalSecurityTokenReferenceInputHandler
= new InternalSecurityTokenReferenceInputProcessor(
securityTokenReferenceType.getId(), attributeName,
attributeValue, (WSSSecurityProperties) securityProperties);
inputProcessorChain.addProcessor(internalSecurityTokenReferenceInputHandler);
} else {
throw new WSSecurityException(WSSecurityException.ErrorCode.UNSUPPORTED_SECURITY_TOKEN);
}