Class FingerprintHelper


  • public class FingerprintHelper
    extends java.lang.Object
    A utility class for computing fingerprints of X.509 certificates.

    This class provides methods to generate a cryptographic fingerprint (hash) of an X.509 certificate using a specified digest algorithm.

    The default digest algorithm used is SHA-1.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String DEFAULT_DIGEST_ALGORITHM
      The default message digest algorithm used for computing fingerprints.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String getFingerprint​(java.security.cert.X509Certificate cert)
      Computes the fingerprint of an X.509 certificate using the default digest algorithm.
      private static java.lang.String hexify​(byte[] bytes)
      Converts a byte array to a hexadecimal string representation.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_DIGEST_ALGORITHM

        public static final java.lang.String DEFAULT_DIGEST_ALGORITHM
        The default message digest algorithm used for computing fingerprints.
        See Also:
        Constant Field Values
    • Constructor Detail

      • FingerprintHelper

        public FingerprintHelper()
    • Method Detail

      • hexify

        private static java.lang.String hexify​(byte[] bytes)
        Converts a byte array to a hexadecimal string representation.
        Parameters:
        bytes - the byte array to convert
        Returns:
        a string containing the hexadecimal representation of the byte array
      • getFingerprint

        public static java.lang.String getFingerprint​(java.security.cert.X509Certificate cert)
                                               throws java.security.NoSuchAlgorithmException,
                                                      java.security.cert.CertificateEncodingException
        Computes the fingerprint of an X.509 certificate using the default digest algorithm.
        Parameters:
        cert - the X.509 certificate for which to compute the fingerprint
        Returns:
        the fingerprint of the certificate as a hexadecimal string
        Throws:
        java.security.NoSuchAlgorithmException - if the specified digest algorithm is not available
        java.security.cert.CertificateEncodingException - if encoding the certificate fails