diff --git a/ballerina/modules/soap11/soap11.bal b/ballerina/modules/soap11/soap11.bal index 74e8c57..5738b71 100644 --- a/ballerina/modules/soap11/soap11.bal +++ b/ballerina/modules/soap11/soap11.bal @@ -71,7 +71,7 @@ public isolated client class Client { xml mimeEntity = body is xml ? body : check body[0].getXml(); lock { xml envelope = body is xml ? body.clone() : mimeEntity.clone(); - securedBody = check soap:applySecurityPolicies(self.inboundSecurity.clone(), envelope.clone()); + securedBody = check soap:applySecurityPolicies(self.inboundSecurity.clone(), envelope.clone(), false); } xml|mime:Entity[] response; if body is mime:Entity[] { @@ -85,10 +85,10 @@ public isolated client class Client { do { if outboundSecurity is wssec:OutboundSecurityConfig && outboundSecurity != {} { if response is xml { - return check soap:applyOutboundConfig(outboundSecurity.clone(), response.clone()); + return check soap:applyOutboundConfig(outboundSecurity.clone(), response.clone(), false); } else { return check soap:applyOutboundConfig(outboundSecurity.clone(), - check response[0].getXml().clone()); + check response[0].getXml().clone(), false); } } } on fail var e { @@ -119,7 +119,7 @@ public isolated client class Client { xml mimeEntity = body is xml ? body : check body[0].getXml(); lock { xml envelope = body is xml ? body.clone() : mimeEntity.clone(); - securedBody = check soap:applySecurityPolicies(self.inboundSecurity.clone(), envelope.clone()); + securedBody = check soap:applySecurityPolicies(self.inboundSecurity.clone(), envelope.clone(), false); } return check soap:sendOnly(securedBody, self.soapClient, action, headers, path, false); } on fail var e { diff --git a/ballerina/modules/soap11/tests/http_soap_service.bal b/ballerina/modules/soap11/tests/http_soap_service.bal index 0c356c5..72eb50e 100644 --- a/ballerina/modules/soap11/tests/http_soap_service.bal +++ b/ballerina/modules/soap11/tests/http_soap_service.bal @@ -63,14 +63,14 @@ service / on new http:Listener(9090) { signatureAlgorithm: soap:RSA_SHA256, decryptionAlgorithm: soap:RSA_ECB, decryptionKey: serverPrivateKey - }, payload); + }, payload, false); xml securedEnv = check soap:applySecurityPolicies( { signatureAlgorithm: soap:RSA_SHA256, encryptionAlgorithm: soap:RSA_ECB, signatureKey: serverPrivateKey, encryptionKey: clientPublicKey - }, applyOutboundConfig); + }, applyOutboundConfig, false); http:Response response = new; mime:Entity[] mtomMessage = []; mime:Entity envelope = new; @@ -91,14 +91,14 @@ service / on new http:Listener(9090) { signatureAlgorithm: soap:RSA_SHA256, decryptionAlgorithm: soap:RSA_ECB, decryptionKey: serverPrivateKey - }, payload); + }, payload, false); xml securedEnv = check soap:applySecurityPolicies( { signatureAlgorithm: soap:RSA_SHA256, encryptionAlgorithm: soap:RSA_ECB, signatureKey: serverPrivateKey, encryptionKey: clientPublicKey - }, applyOutboundConfig); + }, applyOutboundConfig, false); http:Response response = new; response.setPayload(securedEnv); return response; diff --git a/ballerina/modules/soap12/tests/soap12_client_test.bal b/ballerina/modules/soap12/tests/soap12_client_test.bal index 69c11ca..331848f 100644 --- a/ballerina/modules/soap12/tests/soap12_client_test.bal +++ b/ballerina/modules/soap12/tests/soap12_client_test.bal @@ -516,7 +516,7 @@ function testSoapReceiveWithSymmetricBindingAndOutboundConfig() returns error? { } } ); - xml body = xml `23`; + xml body = xml `23`; xml|mime:Entity[] response = check soapClient->sendReceive(body, "http://tempuri.org/Add", path = "/getSamePayload"); return soap:assertSymmetricBinding(response.toString(), string `23`); } @@ -542,7 +542,7 @@ function testSendReceiveWithAsymmetricBindingAndOutboundConfig() returns error? } ); - xml body = xml `23`; + xml body = xml `23`; xml|mime:Entity[] response = check soapClient->sendReceive(body, "http://tempuri.org/Add", path = "/getSecuredPayload"); return soap:assertSymmetricBinding(response.toString(), string `23`); } diff --git a/ballerina/modules/wssec/tests/ws_security_tests.bal b/ballerina/modules/wssec/tests/ws_security_tests.bal index ffd3145..29addfa 100644 --- a/ballerina/modules/wssec/tests/ws_security_tests.bal +++ b/ballerina/modules/wssec/tests/ws_security_tests.bal @@ -211,7 +211,7 @@ function testSymmetricBindingPolicyWithSignatureOnly() returns error? { servicePublicKey: serverPublicKey }; - xml securedEnvelope = check applySymmetricBinding(envelope, symmetricBinding); + xml securedEnvelope = check applySymmetricBinding(envelope, false, symmetricBinding); string envelopeString = securedEnvelope.toString(); byte[] signedData = check getSignatureData(securedEnvelope); @@ -239,7 +239,7 @@ function testSymmetricBindingPolicyEncryptionOnly() returns error? { servicePublicKey: serverPublicKey }; - xml securedEnvelope = check applySymmetricBinding(envelope, symmetricBinding); + xml securedEnvelope = check applySymmetricBinding(envelope, false, symmetricBinding); string envelopeString = securedEnvelope.toString(); byte[] encData = check getEncryptedData(securedEnvelope); @@ -266,7 +266,7 @@ function testSymmetricBindingWithSignatureAndEncryption() returns error? { symmetricKey: symmetricKey, servicePublicKey: serverPublicKey }; - xml securedEnvelope = check applySymmetricBinding(envelope, symmetricBinding); + xml securedEnvelope = check applySymmetricBinding(envelope, false, symmetricBinding); string envelopeString = securedEnvelope.toString(); byte[] signedData = check getSignatureData(securedEnvelope); @@ -302,7 +302,7 @@ function testSymmetricBindingPolicyWithX509SignatureAndEncryption() returns erro x509Token: X509_PUBLIC_CERT_PATH_2 }; - xml securedEnvelope = check applySymmetricBinding(envelope, symmetricBinding); + xml securedEnvelope = check applySymmetricBinding(envelope, false, symmetricBinding); string envelopeString = securedEnvelope.toString(); byte[] signedData = check getSignatureData(securedEnvelope); @@ -344,7 +344,7 @@ function testUsernameTokenWithSymmetricBinding() returns error? { symmetricKey: symmetricKey, servicePublicKey: serverPublicKey }; - xml securedEnvelope = check applySymmetricBinding(envelope, symmetricBinding); + xml securedEnvelope = check applySymmetricBinding(envelope, false, symmetricBinding); string envelopeString = securedEnvelope.toString(); byte[] signedData = check getSignatureData(securedEnvelope); @@ -403,7 +403,7 @@ function testUsernameTokenTimestampWithSymmetricBindingAndX509Token() returns er x509Token: X509_PUBLIC_CERT_PATH_2 }; - xml securedEnvelope = check applySymmetricBinding(envelope, symmetricBinding); + xml securedEnvelope = check applySymmetricBinding(envelope, false, symmetricBinding); string envelopeString = securedEnvelope.toString(); byte[] signedData = check getSignatureData(securedEnvelope); @@ -452,7 +452,7 @@ function testSymmetricBindingWithOutboundConfig() returns error? { servicePublicKey: serverPublicKey }; - xml securedEnvelope = check applySymmetricBinding(envelope, symmetricBinding); + xml securedEnvelope = check applySymmetricBinding(envelope, false, symmetricBinding); string envelopeString = securedEnvelope.toString(); OutboundSecurityConfig outboundConfig = { @@ -492,7 +492,7 @@ function testAsymmetricBindingWithSignatureRsaSha256() returns error? { signatureKey: clientPrivateKey, encryptionKey: serverPublicKey }; - xml securedEnvelope = check applyAsymmetricBinding(envelope, asymmetricBinding); + xml securedEnvelope = check applyAsymmetricBinding(envelope, false, asymmetricBinding); string envelopeString = securedEnvelope.toString(); byte[] signedData = check getSignatureData(securedEnvelope); Error? validity = check verifyData((envelope//*).toString().toBytes(), signedData, @@ -518,7 +518,7 @@ function testAsymmetricBindingWithX509Signature() returns error? { encryptionKey: serverPublicKey, x509Token: X509_PUBLIC_CERT_PATH_2 }; - xml securedEnvelope = check applyAsymmetricBinding(envelope, asymmetricBinding); + xml securedEnvelope = check applyAsymmetricBinding(envelope, false, asymmetricBinding); string envelopeString = securedEnvelope.toString(); byte[] signedData = check getSignatureData(securedEnvelope); @@ -544,7 +544,7 @@ function testAsymmetricBindingWithEncryption() returns error? { signatureKey: clientPrivateKey, encryptionKey: serverPublicKey }; - xml securedEnvelope = check applyAsymmetricBinding(envelope, asymmetricBinding); + xml securedEnvelope = check applyAsymmetricBinding(envelope, false, asymmetricBinding); string envelopeString = securedEnvelope.toString(); byte[] encData = check getEncryptedData(securedEnvelope); @@ -571,7 +571,7 @@ function testAsymmetricBindingWithSignatureAndEncryption() returns error? { encryptionKey: serverPublicKey }; - xml securedEnvelope = check applyAsymmetricBinding(envelope, asymmetricBinding); + xml securedEnvelope = check applyAsymmetricBinding(envelope, false, asymmetricBinding); string envelopeString = securedEnvelope.toString(); byte[] signedData = check getSignatureData(securedEnvelope); @@ -604,7 +604,7 @@ function testAsymmetricBindingWithX509SignatureAndEncryption() returns error? { encryptionKey: serverPublicKey, x509Token: X509_PUBLIC_CERT_PATH_2 }; - xml securedEnvelope = check applyAsymmetricBinding(envelope, asymmetricBinding); + xml securedEnvelope = check applyAsymmetricBinding(envelope, false, asymmetricBinding); string envelopeString = securedEnvelope.toString(); byte[] signedData = check getSignatureData(securedEnvelope); @@ -644,7 +644,7 @@ function testUsernameTokenWithAsymmetricBindingAndX509() returns error? { encryptionKey: serverPublicKey, x509Token: X509_PUBLIC_CERT_PATH_2 }; - xml securedEnvelope = check applyAsymmetricBinding(envelope, asymmetricBinding); + xml securedEnvelope = check applyAsymmetricBinding(envelope, false, asymmetricBinding); string envelopeString = securedEnvelope.toString(); byte[] signedData = check getSignatureData(securedEnvelope); @@ -686,7 +686,7 @@ function testUsernameTokenTimestampWithAsymmetricBindingAndX509() returns error? encryptionKey: serverPublicKey, x509Token: X509_PUBLIC_CERT_PATH_2 }; - xml securedEnvelope = check applyAsymmetricBinding(envelope, asymmetricBinding); + xml securedEnvelope = check applyAsymmetricBinding(envelope, false, asymmetricBinding); string envelopeString = securedEnvelope.toString(); byte[] signedData = check getSignatureData(securedEnvelope); @@ -729,7 +729,7 @@ function testAsymmetricBindingWithOutboundConfig() returns error? { decryptionKey: serverPrivateKey }; - xml securedEnvelope = check applyAsymmetricBinding(envelope, asymmetricBinding); + xml securedEnvelope = check applyAsymmetricBinding(envelope,false, asymmetricBinding); string envelopeString = securedEnvelope.toString(); crypto:PrivateKey|crypto:PublicKey? privateKey = outboundConfig.decryptionKey; if privateKey is crypto:PrivateKey|crypto:PublicKey { @@ -760,7 +760,7 @@ function testAsymmetricBindingWithSignatureWithRsaSha1() returns error? { signatureKey: clientPrivateKey, encryptionKey: serverPublicKey }; - xml securedEnvelope = check applyAsymmetricBinding(envelope, asymmetricBinding); + xml securedEnvelope = check applyAsymmetricBinding(envelope, false, asymmetricBinding); string envelopeString = securedEnvelope.toString(); byte[] signedData = check getSignatureData(securedEnvelope); Error? validity = check verifyData((envelope//*).toString().toBytes(), signedData, @@ -785,7 +785,7 @@ function testAsymmetricBindingWithSignatureWithRsaSha384() returns error? { signatureKey: clientPrivateKey, encryptionKey: serverPublicKey }; - xml securedEnvelope = check applyAsymmetricBinding(envelope, asymmetricBinding); + xml securedEnvelope = check applyAsymmetricBinding(envelope, false, asymmetricBinding); string envelopeString = securedEnvelope.toString(); byte[] signedData = check getSignatureData(securedEnvelope); Error? validity = check verifyData((envelope//*).toString().toBytes(), signedData, @@ -810,7 +810,7 @@ function testAsymmetricBindingWithSignatureWithRsaSha512() returns error? { signatureKey: clientPrivateKey, encryptionKey: serverPublicKey }; - xml securedEnvelope = check applyAsymmetricBinding(envelope, asymmetricBinding); + xml securedEnvelope = check applyAsymmetricBinding(envelope, false, asymmetricBinding); string envelopeString = securedEnvelope.toString(); byte[] signedData = check getSignatureData(securedEnvelope); Error? validity = check verifyData((envelope//*).toString().toBytes(), signedData, diff --git a/ballerina/modules/wssec/ws_security_methods.bal b/ballerina/modules/wssec/ws_security_methods.bal index 9e328d0..9fb5ae7 100644 --- a/ballerina/modules/wssec/ws_security_methods.bal +++ b/ballerina/modules/wssec/ws_security_methods.bal @@ -17,7 +17,8 @@ import ballerina/crypto; import ballerina/lang.regexp; -xmlns "http://schemas.xmlsoap.org/soap/envelope/" as soap; +xmlns "http://schemas.xmlsoap.org/soap/envelope/" as soap11; +xmlns "http://www.w3.org/2003/05/soap-envelope" as soap12; xmlns "http://www.w3.org/2000/09/xmldsig#" as ds; isolated function addSecurityHeader(Document document) returns WSSecurityHeader|Error { @@ -129,9 +130,10 @@ public isolated function applyUsernameToken(xml envelope, *UsernameTokenConfig u # Apply symmetric binding security policy with username token to the SOAP envelope. # # + envelope - The SOAP envelope +# + soap12 - A boolean flag. Set to `true` for SOAP 1.2, or `false` for SOAP 1.1. # + symmetricBinding - The `SymmetricBindingConfig` record with the required parameters # + return - A `xml` type of SOAP envelope if the security binding is successfully added or else `wssec:Error` -public isolated function applySymmetricBinding(xml envelope, *SymmetricBindingConfig symmetricBinding) +public isolated function applySymmetricBinding(xml envelope, boolean soap12, *SymmetricBindingConfig symmetricBinding) returns xml|crypto:Error|Error { Document document = check new (envelope); WSSecurityHeader wsSecurityHeader = check addSecurityHeader(document); @@ -140,8 +142,15 @@ public isolated function applySymmetricBinding(xml envelope, *SymmetricBindingCo EncryptionAlgorithm? encryptionAlgorithm = symmetricBinding.encryptionAlgorithm; if signatureAlgorithm is SignatureAlgorithm { Signature signature = check new (); - byte[] signedData = check signature.signData((envelope//*).toString(), signatureAlgorithm - , symmetricBinding.symmetricKey); + byte[] signedData; + if soap12 { + signedData = check signature.signData((envelope//*).toString(), signatureAlgorithm, + symmetricBinding.symmetricKey); + } else { + signedData = check signature.signData((envelope//*).toString(), signatureAlgorithm, + symmetricBinding.symmetricKey); + } + Signature signatureResult = check addSignature(signature, signatureAlgorithm, signedData); WsSecurity wsSecurity = new; securedEnvelope = check wsSecurity.applySignatureOnlyPolicy(wsSecurityHeader, signatureResult, @@ -149,8 +158,14 @@ public isolated function applySymmetricBinding(xml envelope, *SymmetricBindingCo } if encryptionAlgorithm is EncryptionAlgorithm { Encryption encryption = check new (); - byte[] encryptData = check crypto:encryptRsaEcb((envelope//*).toString().toBytes(), - symmetricBinding.symmetricKey); + byte[] encryptData; + if soap12 { + encryptData = check crypto:encryptRsaEcb((envelope//*).toString().toBytes(), + symmetricBinding.symmetricKey); + } else { + encryptData = check crypto:encryptRsaEcb((envelope//*).toString().toBytes(), + symmetricBinding.symmetricKey); + } Encryption encryptionResult = check addEncryption(encryption, encryptionAlgorithm, encryptData); WsSecurity wsSecurity = new; securedEnvelope = check wsSecurity.applyEncryptionOnlyPolicy(wsSecurityHeader, encryptionResult); @@ -163,9 +178,12 @@ public isolated function applySymmetricBinding(xml envelope, *SymmetricBindingCo # Apply asymmetric binding security policy with X509 token to the SOAP envelope. # # + envelope - The SOAP envelope +# + soap12 - A boolean flag. Set to `true` for SOAP 1.2, or `false` for SOAP 1.1. # + asymmetricBinding - The `AsymmetricBindingConfig` record with the required parameters # + return - A `xml` type of SOAP envelope if the security binding is successfully added or else `wssec:Error` -public isolated function applyAsymmetricBinding(xml envelope, *AsymmetricBindingConfig asymmetricBinding) returns xml|crypto:Error|Error { +public isolated function applyAsymmetricBinding(xml envelope, boolean soap12, + *AsymmetricBindingConfig asymmetricBinding) + returns xml|crypto:Error|Error { Document document = check new (envelope); WSSecurityHeader wsSecurityHeader = check addSecurityHeader(document); string securedEnvelope = envelope.toBalString(); @@ -177,8 +195,14 @@ public isolated function applyAsymmetricBinding(xml envelope, *AsymmetricBinding if signatureKey !is crypto:PrivateKey { return error Error("Signature key cannot be nil"); } - byte[] signedData = check signature.signData((envelope//*).toString(), - signatureAlgorithm, signatureKey); + byte[] signedData; + if soap12 { + signedData = check signature.signData((envelope//*).toString(), + signatureAlgorithm, signatureKey); + } else { + signedData = check signature.signData((envelope//*).toString(), + signatureAlgorithm, signatureKey); + } Signature signatureResult = check addSignature(signature, signatureAlgorithm, signedData); WsSecurity wsSecurity = new; securedEnvelope = check wsSecurity.applySignatureOnlyPolicy(wsSecurityHeader, signatureResult, @@ -190,7 +214,12 @@ public isolated function applyAsymmetricBinding(xml envelope, *AsymmetricBinding if encryptionKey !is crypto:PublicKey { return error Error("Encryption key cannot be nil"); } - byte[] encryptData = check crypto:encryptRsaEcb((envelope//*).toString().toBytes(), encryptionKey); + byte[] encryptData; + if soap12 { + encryptData = check crypto:encryptRsaEcb((envelope//*).toString().toBytes(), encryptionKey); + } else { + encryptData = check crypto:encryptRsaEcb((envelope//*).toString().toBytes(), encryptionKey); + } Encryption encryptionResult = check addEncryption(encryption, encryptionAlgorithm, encryptData); WsSecurity wsSecurity = new; securedEnvelope = check wsSecurity.applyEncryptionOnlyPolicy(wsSecurityHeader, encryptionResult); diff --git a/ballerina/soap_utils.bal b/ballerina/soap_utils.bal index 01bc8db..6338234 100644 --- a/ballerina/soap_utils.bal +++ b/ballerina/soap_utils.bal @@ -18,9 +18,9 @@ import soap.wssec; import ballerina/crypto; import ballerina/http; -import ballerina/mime; -import ballerina/lang.regexp; import ballerina/jballerina.java; +import ballerina/lang.regexp; +import ballerina/mime; import ballerina/test; public isolated function validateTransportBindingPolicy(ClientConfig config) returns Error? { @@ -39,19 +39,20 @@ public isolated function validateTransportBindingPolicy(ClientConfig config) ret } public isolated function getReadOnlyClientConfig(ClientConfig original) returns readonly & ClientConfig = @java:Method { - 'class: "org.wssec.WsSecurity" + 'class: "org.wssec.WsSecurity" } external; public isolated function applySecurityPolicies(wssec:InboundSecurityConfig|wssec:InboundSecurityConfig[] security, - xml envelope) returns xml|crypto:Error|wssec:Error { + xml envelope, boolean soap12 = true) + returns xml|crypto:Error|wssec:Error { if security is wssec:TimestampTokenConfig { return wssec:applyTimestampToken(envelope, security); } else if security is wssec:UsernameTokenConfig { return wssec:applyUsernameToken(envelope, security); } else if security is wssec:SymmetricBindingConfig { - return wssec:applySymmetricBinding(envelope, security); + return wssec:applySymmetricBinding(envelope, soap12, security); } else if security is wssec:AsymmetricBindingConfig { - return wssec:applyAsymmetricBinding(envelope, security); + return wssec:applyAsymmetricBinding(envelope, soap12, security); } else if security is wssec:InboundSecurityConfig { return envelope; } else { @@ -63,9 +64,10 @@ public isolated function applySecurityPolicies(wssec:InboundSecurityConfig|wssec } } -public isolated function applyOutboundConfig(wssec:OutboundSecurityConfig outboundSecurity, xml envelope) - returns xml|Error { - xmlns "http://schemas.xmlsoap.org/soap/envelope/" as soap; +public isolated function applyOutboundConfig(wssec:OutboundSecurityConfig outboundSecurity, xml envelope, + boolean soap12 = true) returns xml|Error { + xmlns "http://schemas.xmlsoap.org/soap/envelope/" as soap11; + xmlns "http://www.w3.org/2003/05/soap-envelope" as soap12; xml soapEnvelope = envelope; do { wssec:EncryptionAlgorithm? encryptionAlgorithm = outboundSecurity.decryptionAlgorithm; @@ -76,7 +78,7 @@ public isolated function applyOutboundConfig(wssec:OutboundSecurityConfig outbou byte[] decryptDataResult = check crypto:decryptRsaEcb(encData, clientPrivateKey); string decryptedBody = "" + check string:fromBytes(decryptDataResult) + ""; string decryptedEnv = regexp:replace(re `.*`, soapEnvelope.toString(), - decryptedBody); + decryptedBody); soapEnvelope = check xml:fromString(decryptedEnv); } } @@ -85,8 +87,14 @@ public isolated function applyOutboundConfig(wssec:OutboundSecurityConfig outbou crypto:PublicKey? serverPublicKey = outboundSecurity.verificationKey; if serverPublicKey is crypto:PublicKey { byte[] signatureData = check wssec:getSignatureData(soapEnvelope); - check wssec:verifyData((soapEnvelope//*).toString().toBytes(), - signatureData, serverPublicKey, signatureAlgorithm); + if soap12 { + check wssec:verifyData((soapEnvelope//*).toString().toBytes(), + signatureData, serverPublicKey, signatureAlgorithm); + } else { + check wssec:verifyData((soapEnvelope//*).toString().toBytes(), + signatureData, serverPublicKey, signatureAlgorithm); + } + } } return soapEnvelope; @@ -96,7 +104,7 @@ public isolated function applyOutboundConfig(wssec:OutboundSecurityConfig outbou } public isolated function sendReceive(xml|mime:Entity[] body, http:Client httpClient, string? soapAction = (), - map headers = {}, string path = "", boolean soap12 = true) + map headers = {}, string path = "", boolean soap12 = true) returns xml|mime:Entity[]|Error { http:Request req = soap12 ? createSoap12HttpRequest(body, soapAction, headers) : createSoap11HttpRequest(body, soapAction, headers); @@ -112,7 +120,7 @@ public isolated function sendReceive(xml|mime:Entity[] body, http:Client httpCli } public isolated function sendOnly(xml|mime:Entity[] body, http:Client httpClient, string? soapAction = (), - map headers = {}, string path = "", boolean soap12 = true) returns Error? { + map headers = {}, string path = "", boolean soap12 = true) returns Error? { http:Request req = soap12 ? createSoap12HttpRequest(body, soapAction, headers) : createSoap11HttpRequest(body, soapAction, headers); http:Response|http:ClientError response = httpClient->post(path, req); @@ -122,7 +130,7 @@ public isolated function sendOnly(xml|mime:Entity[] body, http:Client httpClient } isolated function createSoap11HttpRequest(xml|mime:Entity[] body, string soapAction, - map headers = {}) returns http:Request { + map headers = {}) returns http:Request { http:Request req = new; if body is xml { req.setXmlPayload(body); @@ -139,7 +147,7 @@ isolated function createSoap11HttpRequest(xml|mime:Entity[] body, string soapAct } isolated function createSoap12HttpRequest(xml|mime:Entity[] body, string? soapAction, - map headers = {}) returns http:Request { + map headers = {}) returns http:Request { http:Request req = new; if body is xml { req.setXmlPayload(body); @@ -176,8 +184,8 @@ isolated function createSoap11Response(http:Response response) returns xml|mime: } public function assertUsernameToken(string envelopeString, string username, string password, - wssec:PasswordType passwordType, string body) returns error? { - string:RegExp bodyData = check regexp:fromString(body); + wssec:PasswordType passwordType, string body) returns error? { + string:RegExp bodyData = check regexp:fromString(body); test:assertTrue(envelopeString.includesMatch(bodyData)); string:RegExp usernameTokenTag = re `.*`; string:RegExp usernameTag = re `${username}`; @@ -188,7 +196,7 @@ public function assertUsernameToken(string envelopeString, string username, stri } public function assertSymmetricBinding(string envelopeString, string body) returns error? { - string:RegExp bodyData = check regexp:fromString(body); + string:RegExp bodyData = check regexp:fromString(body); test:assertTrue(envelopeString.includesMatch(bodyData)); assertSignatureWithoutX509(envelopeString); }