diff --git a/cpa-repo/src/main/kotlin/no/nav/emottak/cpa/App.kt b/cpa-repo/src/main/kotlin/no/nav/emottak/cpa/App.kt index 22832c80..d7b130a1 100644 --- a/cpa-repo/src/main/kotlin/no/nav/emottak/cpa/App.kt +++ b/cpa-repo/src/main/kotlin/no/nav/emottak/cpa/App.kt @@ -14,6 +14,7 @@ import io.ktor.server.routing.get import no.nav.emottak.cpa.config.DatabaseConfig import no.nav.emottak.cpa.config.mapHikariConfig import no.nav.emottak.melding.model.Header +import no.nav.emottak.melding.model.SignatureDetailsRequest import no.nav.emottak.melding.model.ValidationResult fun main() { @@ -47,17 +48,13 @@ fun Application.myApplicationModule() { call.respond(partyInfo.getCertificateForEncryption()) } - get("/cpa/{$CPA_ID}/party/{$PARTY_TYPE}/{$PARTY_ID}/signing/certificate/{$ROLE}/{$SERVICE}/{$ACTION}") { - val cpaId = call.parameters[CPA_ID] ?: throw BadRequestException("Mangler $CPA_ID") - val partyType = call.parameters[PARTY_TYPE] ?: throw BadRequestException("Mangler $PARTY_TYPE") - val partyId = call.parameters[PARTY_ID] ?: throw BadRequestException("Mangler $PARTY_ID") - val role = call.parameters[ROLE] ?: throw BadRequestException("Mangler $ROLE") - val service = call.parameters[SERVICE] ?: throw BadRequestException("Mangler $SERVICE") - val action = call.parameters[ACTION] ?: throw BadRequestException("Mangler $ACTION") - val cpa = getCpa(cpaId) ?: throw NotFoundException("Ingen CPA med ID $cpaId funnet") - val partyInfo = cpa.getPartyInfoByTypeAndID(partyType, partyId) + post("/signing/certificate") { + val signatureDetailsRequest = call.receive(SignatureDetailsRequest::class) + val cpa = getCpa(signatureDetailsRequest.cpaId) ?: throw NotFoundException("Ingen CPA med ID ${signatureDetailsRequest.cpaId} funnet") + val partyInfo = cpa.getPartyInfoByTypeAndID(signatureDetailsRequest.partyType, signatureDetailsRequest.partyId) - call.respond(partyInfo.getCertificateForSignatureValidation(role, service, action)) + call.respond(partyInfo.getCertificateForSignatureValidation( + signatureDetailsRequest.role, signatureDetailsRequest.service, signatureDetailsRequest.action)) } } } diff --git a/ebms-provider/src/main/kotlin/no/nav/emottak/ebms/HttpClientUtil.kt b/ebms-provider/src/main/kotlin/no/nav/emottak/ebms/HttpClientUtil.kt index 5a703247..4b01f706 100644 --- a/ebms-provider/src/main/kotlin/no/nav/emottak/ebms/HttpClientUtil.kt +++ b/ebms-provider/src/main/kotlin/no/nav/emottak/ebms/HttpClientUtil.kt @@ -14,6 +14,7 @@ import no.nav.emottak.melding.model.Header import no.nav.emottak.melding.model.PayloadRequest import no.nav.emottak.melding.model.PayloadResponse import no.nav.emottak.melding.model.SignatureDetails +import no.nav.emottak.melding.model.SignatureDetailsRequest import no.nav.emottak.melding.model.ValidationResult import org.oasis_open.committees.ebxml_msg.schema.msg_header_2_0.MessageHeader @@ -32,7 +33,15 @@ fun getPublicSigningDetails(messageHeader: MessageHeader): SignatureDetails = ru } suspend fun getPublicSigningDetails(cpaId: String, partyType: String, partyId: String, service: String, action: String, role: String): SignatureDetails { - return httpClientUtil.makeHttpRequest("$cpaRepoEndpoint/cpa/$cpaId/party/$partyType/$partyId/signing/certificate/$role/$service/$action").body() + val request = SignatureDetailsRequest( + cpaId = cpaId, + partyType = partyType, + partyId = partyId, + role = role, + service = service, + action = action + ) + return httpClientUtil.postSignatureDetailsRequest("$cpaRepoEndpoint/signing/certificate", request) } class HttpClientUtil { @@ -56,6 +65,13 @@ class HttpClientUtil { }.body() } + suspend fun postSignatureDetailsRequest(urlString: String, request: SignatureDetailsRequest): SignatureDetails { + return client.post(urlString) { + setBody(request) + contentType(Json) + }.body() + } + suspend fun makeHttpRequest(urlString: String): HttpResponse { val response: HttpResponse = client.request(urlString) { method = HttpMethod.Get diff --git a/felles/src/main/kotlin/no/nav/emottak/melding/model/SignatureDetails.kt b/felles/src/main/kotlin/no/nav/emottak/melding/model/SignatureDetails.kt index 9bb6850a..30e8a24c 100644 --- a/felles/src/main/kotlin/no/nav/emottak/melding/model/SignatureDetails.kt +++ b/felles/src/main/kotlin/no/nav/emottak/melding/model/SignatureDetails.kt @@ -5,3 +5,13 @@ data class SignatureDetails( val signatureAlgorithm: String, val hashFunction: String ) + + +data class SignatureDetailsRequest( + val cpaId: String, + val partyType: String, + val partyId: String, + val role: String, + val service: String, + val action: String +) \ No newline at end of file