Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.
package com.codename1.backend.security.oauth2.jwt
JSON Web Tokens signed with a public key algorithm or a shared secret:
JwtDecoder verifies one and
reads its claims, JwtEncoder
makes one.
JwtDecoder decoder = JwtDecoders.fromIssuerLocation("https://accounts.example.com");
Jwt jwt = decoder.decode(token); // BadJwtException says why not
String user = jwt.getSubject();
Which algorithm verifies a token is settled by the key the decoder holds and
the algorithms it was told to accept, and the token’s own alg header has
to agree with both. A token that says none, or says HS256 to a decoder
that holds an RSA public key, is refused before anything is computed.
com.codename1.backend.Jwt is not part of this: it issues and checks HS256
tokens between a server and itself, and stays as it is.
Types
class BadJwtException | The token itself is not acceptable: it is malformed, its signature does not verify, it names an algorithm or a key the decoder does not accept, or it fails a validator. |
class DefaultJwtDecoder | Verifies tokens against keys it holds, or keys an issuer publishes. |
class DefaultJwtEncoder | Signs tokens with the keys of a JwkSource. |
class JwsHeader | The header of a signature that is about to be made: which algorithm, and optionally which key and what type of token. |
class Jwt | A JSON Web Token whose signature has been made or verified: its text, the headers of its signature and its claims. |
class JwtAudienceValidator | Refuses a token that is not for this server: one whose aud names none of the audiences given here. |
class JwtClaimNames | The claims RFC 7519 registers. |
class JwtClaimValidator | Refuses a token unless one of its claims passes a test. |
class JwtClaimsSet | The claims of a token that is about to be signed. |
interface JwtDecoder | Verifies a token and reads its claims. |
class JwtDecoders | Makes a decoder for an issuer from what the issuer says about itself. |
interface JwtEncoder | Signs tokens. |
class JwtEncoderParameters | What a JwtEncoder is asked to sign: claims, and optionally a header. |
class JwtEncodingException | A token could not be signed: there is no key for it, or the key does not fit the algorithm. |
class JwtException | A token could not be made or could not be judged: a key is missing or unusable, the server that publishes the keys did not answer. |
class JwtIssuerValidator | Refuses a token whose iss is not exactly the issuer this server trusts. |
class JwtTimestampValidator | Refuses a token past its exp or ahead of its nbf, with a minute’s allowance either way for two machines whose clocks disagree. |
class JwtValidationException | A token whose signature verified and whose claims did not pass: expired, not yet valid, from another issuer, meant for another audience. |
class JwtValidators | The validators a decoder is usually given. |
class RemoteJwkSet | The keys another server publishes at its jwks_uri, fetched when they are first needed and kept. |
class SupplierJwtDecoder | A decoder that is made when the first token arrives, and then kept. |