Skip to content

Commit

Permalink
Returnere detaljer fra simuleringsfeil (#252)
Browse files Browse the repository at this point in the history
* Returnere detaljer fra simuleringsfeil

* Ikke logg sensitivt
  • Loading branch information
ingleivj authored Apr 24, 2024
1 parent ca50487 commit 1d09cfb
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ class SimuleringOppdragConfig(config: Config, private val enableLogging: Boolean
val enabledFeatures = mutableListOf<Feature>().apply {
add(WSAddressingFeature())
if (enableLogging) add(LoggingFeature().apply {
setSensitiveDataHelper(SoapSecurityMaskSensitiveHelper())
setVerbose(true)
setPrettyLogging(true)
setSensitiveElementNames(setOf("oppdragGjelderId", "utbetalesTilId"))
})
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package no.nav.etterlatte.config

import org.apache.cxf.ext.logging.MaskSensitiveHelper
import org.apache.cxf.message.Message
import java.util.regex.Pattern

/**
* Handle tag with multiline content between opening and end.
*/
internal class SoapSecurityMaskSensitiveHelper : MaskSensitiveHelper() {
private val matchPatternXML = Pattern.compile("(<wsse:Security.*?>)([\\s\\S.]*?)(</wsse:Security>)")

override fun maskSensitiveElements(message: Message, originalLogString: String): String {
val resultString = matchPatternXML.matcher(originalLogString).replaceAll("$1***REDACTED***$3")

return super.maskSensitiveElements(message, resultString)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class TilbakekrevingConfig(config: Config, private val enableLogging: Boolean =
val enabledFeatures = mutableListOf<Feature>().apply {
add(WSAddressingFeature())
if (enableLogging) add(LoggingFeature().apply {
setSensitiveDataHelper(SoapSecurityMaskSensitiveHelper())
setVerbose(true)
setPrettyLogging(true)
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package no.nav.etterlatte.routes

import io.ktor.http.HttpStatusCode
import io.ktor.server.application.call
import io.ktor.server.application.log
import io.ktor.server.request.receive
import io.ktor.server.response.respond
import io.ktor.server.routing.Route
import io.ktor.server.routing.application
import io.ktor.server.routing.post
import no.nav.system.os.eksponering.simulerfpservicewsbinding.SimulerBeregningFeilUnderBehandling
import no.nav.system.os.eksponering.simulerfpservicewsbinding.SimulerFpService
import no.nav.system.os.tjenester.simulerfpservice.simulerfpservicegrensesnitt.SimulerBeregningRequest

Expand All @@ -19,8 +21,13 @@ fun Route.simuleringOppdragRoute(simulerFpService: SimulerFpService) {
post("/simuleringoppdrag/simulerberegning") {
val request = call.receive<SimulerBeregningRequest>()

logger.info("Videresender simuleringsberegning for vedtakId=${request.request.oppdrag.oppdragslinje.first().vedtakId} fra proxy")
val response = simulerFpService.simulerBeregning(request)
call.respond(response)
logger.info("Videresender simuleringsberegning for fagsystemId=${request.request.oppdrag.fagsystemId} fra proxy")
try {
val response = simulerFpService.simulerBeregning(request)
call.respond(response)
} catch (e: SimulerBeregningFeilUnderBehandling) {
logger.error("Feil ved kall til simuleringstjeneste i Oppdrag", e)
call.respond(HttpStatusCode.InternalServerError, e.faultInfo)
}
}
}

0 comments on commit 1d09cfb

Please sign in to comment.