Search in sources :

Example 1 with TokenSecurityEvent

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

the class XmlSecInInterceptor method configureSecurityEventListener.

protected SecurityEventListener configureSecurityEventListener(final Crypto sigCrypto, final Message msg, XMLSecurityProperties securityProperties) {
    final List<SecurityEvent> incomingSecurityEventList = new LinkedList<>();
    SecurityEventListener securityEventListener = new SecurityEventListener() {

        @Override
        public void registerSecurityEvent(SecurityEvent securityEvent) throws XMLSecurityException {
            if (securityEvent.getSecurityEventType() == SecurityEventConstants.AlgorithmSuite) {
                if (encryptionProperties != null) {
                    checkEncryptionAlgorithms((AlgorithmSuiteSecurityEvent) securityEvent);
                }
                if (sigProps != null) {
                    checkSignatureAlgorithms((AlgorithmSuiteSecurityEvent) securityEvent);
                }
            } else if (securityEvent.getSecurityEventType() != SecurityEventConstants.EncryptedKeyToken && securityEvent instanceof TokenSecurityEvent<?>) {
                checkSignatureTrust(sigCrypto, msg, (TokenSecurityEvent<?>) securityEvent);
            }
            incomingSecurityEventList.add(securityEvent);
        }
    };
    msg.getExchange().put(SecurityEvent.class.getName() + ".in", incomingSecurityEventList);
    msg.put(SecurityEvent.class.getName() + ".in", incomingSecurityEventList);
    return securityEventListener;
}
Also used : AlgorithmSuiteSecurityEvent(org.apache.xml.security.stax.securityEvent.AlgorithmSuiteSecurityEvent) TokenSecurityEvent(org.apache.xml.security.stax.securityEvent.TokenSecurityEvent) SecurityEvent(org.apache.xml.security.stax.securityEvent.SecurityEvent) TokenSecurityEvent(org.apache.xml.security.stax.securityEvent.TokenSecurityEvent) LinkedList(java.util.LinkedList) SecurityEventListener(org.apache.xml.security.stax.securityEvent.SecurityEventListener)

Example 2 with TokenSecurityEvent

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

the class WSS4JStaxOutInterceptor method configureSecurityEventListener.

protected SecurityEventListener configureSecurityEventListener(final SoapMessage msg, WSSSecurityProperties securityProperties) throws WSSPolicyException {
    final List<SecurityEvent> outgoingSecurityEventList = new LinkedList<>();
    msg.getExchange().put(SecurityEvent.class.getName() + ".out", outgoingSecurityEventList);
    msg.put(SecurityEvent.class.getName() + ".out", outgoingSecurityEventList);
    return new SecurityEventListener() {

        @Override
        public void registerSecurityEvent(SecurityEvent securityEvent) throws XMLSecurityException {
            if (securityEvent.getSecurityEventType() == WSSecurityEventConstants.SAML_TOKEN) {
                // Store SAML keys in case we need them on the inbound side
                TokenSecurityEvent<?> tokenSecurityEvent = (TokenSecurityEvent<?>) securityEvent;
                try {
                    WSS4JUtils.parseAndStoreStreamingSecurityToken(tokenSecurityEvent.getSecurityToken(), msg);
                } catch (TokenStoreException e) {
                    throw new XMLSecurityException(e);
                }
            } else if (securityEvent.getSecurityEventType() == WSSecurityEventConstants.SignatureValue) {
                // Required for Signature Confirmation
                outgoingSecurityEventList.add(securityEvent);
            }
        }
    };
}
Also used : TokenSecurityEvent(org.apache.xml.security.stax.securityEvent.TokenSecurityEvent) SecurityEvent(org.apache.xml.security.stax.securityEvent.SecurityEvent) TokenSecurityEvent(org.apache.xml.security.stax.securityEvent.TokenSecurityEvent) TokenStoreException(org.apache.cxf.ws.security.tokenstore.TokenStoreException) LinkedList(java.util.LinkedList) SecurityEventListener(org.apache.xml.security.stax.securityEvent.SecurityEventListener) XMLSecurityException(org.apache.xml.security.exceptions.XMLSecurityException)

Aggregations

LinkedList (java.util.LinkedList)2 SecurityEvent (org.apache.xml.security.stax.securityEvent.SecurityEvent)2 SecurityEventListener (org.apache.xml.security.stax.securityEvent.SecurityEventListener)2 TokenSecurityEvent (org.apache.xml.security.stax.securityEvent.TokenSecurityEvent)2 TokenStoreException (org.apache.cxf.ws.security.tokenstore.TokenStoreException)1 XMLSecurityException (org.apache.xml.security.exceptions.XMLSecurityException)1 AlgorithmSuiteSecurityEvent (org.apache.xml.security.stax.securityEvent.AlgorithmSuiteSecurityEvent)1