diff options
Diffstat (limited to 'modules/authmodule-eIDAS-v2/src/main/java')
-rw-r--r-- | modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/BmiSoapTransactionHeaderInterceptor.java | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/BmiSoapTransactionHeaderInterceptor.java b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/BmiSoapTransactionHeaderInterceptor.java index 86568796..d1de827b 100644 --- a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/BmiSoapTransactionHeaderInterceptor.java +++ b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/BmiSoapTransactionHeaderInterceptor.java @@ -25,7 +25,14 @@ import lombok.extern.slf4j.Slf4j; */ @Slf4j public class BmiSoapTransactionHeaderInterceptor implements SOAPHandler<SOAPMessageContext> { - private static final String ELEMENT = "Client-Request-Id"; + private static final String AUTH_NS = "http://schemas.xmlsoap.org/ws/2002/04/secext"; + private static final String AUTH_PREFIX = "wss"; + private static final String AUTH_ELEMENT = "Security"; + + + private static final String TRANS_ID_NS = "http://egov.gv.at/pvp1.xsd"; + private static final String TRANS_IDPREFIX = "pvp"; + private static final String TRANS_ID_ELEMENT = "Client-Request-Id"; @Override public boolean handleMessage(SOAPMessageContext context) { @@ -64,11 +71,15 @@ public class BmiSoapTransactionHeaderInterceptor implements SOAPHandler<SOAPMess try { SOAPMessage message = context.getMessage(); SOAPEnvelope envelope = message.getSOAPPart().getEnvelope(); - SOAPFactory soapFactory = SOAPFactory.newInstance(); + SOAPFactory soapFactory = SOAPFactory.newInstance(); + + // Creating WS-Security header element + SOAPElement wsSecHeaderElement = soapFactory.createElement(AUTH_ELEMENT, AUTH_PREFIX, AUTH_NS); - // create header element - SOAPElement transactionIdElm = soapFactory.createElement(ELEMENT); - transactionIdElm.setTextContent(TransactionIdUtils.getTransactionId()); + // create transactionId element + SOAPElement transactionIdElement = soapFactory.createElement(TRANS_ID_ELEMENT, TRANS_IDPREFIX, TRANS_ID_NS); + transactionIdElement.setTextContent(TransactionIdUtils.getTransactionId()); + wsSecHeaderElement.addChildElement(transactionIdElement); // inject header SOAPHeader header = envelope.getHeader(); @@ -76,7 +87,7 @@ public class BmiSoapTransactionHeaderInterceptor implements SOAPHandler<SOAPMess header = envelope.addHeader(); } - header.addChildElement(transactionIdElm); + header.addChildElement(wsSecHeaderElement); } catch (Exception e) { log.warn("Can NOT inject TransactionId into SOAP message. Sending message without Id ...", e); @@ -84,4 +95,4 @@ public class BmiSoapTransactionHeaderInterceptor implements SOAPHandler<SOAPMess } } -} +}
\ No newline at end of file |