Class VariableX509TrustManager


  • public final class VariableX509TrustManager
    extends java.lang.Object
    This class implements an X509 Trust Manager. The certificates it trusts are "variable", in the sense that it can dynamically, and temporarily support different certificates that are not in the keystore.
    • Constructor Summary

      Constructors 
      Constructor Description
      VariableX509TrustManager()
      Constructor initializes the system, user and custom stores
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void checkTrustClient​(java.security.cert.X509Certificate[] chain, java.lang.String authType, java.lang.String hostName)
      Check if client is trusted (no support for custom here, only system/user)
      void checkTrustServer​(java.security.cert.X509Certificate[] chain, java.lang.String authType, java.lang.String hostName, javax.net.ssl.SSLSocket socket, javax.net.ssl.SSLEngine engine)
      Check if the server is trusted.
      protected java.security.cert.X509Certificate[] getAcceptedIssuers()  
      static VariableX509TrustManager getInstance()
      Return an instance of this singleton
      • Methods inherited from class java.lang.Object

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

      • VariableX509TrustManager

        public VariableX509TrustManager()
        Constructor initializes the system, user and custom stores
    • Method Detail

      • checkTrustClient

        public void checkTrustClient​(java.security.cert.X509Certificate[] chain,
                                     java.lang.String authType,
                                     java.lang.String hostName)
                              throws java.security.cert.CertificateException
        Check if client is trusted (no support for custom here, only system/user)
        Parameters:
        chain - certificate chain
        authType - type of authentification
        hostName - hostnem
        Throws:
        java.security.cert.CertificateException - if certificate is wrong
      • checkTrustServer

        public void checkTrustServer​(java.security.cert.X509Certificate[] chain,
                                     java.lang.String authType,
                                     java.lang.String hostName,
                                     javax.net.ssl.SSLSocket socket,
                                     javax.net.ssl.SSLEngine engine)
                              throws java.security.cert.CertificateException
        Check if the server is trusted. First, existing stores are checked to see if the certificate is trusted. Next, if the certificate is not explicitly trusted by the user, a host name check is performed. The user is them prompted as needed.
        Parameters:
        chain - The cert chain
        authType - The auth type algorithm
        hostName - The expected hostName that the server should have
        socket - The SSLSocket in use (may be null)
        engine - The SSLEngine in use (may be null)
        Throws:
        java.security.cert.CertificateException - if certificate is wrong
      • getAcceptedIssuers

        protected java.security.cert.X509Certificate[] getAcceptedIssuers()
      • getInstance

        public static VariableX509TrustManager getInstance()
        Return an instance of this singleton
        Returns:
        The instance