Class KeyUsageExtension


  • public class KeyUsageExtension
    extends CertificateExtension
    Class representing "Key Usage" extenstion.
    • Field Detail

      • keyUsage

        private final int keyUsage
      • resultOnMissingExtension

        private final boolean resultOnMissingExtension
      • messagePreAmble

        private java.lang.String messagePreAmble
      • message

        private java.lang.String message
    • Constructor Detail

      • KeyUsageExtension

        public KeyUsageExtension​(int keyUsage)
        Create new KeyUsageExtension instance using provided int flag.
        Parameters:
        keyUsage - int flag which represents bit values for key usage value bit strings are stored with the big-endian byte order and padding on the end, the big endian notation causes a shift in actual integer values for bits 1-8 becoming 0-7 and bit 1 the 7 bits padding makes for bit 0 to become bit 7 of the first byte
      • KeyUsageExtension

        public KeyUsageExtension​(int keyUsage,
                                 boolean resultOnMissingExtension)
        Create new KeyUsageExtension instance using provided int flag.
        Parameters:
        keyUsage - int flag which represents bit values for key usage value bit strings are stored with the big-endian byte order and padding on the end, the big endian notation causes a shift in actual integer values for bits 1-8 becoming 0-7 and bit 1 the 7 bits padding makes for bit 0 to become bit 7 of the first byte
        resultOnMissingExtension - parameter which represents return value for existsInCertificate(X509Certificate) method in case of the extension not being present in a certificate
      • KeyUsageExtension

        public KeyUsageExtension​(java.util.List<KeyUsage> keyUsages)
        Create new KeyUsageExtension instance using provided key usage enum list.
        Parameters:
        keyUsages - key usages List which represents key usage values
      • KeyUsageExtension

        public KeyUsageExtension​(java.util.List<KeyUsage> keyUsages,
                                 boolean resultOnMissingExtension)
        Create new KeyUsageExtension instance using provided key usage enum list.
        Parameters:
        keyUsages - key usages List which represents key usage values
        resultOnMissingExtension - parameter which represents return value for existsInCertificate(X509Certificate) method in case of the extension not being present in a certificate
      • KeyUsageExtension

        public KeyUsageExtension​(KeyUsage keyUsageValue)
        Create new KeyUsageExtension instance using provided single key usage enum value.
        Parameters:
        keyUsageValue - KeyUsage which represents single key usage enum value
      • KeyUsageExtension

        public KeyUsageExtension​(KeyUsage keyUsageValue,
                                 boolean resultOnMissingExtension)
        Create new KeyUsageExtension instance using provided single key usage enum value.
        Parameters:
        keyUsageValue - KeyUsage which represents single key usage enum value
        resultOnMissingExtension - parameter which represents return value for existsInCertificate(X509Certificate) method in case of the extension not being present in a certificate
    • Method Detail

      • existsInCertificate

        public boolean existsInCertificate​(java.security.cert.X509Certificate certificate)
        Check if this extension is present in the provided certificate. In case of KeyUsageExtension, check if this key usage bit values are present in certificate. Other values may be present as well.
        Overrides:
        existsInCertificate in class CertificateExtension
        Parameters:
        certificate - X509Certificate in which this extension shall be present
        Returns:
        true if this key usage bit values are present in certificate, false otherwise
      • getMessage

        public java.lang.String getMessage()
        Description copied from class: CertificateExtension
        Returns a message with extra information about the check.
        Overrides:
        getMessage in class CertificateExtension
        Returns:
        a message with extra information about the check.
      • convertKeyUsageMaskToString

        private static java.lang.String convertKeyUsageMaskToString​(int keyUsageMask)
      • convertKeyUsageSetToInt

        private static int convertKeyUsageSetToInt​(java.lang.Iterable<KeyUsage> keyUsages)