Class JsonWebKey
java.lang.Object
de.christofreichardt.json.webkey.JsonWebKey
- All Implemented Interfaces:
de.christofreichardt.diagnosis.Traceable
- Direct Known Subclasses:
JsonWebKeyPair, JsonWebPublicKey, JsonWebSecretKey
public abstract sealed class JsonWebKey
extends Object
implements de.christofreichardt.diagnosis.Traceable
permits JsonWebKeyPair, JsonWebPublicKey, JsonWebSecretKey
Base class for JSON web keys.
- Author:
- Christof Reichardt
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classJsonWebKey.Builder<T extends JsonWebKey.Builder<T>>Base class for allJsonWebKey.Builders. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Map<String, ECParameterSpec> Maps curve names on appropriateECParameterSpecs.static final ECParameterSpecPublic parameters of curve 'secp256r1'.static final ECParameterSpecPublic parameters of curve 'secp521r1'. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends JsonWebKey>
TGeneric method to create aJsonWebKeyfrom a JSON representation.de.christofreichardt.diagnosis.AbstractTracerReturns the required "kty" (Key Type) parameter.getKid()Returns the "kid" (Key ID) parameter.jakarta.json.JsonObjecttoJson()Serializes the common JWK parameters.toString()
-
Field Details
-
EC_PARAMETER_SPEC_MAP
Maps curve names on appropriateECParameterSpecs. -
SECP256R1
-
SECP521R1
-
-
Method Details
-
fromJson
public static <T extends JsonWebKey> T fromJson(jakarta.json.JsonObject webKeyView, Class<T> clazz) throws GeneralSecurityException Generic method to create aJsonWebKeyfrom a JSON representation.- Type Parameters:
T- the type of theJsonWebKeyclass, modeled by the givenClassobject.- Parameters:
webKeyView- the JSON representation.clazz- the actualJsonWebKeyclass, could be aJsonWebKeyPair,JsonWebPublicKeyorJsonWebSecretKey.- Returns:
- a
JsonWebKeyobject. - Throws:
GeneralSecurityException- passed through from the underlying implementations of the algorithms by the JDK.
-
getKid
Returns the "kid" (Key ID) parameter.- Returns:
- the key id, may be null.
- See Also:
-
getKeyType
Returns the required "kty" (Key Type) parameter.- Returns:
- the key type.
- See Also:
-
toString
-
toJson
public jakarta.json.JsonObject toJson()Serializes the common JWK parameters.- Returns:
- a JsonObject containing the shared JWK parameters.
-
getCurrentTracer
public de.christofreichardt.diagnosis.AbstractTracer getCurrentTracer()- Specified by:
getCurrentTracerin interfacede.christofreichardt.diagnosis.Traceable
-