Soap 1.2 Response envelope using open saml

16 views Asked by At

I am trying to provide SSO support with WS-Trust protocol and the target application requires SOAP 1.2 and Opensaml SOAP builder seems to have only SOAP 1.1 , is there any alternatives to built SOAP1.2 Response. SAML SOAP response the target application accepts.

<s:Envelope
    xmlns:s="http://www.w3.org/2003/05/soap-envelope"
    xmlns:a="http://www.w3.org/2005/08/addressing"
    xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    <s:Header>
        <a:Action s:mustUnderstand="1">http://docs.oasis-open.org/ws-sx/ws-trust/200512/RSTRC/IssueFinal</a:Action>
        <a:RelatesTo>urn:uuid:A9990D34-0804-4A61-B486-36B55AA1937F</a:RelatesTo>
        <o:Security s:mustUnderstand="1"
            xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
            <u:Timestamp u:Id="_0">
                <u:Created>2024-02-06T07:13:46.347Z</u:Created>
                <u:Expires>2024-02-06T07:18:46.347Z</u:Expires>
            </u:Timestamp>
        </o:Security>
    </s:Header>

Response i generated using Opensaml library

?xml version="1.0" encoding="UTF-8" standalone="no"?>
<soap11:Envelope
    xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/">
    <soap11:Header>
        <wsa:Action
            xmlns:wsa="http://www.w3.org/2005/08/addressing">http://docs.oasis-open.org/ws-sx/ws-trust/200512/RSTRC/IssueFinal
        </wsa:Action>
        <wsa:RelatesTo
            xmlns:wsa="http://www.w3.org/2005/08/addressing" RelationshipType="http://www.w3.org/2005/08/addressing/reply">Test@123
        </wsa:RelatesTo>
        <wsse:Security
            xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
            <wsu:Timestamp
                xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
                <wsu:Created>2024-03-13T13:21:34.976Z</wsu:Created>
                <wsu:Expires>2024-03-13T13:26:34.976Z</wsu:Expires>
            </wsu:Timestamp>
        </wsse:Security>
    </soap11:Header>

Java code that i used

import org.opensaml.ws.soap.soap11.Body;
import org.opensaml.ws.soap.soap11.Envelope;
import org.opensaml.ws.soap.soap11.Header;
import org.opensaml.ws.soap.soap11.impl.BodyBuilder;
import org.opensaml.ws.soap.soap11.impl.EnvelopeBuilder;
import org.opensaml.ws.soap.soap11.impl.HeaderBuilder;
/// other codes
   Envelope envelope = new EnvelopeBuilder().buildObject();
           
            // Building Header element
            Header header = new HeaderBuilder().buildObject();

            Action action = new ActionBuilder().buildObject();
            action.setValue(org.opensaml.ws.wstrust.WSTrustConstants.WSA_ACTION_RSTRC_ISSUE_FINAL);
            RelatesTo relatesTo = new RelatesToBuilder().buildObject();
            relatesTo.setValue(soapRequestValues.getString(SOAP_REQ_MESSAGEID));

            // Security Object
            Security security = new SecurityBuilder().buildObject();
            Timestamp timestamp = new TimestampBuilder().buildObject();
            Created created = new CreatedBuilder().buildObject();
            created.setDateTime(new DateTime());
            Expires expires = new ExpiresBuilder().buildObject();
            expires.setDateTime(new DateTime().plusMinutes(5));
            timestamp.setCreated(created);
            timestamp.setExpires(expires);
            security.getUnknownXMLObjects().add(timestamp);

            header.getUnknownXMLObjects().add(action);
            header.getUnknownXMLObjects().add(relatesTo);
            header.getUnknownXMLObjects().add(security);
             envelope.setHeader(header);
// body element code

Note the response contains body also ignored to avoid sensitive data.

0

There are 0 answers