diff --git a/src/main/kotlin/no/nav/security/mock/oauth2/token/OAuth2TokenProvider.kt b/src/main/kotlin/no/nav/security/mock/oauth2/token/OAuth2TokenProvider.kt index a8f12daf..b3a67390 100644 --- a/src/main/kotlin/no/nav/security/mock/oauth2/token/OAuth2TokenProvider.kt +++ b/src/main/kotlin/no/nav/security/mock/oauth2/token/OAuth2TokenProvider.kt @@ -19,12 +19,23 @@ import java.time.Instant import java.util.Date import java.util.UUID +typealias TimeProvider = () -> Instant? + class OAuth2TokenProvider @JvmOverloads constructor( private val keyProvider: KeyProvider = KeyProvider(), - val systemTime: Instant? = null, + private val timeProvider: TimeProvider, ) { + val systemTime + get() = timeProvider() + + @JvmOverloads + constructor( + keyProvider: KeyProvider = KeyProvider(), + systemTime: Instant? = null, + ) : this(keyProvider, { systemTime }) + @JvmOverloads fun publicJwkSet(issuerId: String = "default"): JWKSet { return JWKSet(keyProvider.signingKey(issuerId)).toPublicJWKSet()