Skip to content

Commit

Permalink
Glemte muligheten for komprimerte filer
Browse files Browse the repository at this point in the history
  • Loading branch information
thburnett committed Nov 27, 2024
1 parent 1bb897b commit 51d8f47
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
16 changes: 15 additions & 1 deletion ebms-payload/src/main/kotlin/no/nav/emottak/payload/Processor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,21 @@ class Processor(
)
}

fun decrypt(bytes: ByteArray) = dekryptering.dekrypter(bytes, isBase64 = false)
fun getDecryptedAndDecompressedBytes(bytes: ByteArray, encrypted: Boolean, compressed: Boolean): ByteArray {
return bytes.let {
if (encrypted) {
dekryptering.dekrypter(bytes, isBase64 = false)
} else {
it
}
}.let {
if (compressed) {
gZipUtil.uncompress(bytes)
} else {
it
}
}
}

private suspend fun processIncoming(payloadRequest: PayloadRequest): Payload {
val processConfig = payloadRequest.processing.processConfig
Expand Down
10 changes: 5 additions & 5 deletions ebms-payload/src/main/kotlin/no/nav/emottak/payload/Routes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ fun Route.postPayload() = post("/payload") {
true -> {
log.info(request.marker(), "Oppretter negativ AppRec for payload <${request.payload.contentId}>")
val msgHead = unmarshal(
if (request.processing.processConfig.kryptering) {
processor.decrypt(request.payload.bytes)
} else {
request.payload.bytes
},
processor.getDecryptedAndDecompressedBytes(
request.payload.bytes,
request.processing.processConfig.kryptering,
request.processing.processConfig.komprimering
),
MsgHead::class.java
)
val apprec = createNegativeApprec(msgHead, originalError as Exception)
Expand Down

0 comments on commit 51d8f47

Please sign in to comment.