Skip to content

Commit

Permalink
Fix formatting in payloads
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuvindu committed Nov 3, 2023
1 parent c50a4a4 commit 14d1d13
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 34 deletions.
55 changes: 33 additions & 22 deletions ballerina/modules/soap11/tests/http_soap_service.bal
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/crypto;
import ballerina/http;
import ballerina/mime;
Expand All @@ -24,7 +23,7 @@ const crypto:KeyStore serverKeyStore = {
password: KEY_PASSWORD
};
crypto:PrivateKey serverPrivateKey = check crypto:decodeRsaPrivateKeyFromKeyStore(serverKeyStore, KEY_ALIAS,
KEY_PASSWORD);
KEY_PASSWORD);
crypto:PublicKey serverPublicKey = check crypto:decodeRsaPublicKeyFromTrustStore(serverKeyStore, KEY_ALIAS);

service / on new http:Listener(9090) {
Expand Down Expand Up @@ -59,18 +58,24 @@ service / on new http:Listener(9090) {
xml payload = check (check request.getBodyParts())[0].getXml();
xml applyOutboundConfig = check soap:applyOutboundConfig(
{
verificationKey: clientPublicKey,
signatureAlgorithm: soap:RSA_SHA256,
decryptionAlgorithm: soap:RSA_ECB,
decryptionKey: serverPrivateKey
}, payload, false);
verificationKey: clientPublicKey,
signatureAlgorithm: soap:RSA_SHA256,
decryptionAlgorithm: soap:RSA_ECB,
decryptionKey: serverPrivateKey
},
payload,
false
);
xml securedEnv = check soap:applySecurityPolicies(
{
signatureAlgorithm: soap:RSA_SHA256,
encryptionAlgorithm: soap:RSA_ECB,
signatureKey: serverPrivateKey,
encryptionKey: clientPublicKey
}, applyOutboundConfig, false);
signatureAlgorithm: soap:RSA_SHA256,
encryptionAlgorithm: soap:RSA_ECB,
signatureKey: serverPrivateKey,
encryptionKey: clientPublicKey
},
applyOutboundConfig,
false
);
http:Response response = new;
mime:Entity[] mtomMessage = [];
mime:Entity envelope = new;
Expand All @@ -87,18 +92,24 @@ service / on new http:Listener(9090) {
xml payload = check request.getXmlPayload();
xml applyOutboundConfig = check soap:applyOutboundConfig(
{
verificationKey: clientPublicKey,
signatureAlgorithm: soap:RSA_SHA256,
decryptionAlgorithm: soap:RSA_ECB,
decryptionKey: serverPrivateKey
}, payload, false);
verificationKey: clientPublicKey,
signatureAlgorithm: soap:RSA_SHA256,
decryptionAlgorithm: soap:RSA_ECB,
decryptionKey: serverPrivateKey
},
payload,
false
);
xml securedEnv = check soap:applySecurityPolicies(
{
signatureAlgorithm: soap:RSA_SHA256,
encryptionAlgorithm: soap:RSA_ECB,
signatureKey: serverPrivateKey,
encryptionKey: clientPublicKey
}, applyOutboundConfig, false);
signatureAlgorithm: soap:RSA_SHA256,
encryptionAlgorithm: soap:RSA_ECB,
signatureKey: serverPrivateKey,
encryptionKey: clientPublicKey
},
applyOutboundConfig,
false
);
http:Response response = new;
response.setPayload(securedEnv);
return response;
Expand Down
32 changes: 20 additions & 12 deletions ballerina/modules/soap12/tests/http_soap_service.bal
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,18 @@ service / on new http:Listener(9090) {
signatureAlgorithm: soap:RSA_SHA256,
decryptionAlgorithm: soap:RSA_ECB,
decryptionKey: serverPrivateKey
}, payload);
},
payload
);
xml securedEnv = check soap:applySecurityPolicies(
{
signatureAlgorithm: soap:RSA_SHA256,
encryptionAlgorithm: soap:RSA_ECB,
signatureKey: serverPrivateKey,
encryptionKey: clientPublicKey
}, applyOutboundConfig);
},
applyOutboundConfig
);
http:Response response = new;
response.setPayload(securedEnv);
return response;
Expand All @@ -80,18 +84,22 @@ service / on new http:Listener(9090) {
xml payload = check (check request.getBodyParts())[0].getXml();
xml applyOutboundConfig = check soap:applyOutboundConfig(
{
verificationKey: clientPublicKey,
signatureAlgorithm: soap:RSA_SHA256,
decryptionAlgorithm: soap:RSA_ECB,
decryptionKey: serverPrivateKey
}, payload);
verificationKey: clientPublicKey,
signatureAlgorithm: soap:RSA_SHA256,
decryptionAlgorithm: soap:RSA_ECB,
decryptionKey: serverPrivateKey
},
payload
);
xml securedEnv = check soap:applySecurityPolicies(
{
signatureAlgorithm: soap:RSA_SHA256,
encryptionAlgorithm: soap:RSA_ECB,
signatureKey: serverPrivateKey,
encryptionKey: clientPublicKey
}, applyOutboundConfig);
signatureAlgorithm: soap:RSA_SHA256,
encryptionAlgorithm: soap:RSA_ECB,
signatureKey: serverPrivateKey,
encryptionKey: clientPublicKey
},
applyOutboundConfig
);
http:Response response = new;
mime:Entity[] mtomMessage = [];
mime:Entity envelope = new;
Expand Down

0 comments on commit 14d1d13

Please sign in to comment.