Class ToolariumTrustManager

  • All Implemented Interfaces:
    javax.net.ssl.TrustManager, javax.net.ssl.X509TrustManager

    public class ToolariumTrustManager
    extends java.lang.Object
    implements javax.net.ssl.X509TrustManager
    Toolariun TrustManager which logs the verification.
    • Constructor Summary

      Constructors 
      Constructor Description
      ToolariumTrustManager()
      Constructor for ToolariumTrustManager
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addTrustedCertificate​(java.security.cert.X509Certificate cert)
      Adds a trusted certificate
      protected void checkCACertificate​(java.security.cert.X509Certificate cacert)
      Checks the CA certificate
      protected void checkCertificate​(java.security.cert.X509Certificate cert)
      Checks the certificate
      protected void checkCertificateChain​(java.security.cert.X509Certificate[] chain)
      Checks the certificate chain
      void checkClientTrusted​(java.security.cert.X509Certificate[] chain, java.lang.String protocol)  
      void checkServerTrusted​(java.security.cert.X509Certificate[] chain, java.lang.String protocol)  
      java.security.cert.X509Certificate[] getAcceptedIssuers()  
      int getCheckResult()
      Gets the check result
      protected java.lang.String getHostname()
      Gets the host name
      void setVerifyCertificate​(boolean verifyCertificate)
      Set the verify certificate
      protected boolean trustServerCertificate​(java.security.cert.X509Certificate certificate)
      Check if the given certificate should be trust and added to the certificate server list
      void verifyCertificateChain​(java.security.cert.X509Certificate[] chain, java.lang.String protocol)
      Verifies a certificate chain.
      • Methods inherited from class java.lang.Object

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

      • ToolariumTrustManager

        public ToolariumTrustManager()
        Constructor for ToolariumTrustManager
    • Method Detail

      • addTrustedCertificate

        public void addTrustedCertificate​(java.security.cert.X509Certificate cert)
        Adds a trusted certificate
        Parameters:
        cert - the certificate to trust
      • checkClientTrusted

        public void checkClientTrusted​(java.security.cert.X509Certificate[] chain,
                                       java.lang.String protocol)
                                throws java.security.cert.CertificateException
        Specified by:
        checkClientTrusted in interface javax.net.ssl.X509TrustManager
        Throws:
        java.security.cert.CertificateException
        See Also:
        X509TrustManager.checkClientTrusted(java.security.cert.X509Certificate[], java.lang.String)
      • checkServerTrusted

        public void checkServerTrusted​(java.security.cert.X509Certificate[] chain,
                                       java.lang.String protocol)
                                throws java.security.cert.CertificateException
        Specified by:
        checkServerTrusted in interface javax.net.ssl.X509TrustManager
        Throws:
        java.security.cert.CertificateException
        See Also:
        X509TrustManager.checkServerTrusted(java.security.cert.X509Certificate[], java.lang.String)
      • setVerifyCertificate

        public void setVerifyCertificate​(boolean verifyCertificate)
        Set the verify certificate
        Parameters:
        verifyCertificate - true to verify certificates
      • getAcceptedIssuers

        public java.security.cert.X509Certificate[] getAcceptedIssuers()
        Specified by:
        getAcceptedIssuers in interface javax.net.ssl.X509TrustManager
        See Also:
        X509TrustManager.getAcceptedIssuers()
      • getCheckResult

        public int getCheckResult()
        Gets the check result
        Returns:
        the check result
      • verifyCertificateChain

        public void verifyCertificateChain​(java.security.cert.X509Certificate[] chain,
                                           java.lang.String protocol)
                                    throws java.security.cert.CertificateException
        Verifies a certificate chain.
        Parameters:
        chain - a certificate chain
        protocol - the protocol
        Throws:
        java.security.cert.CertificateException - in case of error
      • checkCertificate

        protected void checkCertificate​(java.security.cert.X509Certificate cert)
                                 throws java.security.cert.CertificateException
        Checks the certificate
        Parameters:
        cert - the certificate to test
        Throws:
        java.security.cert.CertificateException - In case of a certificate error
      • checkCACertificate

        protected void checkCACertificate​(java.security.cert.X509Certificate cacert)
                                   throws java.security.cert.CertificateException
        Checks the CA certificate
        Parameters:
        cacert - the certificate to test
        Throws:
        java.security.cert.CertificateException - In case of a certificate error
      • checkCertificateChain

        protected void checkCertificateChain​(java.security.cert.X509Certificate[] chain)
                                      throws java.security.cert.CertificateException
        Checks the certificate chain
        Parameters:
        chain - the chain
        Throws:
        java.security.cert.CertificateException - In case of a certificate error
      • trustServerCertificate

        protected boolean trustServerCertificate​(java.security.cert.X509Certificate certificate)
        Check if the given certificate should be trust and added to the certificate server list
        Parameters:
        certificate - the server certificate
        Returns:
        true if we trust the server certificate
      • getHostname

        protected java.lang.String getHostname()
        Gets the host name
        Returns:
        the name