Skip to content

Commit

Permalink
Merge pull request #15 from netkicorp/upgrade_beta5
Browse files Browse the repository at this point in the history
Upgrade to version Beta5
  • Loading branch information
alan10fm authored Feb 17, 2021
2 parents b910db6 + 87bba33 commit c9a07b5
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 14 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.netki.transactidlibraryjavademo.model

import com.fasterxml.jackson.annotation.JsonProperty

data class Information(
@JsonProperty("vasp_certificate")
val vaspCertificate: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand All @@ -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...")
Expand All @@ -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...")
Expand All @@ -206,7 +210,7 @@ class TransactIdService {
senderParameters = sender,
attestationsRequested = ATTESTATIONS_REQUESTED
)
transactId.createPaymentRequest(paymentRequestParameters)
transactId.createPaymentRequest(paymentRequestParameters, identifier)
}
}

Expand Down Expand Up @@ -270,7 +274,7 @@ class TransactIdService {
senderParameters = senderParameters,
recipientParameters = recipientParameters
)
transactId.createPayment(paymentParameters)
transactId.createPayment(paymentParameters, paymentRequestModel.protocolMessageMetadata.identifier)

} else {
logger.info("Creating Payment...")
Expand All @@ -293,7 +297,7 @@ class TransactIdService {
originatorParameters = originators,
beneficiaryParameters = beneficiaries
)
transactId.createPayment(paymentParameters)
transactId.createPayment(paymentParameters, paymentRequestModel.protocolMessageMetadata.identifier)
}
}

Expand All @@ -313,15 +317,15 @@ class TransactIdService {
senderParameters = senderParameters,
recipientParameters = recipientParameters
)
transactId.createPaymentAck(paymentAckParameters)
transactId.createPaymentAck(paymentAckParameters, paymentModel.protocolMessageMetadata!!.identifier)
} else {
logger.info("Creating PaymentAck...")
logger.info("Returning PaymentAck...")
val paymentAckParameters = PaymentAckParameters(
payment = PAYMENT,
memo = "memo ack"
)
transactId.createPaymentAck(paymentAckParameters)
transactId.createPaymentAck(paymentAckParameters, paymentModel.protocolMessageMetadata!!.identifier)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.netki.transactidlibraryjavademo.util

object Certificates {

const val VASP_CERTIFICATE = "-----BEGIN CERTIFICATE-----\n" +
"MIIEWDCCA0CgAwIBAgIUbSYo375w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KwYBBQUHAQEEKDAmMCQGCCsGAQUFBzAB\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-----"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
)
Expand Down

0 comments on commit c9a07b5

Please sign in to comment.