Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.

public final class RemoteOpaqueTokenIntrospector

  1. Object
  2. RemoteOpaqueTokenIntrospector

ImplementsOpaqueTokenIntrospector

Introspects tokens at an authorization server’s RFC 7662 endpoint, as a client of it: with a secret (client_secret_basic) or with a JWT signed by a private key (private_key_jwt).

http.oauth2ResourceServer(rs -> rs.opaqueToken(o -> o
        .introspectionUri("https://auth.example.com/oauth2/introspect")
        .introspectionClientCredentials("orders-api", secret)));

Every request with a token costs a call to the endpoint unless answers are cached with setCacheSeconds. A cached answer outlives a revocation by up to that long, which is the trade being made; it never outlives the token’s own exp.

Constructors

public RemoteOpaqueTokenIntrospector(String introspectionUri, String clientId, String clientSecret)Authenticates to the endpoint with HTTP Basic.

Methods

public static RemoteOpaqueTokenIntrospector withPrivateKeyJwt(String introspectionUri, String clientId, Jwk privateKey)Authenticates to the endpoint with private_key_jwt: each call signs a fresh assertion addressed to the endpoint.
public void setTransport(TokenEndpoint.Transport transport)Where the requests go; TokenEndpoint.WEB unless set.
public synchronized void setClock(Clock clock)
public synchronized void setCacheSeconds(long seconds)How long an active answer is reused; 0, the default, asks every time.
public Map<String, Object> introspect(String token)The claims of an active token: sub, scope, client_id, exp and whatever else the authorization server answers, without active.

Inherited methods

Constructor details

RemoteOpaqueTokenIntrospector

public RemoteOpaqueTokenIntrospector(String introspectionUri, String clientId, String clientSecret)
Authenticates to the endpoint with HTTP Basic.

Method details

withPrivateKeyJwt

public static RemoteOpaqueTokenIntrospector withPrivateKeyJwt(String introspectionUri, String clientId, Jwk privateKey)
Authenticates to the endpoint with private_key_jwt: each call signs a fresh assertion addressed to the endpoint.

setTransport

public void setTransport(TokenEndpoint.Transport transport)
Where the requests go; TokenEndpoint.WEB unless set.

setClock

public synchronized void setClock(Clock clock)

setCacheSeconds

public synchronized void setCacheSeconds(long seconds)
How long an active answer is reused; 0, the default, asks every time.

introspect

public Map<String, Object> introspect(String token)
The claims of an active token: sub, scope, client_id, exp and whatever else the authorization server answers, without active.

Throws

InvalidBearerTokenException
when the token is not active
com.codename1.backend.security.AuthenticationServiceException
when the authorization server could not be asked