Class RemoteOpaqueTokenIntrospector

java.lang.Object
com.codename1.backend.security.oauth2.server.resource.RemoteOpaqueTokenIntrospector
All Implemented Interfaces:
OpaqueTokenIntrospector

public final class RemoteOpaqueTokenIntrospector extends Object implements OpaqueTokenIntrospector

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(long). 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.

  • 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 void setClock(Clock clock)
    • setCacheSeconds

      public 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)
      Description copied from interface: OpaqueTokenIntrospector
      The claims of an active token: sub, scope, client_id, exp and whatever else the authorization server answers, without active.
      Specified by:
      introspect in interface OpaqueTokenIntrospector