Search in sources :

Example 6 with SecurityEventListener

use of org.apache.xml.security.stax.securityEvent.SecurityEventListener in project cxf by apache.

the class PolicyBasedWSS4JStaxInInterceptor method configureSecurityEventListeners.

@Override
protected List<SecurityEventListener> configureSecurityEventListeners(SoapMessage msg, WSSSecurityProperties securityProperties) throws WSSPolicyException {
    final List<SecurityEventListener> securityEventListeners = new ArrayList<>(2);
    securityEventListeners.addAll(super.configureSecurityEventListeners(msg, securityProperties));
    Endpoint endoint = msg.getExchange().getEndpoint();
    PolicyEnforcer policyEnforcer = createPolicyEnforcer(endoint.getEndpointInfo(), msg);
    securityProperties.addInputProcessor(new PolicyInputProcessor(policyEnforcer, securityProperties));
    securityEventListeners.add(policyEnforcer);
    return securityEventListeners;
}
Also used : PolicyInputProcessor(org.apache.wss4j.policy.stax.enforcer.PolicyInputProcessor) Endpoint(org.apache.cxf.endpoint.Endpoint) ArrayList(java.util.ArrayList) PolicyEnforcer(org.apache.wss4j.policy.stax.enforcer.PolicyEnforcer) SecurityEventListener(org.apache.xml.security.stax.securityEvent.SecurityEventListener)

Example 7 with SecurityEventListener

use of org.apache.xml.security.stax.securityEvent.SecurityEventListener in project cxf by apache.

the class XmlSecInInterceptor method prepareMessage.

private void prepareMessage(Message inMsg) throws Fault {
    XMLStreamReader originalXmlStreamReader = inMsg.getContent(XMLStreamReader.class);
    if (originalXmlStreamReader == null) {
        InputStream is = inMsg.getContent(InputStream.class);
        if (is != null) {
            originalXmlStreamReader = StaxUtils.createXMLStreamReader(is);
        }
    }
    try {
        XMLSecurityProperties properties = new XMLSecurityProperties();
        configureDecryptionKeys(inMsg, properties);
        Crypto signatureCrypto = getSignatureCrypto(inMsg);
        configureSignatureKeys(signatureCrypto, inMsg, properties);
        SecurityEventListener securityEventListener = configureSecurityEventListener(signatureCrypto, inMsg, properties);
        InboundXMLSec inboundXMLSec = XMLSec.getInboundWSSec(properties);
        XMLStreamReader newXmlStreamReader = inboundXMLSec.processInMessage(originalXmlStreamReader, null, securityEventListener);
        inMsg.setContent(XMLStreamReader.class, newXmlStreamReader);
    } catch (XMLStreamException e) {
        throwFault(e.getMessage(), e);
    } catch (XMLSecurityException e) {
        throwFault(e.getMessage(), e);
    } catch (IOException e) {
        throwFault(e.getMessage(), e);
    } catch (UnsupportedCallbackException e) {
        throwFault(e.getMessage(), e);
    }
}
Also used : Crypto(org.apache.wss4j.common.crypto.Crypto) XMLStreamReader(javax.xml.stream.XMLStreamReader) XMLStreamException(javax.xml.stream.XMLStreamException) InputStream(java.io.InputStream) XMLSecurityProperties(org.apache.xml.security.stax.ext.XMLSecurityProperties) InboundXMLSec(org.apache.xml.security.stax.ext.InboundXMLSec) IOException(java.io.IOException) UnsupportedCallbackException(javax.security.auth.callback.UnsupportedCallbackException) SecurityEventListener(org.apache.xml.security.stax.securityEvent.SecurityEventListener) XMLSecurityException(org.apache.xml.security.exceptions.XMLSecurityException)

Aggregations

SecurityEventListener (org.apache.xml.security.stax.securityEvent.SecurityEventListener)7 LinkedList (java.util.LinkedList)5 SecurityEvent (org.apache.xml.security.stax.securityEvent.SecurityEvent)5 XMLStreamException (javax.xml.stream.XMLStreamException)3 TokenSecurityEvent (org.apache.xml.security.stax.securityEvent.TokenSecurityEvent)3 List (java.util.List)2 XMLStreamReader (javax.xml.stream.XMLStreamReader)2 WSSPolicyException (org.apache.wss4j.common.WSSPolicyException)2 WSSecurityException (org.apache.wss4j.common.ext.WSSecurityException)2 WSSSecurityProperties (org.apache.wss4j.stax.ext.WSSSecurityProperties)2 XMLSecurityException (org.apache.xml.security.exceptions.XMLSecurityException)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 Provider (java.security.Provider)1 ArrayList (java.util.ArrayList)1 UnsupportedCallbackException (javax.security.auth.callback.UnsupportedCallbackException)1 XMLStreamWriter (javax.xml.stream.XMLStreamWriter)1 StreamReaderDelegate (javax.xml.stream.util.StreamReaderDelegate)1 SoapFault (org.apache.cxf.binding.soap.SoapFault)1