Class JsonWebKeyPair
java.lang.Object
de.christofreichardt.json.webkey.JsonWebKey
de.christofreichardt.json.webkey.JsonWebKeyPair
- All Implemented Interfaces:
de.christofreichardt.diagnosis.Traceable
Convenient for the handling of key pairs in the spirit of RFC 7517 (JSON Web Key) and RFC 7518 (JSON Web Algorithms).
- Author:
- Christof Reichardt
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAJsonWebKey.Builderfor buildingJsonWebKeyPairs by internally generating an EC key pair for the curve "secp256r1".static classstatic class -
Field Summary
Fields inherited from class JsonWebKey
EC_PARAMETER_SPEC_MAP, SECP256R1, SECP521R1 -
Method Summary
Modifier and TypeMethodDescriptionbooleanCompares thisJsonWebKeyPairwith anotherJsonWebKeyPair.static JsonWebKeyPairfromJson(jakarta.json.JsonObject jwkView) Factory method to create aJsonWebKeyPairinstance from a plainJsonObject.Returns the appliedAlgorithmParameterSpec, may be null.Returns the actualKeyPair.inthashCode()A hash code for thisJsonWebKeyPair.Creates aJsonWebPublicKeyfrom thisJsonWebKeyPair.static JsonWebKeyPair.Builderof()Creates the default builder for aJsonWebKeyPair.Creates a special builder for aJsonWebKeyPair.of(AlgorithmParameterSpec algorithmParameterSpec) Creates a special builder for aJsonWebKeyPair.jakarta.json.JsonObjecttoJson()Converts thisJsonWebKeyPairinto a plainJsonObject.toString()Returns a textual representation of thisJsonWebKeyPair.Methods inherited from class JsonWebKey
fromJson, getCurrentTracer, getKeyType, getKid
-
Method Details
-
of
Creates the default builder for aJsonWebKeyPair. Use this variant if you want to automatically create an EC key pair for curve "secp256r1".- Returns:
- a
JsonWebKeyPair.Builder.
-
of
Creates a special builder for aJsonWebKeyPair. Use this variant if you already have aKeyPair.- Parameters:
keyPair- the providedKeyPair.- Returns:
- a
JsonWebKeyPair.KeyPairBuilder.
-
of
Creates a special builder for aJsonWebKeyPair. Use this variant if you want to create aKeyPairfrom a providedAlgorithmParameterSpec.- Parameters:
algorithmParameterSpec- the providedAlgorithmParameterSpec.- Returns:
- a
JsonWebKeyPair.ParameterSpecBuilder.
-
getKeyPair
-
getAlgorithmParameterSpec
Returns the appliedAlgorithmParameterSpec, may be null.- Returns:
- the applied
AlgorithmParameterSpec
-
jsonWebPublicKey
Creates aJsonWebPublicKeyfrom thisJsonWebKeyPair. Firstly thisJsonWebKeyPairinstance will be serialized into aJsonObjectand thenJsonWebPublicKey.fromJson(jakarta.json.JsonObject)will be invoked.- Returns:
- a
JsonWebPublicKey - Throws:
GeneralSecurityException- passed through from the underlying implementations of the algorithms by the JDK.
-
toString
Returns a textual representation of thisJsonWebKeyPair.- Overrides:
toStringin classJsonWebKey- Returns:
- a textual representation of this
JsonWebKeyPair.
-
equals
Compares thisJsonWebKeyPairwith anotherJsonWebKeyPair. Compares thisJsonWebKeyPairwith another ensuring that it contains the same configuration. Only objects of typeJsonWebKeyPairare considered, other types return false. -
hashCode
-
toJson
public jakarta.json.JsonObject toJson()Converts thisJsonWebKeyPairinto a plainJsonObject.- Overrides:
toJsonin classJsonWebKey- Returns:
- a
JsonObjectcorresponding to thisJsonWebKeyPair. - See Also:
-
fromJson
public static JsonWebKeyPair fromJson(jakarta.json.JsonObject jwkView) throws GeneralSecurityException Factory method to create aJsonWebKeyPairinstance from a plainJsonObject.- Parameters:
jwkView- the givenJsonObject.- Returns:
- a
JsonWebKeyPair - Throws:
GeneralSecurityException- passed through from the underlying implementations of the algorithms by the JDK.
-