Search in sources :

Example 1 with EncryptedKeyType

use of org.apache.xml.security.binding.xmlenc.EncryptedKeyType in project santuario-java by apache.

the class AbstractDecryptInputProcessor method getSecurityToken.

private InboundSecurityToken getSecurityToken(InputProcessorChain inputProcessorChain, XMLSecStartElement xmlSecStartElement, EncryptedDataType encryptedDataType) throws XMLSecurityException {
    KeyInfoType keyInfoType = this.keyInfoType;
    if (keyInfoType == null) {
        keyInfoType = encryptedDataType.getKeyInfo();
    }
    if (keyInfoType != null) {
        final EncryptedKeyType encryptedKeyType = XMLSecurityUtils.getQNameType(keyInfoType.getContent(), XMLSecurityConstants.TAG_xenc_EncryptedKey);
        if (encryptedKeyType != null) {
            XMLEncryptedKeyInputHandler handler = new XMLEncryptedKeyInputHandler();
            handler.handle(inputProcessorChain, encryptedKeyType, xmlSecStartElement, getSecurityProperties());
            SecurityTokenProvider<? extends InboundSecurityToken> securityTokenProvider = inputProcessorChain.getSecurityContext().getSecurityTokenProvider(encryptedKeyType.getId());
            return securityTokenProvider.getSecurityToken();
        }
    }
    // retrieve the securityToken which must be used for decryption
    return SecurityTokenFactory.getInstance().getSecurityToken(keyInfoType, SecurityTokenConstants.KeyUsage_Decryption, getSecurityProperties(), inputProcessorChain.getSecurityContext());
}
Also used : EncryptedKeyType(org.apache.xml.security.binding.xmlenc.EncryptedKeyType) KeyInfoType(org.apache.xml.security.binding.xmldsig.KeyInfoType)

Example 2 with EncryptedKeyType

use of org.apache.xml.security.binding.xmlenc.EncryptedKeyType in project santuario-java by apache.

the class XMLEncryptedKeyInputHandler method handle.

@Override
public void handle(final InputProcessorChain inputProcessorChain, final XMLSecurityProperties securityProperties, final Deque<XMLSecEvent> eventQueue, final Integer index) throws XMLSecurityException {
    @SuppressWarnings("unchecked") final EncryptedKeyType encryptedKeyType = ((JAXBElement<EncryptedKeyType>) parseStructure(eventQueue, index, securityProperties)).getValue();
    final XMLSecEvent responsibleXMLSecStartXMLEvent = getResponsibleStartXMLEvent(eventQueue, index);
    handle(inputProcessorChain, encryptedKeyType, responsibleXMLSecStartXMLEvent, securityProperties);
}
Also used : EncryptedKeyType(org.apache.xml.security.binding.xmlenc.EncryptedKeyType) JAXBElement(javax.xml.bind.JAXBElement) XMLSecEvent(org.apache.xml.security.stax.ext.stax.XMLSecEvent)

Aggregations

EncryptedKeyType (org.apache.xml.security.binding.xmlenc.EncryptedKeyType)2 JAXBElement (javax.xml.bind.JAXBElement)1 KeyInfoType (org.apache.xml.security.binding.xmldsig.KeyInfoType)1 XMLSecEvent (org.apache.xml.security.stax.ext.stax.XMLSecEvent)1