/** * Creates and configures an inbound streaming security engine * * @param securityProperties The user-defined security configuration * @return A new InboundWSSec * @throws XMLSecurityException * if the initialisation failed * @throws org.apache.xml.security.stax.ext.XMLSecurityConfigurationException * if the configuration is invalid */ public static InboundXMLSec getInboundWSSec(XMLSecurityProperties securityProperties) throws XMLSecurityException { if (securityProperties == null) { throw new XMLSecurityConfigurationException("stax.missingSecurityProperties"); } securityProperties = validateAndApplyDefaultsToInboundSecurityProperties(securityProperties); return new InboundXMLSec(securityProperties); }
/** * Creates and configures an outbound streaming security engine * * @param securityProperties The user-defined security configuration * @return A new OutboundXMLSec * @throws XMLSecurityException * if the initialisation failed * @throws org.apache.xml.security.stax.ext.XMLSecurityConfigurationException * if the configuration is invalid */ public static OutboundXMLSec getOutboundXMLSec(XMLSecurityProperties securityProperties) throws XMLSecurityException { if (securityProperties == null) { throw new XMLSecurityConfigurationException("stax.missingSecurityProperties"); } securityProperties = validateAndApplyDefaultsToOutboundSecurityProperties(securityProperties); return new OutboundXMLSec(securityProperties); }
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 | XMLSecurityException | IOException | UnsupportedCallbackException e) { throwFault(e.getMessage(), e); } }
OutboundXMLSec outboundXMLSec = XMLSec.getOutboundXMLSec(properties);
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 | XMLSecurityException | IOException | UnsupportedCallbackException e) { throwFault(e.getMessage(), e); } }
OutboundXMLSec outboundXMLSec = XMLSec.getOutboundXMLSec(properties);