Package org.forgerock.json.jose.jwk
Class JWK
- java.lang.Object
- 
- org.forgerock.json.jose.jwk.JWK
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classJWK.Builder<B extends JWK.Builder>JWK builder.
 - 
Field SummaryFields Modifier and Type Field Description protected static StringJSON_KEY_ALGThe Algorithm key.protected static StringJSON_KEY_KIDThe KeyID key.protected static StringJSON_KEY_KTYThe KeyType key.protected static StringJSON_KEY_OPERATIONSThe KeyOperations key.protected static StringJSON_KEY_USEThe KeyUse key.protected static StringJSON_KEY_X5CThe X509 chain key.protected static StringJSON_KEY_X5TThe X509 thumbprint.protected static StringJSON_KEY_X5T_S256The X509 SHA-256 thumbprint.protected static StringJSON_KEY_X5UThe X509 URL key.
 - 
Constructor SummaryConstructors Modifier Constructor Description protectedJWK(KeyType keyType, String use, String algorithm, String keyId)Deprecated.Use the builder instead.protectedJWK(KeyType keyType, String use, String algorithm, String keyId, String x509url, String x509Thumbprint, List<String> x509Chain)Deprecated.Use the builder instead.protectedJWK(KeyType keyType, String use, Set<KeyOperation> keyOperations, Algorithm algorithm, String keyId, String x509url, String x509Thumbprint, List<String> x509Chain)Creates a JWK given the basic parameters.
 - 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description StringgetAlgorithm()Deprecated.replaced bygetJwaAlgorithm()static AlgorithmgetAlgorithm(String algorithmName)Get the algorithm corresponding.AlgorithmgetJwaAlgorithm()Gets the alg parameter of the JWK.StringgetJwkThumbprint(String hashAlgorithm)Calculates the JWK Thumbprint of this JWK.StringgetKeyId()Gets the keyId parameter of the JWK.Set<KeyOperation>getKeyOperations()Gets the key operations parameter of the JWK.KeyTypegetKeyType()Gets the kty parameter of the JWK.protected abstract Optional<JWK.Builder<?>>getPublicJwkBuilder()Return a builder with all the values set for representing the public components of the JWK.StringgetUse()Gets the use parameter of the JWK.List<String>getX509Chain()Gets a List of X509 chain certs.StringgetX509Thumbnail()Deprecated.UsegetX509Thumbprint()instead.StringgetX509Thumbprint()Gets the X509 thumbprint.StringgetX509ThumbprintS256()Gets the X.509 SHA-256 thumbprint.StringgetX509URL()Gets the X509 URL.booleanisPrivate()Indicates if any private key attributes are present in the JWK.protected static voidloadJWKFromJson(JWK.Builder builder, JsonValue json)Load the generic JWK attributes from the json, by side effect.static JWKparse(String json)Parses a String into the proper JWK type.static JWKparse(JsonValue jwk)Parses a JsonValue into the proper JWK type.protected voidputField(JsonValue jsonValue, String key, Object value)Add a string value into a json only if it's not null.<T extends CryptoKey>
 TtoCryptoKey(Purpose<T> purpose, Instant expiry)Converts this JWK into aCryptoKeysubclass object for use with the Secrets API.StringtoJsonString()Prints the JWK Object as a json string.JsonValuetoJsonValue()Returns a json representation of the JWK.protected static JsonValuetoJsonValue(String json)Converts a String into a JsonValue.Optional<JWK>toPublicJwk()For asymmetric keys, get the public JWK representation of this JWK.
 
- 
- 
- 
Field Detail- 
JSON_KEY_KTYprotected static final String JSON_KEY_KTY The KeyType key.- See Also:
- Constant Field Values
 
 - 
JSON_KEY_USEprotected static final String JSON_KEY_USE The KeyUse key.- See Also:
- Constant Field Values
 
 - 
JSON_KEY_OPERATIONSprotected static final String JSON_KEY_OPERATIONS The KeyOperations key.- See Also:
- Constant Field Values
 
 - 
JSON_KEY_ALGprotected static final String JSON_KEY_ALG The Algorithm key.- See Also:
- Constant Field Values
 
 - 
JSON_KEY_KIDprotected static final String JSON_KEY_KID The KeyID key.- See Also:
- Constant Field Values
 
 - 
JSON_KEY_X5Uprotected static final String JSON_KEY_X5U The X509 URL key.- See Also:
- Constant Field Values
 
 - 
JSON_KEY_X5Tprotected static final String JSON_KEY_X5T The X509 thumbprint.- See Also:
- Constant Field Values
 
 - 
JSON_KEY_X5Cprotected static final String JSON_KEY_X5C The X509 chain key.- See Also:
- Constant Field Values
 
 - 
JSON_KEY_X5T_S256protected static final String JSON_KEY_X5T_S256 The X509 SHA-256 thumbprint.- See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
JWK@Deprecated protected JWK(KeyType keyType, String use, String algorithm, String keyId) Deprecated.Use the builder instead.Creates a JWK given the basic parameters.- Parameters:
- keyType- the JWK key type
- use- the JWK use
- algorithm- the JWK algorithm
- keyId- the JWK key id
 
 - 
JWK@Deprecated protected JWK(KeyType keyType, String use, String algorithm, String keyId, String x509url, String x509Thumbprint, List<String> x509Chain) Deprecated.Use the builder instead.Creates a JWK given the basic parameters.- Parameters:
- keyType- the JWK key type
- use- the JWK use
- algorithm- the JWK algorithm
- keyId- the JWK key id
- x509url- the x509 url for the key
- x509Thumbprint- the x509 thumbnail for the key
- x509Chain- the x509 chain as a list of Base64 encoded strings
 
 - 
JWKprotected JWK(KeyType keyType, String use, Set<KeyOperation> keyOperations, Algorithm algorithm, String keyId, String x509url, String x509Thumbprint, List<String> x509Chain) Creates a JWK given the basic parameters.- Parameters:
- keyType- the JWK key type
- use- the JWK use
- keyOperations- the JWK key Operations
- algorithm- the JWK algorithm
- keyId- the JWK key id
- x509url- the x509 url for the key
- x509Thumbprint- the x509 thumbprint for the key
- x509Chain- the x509 chain as a list of Base64 encoded strings
 
 
- 
 - 
Method Detail- 
getKeyTypepublic KeyType getKeyType() Gets the kty parameter of the JWK.- Returns:
- The KeyType for the JWK
 
 - 
getUsepublic String getUse() Gets the use parameter of the JWK.- Returns:
- The key use.
 
 - 
getKeyOperationspublic Set<KeyOperation> getKeyOperations() Gets the key operations parameter of the JWK.- Returns:
- A possibly nullset of key operations representing the key operations parameter. Ifnull, then all operations are allowed. An empty set mean that no key operations are allowed.
 
 - 
getAlgorithm@Deprecated public String getAlgorithm() Deprecated.replaced bygetJwaAlgorithm()Gets the alg parameter of the JWK.- Returns:
- The algorithm name representing the alg parameter
 
 - 
getJwaAlgorithmpublic Algorithm getJwaAlgorithm() Gets the alg parameter of the JWK.- Returns:
- The algorithm
 
 - 
getKeyIdpublic String getKeyId() Gets the keyId parameter of the JWK.- Returns:
- A String representing the keyId parameter
 
 - 
toJsonStringpublic String toJsonString() Prints the JWK Object as a json string.- Returns:
- A String representing JWK
 
 - 
toJsonValuepublic JsonValue toJsonValue() Returns a json representation of the JWK.- Returns:
- A JSON representation.
 
 - 
putFieldprotected void putField(JsonValue jsonValue, String key, Object value) Add a string value into a json only if it's not null.- Parameters:
- jsonValue- the json
- key- the- Mapkey or- Listindex identifying the child value to set.
- value- the value to assign to the member.
 
 - 
parsepublic static JWK parse(String json) Parses a String into the proper JWK type.- Parameters:
- json- The json String.
- Returns:
- A JWK object
- Throws:
- JsonException- If there is a problem parsing the json String.
 
 - 
parsepublic static JWK parse(JsonValue jwk) Parses a JsonValue into the proper JWK type.- Parameters:
- jwk- The JsonValue Object.
- Returns:
- A JWK object
- Throws:
- JsonException- If there is a problem analyzing the JsonValue Object.
 
 - 
loadJWKFromJsonprotected static void loadJWKFromJson(JWK.Builder builder, JsonValue json) Load the generic JWK attributes from the json, by side effect.- Parameters:
- builder- builder will be modified by side effect.
- json- the json value.
 
 - 
getAlgorithmpublic static Algorithm getAlgorithm(String algorithmName) Get the algorithm corresponding.- Parameters:
- algorithmName- The algorithm name..
- Returns:
- An algorithm
- Throws:
- IllegalArgumentException- If the algorithm is not supported.
 
 - 
toJsonValueprotected static JsonValue toJsonValue(String json) Converts a String into a JsonValue.- Parameters:
- json- The json String.
- Returns:
- A JsonValue object.
- Throws:
- JsonException- If there is a problem parsing the json String.
 
 - 
getX509URLpublic String getX509URL() Gets the X509 URL.- Returns:
- the url of the 509 cert header or null
 
 - 
getX509Thumbprintpublic String getX509Thumbprint() Gets the X509 thumbprint.- Returns:
- Base64url of the X509 thumbprint.
 
 - 
getX509Thumbnail@Deprecated public String getX509Thumbnail() Deprecated.UsegetX509Thumbprint()instead.Gets the X509 thumbprint.- Returns:
- Base64url of the X509 thumbnail
 
 - 
getX509ThumbprintS256public String getX509ThumbprintS256() Gets the X.509 SHA-256 thumbprint.- Returns:
- Base64url of the X.509 SHA-256 thumbprint.
 
 - 
getX509Chainpublic List<String> getX509Chain() Gets a List of X509 chain certs.- Returns:
- X509 Cert Chain as list of encoded strings or null if none are available.
 
 - 
isPrivatepublic boolean isPrivate() Indicates if any private key attributes are present in the JWK.- Returns:
- true if this JWK contains any private key attributes.
 
 - 
toPublicJwkpublic Optional<JWK> toPublicJwk() For asymmetric keys, get the public JWK representation of this JWK.- Returns:
- The public JWK.
 
 - 
getPublicJwkBuilderprotected abstract Optional<JWK.Builder<?>> getPublicJwkBuilder() Return a builder with all the values set for representing the public components of the JWK. Common JWK attributes will be added intoPublicJwk().- Returns:
- The builder.
 
 - 
getJwkThumbprintpublic String getJwkThumbprint(String hashAlgorithm) Calculates the JWK Thumbprint of this JWK.- Parameters:
- hashAlgorithm- the hash algorithm, e.g. SHA-256.
- Returns:
- the JWK thumbprint.
 
 - 
toCryptoKeypublic <T extends CryptoKey> T toCryptoKey(Purpose<T> purpose, Instant expiry) throws NoSuchSecretException Converts this JWK into aCryptoKeysubclass object for use with the Secrets API. Public and private key material is copied to the resulting object, as is any certificate chain. Any algorithm or key usage constraints are also applied to the resulting key object.- Type Parameters:
- T- the type of key to be built.
- Parameters:
- purpose- the purpose that the key will be used for.
- expiry- the expiry time for the resulting key object.
- Returns:
- the constructed key object.
- Throws:
- NoSuchSecretException- if the key cannot be built for any reason, is is not allowed to be used for the given purpose.
 
 
- 
 
-