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

public final class JwtClaimValidator

  1. Object
  2. JwtClaimValidator

ImplementsOAuth2TokenValidator<Jwt>

Refuses a token unless one of its claims passes a test.

// An ID token must carry the nonce this server sent with the request.
OAuth2TokenValidator<Jwt> nonce = new JwtClaimValidator("nonce", expected::equals);

The test is handed the claim as the JSON had it – a String, a Long or Double, a Boolean, a List or a Map – and null when the token has none of that name. It is handed an Object and not something narrower on purpose: what type a claim has is the issuer’s choice, and a test that assumed one would be casting a value it has not looked at. Ask with instanceof.

Constructors

public JwtClaimValidator(String claim, Predicate<Object> test)

Methods

public OAuth2TokenValidatorResult validate(Jwt jwt)Whether token passes, and why not.

Inherited methods

Constructor details

JwtClaimValidator

public JwtClaimValidator(String claim, Predicate<Object> test)

Method details

validate

public OAuth2TokenValidatorResult validate(Jwt jwt)
Whether token passes, and why not.