diff --git a/apps/etterlatte-proxy/src/main/kotlin/config/SimuleringOppdragConfig.kt b/apps/etterlatte-proxy/src/main/kotlin/config/SimuleringOppdragConfig.kt index fe357659..e7380163 100644 --- a/apps/etterlatte-proxy/src/main/kotlin/config/SimuleringOppdragConfig.kt +++ b/apps/etterlatte-proxy/src/main/kotlin/config/SimuleringOppdragConfig.kt @@ -22,8 +22,10 @@ class SimuleringOppdragConfig(config: Config, private val enableLogging: Boolean val enabledFeatures = mutableListOf().apply { add(WSAddressingFeature()) if (enableLogging) add(LoggingFeature().apply { + setSensitiveDataHelper(SoapSecurityMaskSensitiveHelper()) setVerbose(true) setPrettyLogging(true) + setSensitiveElementNames(setOf("oppdragGjelderId", "utbetalesTilId")) }) } diff --git a/apps/etterlatte-proxy/src/main/kotlin/config/SoapSecurityMaskSensitiveHelper.kt b/apps/etterlatte-proxy/src/main/kotlin/config/SoapSecurityMaskSensitiveHelper.kt new file mode 100644 index 00000000..8b74f5b6 --- /dev/null +++ b/apps/etterlatte-proxy/src/main/kotlin/config/SoapSecurityMaskSensitiveHelper.kt @@ -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("()([\\s\\S.]*?)()") + + override fun maskSensitiveElements(message: Message, originalLogString: String): String { + val resultString = matchPatternXML.matcher(originalLogString).replaceAll("$1***REDACTED***$3") + + return super.maskSensitiveElements(message, resultString) + } +} \ No newline at end of file diff --git a/apps/etterlatte-proxy/src/main/kotlin/config/TilbakekrevingConfig.kt b/apps/etterlatte-proxy/src/main/kotlin/config/TilbakekrevingConfig.kt index fd8d8133..c209be02 100644 --- a/apps/etterlatte-proxy/src/main/kotlin/config/TilbakekrevingConfig.kt +++ b/apps/etterlatte-proxy/src/main/kotlin/config/TilbakekrevingConfig.kt @@ -22,6 +22,7 @@ class TilbakekrevingConfig(config: Config, private val enableLogging: Boolean = val enabledFeatures = mutableListOf().apply { add(WSAddressingFeature()) if (enableLogging) add(LoggingFeature().apply { + setSensitiveDataHelper(SoapSecurityMaskSensitiveHelper()) setVerbose(true) setPrettyLogging(true) }) diff --git a/apps/etterlatte-proxy/src/main/kotlin/routes/SimuleringOppdragRoute.kt b/apps/etterlatte-proxy/src/main/kotlin/routes/SimuleringOppdragRoute.kt index 7c49bed1..faf51cd2 100644 --- a/apps/etterlatte-proxy/src/main/kotlin/routes/SimuleringOppdragRoute.kt +++ b/apps/etterlatte-proxy/src/main/kotlin/routes/SimuleringOppdragRoute.kt @@ -1,5 +1,6 @@ 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 @@ -7,6 +8,7 @@ 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 @@ -19,8 +21,13 @@ fun Route.simuleringOppdragRoute(simulerFpService: SimulerFpService) { post("/simuleringoppdrag/simulerberegning") { val request = call.receive() - 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) + } } } \ No newline at end of file