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

public final class JwkSet

  1. Object
  2. JwkSet

ImplementsJwkSource

A set of keys, as a JSON Web Key Set publishes one (RFC 7517 5): what a server that signs tokens serves at its jwks_uri, and what a server that verifies them reads from there.

JwkSet keys = JwkSet.of(current, previous);
return HttpServer.Response.json(200, keys.toJson());   // public halves only

The set does not change. A server that rotates its key builds a new set and answers with it from its JwkSource.

Constructors

public JwkSet(List<Jwk> keys)

Methods

public static JwkSet of(Jwk... keys)A set of these keys, the one to sign with first.
public static JwkSet parse(String json) throws IOExceptionThe public keys in a JSON Web Key Set document.
public List<Jwk> getKeys()The keys, the one to sign with first.
public Jwk get(String keyId)The key with this id, or null.
public Map<String, Object> toPublicJson()The set as a jwks_uri serves it: the public half of every RSA and EC key.
public String toJson()toPublicJson as text.
public String toString()Returns a string representation of the object.

Inherited methods

Constructor details

JwkSet

public JwkSet(List<Jwk> keys)

Method details

of

public static JwkSet of(Jwk... keys)
A set of these keys, the one to sign with first.

parse

public static JwkSet parse(String json) throws IOException

The public keys in a JSON Web Key Set document.

A key this runtime has no use for – a type or a curve it does not verify with, an encryption key – is left out rather than failing the set: a provider adding a key of a new kind must not stop the ones that were working.

Throws

IOException
when the text is not a key set at all

getKeys

public List<Jwk> getKeys()
The keys, the one to sign with first.

Throws

IOException
when the keys cannot be had: a server that publishes them is not answering

get

public Jwk get(String keyId)
The key with this id, or null.

toPublicJson

public Map<String, Object> toPublicJson()
The set as a jwks_uri serves it: the public half of every RSA and EC key. A shared secret is left out.

toJson

public String toJson()
toPublicJson as text.

toString

public String toString()
Returns a string representation of the object. In general, the toString method returns a string that “textually represents” this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method. The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@’, and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: getClass().getName() + ‘@’ + Integer.toHexString(hashCode())