diff --git a/build.gradle.kts b/build.gradle.kts index 6a7bba7..d0dd82c 100755 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ plugins { } group = "com.netki" -version = "1.0.0-beta1" +version = "1.0.0-beta5" java.sourceCompatibility = JavaVersion.VERSION_1_8 repositories { @@ -18,7 +18,7 @@ repositories { } dependencies { - implementation("com.netki:transactid:1.0.0-beta4") + implementation("com.netki:transactid:1.0.0-beta5") implementation("org.springframework.boot:spring-boot-starter-web") implementation("com.fasterxml.jackson.module:jackson-module-kotlin") diff --git a/src/main/java/com/netki/transactidlibraryjavademo/controller/TransactIdController.kt b/src/main/java/com/netki/transactidlibraryjavademo/controller/TransactIdController.kt index b0db6f0..d46f54c 100755 --- a/src/main/java/com/netki/transactidlibraryjavademo/controller/TransactIdController.kt +++ b/src/main/java/com/netki/transactidlibraryjavademo/controller/TransactIdController.kt @@ -1,5 +1,6 @@ package com.netki.transactidlibraryjavademo.controller +import com.netki.transactidlibraryjavademo.model.Information import com.netki.transactidlibraryjavademo.service.TransactIdService import io.swagger.v3.oas.annotations.Operation import io.swagger.v3.oas.annotations.Parameter @@ -23,6 +24,30 @@ class TransactIdController { @Autowired private lateinit var transactIdService: TransactIdService + @Operation( + summary = "Get VASP certificate", + description = "Returns the VASP certificate" + ) + @RequestMapping( + method = [RequestMethod.GET], + value = ["/"], + produces = [MediaType.APPLICATION_JSON_VALUE] + ) + @ApiResponse( + responseCode = "200", + description = "VASP certificate.", + content = [ + Content( + mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = Schema(implementation = Information::class) + ) + ] + ) + fun getVASPCertificate() = ResponseEntity( + transactIdService.getVaspCertificate(), + HttpStatus.OK + ) + @Operation( summary = "Get invoiceRequest binary", description = "Returns an invoiceRequest binary so that you can start testing your flow" diff --git a/src/main/java/com/netki/transactidlibraryjavademo/model/Information.kt b/src/main/java/com/netki/transactidlibraryjavademo/model/Information.kt new file mode 100644 index 0000000..6bfab49 --- /dev/null +++ b/src/main/java/com/netki/transactidlibraryjavademo/model/Information.kt @@ -0,0 +1,8 @@ +package com.netki.transactidlibraryjavademo.model + +import com.fasterxml.jackson.annotation.JsonProperty + +data class Information( + @JsonProperty("vasp_certificate") + val vaspCertificate: String +) diff --git a/src/main/java/com/netki/transactidlibraryjavademo/service/TransactIdService.kt b/src/main/java/com/netki/transactidlibraryjavademo/service/TransactIdService.kt index 781c125..88b8e2a 100755 --- a/src/main/java/com/netki/transactidlibraryjavademo/service/TransactIdService.kt +++ b/src/main/java/com/netki/transactidlibraryjavademo/service/TransactIdService.kt @@ -3,7 +3,9 @@ package com.netki.transactidlibraryjavademo.service import com.netki.TransactId import com.netki.model.* import com.netki.transactidlibraryjavademo.model.EncryptionKeys +import com.netki.transactidlibraryjavademo.model.Information import com.netki.transactidlibraryjavademo.repo.TransactIdRepository +import com.netki.transactidlibraryjavademo.util.Certificates.VASP_CERTIFICATE import com.netki.transactidlibraryjavademo.util.TestData.Attestations.ATTESTATIONS_REQUESTED import com.netki.transactidlibraryjavademo.util.TestData.Beneficiaries.NO_PRIMARY_BENEFICIARY_PKI_X509SHA256 import com.netki.transactidlibraryjavademo.util.TestData.Beneficiaries.PRIMARY_BENEFICIARY_PKI_X509SHA256 @@ -64,6 +66,8 @@ class TransactIdService { fun getEncryptionKeys() = encryptionKeys + fun getVaspCertificate() = Information(VASP_CERTIFICATE) + fun sendInitialInvoiceRequest(url: String) { val invoiceRequest = getInitialInvoiceRequest() transactIdRepository.sendRequestNoResponse(invoiceRequest, url) @@ -138,7 +142,7 @@ class TransactIdService { val invoiceRequestModel = transactId.parseInvoiceRequest(invoiceRequest, recipientParameters) logger.info("InvoiceRequest parsed: $invoiceRequestModel") - return createPaymentRequest(invoiceRequestModel.protocolMessageMetadata.encrypted) + return createPaymentRequest(invoiceRequestModel.protocolMessageMetadata.encrypted, invoiceRequestModel.protocolMessageMetadata.identifier) } fun postInvoiceRequestAsync(invoiceRequest: ByteArray) { @@ -158,12 +162,12 @@ class TransactIdService { throw IllegalArgumentException("Missing notificationUrl to send the async response") } else { val paymentRequest = - createPaymentRequest(invoiceRequestModel.protocolMessageMetadata.encrypted) + createPaymentRequest(invoiceRequestModel.protocolMessageMetadata.encrypted, invoiceRequestModel.protocolMessageMetadata.identifier) transactIdRepository.sendRequestNoResponse(paymentRequest, notificationUrl) } } - private fun createPaymentRequest(encrypted: Boolean): ByteArray { + private fun createPaymentRequest(encrypted: Boolean, identifier: String): ByteArray { return if (encrypted) { logger.info("Creating PaymentRequest Encrypted...") logger.info("Returning PaymentRequest Encrypted...") @@ -185,7 +189,7 @@ class TransactIdService { messageInformation = messageInformationEncrypted, recipientParameters = recipientParameters ) - transactId.createPaymentRequest(paymentRequestParameters) + transactId.createPaymentRequest(paymentRequestParameters, identifier) } else { logger.info("Creating PaymentRequest...") logger.info("Returning PaymentRequest...") @@ -206,7 +210,7 @@ class TransactIdService { senderParameters = sender, attestationsRequested = ATTESTATIONS_REQUESTED ) - transactId.createPaymentRequest(paymentRequestParameters) + transactId.createPaymentRequest(paymentRequestParameters, identifier) } } @@ -270,7 +274,7 @@ class TransactIdService { senderParameters = senderParameters, recipientParameters = recipientParameters ) - transactId.createPayment(paymentParameters) + transactId.createPayment(paymentParameters, paymentRequestModel.protocolMessageMetadata.identifier) } else { logger.info("Creating Payment...") @@ -293,7 +297,7 @@ class TransactIdService { originatorParameters = originators, beneficiaryParameters = beneficiaries ) - transactId.createPayment(paymentParameters) + transactId.createPayment(paymentParameters, paymentRequestModel.protocolMessageMetadata.identifier) } } @@ -313,7 +317,7 @@ class TransactIdService { senderParameters = senderParameters, recipientParameters = recipientParameters ) - transactId.createPaymentAck(paymentAckParameters) + transactId.createPaymentAck(paymentAckParameters, paymentModel.protocolMessageMetadata!!.identifier) } else { logger.info("Creating PaymentAck...") logger.info("Returning PaymentAck...") @@ -321,7 +325,7 @@ class TransactIdService { payment = PAYMENT, memo = "memo ack" ) - transactId.createPaymentAck(paymentAckParameters) + transactId.createPaymentAck(paymentAckParameters, paymentModel.protocolMessageMetadata!!.identifier) } } } diff --git a/src/main/java/com/netki/transactidlibraryjavademo/util/Certificates.kt b/src/main/java/com/netki/transactidlibraryjavademo/util/Certificates.kt new file mode 100644 index 0000000..6d18d8d --- /dev/null +++ b/src/main/java/com/netki/transactidlibraryjavademo/util/Certificates.kt @@ -0,0 +1,31 @@ +package com.netki.transactidlibraryjavademo.util + +object Certificates { + + const val VASP_CERTIFICATE = "-----BEGIN CERTIFICATE-----\n" + + "MIIEWDCCA0CgAwIBAgIUbSYo375wYh5Jnp0OiVOP2Io+wRIwDQYJKoZIhvcNAQEL\n" + + "BQAwfzELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRQwEgYDVQQHEwtMb3MgQW5n\n" + + "ZWxlczEZMBcGA1UECxMQTmV0a2kgT3BlcmF0aW9uczEyMDAGA1UEAxMpVHJhbnNh\n" + + "Y3RJRCBJbnRlcm1lZGlhdGUgQ0FpIC0gREVWRUxPUE1FTlQwHhcNMjEwMTA3MjMx\n" + + "NDAwWhcNMjQwMTA3MjMxNDAwWjBwMQswCQYDVQQGEwJVUzEOMAwGA1UECBMFMTIz\n" + + "NEExFjAUBgNVBAcTDU1vY2sgUmVnaXN0ZXIxHjAcBgNVBAsTFU1vY2sgU2VydmVy\n" + + "LCBUZXN0T25seTEZMBcGA1UEAxMQTW9jayBTZXJ2ZXIgVkFTUDCCASIwDQYJKoZI\n" + + "hvcNAQEBBQADggEPADCCAQoCggEBAL1seMgeWBQ0A+jQD7CufSZWgVKeHe5Uw1ZK\n" + + "qmykRSyivsPGsWgl9WsHF0LKNkVHItbVMy48C7h/YBYEl6gT9NBv4xX5nUeudwti\n" + + "gf5nonbyIexsa69Lqu5AJ2A0iWsGscP4DHzSbuqmg5tX2J9UJTBcBwFzRia03uQd\n" + + "/rqiNiAtEARyMkEnkfEPRS9ItD7FtqTmYEdYisjS9PEKaMXktPT8/tuv1kwmd1lU\n" + + "mazBXeHsLvevBfmIkzVYquz1zy0sSK25d+YtS680xIlFtYEmqqrMBn0Dc4Ygc0s5\n" + + "YTi2i6c6Y615TrTHLa/aCx4Mw8m3aBzuAk52rEA6GZH2EUGDVg0CAwEAAaOB2jCB\n" + + "1zAOBgNVHQ8BAf8EBAMCBaAwEwYDVR0lBAwwCgYIKwYBBQUHAwIwDAYDVR0TAQH/\n" + + "BAIwADAdBgNVHQ4EFgQUenhX6SpiqYSxu2prMbv23Tp3wScwHwYDVR0jBBgwFoAU\n" + + "GmE4AzynQJG7T3cMOJxhiRuxzsEwNAYIKwYBBQUHAQEEKDAmMCQGCCsGAQUFBzAB\n" + + "hhhodHRwczovL29jc3AubXl2ZXJpZnkuaW8wLAYDVR0fBCUwIzAhoB+gHYYbaHR0\n" + + "cHM6Ly9jcmwubXl2ZXJpZnkuaW8vY3JsMA0GCSqGSIb3DQEBCwUAA4IBAQDIEY96\n" + + "w48Ys3hEa3xnsF5NjDWcCaj3IQNdSR9lPG7bKSMFKEM4IPjn/F8BZ6SgTRCddjlR\n" + + "4mN26p67v5W5IEb8m2YMqQj93NUWZFntnoCUI65+m3gg0FdcUL36tu+O/ocBNC/f\n" + + "XZNXz23ZXnQsJO7cc2JJKSElWowZHtnhpHCOJpT/CO52a4YM3E5BaANZFqjKUlak\n" + + "tX4nQz33vmPHKasQPOqH6bh1vN9Uc0rEvVoifNn2uvdnLPvFH0KDDzqj+st/clKb\n" + + "00gydlRkvjN6+sZLjnIq7GsdznieRUZg7TYJfrxLwxQoA1ch3UBs8bYcy9Z2mR2U\n" + + "BEGydYvYrJ+wUri4\n" + + "-----END CERTIFICATE-----" +} diff --git a/src/main/java/com/netki/transactidlibraryjavademo/util/TestData.kt b/src/main/java/com/netki/transactidlibraryjavademo/util/TestData.kt index 47e8555..6ec05ec 100644 --- a/src/main/java/com/netki/transactidlibraryjavademo/util/TestData.kt +++ b/src/main/java/com/netki/transactidlibraryjavademo/util/TestData.kt @@ -202,14 +202,14 @@ object TestData { object PkiData { val PKI_DATA_ONE_OWNER_X509SHA256 = PkiDataParameters( - attestation = Attestation.LEGAL_PERSON_SECONDARY_NAME, + attestation = Attestation.LEGAL_PERSON_NAME, privateKeyPem = CLIENT_PRIVATE_KEY_CHAIN_ONE, certificatePem = CLIENT_CERTIFICATE_CHAIN_ONE, type = PkiType.X509SHA256 ) val PKI_DATA_TWO_OWNER_X509SHA256 = PkiDataParameters( - attestation = Attestation.LEGAL_PERSON_PRIMARY_NAME, + attestation = Attestation.LEGAL_PERSON_NAME, privateKeyPem = CLIENT_PRIVATE_KEY_CHAIN_TWO, certificatePem = CLIENT_CERTIFICATE_CHAIN_TWO, type = PkiType.X509SHA256 @@ -224,7 +224,7 @@ object TestData { object Attestations { val ATTESTATIONS_REQUESTED = listOf( - Attestation.LEGAL_PERSON_PRIMARY_NAME, + Attestation.LEGAL_PERSON_NAME, Attestation.ADDRESS_STREET_NAME, Attestation.ADDRESS_ADDRESS_LINE )