- java.lang.Object
-
- org.shredzone.acme4j.toolbox.JoseUtils
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Map<String,Object>
createExternalAccountBinding(String kid, PublicKey accountKey, SecretKey macKey, String macAlgorithm, URL resource)
Creates a JSON structure for external account binding.static JSONBuilder
createJoseRequest(URL url, KeyPair keypair, JSONBuilder payload, String nonce, String kid)
Creates an ACME JOSE request.static PublicKey
jwkToPublicKey(Map<String,Object> jwk)
Converts a JOSE JWK structure to aPublicKey
.static String
keyAlgorithm(org.jose4j.jwk.JsonWebKey jwk)
Analyzes the key used in theJsonWebKey
, and returns the key algorithm identifier forJsonWebSignature
.static String
macKeyAlgorithm(SecretKey macKey)
Analyzes theSecretKey
, and returns the key algorithm identifier forJsonWebSignature
.static Map<String,Object>
publicKeyToJWK(PublicKey key)
Converts aPublicKey
to a JOSE JWK structure.static byte[]
thumbprint(PublicKey key)
Computes a thumbprint of the given public key.
-
-
-
Method Detail
-
createJoseRequest
public static JSONBuilder createJoseRequest(URL url, KeyPair keypair, @Nullable JSONBuilder payload, @Nullable String nonce, @Nullable String kid)
Creates an ACME JOSE request.- Parameters:
url
-URL
of the ACME callkeypair
-KeyPair
to sign the request withpayload
- ACME JSON payload. Ifnull
, a POST-as-GET request is generated instead.nonce
- Nonce to be used.null
if no nonce is to be used in the JOSE header.kid
- kid to be used in the JOSE header. Ifnull
, a jwk header of the given key is used instead.- Returns:
- JSON structure of the JOSE request, ready to be sent.
-
createExternalAccountBinding
public static Map<String,Object> createExternalAccountBinding(String kid, PublicKey accountKey, SecretKey macKey, String macAlgorithm, URL resource)
Creates a JSON structure for external account binding.
-
publicKeyToJWK
public static Map<String,Object> publicKeyToJWK(PublicKey key)
Converts aPublicKey
to a JOSE JWK structure.- Parameters:
key
-PublicKey
to convert- Returns:
- JSON map containing the JWK structure
-
jwkToPublicKey
public static PublicKey jwkToPublicKey(Map<String,Object> jwk)
Converts a JOSE JWK structure to aPublicKey
.- Parameters:
jwk
- Map containing a JWK structure- Returns:
- the extracted
PublicKey
-
thumbprint
public static byte[] thumbprint(PublicKey key)
Computes a thumbprint of the given public key.- Parameters:
key
-PublicKey
to get the thumbprint of- Returns:
- Thumbprint of the key
-
keyAlgorithm
public static String keyAlgorithm(org.jose4j.jwk.JsonWebKey jwk)
Analyzes the key used in theJsonWebKey
, and returns the key algorithm identifier forJsonWebSignature
.- Parameters:
jwk
-JsonWebKey
to analyze- Returns:
- algorithm identifier
- Throws:
IllegalArgumentException
- there is no corresponding algorithm identifier for the key
-
macKeyAlgorithm
public static String macKeyAlgorithm(SecretKey macKey)
Analyzes theSecretKey
, and returns the key algorithm identifier forJsonWebSignature
.- Parameters:
macKey
-SecretKey
to analyze- Returns:
- algorithm identifier
- Throws:
IllegalArgumentException
- there is no corresponding algorithm identifier for the key
-
-