Class JsonWebSecretKey
java.lang.Object
de.christofreichardt.json.webkey.JsonWebKey
de.christofreichardt.json.webkey.JsonWebSecretKey
- All Implemented Interfaces:
de.christofreichardt.diagnosis.Traceable
Convenient for the handling of secret keys 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 buildingJsonWebSecretKeys by specifying an algorithm and a keysize.static class -
Field Summary
Fields inherited from class JsonWebKey
EC_PARAMETER_SPEC_MAP, SECP256R1, SECP521R1 -
Method Summary
Modifier and TypeMethodDescriptionbooleanCompares thisJsonWebSecretKeywith anotherJsonWebSecretKey.static JsonWebSecretKeyfromJson(jakarta.json.JsonObject jwkView) Factory method to create aJsonWebSecretKeyinstance from a plainJsonObject.Return the algorithm to be used with the wrappedSecretKey, e.g.Returns the wrappedSecretKey.inthashCode()A hash code for thisJsonWebSecretKey.static JsonWebSecretKey.Builderof()Creates the default builder for aJsonWebSecretKey.Creates a special builder for aJsonWebSecretKey.jakarta.json.JsonObjecttoJson()Converts thisJsonWebSecretKeyinto a plainJsonObject.toString()Returns a textual representation of thisJsonWebSecretKey.Methods inherited from class JsonWebKey
fromJson, getCurrentTracer, getKeyType, getKid
-
Method Details
-
of
Creates the default builder for aJsonWebSecretKey. Use this variant if you don't already have a secret key.- Returns:
- a
JsonWebSecretKey.Builder.
-
of
Creates a special builder for aJsonWebSecretKey. Use this variant if you already have aSecretKey.- Parameters:
secretKey- the givenSecretKey- Returns:
- a
JsonWebSecretKey.SecretKeyBuilder. - See Also:
-
getSecretKey
Returns the wrappedSecretKey.- Returns:
- the wrapped
SecretKeyinstance.
-
getAlgorithm
Return the algorithm to be used with the wrappedSecretKey, e.g.HS256.- Returns:
- the algorithm
-
toString
Returns a textual representation of thisJsonWebSecretKey.- Overrides:
toStringin classJsonWebKey- Returns:
- a textual representation of this
JsonWebSecretKey.
-
equals
Compares thisJsonWebSecretKeywith anotherJsonWebSecretKey. Compares thisJsonWebSecretKeywith another ensuring that it contains the same configuration. Only objects of typeJsonWebSecretKeyare considered, other types return false. -
hashCode
-
toJson
public jakarta.json.JsonObject toJson()Converts thisJsonWebSecretKeyinto a plainJsonObject.- Overrides:
toJsonin classJsonWebKey- Returns:
- a
JsonObjectcorresponding to thisJsonWebSecretKey. - See Also:
-
fromJson
public static JsonWebSecretKey fromJson(jakarta.json.JsonObject jwkView) throws GeneralSecurityException Factory method to create aJsonWebSecretKeyinstance from a plainJsonObject.- Parameters:
jwkView- the givenJsonObject.- Returns:
- a
JsonWebSecretKey - Throws:
GeneralSecurityException- passed through from the underlying implementations of the algorithms by the JDK.
-