Examples of TrustManagerFactory


Examples of javax.net.ssl.TrustManagerFactory

        TrustManager[] tms = null;

        KeyStore trustStore = getTrustStore(keystoreType, keystoreProvider);
        if (trustStore != null || endpoint.getTrustManagerClassName() != null) {
            if (crlf == null) {
                TrustManagerFactory tmf =
                    TrustManagerFactory.getInstance(algorithm);
                tmf.init(trustStore);
                tms = tmf.getTrustManagers();
            } else {
                TrustManagerFactory tmf =
                    TrustManagerFactory.getInstance(algorithm);
                CertPathParameters params =
                    getParameters(algorithm, crlf, trustStore);
                ManagerFactoryParameters mfp =
                    new CertPathTrustManagerParameters(params);
                tmf.init(mfp);
                tms = tmf.getTrustManagers();
            }
        }

        return tms;
    }
View Full Code Here

Examples of javax.net.ssl.TrustManagerFactory

        if (trustStorePath != null)
        {
            final KeyStore ts = SSLUtil.getInitializedKeyStore(trustStorePath,
                    trustStorePassword, trustStoreType);
            final TrustManagerFactory tmf = TrustManagerFactory
                    .getInstance(trustManagerFactoryAlgorithm);
            tmf.init(ts);

            trustManagers = tmf.getTrustManagers();
        }
        else
        {
            trustManagers = null;
        }
View Full Code Here

Examples of javax.net.ssl.TrustManagerFactory

              InputStream truststoreStream = new FileInputStream(truststore);
              keystore = KeyStore.getInstance(truststoreType);
              keystore.load(truststoreStream, truststorePassword.toCharArray());
            }

            TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
            // null keystore is OK, with SunX509 it defaults to system CA Certs
            // see http://docs.oracle.com/javase/6/docs/technotes/guides/security/jsse/JSSERefGuide.html#X509TrustManager
            tmf.init(keystore);
            managers = tmf.getTrustManagers();
          }

          SSLContext sslContext = SSLContext.getInstance("TLS");
          sslContext.init(null, managers, null);
          SSLEngine sslEngine = sslContext.createSSLEngine();
View Full Code Here

Examples of javax.net.ssl.TrustManagerFactory

    }
    return factory.getKeyManagers();
  }

  private TrustManager[] getTrustManagers(Certificate trust) throws Exception {
    TrustManagerFactory factory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
    InputStream certificate = trust.getFile().openStream();
    try {
      KeyStore ks = KeyStore.getInstance(this.keystore);
      ks.load(certificate, trust.getPassword());
      factory.init(ks);
    } finally {
      IOUtil.closeQuietly(certificate);
    }
    return factory.getTrustManagers();
  }
View Full Code Here

Examples of javax.net.ssl.TrustManagerFactory

    }

    final KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(algorithm);
    keyManagerFactory.init(keyStore, KEYSTORE_PASSWORD);

    final TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(algorithm);
    trustManagerFactory.init(keyStore);

    // Initialize the SSLContext to work with our key managers.
    final SSLContext sslContext = SSLContext.getInstance(PROTOCOL);
    sslContext.init(keyManagerFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(), null);

    return sslContext;
  }
View Full Code Here

Examples of javax.net.ssl.TrustManagerFactory

    if (keyStore.size() == 0) {
      throw new KeyStoreException("Keystore is empty; while this is legal for keystores in general, APNs clients must have at least one key.");
    }

    final TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(algorithm);
    trustManagerFactory.init((KeyStore) null);

    final KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(algorithm);
    keyManagerFactory.init(keyStore, keyStorePassword);

    final SSLContext sslContext = SSLContext.getInstance(PROTOCOL);
    sslContext.init(keyManagerFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(), null);

    return sslContext;
  }
View Full Code Here

Examples of javax.net.ssl.TrustManagerFactory

            return null;
        }

        char[] pass = (StringUtils.hasText(trustStorePass) ? trustStorePass.trim().toCharArray() : null);
        KeyStore keyStore = loadKeyStore(trustStoreLocation, pass);
        TrustManagerFactory tmFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
        tmFactory.init(keyStore);
    TrustManager[] tms = tmFactory.getTrustManagers();

    if (tms != null && trust != null) {
      // be defensive since the underlying impl might not give us a copy
      TrustManager[] clone = new TrustManager[tms.length];
View Full Code Here

Examples of javax.net.ssl.TrustManagerFactory

      {
         return null;
      }
      else
      {
         TrustManagerFactory trustMgrFactory;
         KeyStore trustStore = SSLSupport.loadKeystore(trustStorePath, trustStorePassword);
         trustMgrFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
         trustMgrFactory.init(trustStore);
         return trustMgrFactory.getTrustManagers();
      }
   }
View Full Code Here

Examples of javax.net.ssl.TrustManagerFactory

      keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
      FileInputStream fis = new FileInputStream(getTrustStoreLocation());
      keyStore.load(fis, getTrustStorePassword().toCharArray());
      fis.close();

      TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
      tmf.init(keyStore);
      SSLContext ctx = SSLContext.getInstance("TLS");
      ctx.init(null, tmf.getTrustManagers(), null);
      return ctx.getSocketFactory();
    } catch (Exception e) {
      e.printStackTrace();
    }
View Full Code Here

Examples of javax.net.ssl.TrustManagerFactory

               final KeyManagerFactory kmf = KeyManagerFactory.getInstance(ksAlgorithm);
               kmf.init(ks, password.toCharArray());

               // Get a TrustManagerFactory with the DEFAULT KEYSTORE, so we have all
               // the certificates in cacerts trusted
               final TrustManagerFactory tmf = TrustManagerFactory.getInstance(ksAlgorithm);
               tmf.init((KeyStore)null);

               // Get the SSLContext to help create SSLSocketFactory
               final SSLContext sslContext = SSLContext.getInstance("TLS");
               sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
               return sslContext;
           } catch (final GeneralSecurityException e) {
               throw new InvalidSSLConfig(e);
           }
       }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.