-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1036 from navikt/krr-integrasjon
Krr integrasjon
- Loading branch information
Showing
14 changed files
with
177 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/main/kotlin/no/nav/klage/oppgave/clients/krrproxy/KrrProxyClient.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package no.nav.klage.oppgave.clients.krrproxy | ||
|
||
import brave.Tracer | ||
import no.nav.klage.oppgave.config.CacheWithJCacheConfiguration | ||
import no.nav.klage.oppgave.util.TokenUtil | ||
import no.nav.klage.oppgave.util.getLogger | ||
import no.nav.klage.oppgave.util.getSecureLogger | ||
import no.nav.klage.oppgave.util.logErrorResponse | ||
import org.springframework.cache.annotation.Cacheable | ||
import org.springframework.http.HttpHeaders | ||
import org.springframework.http.HttpStatusCode | ||
import org.springframework.stereotype.Component | ||
import org.springframework.web.reactive.function.client.WebClient | ||
import org.springframework.web.reactive.function.client.WebClientResponseException | ||
import org.springframework.web.reactive.function.client.bodyToMono | ||
import reactor.core.publisher.Mono | ||
|
||
@Component | ||
class KrrProxyClient( | ||
private val krrProxyWebClient: WebClient, | ||
private val tokenUtil: TokenUtil, | ||
private val tracer: Tracer | ||
) { | ||
companion object { | ||
@Suppress("JAVA_CLASS_ON_COMPANION") | ||
private val logger = getLogger(javaClass.enclosingClass) | ||
private val secureLogger = getSecureLogger() | ||
} | ||
|
||
@Cacheable(CacheWithJCacheConfiguration.KRR_INFO_CACHE) | ||
fun getDigitalKontaktinformasjonForFnr(fnr: String): DigitalKontaktinformasjon? { | ||
logger.debug("Getting info from KRR") | ||
return krrProxyWebClient.get() | ||
.uri("/rest/v1/person") | ||
.header("Nav-Call-Id", tracer.currentSpan().context().traceIdString()) | ||
.header( | ||
HttpHeaders.AUTHORIZATION, | ||
"Bearer ${tokenUtil.getOnBehalfOfTokenWithKrrProxyScope()}" | ||
) | ||
.header( | ||
"Nav-Personident", | ||
fnr | ||
) | ||
.retrieve() | ||
.onStatus(HttpStatusCode::isError) { response -> | ||
logErrorResponse(response, ::getDigitalKontaktinformasjonForFnr.name, secureLogger) | ||
} | ||
.bodyToMono<DigitalKontaktinformasjon>() | ||
.onErrorResume { Mono.empty() } | ||
.block() | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/kotlin/no/nav/klage/oppgave/clients/krrproxy/KrrProxyResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package no.nav.klage.oppgave.clients.krrproxy | ||
|
||
import java.time.LocalDate | ||
import java.time.ZonedDateTime | ||
|
||
|
||
data class DigitalKontaktinformasjon ( | ||
val personident: String? = null, | ||
val aktiv: Boolean? = null, | ||
val kanVarsles: Boolean? = null, | ||
val reservasjonOppdatert: ZonedDateTime? = null, | ||
val reservert: Boolean? = null, | ||
val spraak: String? = null, | ||
val spraakOppdatert: ZonedDateTime? = null, | ||
val epostadresse: String? = null, | ||
val epostadresseOppdatert: ZonedDateTime? = null, | ||
val epostadresseVerifisert: ZonedDateTime? = null, | ||
val mobiltelefonnummer: String? = null, | ||
val mobiltelefonnummerOppdatert: ZonedDateTime? = null, | ||
val mobiltelefonnummerVerifisert: ZonedDateTime? = null, | ||
val sikkerDigitalPostkasse: SikkerDigitalPostkasse? = null, | ||
) | ||
|
||
data class SikkerDigitalPostkasse ( | ||
val adresse: String? = null, | ||
val leverandoerAdresse: String? = null, | ||
val leverandoerSertifikat: String? = null | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/main/kotlin/no/nav/klage/oppgave/config/KrrProxyClientConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package no.nav.klage.oppgave.config | ||
|
||
|
||
import no.nav.klage.oppgave.util.getLogger | ||
import org.springframework.beans.factory.annotation.Value | ||
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Configuration | ||
import org.springframework.http.client.reactive.ReactorClientHttpConnector | ||
import org.springframework.web.reactive.function.client.WebClient | ||
import reactor.netty.http.client.HttpClient | ||
|
||
|
||
@Configuration | ||
class KrrProxyClientConfiguration( | ||
private val webClientBuilder: WebClient.Builder | ||
) { | ||
|
||
companion object { | ||
@Suppress("JAVA_CLASS_ON_COMPANION") | ||
private val logger = getLogger(javaClass.enclosingClass) | ||
} | ||
|
||
@Value("\${KRR_PROXY_REST_URL}") | ||
private lateinit var krrProxyURL: String | ||
|
||
@Bean | ||
fun krrProxyWebClient(): WebClient { | ||
return webClientBuilder | ||
.baseUrl(krrProxyURL) | ||
.clientConnector(ReactorClientHttpConnector(HttpClient.newConnection())) | ||
.build() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.