Skip to content

Commit 78567a4

Browse files
authored
Merge pull request #91 from navikt/dependabot/gradle/backend-81b60f703d
Bump the backend group across 1 directory with 5 updates
2 parents c2457e0 + 76d9e84 commit 78567a4

File tree

6 files changed

+33
-10
lines changed

6 files changed

+33
-10
lines changed

http-client/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
val tokenSupportVersion = "5.0.20"
1+
val tokenSupportVersion = "5.0.24"
22
val wiremockVersion = "3.0.1"
33
val tilleggsstønaderKontrakterVersion = "2025.03.24-08.34.c5f84c4f3794"
44

http-client/main/no/nav/tilleggsstonader/libs/http/client/RetryOAuth2HttpClient.kt

+28-5
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
package no.nav.tilleggsstonader.libs.http.client
22

3+
import no.nav.security.token.support.client.core.OAuth2ClientException
4+
import no.nav.security.token.support.client.core.http.OAuth2HttpClient
35
import no.nav.security.token.support.client.core.http.OAuth2HttpRequest
46
import no.nav.security.token.support.client.core.oauth2.OAuth2AccessTokenResponse
57
import no.nav.security.token.support.client.spring.oauth2.DefaultOAuth2HttpClient
8+
import no.nav.tilleggsstonader.libs.log.SecureLogger.secureLogger
69
import org.apache.hc.core5.http.NoHttpResponseException
710
import org.slf4j.LoggerFactory
811
import org.springframework.core.NestedExceptionUtils
12+
import org.springframework.http.HttpHeaders
13+
import org.springframework.util.LinkedMultiValueMap
914
import org.springframework.web.client.HttpServerErrorException
1015
import org.springframework.web.client.RestClient
16+
import org.springframework.web.client.body
1117
import java.net.SocketException
1218
import java.net.SocketTimeoutException
1319

1420
class RetryOAuth2HttpClient(
15-
restClient: RestClient,
21+
private val restClient: RestClient,
1622
private val maxRetries: Int = 2,
17-
) : DefaultOAuth2HttpClient(restClient) {
23+
) : OAuth2HttpClient {
1824
private val logger = LoggerFactory.getLogger(javaClass)
19-
private val secureLogger = LoggerFactory.getLogger("secureLogger")
2025

2126
// ServiceUnavailable håndteres av apache http-client
2227
private val retryExceptions =
@@ -32,14 +37,32 @@ class RetryOAuth2HttpClient(
3237

3338
while (true) {
3439
try {
35-
val response = super.post(req)
36-
return response
40+
return postRequest(req)
3741
} catch (e: Exception) {
3842
handleException(e, retries++, req)
3943
}
4044
}
4145
}
4246

47+
/**
48+
* Kopi fra [DefaultOAuth2HttpClient]
49+
*/
50+
private fun postRequest(req: OAuth2HttpRequest): OAuth2AccessTokenResponse =
51+
restClient
52+
.post()
53+
.uri(req.tokenEndpointUrl)
54+
.headers { it.addAll(headers(req)) }
55+
.body(
56+
LinkedMultiValueMap<String, String>().apply {
57+
setAll(req.formParameters)
58+
},
59+
).retrieve()
60+
.onStatus({ it.isError }) { _, response ->
61+
throw OAuth2ClientException("Received ${response.statusCode} from ${req.tokenEndpointUrl}")
62+
}.body<OAuth2AccessTokenResponse>() ?: throw OAuth2ClientException("No body in response from ${req.tokenEndpointUrl}")
63+
64+
private fun headers(req: OAuth2HttpRequest): HttpHeaders = HttpHeaders().apply { putAll(req.oAuth2HttpHeaders.headers) }
65+
4366
private fun handleException(
4467
e: Exception,
4568
retries: Int,

kafka/main/no/nav/tilleggsstonader/libs/kafka/KafkaErrorHandler.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package no.nav.tilleggsstonader.libs.kafka
22

3+
import no.nav.tilleggsstonader.libs.log.SecureLogger.secureLogger
34
import org.apache.kafka.clients.consumer.Consumer
45
import org.apache.kafka.clients.consumer.ConsumerRecord
56
import org.slf4j.Logger
@@ -18,7 +19,6 @@ class KafkaErrorHandler(
1819
private val taskScheduler: TaskScheduler,
1920
) : CommonContainerStoppingErrorHandler() {
2021
private val logger: Logger = LoggerFactory.getLogger(javaClass)
21-
private val secureLogger: Logger = LoggerFactory.getLogger("secureLogger")
2222

2323
private val counter = AtomicInteger(0)
2424
private val lastError = AtomicLong(0)

settings.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
rootProject.name = "tilleggsstonader-libs"
22

33
plugins {
4-
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
4+
id("org.gradle.toolchains.foojay-resolver-convention") version "0.9.0"
55
}
66

77
include("http-client")

sikkerhet/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
val tokenSupportVersion = "5.0.20"
1+
val tokenSupportVersion = "5.0.24"
22

33
plugins {
44
kotlin("plugin.spring") version "2.1.20"

unleash/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
dependencies {
66
implementation("org.springframework.boot:spring-boot")
77
implementation("org.springframework.boot:spring-boot-autoconfigure")
8-
api("io.getunleash:unleash-client-java:10.2.0")
8+
api("io.getunleash:unleash-client-java:10.2.2")
99
}
1010

1111
tasks.sourcesJar {

0 commit comments

Comments
 (0)