All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.http4k.security.oauth.client.AccessTokens.kt Maven / Gradle / Ivy

The newest version!
package org.http4k.security.oauth.client

import org.http4k.security.AccessToken
import org.http4k.security.ExpiringCredentials
import org.http4k.security.oauth.core.RefreshToken

interface AccessTokens {
    operator fun get(refreshToken: RefreshToken): ExpiringCredentials?
    operator fun set(refreshToken: RefreshToken, accessToken: ExpiringCredentials)
    companion object
}

fun AccessTokens.Companion.None() = object : AccessTokens {
    override fun get(refreshToken: RefreshToken): Nothing? = null
    override fun set(refreshToken: RefreshToken, accessToken: ExpiringCredentials) {}
}

fun AccessTokens.Companion.InMemory() = object : AccessTokens {
    var tokens = mutableMapOf>()

    override fun get(refreshToken: RefreshToken) = tokens[refreshToken]

    override fun set(refreshToken: RefreshToken, accessToken: ExpiringCredentials) {
        tokens[refreshToken] = accessToken
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy