Class AuthUtils


  • public class AuthUtils
    extends Object
    Utilities dealing with authorization.
    • Method Detail

      • getFingerPrint

        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

        Parameters:
        certificate - the certificate
        Returns:
        Fingerprint of the certificate
        Throws:
        Error - if there is an error
      • toJwk

        public static Optional<JWK> toJwk​(String json)
        Convert JSON string into JWK.
        Parameters:
        json - the json string
        Returns:
        Optional of JWK
      • toByteArrayFromRSAPrivateKey

        public static byte[] toByteArrayFromRSAPrivateKey​(RSAPrivateKey key)
        Converts a private key back to a PEM formatted input stream.
        Parameters:
        key - The key to convert.
        Returns:
        A new input stream
      • base64EncodeNoChunking

        public static String base64EncodeNoChunking​(RSAPublicKey publicKey)
        Base64 encodes a public key with no chunking.
        Parameters:
        publicKey - The public key
        Returns:
        Base64 representation
      • base64Decode

        public static byte[] base64Decode​(String base64)
        Decode the base64 string.

        This supports both ‘+’ and ‘/’ as well as ‘-’ and ‘_’.

        Parameters:
        base64 - base64 string
        Returns:
        decoded bytes
      • getTenantIdFromCertificate

        public static String getTenantIdFromCertificate​(X509Certificate certificate)
        Get the tenant id from the given certificate.
        Parameters:
        certificate - the given certificate.
        Returns:
        the tenant id.