Modifier and Type | Method and Description |
---|---|
static String |
base64UrlEncode(byte[] data)
Base64 encodes the given byte array, using URL style encoding.
|
static String |
getContentType(String header)
Extracts the content type of a Content-Type header.
|
static String |
hexEncode(byte[] data)
Hex encodes the given byte array.
|
static String |
keyAlgorithm(org.jose4j.jwk.JsonWebKey jwk)
Analyzes the key used in the
JsonWebKey , and returns the key algorithm
identifier for JsonWebSignature . |
static Instant |
parseTimestamp(String str)
Parses a RFC 3339 formatted date.
|
static byte[] |
sha256hash(String z)
Computes a SHA-256 hash of the given string.
|
static String |
stripErrorPrefix(String type)
Strips the acme error prefix from the error string.
|
static String |
toAce(String domain)
ASCII encodes a domain name.
|
public static byte[] sha256hash(String z)
z
- String to hashpublic static String hexEncode(byte[] data)
data
- byte array to hex encodepublic static String base64UrlEncode(byte[] data)
data
- byte array to base64 encodepublic static String toAce(String domain)
The conversion is done as described in RFC 3490. Additionally, all leading and trailing white spaces are trimmed, and the result is lowercased.
It is safe to pass in ACE encoded domains, they will be returned unchanged.
domain
- Domain name to encodenull
if
null
was passed in.public static String keyAlgorithm(org.jose4j.jwk.JsonWebKey jwk)
JsonWebKey
, and returns the key algorithm
identifier for JsonWebSignature
.jwk
- JsonWebKey
to analyzeIllegalArgumentException
- there is no corresponding algorithm identifier for the keypublic static Instant parseTimestamp(String str)
str
- Date stringInstant
that was parsedIllegalArgumentException
- if the date string was not RFC 3339 formattedpublic static String stripErrorPrefix(String type)
For example, for "urn:ietf:params:acme:error:conflict", "conflict" is returned.
This method also handles the deprecated prefix "urn:acme:error:" that is still in use at Let's Encrypt.
type
- Error type to strip the prefix from. null
is safe.null
if the prefix was not found.public static String getContentType(String header)
header
- Content-Type headernull
if the header was invalid or emptyAcmeProtocolException
- if the Content-Type header contains a different charset than "utf-8".Copyright © 2015–2019. All rights reserved.