Skip to content

Commit 1a391d8

Browse files
authored
Change ClientProperties and ClientAuthenticationProperties to data classes for caching to work (#1011)
1 parent 14b2b29 commit 1a391d8

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

token-client-core/src/main/kotlin/no/nav/security/token/support/client/core/ClientAuthenticationProperties.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import com.nimbusds.oauth2.sdk.auth.ClientAuthenticationMethod.PRIVATE_KEY_JWT
88
import no.nav.security.token.support.client.core.jwk.JwkFactory.fromJson
99
import no.nav.security.token.support.client.core.jwk.JwkFactory.fromJsonFile
1010

11-
class ClientAuthenticationProperties @JvmOverloads constructor(val clientId: String, val clientAuthMethod: ClientAuthenticationMethod,val clientSecret: String?,val clientJwk: String? = null, val clientRsaKey: RSAKey? = loadKey(clientJwk)) {
11+
data class ClientAuthenticationProperties @JvmOverloads constructor(val clientId: String, val clientAuthMethod: ClientAuthenticationMethod,val clientSecret: String?,val clientJwk: String? = null, val clientRsaKey: RSAKey? = loadKey(clientJwk)) {
1212

1313
init {
1414
require(clientAuthMethod in CLIENT_AUTH_METHODS) {
@@ -22,7 +22,6 @@ class ClientAuthenticationProperties @JvmOverloads constructor(val clientId: Str
2222
}
2323
}
2424

25-
2625
companion object {
2726
private val CLIENT_AUTH_METHODS = listOf(CLIENT_SECRET_BASIC, CLIENT_SECRET_POST, PRIVATE_KEY_JWT)
2827

token-client-core/src/main/kotlin/no/nav/security/token/support/client/core/ClientProperties.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import com.nimbusds.oauth2.sdk.`as`.AuthorizationServerMetadata.parse
1010
import java.io.IOException
1111
import java.net.URI
1212

13-
class ClientProperties @JvmOverloads constructor(var tokenEndpointUrl: URI? = null,
13+
data class ClientProperties @JvmOverloads constructor(var tokenEndpointUrl: URI? = null,
1414
private val wellKnownUrl: URI? = null,
1515
val grantType: GrantType,
1616
val scope: List<String> = emptyList(),
@@ -24,7 +24,6 @@ class ClientProperties @JvmOverloads constructor(var tokenEndpointUrl: URI? = nu
2424
require(grantType in GRANT_TYPES) { "Unsupported grantType $grantType, must be one of $GRANT_TYPES" }
2525
}
2626

27-
2827
fun toBuilder() =
2928
ClientPropertiesBuilder(grantType, authentication)
3029
.tokenEndpointUrl(tokenEndpointUrl)

token-client-core/src/test/kotlin/no/nav/security/token/support/client/core/oauth2/OAuth2AccessTokenServiceTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ internal class OAuth2AccessTokenServiceTest {
130130
assertThat(res1).hasNoNullFieldsOrProperties()
131131
assertThat(res1.access_token).isEqualTo("first_access_token")
132132

133+
clientProperties = clientCredentialsProperties()
134+
133135
//should get response from cache and NOT invoke client
134136
reset(clientCredentialsTokenResponseClient)
135137
val res2 = oAuth2AccessTokenService.getAccessToken(clientProperties)

0 commit comments

Comments
 (0)