public class AuthUtils extends Object
Utilities dealing with authorization.
Modifier and Type | Method and Description |
---|---|
static byte[] |
base64Decode(String base64)
Decode the base64 string.
|
static String |
base64EncodeNoChunking(RSAPublicKey publicKey)
Base64 encodes a public key with no chunking.
|
static String |
base64EncodeNoChunking(X509Certificate certificate)
Base64 encodes a X509Certificate with no chunking.
|
static String |
getFingerPrint(X509Certificate certificate)
Gets the fingerprint of a certificate using Sha256.
|
static String |
getTenantIdFromCertificate(X509Certificate certificate)
Get the tenant id from the given certificate.
|
static byte[] |
toByteArrayFromRSAPrivateKey(RSAPrivateKey key)
Converts a private key back to a PEM formatted input stream.
|
static Optional<JWK> |
toJwk(String json)
Convert JSON string into
JWK . |
static Optional<RSAPublicKey> |
toPublicKeyFromJson(String json)
Convert JWK JSON string into a
RSAPublicKey . |
static Optional<RSAPublicKey> |
toPublicKeyFromJwk(JWK jwk)
Convert
JWK into RSAPublicKey . |
public static String getFingerPrint(X509Certificate certificate)
Gets the fingerprint of a certificate using Sha256. This is the same value that you would get
by running, openssl x509 -in certificate.pem -noout -fingerprint
certificate
- the certificateError
- if there is an errorpublic static Optional<RSAPublicKey> toPublicKeyFromJson(String json)
Convert JWK JSON string into a RSAPublicKey
.
public static Optional<JWK> toJwk(String json)
Convert JSON string into JWK
.
json
- the json stringpublic static Optional<RSAPublicKey> toPublicKeyFromJwk(JWK jwk)
Convert JWK
into RSAPublicKey
.
jwk
- the jwk objectpublic static byte[] toByteArrayFromRSAPrivateKey(RSAPrivateKey key)
Converts a private key back to a PEM formatted input stream.
key
- The key to convert.public static String base64EncodeNoChunking(RSAPublicKey publicKey)
Base64 encodes a public key with no chunking.
publicKey
- The public keypublic static String base64EncodeNoChunking(X509Certificate certificate) throws CertificateEncodingException
Base64 encodes a X509Certificate with no chunking.
certificate
- The certificateCertificateEncodingException
public static byte[] base64Decode(String base64)
Decode the base64 string. This supports both ‘+’ and ‘/’ as well as ‘-’ and ‘_’.
base64
- base64 stringpublic static String getTenantIdFromCertificate(X509Certificate certificate)
Get the tenant id from the given certificate.
certificate
- the given certificate.Copyright © 2016–2024. All rights reserved.