// RequestedAttachedReference
RequestedReferenceType requestedReferenceType = WS_TRUST_FACTORY
.createRequestedReferenceType();
SecurityTokenReferenceType securityTokenReferenceType = WSSE_FACTORY
.createSecurityTokenReferenceType();
KeyIdentifierType keyIdentifierType = WSSE_FACTORY
.createKeyIdentifierType();
keyIdentifierType.setValue(tokenId);
JAXBElement<KeyIdentifierType> keyIdentifier = WSSE_FACTORY
.createKeyIdentifier(keyIdentifierType);
if (WSConstants.WSS_SAML_TOKEN_TYPE.equals(tokenType)
|| WSConstants.SAML_NS.equals(tokenType)) {
securityTokenReferenceType.getOtherAttributes().put(
TOKEN_TYPE, WSConstants.WSS_SAML_TOKEN_TYPE
);
keyIdentifierType.setValueType(WSConstants.WSS_SAML_KI_VALUE_TYPE);
} else if (WSConstants.WSS_SAML2_TOKEN_TYPE.equals(tokenType)
|| WSConstants.SAML2_NS.equals(tokenType)) {
securityTokenReferenceType.getOtherAttributes().put(
TOKEN_TYPE, WSConstants.WSS_SAML2_TOKEN_TYPE
);
keyIdentifierType.setValueType(WSConstants.WSS_SAML2_KI_VALUE_TYPE);
}
securityTokenReferenceType.getAny().add(keyIdentifier);
requestedReferenceType
.setSecurityTokenReference(securityTokenReferenceType);