java.lang.Object
io.helidon.security.jwt.JwtUtil
Utilities for JWT and JWK parsing.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAddress class representing the JSON object for address. -
Method Summary
Modifier and TypeMethodDescriptionstatic BigIntegerasBigInteger(JsonObject json, String key, String description) Extract a key value from json object that is base64-url encoded and convert it to big integer.static BigIntegerasBigInteger(JsonObject json, String key, String description) Deprecated, for removal: This API element is subject to removal in a future version.static byte[]asByteArray(JsonObject json, String key, String description) Extract a key value from json object that is a base64-url encoded byte array.static byte[]asByteArray(JsonObject json, String key, String description) Deprecated, for removal: This API element is subject to removal in a future version.static StringasString(JsonObject json, String key, String description) Extract a key value from json object that is string.static StringasString(JsonObject json, String key, String description) Deprecated, for removal: This API element is subject to removal in a future version.static Optional<BigInteger> getBigInteger(JsonObject json, String key, String description) Extract a key value from json object that is base64-url encoded and convert it to big integer if present.static Optional<BigInteger> getBigInteger(JsonObject json, String key, String description) Deprecated, for removal: This API element is subject to removal in a future version.static Optional<byte[]> getByteArray(JsonObject json, String key, String description) Extract a key value from json object that is a base64-url encoded byte array, if present.static Optional<byte[]> getByteArray(JsonObject json, String key, String description) Deprecated, for removal: This API element is subject to removal in a future version.static KeyFactorygetKeyFactory(String algorithm) Create a key factory for algorithm.static MacCreate a MAC for algorithm.static SignaturegetSignature(String signatureAlgorithm) Create a signature for algorithm.getString(JsonObject json, String key) Extract a key value from json object that is string if present.getString(JsonObject json, String key) Deprecated, for removal: This API element is subject to removal in a future version.usegetString(io.helidon.json.JsonObject, String)insteadgetStrings(JsonObject json, String key) Extract a key value from json object that is a list of strings if present.getStrings(JsonObject json, String key) Deprecated, for removal: This API element is subject to removal in a future version.usegetStrings(io.helidon.json.JsonObject, String)insteadstatic JsonValueDeprecated, for removal: This API element is subject to removal in a future version.usetoJsonValue(Object)insteadstatic JsonValuetoJsonValue(Object object) Create aJsonValuefrom an object.static ObjectTransform from json to object.static ObjectDeprecated, for removal: This API element is subject to removal in a future version.usetoObject(io.helidon.json.JsonValue)insteadtransformToJson(Map<String, Object> claims) Deprecated, for removal: This API element is subject to removal in a future version.usetransformToJsonValue(Map)insteadtransformToJsonValue(Map<String, Object> claims) Transform a map of strings to objects to a map of string to JSON values.
-
Method Details
-
asBigInteger
public static BigInteger asBigInteger(JsonObject json, String key, String description) throws JwtException Extract a key value from json object that is base64-url encoded and convert it to big integer.- Parameters:
json- JsonObject to read key fromkey- key of the value we want to readdescription- description of the field for error handling- Returns:
- BigInteger value
- Throws:
JwtException- in case the key is not present or is of invalid content
-
asBigInteger
@Deprecated(since="4.5.0", forRemoval=true) public static BigInteger asBigInteger(JsonObject json, String key, String description) throws JwtException Deprecated, for removal: This API element is subject to removal in a future version.Extract a key value from json object that is base64-url encoded and convert it to big integer.- Parameters:
json- JsonObject to read key fromkey- key of the value we want to readdescription- description of the field for error handling- Returns:
- BigInteger value
- Throws:
JwtException- in case the key is not present or is of invalid content
-
asString
Extract a key value from json object that is string.- Parameters:
json- JsonObject to read key fromkey- key of the value we want to readdescription- description of the field for error handling- Returns:
- String value
- Throws:
JwtException- in case the key is not present or is of invalid content
-
asString
@Deprecated(since="4.5.0", forRemoval=true) public static String asString(JsonObject json, String key, String description) throws JwtException Deprecated, for removal: This API element is subject to removal in a future version.Extract a key value from json object that is string.- Parameters:
json- JsonObject to read key fromkey- key of the value we want to readdescription- description of the field for error handling- Returns:
- String value
- Throws:
JwtException- in case the key is not present or is of invalid content
-
getBigInteger
public static Optional<BigInteger> getBigInteger(JsonObject json, String key, String description) throws JwtException Extract a key value from json object that is base64-url encoded and convert it to big integer if present.- Parameters:
json- JsonObject to read key fromkey- key of the value we want to readdescription- description of the field for error handling- Returns:
- BigInteger value if present
- Throws:
JwtException- in case the key is of invalid content
-
getBigInteger
@Deprecated(since="4.5.0", forRemoval=true) public static Optional<BigInteger> getBigInteger(JsonObject json, String key, String description) throws JwtException Deprecated, for removal: This API element is subject to removal in a future version.Extract a key value from json object that is base64-url encoded and convert it to big integer if present.- Parameters:
json- JsonObject to read key fromkey- key of the value we want to readdescription- description of the field for error handling- Returns:
- BigInteger value if present
- Throws:
JwtException- in case the key is of invalid content
-
getStrings
Extract a key value from json object that is a list of strings if present.- Parameters:
json- JsonObject to read key fromkey- key of the value we want to read- Returns:
- List of String value if present
- Throws:
JwtException- in case the key is of invalid content
-
getStrings
@Deprecated(since="4.5.0", forRemoval=true) public static Optional<List<String>> getStrings(JsonObject json, String key) throws JwtException Deprecated, for removal: This API element is subject to removal in a future version.usegetStrings(io.helidon.json.JsonObject, String)insteadExtract a key value from json object that is a list of strings if present.- Parameters:
json- JsonObject to read key fromkey- key of the value we want to read- Returns:
- List of String value if present
- Throws:
JwtException- in case the key is of invalid content
-
getString
Extract a key value from json object that is string if present.- Parameters:
json- JsonObject to read key fromkey- key of the value we want to read- Returns:
- String value if present
- Throws:
JwtException- in case the key is of invalid content
-
getString
@Deprecated(since="4.5.0", forRemoval=true) public static Optional<String> getString(JsonObject json, String key) throws JwtException Deprecated, for removal: This API element is subject to removal in a future version.usegetString(io.helidon.json.JsonObject, String)insteadExtract a key value from json object that is string if present.- Parameters:
json- JsonObject to read key fromkey- key of the value we want to read- Returns:
- String value if present
- Throws:
JwtException- in case the key is of invalid content
-
getByteArray
public static Optional<byte[]> getByteArray(JsonObject json, String key, String description) throws JwtException Extract a key value from json object that is a base64-url encoded byte array, if present.- Parameters:
json- JsonObject to read key fromkey- key of the value we want to readdescription- description of the field for error handling- Returns:
- byte array value if present
- Throws:
JwtException- in case the key is of invalid content or not base64 encoded
-
getByteArray
@Deprecated(since="4.5.0", forRemoval=true) public static Optional<byte[]> getByteArray(JsonObject json, String key, String description) throws JwtException Deprecated, for removal: This API element is subject to removal in a future version.Extract a key value from json object that is a base64-url encoded byte array, if present.- Parameters:
json- JsonObject to read key fromkey- key of the value we want to readdescription- description of the field for error handling- Returns:
- byte array value if present
- Throws:
JwtException- in case the key is of invalid content or not base64 encoded
-
asByteArray
public static byte[] asByteArray(JsonObject json, String key, String description) throws JwtException Extract a key value from json object that is a base64-url encoded byte array.- Parameters:
json- JsonObject to read key fromkey- key of the value we want to readdescription- description of the field for error handling- Returns:
- byte array value
- Throws:
JwtException- in case the key is not present, is of invalid content or not base64 encoded
-
asByteArray
@Deprecated(since="4.5.0", forRemoval=true) public static byte[] asByteArray(JsonObject json, String key, String description) throws JwtException Deprecated, for removal: This API element is subject to removal in a future version.Extract a key value from json object that is a base64-url encoded byte array.- Parameters:
json- JsonObject to read key fromkey- key of the value we want to readdescription- description of the field for error handling- Returns:
- byte array value
- Throws:
JwtException- in case the key is not present, is of invalid content or not base64 encoded
-
getKeyFactory
Create a key factory for algorithm.- Parameters:
algorithm- security algorithm (such as RSA, EC)- Returns:
- KeyFactory instance
- Throws:
JwtException- in case the algorithm is invalid
-
getSignature
Create a signature for algorithm.- Parameters:
signatureAlgorithm- security signature algorithm (such as "SHA512withRSA")- Returns:
- Signature instance
- Throws:
JwtException- in case the algorithm is invalid or not supported by this JVM
-
getMac
Create a MAC for algorithm. Similar to signature for symmetric ciphers (such as "HmacSHA256").- Parameters:
algorithm- security MAC algorithm- Returns:
- Mac instance
- Throws:
JwtException- in case the algorithm is invalid or not supported by this JVM
-
transformToJsonValue
Transform a map of strings to objects to a map of string to JSON values. Each object is checked for type and if supported, transformed to appropriate JSON value.- Parameters:
claims- map to transform from- Returns:
- resulting map
-
transformToJson
@Deprecated(since="4.5.0", forRemoval=true) public static Map<String,JsonValue> transformToJson(Map<String, Object> claims) Deprecated, for removal: This API element is subject to removal in a future version.usetransformToJsonValue(Map)insteadTransform a map of strings to objects to a map of string to JSON values. Each object is checked for type and if supported, transformed to appropriate JSON value.- Parameters:
claims- map to transform from- Returns:
- resulting map
-
toJsonValue
Create aJsonValuefrom an object. This will use correct types for known primitives,JwtUtil.Addressotherwise it uses String value.- Parameters:
object- object to create json value from- Returns:
- json value
-
toJson
Deprecated, for removal: This API element is subject to removal in a future version.usetoJsonValue(Object)insteadCreate aJsonValuefrom an object. This will use correct types for known primitives,JwtUtil.Addressotherwise it uses String value.- Parameters:
object- object to create json value from- Returns:
- json value
-
toObject
Transform from json to object.- Parameters:
jsonValue- json value- Returns:
- object most correct for the type, or string value if not understood (e.g. json object)
-
toObject
Deprecated, for removal: This API element is subject to removal in a future version.usetoObject(io.helidon.json.JsonValue)insteadTransform from json to object.- Parameters:
jsonValue- json value- Returns:
- object most correct for the type, or string value if not understood (e.g. json object)
-
asBigInteger(io.helidon.json.JsonObject, String, String)instead