Skip to content

Commit

Permalink
Bump the all-dependencies group across 1 directory with 16 updates (#843
Browse files Browse the repository at this point in the history
)

* Bump the all-dependencies group across 1 directory with 16 updates

Bumps the all-dependencies group with 16 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [org.springframework.boot:spring-boot-dependencies](https://github.com/spring-projects/spring-boot) | `3.3.3` | `3.3.5` |
| [no.nav.familie.kontrakter:felles](https://github.com/navikt/familie-kontrakter) | `3.0_20240906070327_03089ba` | `3.0_20241102131210_d65efd1` |
| [no.nav.familie.kontrakter:enslig-forsorger](https://github.com/navikt/familie-kontrakter) | `3.0_20240906070327_03089ba` | `3.0_20241102131210_d65efd1` |
| [org.jetbrains.kotlin:kotlin-stdlib](https://github.com/JetBrains/kotlin) | `2.0.20` | `2.0.21` |
| [org.jetbrains.kotlin:kotlin-reflect](https://github.com/JetBrains/kotlin) | `2.0.20` | `2.0.21` |
| [org.jetbrains.kotlin:kotlin-test-junit5](https://github.com/JetBrains/kotlin) | `2.0.20` | `2.0.21` |
| org.jetbrains.kotlin:kotlin-maven-plugin | `2.0.20` | `2.0.21` |
| org.jetbrains.kotlin:kotlin-maven-allopen | `2.0.20` | `2.0.21` |
| [io.mockk:mockk-jvm](https://github.com/mockk/mockk) | `1.13.12` | `1.13.13` |
| [com.nimbusds:oauth2-oidc-sdk](https://bitbucket.org/connect2id/oauth-2.0-sdk-with-openid-connect-extensions) | `11.19.1` | `11.20.1` |
| [org.wiremock:wiremock-standalone](https://github.com/wiremock/wiremock) | `3.9.1` | `3.9.2` |
| [com.pinterest.ktlint:ktlint-cli](https://github.com/pinterest/ktlint) | `1.3.1` | `1.4.1` |
| [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) | `3.5.0` | `3.5.2` |
| [no.nav.security:token-client-core](https://github.com/navikt/token-support) | `5.0.5` | `5.0.10` |
| [no.nav.security:token-client-spring](https://github.com/navikt/token-support) | `5.0.5` | `5.0.10` |
| [no.nav.security:token-validation-spring](https://github.com/navikt/token-support) | `5.0.5` | `5.0.10` |



Updates `org.springframework.boot:spring-boot-dependencies` from 3.3.3 to 3.3.5
- [Release notes](https://github.com/spring-projects/spring-boot/releases)
- [Commits](spring-projects/spring-boot@v3.3.3...v3.3.5)

Updates `no.nav.familie.kontrakter:felles` from 3.0_20240906070327_03089ba to 3.0_20241102131210_d65efd1
- [Commits](https://github.com/navikt/familie-kontrakter/commits)

Updates `no.nav.familie.kontrakter:enslig-forsorger` from 3.0_20240906070327_03089ba to 3.0_20241102131210_d65efd1
- [Commits](https://github.com/navikt/familie-kontrakter/commits)

Updates `org.jetbrains.kotlin:kotlin-stdlib` from 2.0.20 to 2.0.21
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](JetBrains/kotlin@v2.0.20...v2.0.21)

Updates `org.jetbrains.kotlin:kotlin-reflect` from 2.0.20 to 2.0.21
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](JetBrains/kotlin@v2.0.20...v2.0.21)

Updates `org.jetbrains.kotlin:kotlin-test-junit5` from 2.0.20 to 2.0.21
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](JetBrains/kotlin@v2.0.20...v2.0.21)

Updates `org.jetbrains.kotlin:kotlin-maven-plugin` from 2.0.20 to 2.0.21

Updates `org.jetbrains.kotlin:kotlin-maven-allopen` from 2.0.20 to 2.0.21

Updates `org.jetbrains.kotlin:kotlin-reflect` from 2.0.20 to 2.0.21
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](JetBrains/kotlin@v2.0.20...v2.0.21)

Updates `io.mockk:mockk-jvm` from 1.13.12 to 1.13.13
- [Release notes](https://github.com/mockk/mockk/releases)
- [Commits](mockk/mockk@1.13.12...1.13.13)

Updates `com.nimbusds:oauth2-oidc-sdk` from 11.19.1 to 11.20.1
- [Changelog](https://bitbucket.org/connect2id/oauth-2.0-sdk-with-openid-connect-extensions/src/master/CHANGELOG.txt)
- [Commits](https://bitbucket.org/connect2id/oauth-2.0-sdk-with-openid-connect-extensions/branches/compare/11.20.1..11.19.1)

Updates `org.wiremock:wiremock-standalone` from 3.9.1 to 3.9.2
- [Release notes](https://github.com/wiremock/wiremock/releases)
- [Commits](wiremock/wiremock@3.9.1...3.9.2)

Updates `org.jetbrains.kotlin:kotlin-test-junit5` from 2.0.20 to 2.0.21
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](JetBrains/kotlin@v2.0.20...v2.0.21)

Updates `no.nav.familie.kontrakter:enslig-forsorger` from 3.0_20240906070327_03089ba to 3.0_20241102131210_d65efd1
- [Commits](https://github.com/navikt/familie-kontrakter/commits)

Updates `com.pinterest.ktlint:ktlint-cli` from 1.3.1 to 1.4.1
- [Release notes](https://github.com/pinterest/ktlint/releases)
- [Changelog](https://github.com/pinterest/ktlint/blob/master/CHANGELOG.md)
- [Commits](pinterest/ktlint@1.3.1...1.4.1)

Updates `org.apache.maven.plugins:maven-surefire-plugin` from 3.5.0 to 3.5.2
- [Release notes](https://github.com/apache/maven-surefire/releases)
- [Commits](apache/maven-surefire@surefire-3.5.0...surefire-3.5.2)

Updates `org.jetbrains.kotlin:kotlin-maven-plugin` from 2.0.20 to 2.0.21

Updates `no.nav.security:token-client-core` from 5.0.5 to 5.0.10
- [Release notes](https://github.com/navikt/token-support/releases)
- [Commits](navikt/token-support@5.0.5...5.0.10)

Updates `no.nav.security:token-client-spring` from 5.0.5 to 5.0.10
- [Release notes](https://github.com/navikt/token-support/releases)
- [Commits](navikt/token-support@5.0.5...5.0.10)

Updates `no.nav.security:token-validation-spring` from 5.0.5 to 5.0.10
- [Release notes](https://github.com/navikt/token-support/releases)
- [Commits](navikt/token-support@5.0.5...5.0.10)

Updates `no.nav.security:token-client-spring` from 5.0.5 to 5.0.10
- [Release notes](https://github.com/navikt/token-support/releases)
- [Commits](navikt/token-support@5.0.5...5.0.10)

Updates `org.jetbrains.kotlin:kotlin-maven-allopen` from 2.0.20 to 2.0.21

Updates `no.nav.security:token-validation-spring` from 5.0.5 to 5.0.10
- [Release notes](https://github.com/navikt/token-support/releases)
- [Commits](navikt/token-support@5.0.5...5.0.10)

---
updated-dependencies:
- dependency-name: org.springframework.boot:spring-boot-dependencies
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-dependencies
- dependency-name: no.nav.familie.kontrakter:felles
  dependency-type: direct:production
  dependency-group: all-dependencies
- dependency-name: no.nav.familie.kontrakter:enslig-forsorger
  dependency-type: direct:production
  dependency-group: all-dependencies
- dependency-name: org.jetbrains.kotlin:kotlin-stdlib
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-dependencies
- dependency-name: org.jetbrains.kotlin:kotlin-reflect
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-dependencies
- dependency-name: org.jetbrains.kotlin:kotlin-test-junit5
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-dependencies
- dependency-name: org.jetbrains.kotlin:kotlin-maven-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-dependencies
- dependency-name: org.jetbrains.kotlin:kotlin-maven-allopen
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-dependencies
- dependency-name: org.jetbrains.kotlin:kotlin-reflect
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-dependencies
- dependency-name: io.mockk:mockk-jvm
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-dependencies
- dependency-name: com.nimbusds:oauth2-oidc-sdk
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all-dependencies
- dependency-name: org.wiremock:wiremock-standalone
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-dependencies
- dependency-name: org.jetbrains.kotlin:kotlin-test-junit5
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-dependencies
- dependency-name: no.nav.familie.kontrakter:enslig-forsorger
  dependency-type: direct:production
  dependency-group: all-dependencies
- dependency-name: com.pinterest.ktlint:ktlint-cli
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all-dependencies
- dependency-name: org.apache.maven.plugins:maven-surefire-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-dependencies
- dependency-name: org.jetbrains.kotlin:kotlin-maven-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-dependencies
- dependency-name: no.nav.security:token-client-core
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-dependencies
- dependency-name: no.nav.security:token-client-spring
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-dependencies
- dependency-name: no.nav.security:token-validation-spring
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-dependencies
- dependency-name: no.nav.security:token-client-spring
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-dependencies
- dependency-name: org.jetbrains.kotlin:kotlin-maven-allopen
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-dependencies
- dependency-name: no.nav.security:token-validation-spring
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>

* utelater bumping av token-client-core

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: throndi <56258085+throndi@users.noreply.github.com>
  • Loading branch information
dependabot[bot] and throndi authored Nov 11, 2024
1 parent adb42f8 commit be51eee
Show file tree
Hide file tree
Showing 61 changed files with 480 additions and 405 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import java.net.URI
abstract class AbstractPingableRestClient(
operations: RestOperations,
metricsPrefix: String,
) : AbstractRestClient(operations, metricsPrefix), Pingable {
) : AbstractRestClient(operations, metricsPrefix),
Pingable {
abstract val pingUri: URI

override fun ping() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,41 +37,31 @@ abstract class AbstractRestClient(
inline fun <reified T : Any> getForEntity(
uri: URI,
httpHeaders: HttpHeaders? = null,
): T {
return executeMedMetrics(uri) { operations.exchange<T>(uri, HttpMethod.GET, HttpEntity(null, httpHeaders)) }
}
): T = executeMedMetrics(uri) { operations.exchange<T>(uri, HttpMethod.GET, HttpEntity(null, httpHeaders)) }

inline fun <reified T : Any> postForEntity(
uri: URI,
payload: Any,
httpHeaders: HttpHeaders? = null,
): T {
return executeMedMetrics(uri) { operations.exchange<T>(uri, HttpMethod.POST, HttpEntity(payload, httpHeaders)) }
}
): T = executeMedMetrics(uri) { operations.exchange<T>(uri, HttpMethod.POST, HttpEntity(payload, httpHeaders)) }

inline fun <reified T : Any> putForEntity(
uri: URI,
payload: Any,
httpHeaders: HttpHeaders? = null,
): T {
return executeMedMetrics(uri) { operations.exchange<T>(uri, HttpMethod.PUT, HttpEntity(payload, httpHeaders)) }
}
): T = executeMedMetrics(uri) { operations.exchange<T>(uri, HttpMethod.PUT, HttpEntity(payload, httpHeaders)) }

inline fun <reified T : Any> patchForEntity(
uri: URI,
payload: Any,
httpHeaders: HttpHeaders? = null,
): T {
return executeMedMetrics(uri) { operations.exchange<T>(uri, HttpMethod.PATCH, HttpEntity(payload, httpHeaders)) }
}
): T = executeMedMetrics(uri) { operations.exchange<T>(uri, HttpMethod.PATCH, HttpEntity(payload, httpHeaders)) }

inline fun <reified T : Any> deleteForEntity(
uri: URI,
payload: Any? = null,
httpHeaders: HttpHeaders? = null,
): T {
return executeMedMetrics(uri) { operations.exchange<T>(uri, HttpMethod.DELETE, HttpEntity(payload, httpHeaders)) }
}
): T = executeMedMetrics(uri) { operations.exchange<T>(uri, HttpMethod.DELETE, HttpEntity(payload, httpHeaders)) }

private fun <T> validerOgPakkUt(
respons: ResponseEntity<T>,
Expand Down Expand Up @@ -110,8 +100,8 @@ abstract class AbstractRestClient(
}
}

private fun lesRessurs(e: RestClientResponseException): Ressurs<Any>? {
return try {
private fun lesRessurs(e: RestClientResponseException): Ressurs<Any>? =
try {
if (e.responseBodyAsString.contains("status")) {
objectMapper.readValue<Ressurs<Any>>(e.responseBodyAsString)
} else {
Expand All @@ -120,7 +110,6 @@ abstract class AbstractRestClient(
} catch (ex: Exception) {
null
}
}

override fun toString(): String = this::class.simpleName + " [operations=" + operations + "]"
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import io.micrometer.core.instrument.Metrics
import io.micrometer.core.instrument.Timer
import java.util.concurrent.TimeUnit

abstract class AbstractSoapClient(metricsPrefix: String) {
abstract class AbstractSoapClient(
metricsPrefix: String,
) {
protected val responstid: Timer = Metrics.timer("$metricsPrefix.tid")
protected val responsSuccess: Counter = Metrics.counter("$metricsPrefix.response", "status", "success")
protected val responsFailure: Counter = Metrics.counter("$metricsPrefix.response", "status", "failure")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,15 @@ class MultipartBuilder {
): MultipartBuilder {
val request =
object : ByteArrayResource(bytes) {
override fun getFilename(): String? {
return filename
}
override fun getFilename(): String? = filename
}
multipartRequest.add(name, request)
return this
}

fun build(): MultiValueMap<String, Any> {
return multipartRequest
}
fun build(): MultiValueMap<String, Any> = multipartRequest

fun asEntity(): HttpEntity<MultiValueMap<String, Any>> {
return HttpEntity(multipartRequest, MULTIPART_HEADERS)
}
fun asEntity(): HttpEntity<MultiValueMap<String, Any>> = HttpEntity(multipartRequest, MULTIPART_HEADERS)

companion object {
val MULTIPART_HEADERS: HttpHeaders =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,5 @@ class RetryOAuth2HttpClient(
}
}

private fun shouldRetry(e: Exception): Boolean {
return retryExceptions.contains(e.cause?.let { it::class })
}
private fun shouldRetry(e: Exception): Boolean = retryExceptions.contains(e.cause?.let { it::class })
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,34 @@ class NaisProxyCustomizer(
override fun customize(restTemplate: RestTemplate) {
val proxy = HttpHost("webproxy-nais.nav.no", 8088)
val client: HttpClient =
HttpClientBuilder.create()
HttpClientBuilder
.create()
.setDefaultRequestConfig(
RequestConfig.custom()
RequestConfig
.custom()
.setConnectTimeout(Timeout.ofSeconds(connectTimeout))
.setConnectionRequestTimeout(Timeout.ofSeconds(requestTimeout))
.build(),
)
.setConnectionManager(
PoolingHttpClientConnectionManagerBuilder.create()
).setConnectionManager(
PoolingHttpClientConnectionManagerBuilder
.create()
.setDefaultSocketConfig(
SocketConfig.custom()
SocketConfig
.custom()
.setSoTimeout(Timeout.ofMilliseconds(socketTimeout))
.build(),
)
.build(),
)
.setRoutePlanner(
).build(),
).setRoutePlanner(
object : DefaultProxyRoutePlanner(proxy) {
public override fun determineProxy(
target: HttpHost,
context: HttpContext,
): HttpHost? {
return if (target.hostName.contains("microsoft")) {
): HttpHost? =
if (target.hostName.contains("microsoft")) {
super.determineProxy(target, context)
} else {
null
}
}
},
).build()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,39 +29,39 @@ class RestTemplateAzure {
consumerIdClientInterceptor: ConsumerIdClientInterceptor,
internLoggerInterceptor: InternLoggerInterceptor,
bearerTokenClientInterceptor: BearerTokenClientInterceptor,
): RestOperations {
return restTemplateBuilder.additionalInterceptors(
consumerIdClientInterceptor,
bearerTokenClientInterceptor,
MdcValuesPropagatingClientInterceptor(),
).build()
}
): RestOperations =
restTemplateBuilder
.additionalInterceptors(
consumerIdClientInterceptor,
bearerTokenClientInterceptor,
MdcValuesPropagatingClientInterceptor(),
).build()

@Bean("azureClientCredential")
fun restTemplateClientCredentialBearer(
restTemplateBuilder: RestTemplateBuilder,
consumerIdClientInterceptor: ConsumerIdClientInterceptor,
internLoggerInterceptor: InternLoggerInterceptor,
bearerTokenClientInterceptor: BearerTokenClientCredentialsClientInterceptor,
): RestOperations {
return restTemplateBuilder.additionalInterceptors(
consumerIdClientInterceptor,
bearerTokenClientInterceptor,
MdcValuesPropagatingClientInterceptor(),
).build()
}
): RestOperations =
restTemplateBuilder
.additionalInterceptors(
consumerIdClientInterceptor,
bearerTokenClientInterceptor,
MdcValuesPropagatingClientInterceptor(),
).build()

@Bean("azureOnBehalfOf")
fun restTemplateOnBehalfOfBearer(
restTemplateBuilder: RestTemplateBuilder,
consumerIdClientInterceptor: ConsumerIdClientInterceptor,
internLoggerInterceptor: InternLoggerInterceptor,
bearerTokenClientInterceptor: BearerTokenOnBehalfOfClientInterceptor,
): RestOperations {
return restTemplateBuilder.additionalInterceptors(
consumerIdClientInterceptor,
bearerTokenClientInterceptor,
MdcValuesPropagatingClientInterceptor(),
).build()
}
): RestOperations =
restTemplateBuilder
.additionalInterceptors(
consumerIdClientInterceptor,
bearerTokenClientInterceptor,
MdcValuesPropagatingClientInterceptor(),
).build()
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,13 @@ import org.springframework.context.annotation.Import
class RestTemplateBuilderBean {
@Bean
@ConditionalOnProperty("no.nav.security.jwt.issuer.azuread.proxyurl")
fun restTemplateBuilder(iNaisProxyCustomizer: INaisProxyCustomizer): RestTemplateBuilder {
return RestTemplateBuilder(iNaisProxyCustomizer)
}
fun restTemplateBuilder(iNaisProxyCustomizer: INaisProxyCustomizer): RestTemplateBuilder = RestTemplateBuilder(iNaisProxyCustomizer)

/**
* Denne bønnnen initialiseres hvis proxy-url ikke finnes. Hvis proxy-url finnnes vil bønnen over initialiseres og
* denne det ikke med mindre proxyen har verdien "umulig verdi", som den aldri skal ha.
*/
@Bean
@ConditionalOnProperty("no.nav.security.jwt.issuer.azuread.proxyurl", matchIfMissing = true, havingValue = "Umulig verdi")
fun restTemplateBuilderNoProxy(): RestTemplateBuilder {
return RestTemplateBuilder()
}
fun restTemplateBuilderNoProxy(): RestTemplateBuilder = RestTemplateBuilder()
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ class RestTemplateSts {
restTemplateBuilder: RestTemplateBuilder,
stsBearerTokenClientInterceptor: StsBearerTokenClientInterceptor,
consumerIdClientInterceptor: ConsumerIdClientInterceptor,
): RestOperations {
return restTemplateBuilder.additionalInterceptors(
consumerIdClientInterceptor,
stsBearerTokenClientInterceptor,
MdcValuesPropagatingClientInterceptor(),
).build()
}
): RestOperations =
restTemplateBuilder
.additionalInterceptors(
consumerIdClientInterceptor,
stsBearerTokenClientInterceptor,
MdcValuesPropagatingClientInterceptor(),
).build()
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ abstract class AbstractHealthIndicator(
private val log: Logger = LoggerFactory.getLogger(this::class.java)
private val failureCounter: Counter = Metrics.counter(metricsNavn, "status", "nede")

override fun health(): Health {
return try {
override fun health(): Health =
try {
pingable.ping()
Health.up().build()
} catch (e: Exception) {
failureCounter.increment()
log.info("Feil ved helsesjekk ${this::class.simpleName}", e)
Health.status(statusCode)
Health
.status(statusCode)
.withDetail("Feilmelding", NestedExceptionUtils.getMostSpecificCause(e).javaClass.name + ": " + e.message)
.build()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import org.springframework.stereotype.Component
import java.net.URI

@Component
class ApiKeyInjectingClientInterceptor(private val apiKeys: Map<URI, Pair<String, String>>) : ClientHttpRequestInterceptor {
class ApiKeyInjectingClientInterceptor(
private val apiKeys: Map<URI, Pair<String, String>>,
) : ClientHttpRequestInterceptor {
private val logger = LoggerFactory.getLogger(ApiKeyInjectingClientInterceptor::class.java)

override fun intercept(
Expand All @@ -31,10 +33,9 @@ class ApiKeyInjectingClientInterceptor(private val apiKeys: Map<URI, Pair<String
return execution.execute(request, body)
}

private fun apiKeyFor(uri: URI): Pair<String, String>? {
return apiKeys.entries
private fun apiKeyFor(uri: URI): Pair<String, String>? =
apiKeys.entries
.filter { s -> uri.toString().startsWith(s.key.toString()) }
.map { it.value }
.firstOrNull()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ import java.net.URI
class BearerTokenClientInterceptor(
private val oAuth2AccessTokenService: OAuth2AccessTokenService,
private val clientConfigurationProperties: ClientConfigurationProperties,
) :
ClientHttpRequestInterceptor {
) : ClientHttpRequestInterceptor {
override fun intercept(
request: HttpRequest,
body: ByteArray,
Expand All @@ -41,8 +40,7 @@ class BearerTokenClientInterceptor(
class BearerTokenClientCredentialsClientInterceptor(
private val oAuth2AccessTokenService: OAuth2AccessTokenService,
private val clientConfigurationProperties: ClientConfigurationProperties,
) :
ClientHttpRequestInterceptor {
) : ClientHttpRequestInterceptor {
override fun intercept(
request: HttpRequest,
body: ByteArray,
Expand All @@ -64,8 +62,7 @@ class BearerTokenClientCredentialsClientInterceptor(
class BearerTokenExchangeClientInterceptor(
private val oAuth2AccessTokenService: OAuth2AccessTokenService,
private val clientConfigurationProperties: ClientConfigurationProperties,
) :
ClientHttpRequestInterceptor {
) : ClientHttpRequestInterceptor {
override fun intercept(
request: HttpRequest,
body: ByteArray,
Expand All @@ -87,8 +84,7 @@ class BearerTokenExchangeClientInterceptor(
class BearerTokenOnBehalfOfClientInterceptor(
private val oAuth2AccessTokenService: OAuth2AccessTokenService,
private val clientConfigurationProperties: ClientConfigurationProperties,
) :
ClientHttpRequestInterceptor {
) : ClientHttpRequestInterceptor {
override fun intercept(
request: HttpRequest,
body: ByteArray,
Expand All @@ -111,8 +107,7 @@ class BearerTokenWithSTSFallbackClientInterceptor(
private val oAuth2AccessTokenService: OAuth2AccessTokenService,
private val clientConfigurationProperties: ClientConfigurationProperties,
private val stsRestClient: StsRestClient,
) :
ClientHttpRequestInterceptor {
) : ClientHttpRequestInterceptor {
override fun intercept(
request: HttpRequest,
body: ByteArray,
Expand Down Expand Up @@ -145,9 +140,10 @@ private fun genererAccessToken(
clientConfigurationProperties,
grantType,
)
return oAuth2AccessTokenService.getAccessToken(
clientProperties,
).accessToken ?: throw JwtTokenValidatorException("Kunne ikke hente accesstoken")
return oAuth2AccessTokenService
.getAccessToken(
clientProperties,
).accessToken ?: throw JwtTokenValidatorException("Kunne ikke hente accesstoken")
}

/**
Expand Down Expand Up @@ -186,10 +182,9 @@ private fun clientPropertiesForGrantType(
values: List<ClientProperties>,
grantType: GrantType,
uri: URI,
): ClientProperties {
return values.firstOrNull { grantType == it.grantType }
): ClientProperties =
values.firstOrNull { grantType == it.grantType }
?: error("could not find oauth2 client config for uri=$uri and grant type=$grantType")
}

private fun clientCredentialOrJwtBearer() = if (erSystembruker()) OAuth2GrantType.CLIENT_CREDENTIALS else OAuth2GrantType.JWT_BEARER

Expand Down
Loading

0 comments on commit be51eee

Please sign in to comment.