Skip to content

Commit

Permalink
Flytter signaturvalidator
Browse files Browse the repository at this point in the history
  • Loading branch information
thburnett committed Oct 25, 2023
1 parent 2aee46c commit ce8e3ad
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package no.nav.emottak.ebms.model

import no.nav.emottak.EBMS_SERVICE_URI
import no.nav.emottak.ebms.createResponseHeader
import no.nav.emottak.ebms.processing.SignaturValidator
import no.nav.emottak.ebms.validation.SignaturValidator
import no.nav.emottak.ebms.xml.xmlMarshaller
import no.nav.emottak.melding.model.SignatureDetails
import no.nav.emottak.util.marker
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package no.nav.emottak.ebms.model

import no.nav.emottak.ebms.getPublicSigningDetails
import no.nav.emottak.ebms.processing.CPAValidationProcessor
import no.nav.emottak.ebms.processing.SertifikatsjekkProcessor
import no.nav.emottak.ebms.processing.SignaturValidator
import no.nav.emottak.ebms.processing.signer
import no.nav.emottak.ebms.xml.xmlMarshaller
import no.nav.emottak.util.marker
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package no.nav.emottak.ebms.model

import no.nav.emottak.ebms.getPublicSigningDetails
import no.nav.emottak.ebms.processing.CPAValidationProcessor
import no.nav.emottak.ebms.processing.SertifikatsjekkProcessor
import no.nav.emottak.ebms.processing.SignaturValidator
import no.nav.emottak.ebms.processing.signer
import no.nav.emottak.ebms.xml.xmlMarshaller
import no.nav.emottak.util.marker
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package no.nav.emottak.ebms.processing
package no.nav.emottak.ebms.validation

import no.nav.emottak.ebms.model.EbMSAttachment
import no.nav.emottak.ebms.validation.CID_PREFIX
import no.nav.emottak.ebms.validation.EbMSAttachmentResolver
import no.nav.emottak.melding.model.SignatureDetails
import no.nav.emottak.util.retrievePublicX509Certificate
import no.nav.emottak.util.retrieveSignatureElement
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package no.nav.emottak.ebms.processing
package no.nav.emottak.ebms.validation

import no.nav.emottak.ebms.model.EbMSAttachment
import no.nav.emottak.ebms.model.EbMSDocument
Expand All @@ -9,9 +9,9 @@ import no.nav.emottak.util.signatur.SignatureException
import org.apache.xml.security.algorithms.MessageDigestAlgorithm
import org.apache.xml.security.signature.XMLSignature
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows

class SignaturvalidatorTest {
class SignaturValidatorTest {

@Test
fun `Validering av signatur`() {

Expand Down Expand Up @@ -45,15 +45,16 @@ class SignaturvalidatorTest {
)

val signatursjekk = SignaturValidator()
assertThrows<SignatureException> {
signatursjekk.validate(getSignatureDetailsForTest(),dokument,ebMSDocument.attachments)
org.junit.jupiter.api.assertThrows<SignatureException> {
signatursjekk.validate(getSignatureDetailsForTest(), dokument, ebMSDocument.attachments)
}
}

}

fun getSignatureDetailsForTest(): SignatureDetails =
SignatureDetails(
certificate = decodeBase64("MIIGKzCCBBOgAwIBAgILAZV/ETITzRpPW2AwDQYJKoZIhvcNAQELBQAwbjELMAkGA1UEBhMCTk8xGDAWBgNVBGEMD05UUk5PLTk4MzE2MzMyNzETMBEGA1UECgwKQnV5cGFzcyBBUzEwMC4GA1UEAwwnQnV5cGFzcyBDbGFzcyAzIFRlc3Q0IENBIEcyIFNUIEJ1c2luZXNzMB4XDTIyMDkyMjExMzQxN1oXDTI1MDkyMjIxNTkwMFowTzELMAkGA1UEBhMCTk8xEjAQBgNVBAoMCVNQRUFSRSBBUzESMBAGA1UEAwwJU1BFQVJFIEFTMRgwFgYDVQRhDA9OVFJOTy05OTM5NTQ4OTYwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQCwHoYUs81oVde0a8JgduNSSxeNaDs3kUleGjRApc+kz7tc7k386zXenFxnvIwNaVGdHVs3dN5O06h5QlG7rlFsxR+Btz6oFFwi/5WcAtDxJj4XRVL0evLXZY86D8TmAtMgdTQvRZ39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iqq2bi4iqJZLEFFyQBa8lbDzX674npviavB+Oi4SScJZOtV+HwtV8GXKDfPB8SKIKjpAWF1sqijn3T45cLWDn87teaVtURCu+VrxWuvb48RJBPotf3JpHBzKeAQfOdxVLD2VuDI9EtC77ZvGWbY2ve9Va99pZ7z1iXLvXiqjcm+4AKNtjgnLcVBEYw1DZBM/0ZaRv2o4PK5mX/faGeA0zCQa1dd8BkkUW6AvLFHUR2QEwcbhd78PR5wtbqoA+C945HK6u74VDYlpMQSO5JtKdZlgoscuf4RRhPkDAPUkKtwcL3jO6ep4yr958xL+EVYd9tKpbmGArXwD9JlEkfURMi06iHXkQKiwEQ26hrNcd4snBjsvtqWm6A0BhGToLhXTYJNfTYZNh5CG10C7IzBGzFqwG+ZQmeu1RV4ltIiJQWn6NO32fFi5pSkfJ04O+W6hsaFiIMH7khgaGYdV32zfHP34Pj1sfjUoWmKIyU1J3gifWnidhZgFNx+senCTMBHYHU=".toByteArray()),
signatureAlgorithm = XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA256,
hashFunction = MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA256
)
)

0 comments on commit ce8e3ad

Please sign in to comment.