if (object instanceof JAXBElement) {
object = ((JAXBElement<?>) object).getValue();
}
KeyInfoType keyInfoType = null;
if (object instanceof X509DataType) {
JAXBElement<X509DataType> x509DataTypeJAXBElement =
new org.apache.xml.security.binding.xmldsig.ObjectFactory().createX509Data((X509DataType) object);
keyInfoType = new KeyInfoType();
SecurityTokenReferenceType securityTokenReferenceType = new SecurityTokenReferenceType();
securityTokenReferenceType.getAny().add(x509DataTypeJAXBElement);
JAXBElement<SecurityTokenReferenceType> securityTokenReferenceTypeJAXBElement =
new ObjectFactory().createSecurityTokenReference(securityTokenReferenceType);
keyInfoType.getContent().add(securityTokenReferenceTypeJAXBElement);
} else if (object instanceof EncryptedKeyType) {
EncryptedKeyType encryptedKeyType = (EncryptedKeyType) object;
WSSEncryptedKeyInputHandler encryptedKeyInputHandler = new WSSEncryptedKeyInputHandler();
encryptedKeyInputHandler.handle(inputProcessorChain, encryptedKeyType, xmlSecStartElement, securityProperties);
SecurityTokenProvider<? extends InboundSecurityToken> securityTokenProvider =
inputProcessorChain.getSecurityContext().getSecurityTokenProvider(encryptedKeyType.getId());
if (securityTokenProvider != null) {
return securityTokenProvider.getSecurityToken();
}
} else if (object instanceof SecurityTokenReferenceType) {
JAXBElement<SecurityTokenReferenceType> securityTokenReferenceTypeJAXBElement =
new ObjectFactory().createSecurityTokenReference((SecurityTokenReferenceType) object);
keyInfoType = new KeyInfoType();
keyInfoType.getContent().add(securityTokenReferenceTypeJAXBElement);
} else if (object instanceof KeyValueType) {
JAXBElement<KeyValueType> keyValueTypeJAXBElement =
new org.apache.xml.security.binding.xmldsig.ObjectFactory().createKeyValue((KeyValueType) object);
keyInfoType = new KeyInfoType();
keyInfoType.getContent().add(keyValueTypeJAXBElement);
} else {
throw new WSSecurityException(WSSecurityException.ErrorCode.UNSUPPORTED_SECURITY_TOKEN, "unsupportedKeyInfo");
}
return SecurityTokenFactory.getInstance().getSecurityToken(