Skip to content

Latest commit

 

History

History
106 lines (68 loc) · 3.76 KB

README.md

File metadata and controls

106 lines (68 loc) · 3.76 KB

Table of Contents

Overview

This SDK library provides reference implementation of ISO 20022 Digital Signature specification to sign and verify XML messages. It assumes that you have read the specification prior to coming here.

Refer to ISO20022 Signed Unsigned Message Examples for understanding the difference between a signed and unsigned message.

In Signed XML payload, you will see three reference nodes:

  • Resource as uri="" - will get resolved to AppHdr
  • Resource with no uri - will get resolved to Document
  • Resource as uri="#id" - will get resolved to element as per that id value

Compatibility

Java 11+

Maven 3.6.1+

Usage

Signing the request

XmlSignUtil.sign(Document document, SignatureInfo signatureInfo, SignatureKeyInfo signatureKeyInfo) signs the XML Document where:

  • document - the unsigned payload
  • signatureInfo - signature info which is used in signing the payload
  • signatureKeyInfo - signature key info which holds private key and ski bytes to be set in X509 Data element

Refer to detailed message signing flow

Verifying the request

XmlSignUtil.verify(Document document, PublicKey publicKey) verifies the signed payload where:

  • document - the signed payload
  • publicKey - the public key

Refer to detailed message verification flow

Adding the Library to Your Project

Maven

<dependency>
    <groupId>com.mastercard.ap.security</groupId>
    <artifactId>ap-bah-crypto-utility</artifactId>
    <version>${bah-crypto-utility-version}</version>
</dependency>

Keytool Command to generate public-private key pair

Execute the command from command prompt

keytool -genkey -alias test -keyalg RSA -validity 3060 -keysize 2048 -keystore keystore.jks -storetype JKS

Enter keystore password:

Re-enter new password:

What is your first and last name?

[Unknown]:  Test

What is the name of your organizational unit?

[Unknown]:  OU

What is the name of your organization?

[Unknown]:  O

What is the name of your City or Locality?

[Unknown]:  London

What is the name of your State or Province?

[Unknown]:  S

What is the two-letter country code for this unit?

[Unknown]:  UK

Is CN=Test, OU=OU, O=O, L=London, ST=S, C=UK correct?

[no]:  yes

Enter key password for (RETURN if same as keystore password):

Re-enter new password: