Class BaSyxJerseyHttpsClientFactory


  • public class BaSyxJerseyHttpsClientFactory
    extends java.lang.Object
    A factory for creating an HTTPS client. By default, the client is created for no verification and validation for self signed SSL.
    Author:
    haque (taken over from BaSyx tests), Holger Eichelberger, SSE
    • Constructor Summary

      Constructors 
      Constructor Description
      BaSyxJerseyHttpsClientFactory()
      Creates a default HTTPS client factory with DEFAULT_PROTOCOL, ALLOW_ALL_HOSTS, new secure random seed for self-signed certificates and TSLv1 protocol.
      BaSyxJerseyHttpsClientFactory​(java.lang.String protocol, javax.net.ssl.HostnameVerifier hostNameVerifier, javax.net.ssl.KeyManager[] keyManagers, java.security.SecureRandom seed, javax.net.ssl.TrustManager[] trustManagers)
      Creates a default HTTPS client factory for self-signed certificates and TSLv1 protocol.
      BaSyxJerseyHttpsClientFactory​(javax.net.ssl.KeyManager[] keyManagers, javax.net.ssl.TrustManager[] trustManagers)
      Creates a default HTTPS client factory with DEFAULT_PROTOCOL, ALLOW_ALL_HOSTS and new secure random seed.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      javax.ws.rs.client.Client getJerseyHTTPSClient()
      Returns an HTTPS client.
      private javax.net.ssl.SSLContext getSslContext()
      Retrieves an SSL Context.
      • Methods inherited from class java.lang.Object

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

      • DEFAULT_PROTOCOL

        public static final java.lang.String DEFAULT_PROTOCOL
        See Also:
        Constant Field Values
      • ALLOW_ALL_HOSTS

        public static final javax.net.ssl.HostnameVerifier ALLOW_ALL_HOSTS
      • hostNameVerifier

        private javax.net.ssl.HostnameVerifier hostNameVerifier
      • trustManagers

        private javax.net.ssl.TrustManager[] trustManagers
      • keyManagers

        private javax.net.ssl.KeyManager[] keyManagers
      • seed

        private java.security.SecureRandom seed
      • protocol

        private java.lang.String protocol
    • Constructor Detail

      • BaSyxJerseyHttpsClientFactory

        public BaSyxJerseyHttpsClientFactory()
        Creates a default HTTPS client factory with DEFAULT_PROTOCOL, ALLOW_ALL_HOSTS, new secure random seed for self-signed certificates and TSLv1 protocol.
      • BaSyxJerseyHttpsClientFactory

        public BaSyxJerseyHttpsClientFactory​(javax.net.ssl.KeyManager[] keyManagers,
                                             javax.net.ssl.TrustManager[] trustManagers)
        Creates a default HTTPS client factory with DEFAULT_PROTOCOL, ALLOW_ALL_HOSTS and new secure random seed.
        Parameters:
        keyManagers - the key managers
        trustManagers - the trust managers.
      • BaSyxJerseyHttpsClientFactory

        public BaSyxJerseyHttpsClientFactory​(java.lang.String protocol,
                                             javax.net.ssl.HostnameVerifier hostNameVerifier,
                                             javax.net.ssl.KeyManager[] keyManagers,
                                             java.security.SecureRandom seed,
                                             javax.net.ssl.TrustManager[] trustManagers)
        Creates a default HTTPS client factory for self-signed certificates and TSLv1 protocol.
        Parameters:
        protocol - the protocol, e.g., TLSv1
        hostNameVerifier - the host name verifier
        keyManagers - the key managers
        seed - the context initialization seed
        trustManagers - the trust managers.
    • Method Detail

      • getJerseyHTTPSClient

        public javax.ws.rs.client.Client getJerseyHTTPSClient()
                                                       throws java.security.KeyManagementException,
                                                              java.security.NoSuchAlgorithmException
        Returns an HTTPS client.
        Returns:
        the HTTPS client
        Throws:
        java.security.KeyManagementException - in case that key management problems occur
        java.security.NoSuchAlgorithmException - if the SSL algorithm is not available
      • getSslContext

        private javax.net.ssl.SSLContext getSslContext()
                                                throws java.security.KeyManagementException,
                                                       java.security.NoSuchAlgorithmException
        Retrieves an SSL Context.
        Returns:
        the SSL context
        Throws:
        java.security.KeyManagementException - in case that key management problems occur
        java.security.NoSuchAlgorithmException - if the protocol algorithm is not available