code: public SSLContext createSSLContext() throws Exception 
      {
          SSLContext ctx = SSLContext.getInstance(this.protocol);
          TrustManagerFactory tmf = null;
          KeyManagerFactory kmf = null;
  
          if (this.isTrustStoreSet) 
          {
              tmf = TrustManagerFactory.getInstance(this.trustManagerType);
              KeyStore ts = KeyStore.getInstance(this.trustStoreType);
              ts.load(new FileInputStream(this.trustStore), this.trustPass.toCharArray());
              tmf.init(ts);
          }
  
          if (this.isKeyStoreSet) 
          {
              kmf = KeyManagerFactory.getInstance(this.keyManagerType);
              KeyStore ks = KeyStore.getInstance(this.keyStoreType);
              ks.load(new FileInputStream(this.keyStore), this.keyPass.toCharArray());
              kmf.init(ks, this.keyPass.toCharArray());
          }
  
          if (this.isKeyStoreSet && this.isTrustStoreSet)
          {
              ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
          }
          else if (this.isKeyStoreSet) 
          {
              ctx.init(kmf.getKeyManagers(), null, null);
          }
          else
          {
              ctx.init(null, tmf.getTrustManagers(), null);
          }
          return ctx;
      }
docs: Create an SSLContext based on the truststore and/or keystore parameters
  defined for this obejct. An exception is thrown if any paramters are invalid.
  
  @return  New SSLContext based on the parameters in this object.
  @throws  Exception   If any parameters are invalid.