Package uk.co.spudsoft.jwtvalidatorvertx
Class JwkBuilder
java.lang.Object
uk.co.spudsoft.jwtvalidatorvertx.JwkBuilder
- Direct Known Subclasses:
ECJwkBuilder
,EdECJwkBuilder
,RSAJwkBuilder
The JwkBuilder class is an SPI for containing the algorithm-specific conversions from Token to JWK or from JSON to JWK.
- Author:
- jtalbut
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Base64.Encoder
Instance of aBase64.Encoder
for encoding values used in JWK JSON. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract boolean
canHandleKey
(PublicKey key) Return true if the builder can create a JWK by generating JSON for the given PublicKey.static JwkBuilder
Get the appropriate builder for the given public key.abstract io.vertx.core.json.JsonObject
Convert the given public key into a valid JWK JSON representation.
-
Field Details
-
B64ENCODER
Instance of aBase64.Encoder
for encoding values used in JWK JSON. Used when creating JSON for implementations oftoJson(java.lang.String, java.lang.String, java.security.PublicKey)
.
-
-
Constructor Details
-
JwkBuilder
protected JwkBuilder()Protected constructor used by subclasses.
-
-
Method Details
-
get
Get the appropriate builder for the given public key.- Parameters:
publicKey
- The public key whose builder is being sought.- Returns:
- A JwkBuilder able to work with the given public key.
- Throws:
IllegalArgumentException
- if now builder can be found for the provided key.
-
canHandleKey
Return true if the builder can create a JWK by generating JSON for the given PublicKey.- Parameters:
key
- The key that that this builder is being asked about.- Returns:
- true if the builder can create a JWK by generating JSON for the given PublicKey.
-
toJson
public abstract io.vertx.core.json.JsonObject toJson(String kid, String algorithm, PublicKey publicKey) throws InvalidParameterSpecException, NoSuchAlgorithmException Convert the given public key into a valid JWK JSON representation.- Parameters:
kid
- The ID for the key.algorithm
- The algorithm to be used with the key.publicKey
- The public key.- Returns:
- The JWK representation of the key,
- Throws:
InvalidParameterSpecException
- if the security subsystem does so.NoSuchAlgorithmException
- if the security subsystem does so.
-