Class HttpsCertVerifier

  • All Implemented Interfaces:
    CertVerifier

    public class HttpsCertVerifier
    extends java.lang.Object
    implements CertVerifier
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.security.cert.X509Certificate[] chain  
      private java.util.ArrayList<java.lang.String> details  
      private boolean hostMatched  
      private java.lang.String hostName  
      private boolean isTrusted  
      private static Logger LOG  
    • Constructor Summary

      Constructors 
      Constructor Description
      HttpsCertVerifier​(java.security.cert.X509Certificate[] chain, boolean isTrusted, boolean hostMatched, java.lang.String hostName)  
    • Field Detail

      • LOG

        private static final Logger LOG
      • chain

        private final java.security.cert.X509Certificate[] chain
      • hostName

        private final java.lang.String hostName
      • isTrusted

        private final boolean isTrusted
      • hostMatched

        private final boolean hostMatched
      • details

        private final java.util.ArrayList<java.lang.String> details
    • Constructor Detail

      • HttpsCertVerifier

        HttpsCertVerifier​(java.security.cert.X509Certificate[] chain,
                          boolean isTrusted,
                          boolean hostMatched,
                          java.lang.String hostName)
    • Method Detail

      • getAlreadyTrustPublisher

        public boolean getAlreadyTrustPublisher()
        Specified by:
        getAlreadyTrustPublisher in interface CertVerifier
        Returns:
        if the publisher is already trusted
      • getCertPath

        public java.security.cert.CertPath getCertPath()
        Specified by:
        getCertPath in interface CertVerifier
        Returns:
        a valid certificate path to this certificate being verified
      • getDetails

        public java.util.List<java.lang.String> getDetails​(java.security.cert.CertPath certPath)
        Specified by:
        getDetails in interface CertVerifier
        Parameters:
        certPath - certificate
        Returns:
        the details regarding issue with this certificate
      • getMostSpecificCommonName

        static java.lang.String getMostSpecificCommonName​(java.security.cert.X509Certificate c)
                                                   throws javax.naming.InvalidNameException
        Returns:
        the last (most specific) CN of the subject, or null
        Throws:
        javax.naming.InvalidNameException
      • getNamesForCert

        private java.lang.String getNamesForCert​(java.security.cert.X509Certificate c)
      • addToDetails

        private void addToDetails​(java.lang.String detail)
      • getPublisher

        public java.security.cert.Certificate getPublisher​(java.security.cert.CertPath certPath)
        Specified by:
        getPublisher in interface CertVerifier
        Parameters:
        certPath - to be read for publisher
        Returns:
        the application's publisher's certificate.
      • getRoot

        public java.security.cert.Certificate getRoot​(java.security.cert.CertPath certPath)
        Specified by:
        getRoot in interface CertVerifier
        Parameters:
        certPath - certificate
        Returns:
        the application's root's certificate. This may return the same certificate as getPublisher(CertPath certPath) in the event that the application is self signed.
      • getRootInCaCerts

        public boolean getRootInCaCerts()
        Specified by:
        getRootInCaCerts in interface CertVerifier
        Returns:
        if the root is in CA certs