Examples of TrustManagerFactory


Examples of javax.net.ssl.TrustManagerFactory

           
            TrustManager[] trustStoreManagers = null;
            KeyStore trustedCertStore = KeyStore.getInstance(trustStoreType);
           
            trustedCertStore.load(new FileInputStream(trustStoreLocation), null);
            TrustManagerFactory tmf  =
                TrustManagerFactory.getInstance(trustStoreKeyManagerFactoryAlgorithm);
            try {
                tmf.init(trustedCertStore);
                trustStoreManagers = tmf.getTrustManagers();
                LogUtils.log(LOG, Level.INFO, "LOADED_TRUST_STORE", new Object[]{trustStoreLocation});
            } catch (Exception e) {
                LogUtils.log(LOG, Level.WARNING, "FAILED_TO_LOAD_TRUST_STORE",
                             new Object[]{trustStoreLocation, e.getMessage()});
            }
View Full Code Here

Examples of javax.net.ssl.TrustManagerFactory

                }
            } catch (Exception e) {
                LogUtils.log(LOG, Level.WARNING, "FAILED_TO_LOAD_TRUST_STORE",
                             new Object[]{trustStoreLocation, e.getMessage()});
            }
            TrustManagerFactory tmf  =
                TrustManagerFactory.getInstance(trustStoreKeyManagerFactoryAlgorithm);

            tmf.init(trustedCertStore);
            LogUtils.log(LOG, Level.INFO, "LOADED_TRUST_STORE", new Object[]{trustStoreLocation});
           
            trustStoreManagers = tmf.getTrustManagers();

            sslctx.init(keystoreManagers, trustStoreManagers, null)
            httpsConnection.setSSLSocketFactory(new SSLSocketFactoryWrapper(sslctx.getSocketFactory(),
                                                                            cipherSuites));
View Full Code Here

Examples of javax.net.ssl.TrustManagerFactory

      ks.load(new FileInputStream(filename), passphrase);
 
      KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
      kmf.init(ks, passphrase);
     
      TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
      tmf.init(ks);
 
      SSLContext sslContext = SSLContext.getInstance("TLS");
      sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);

      return sslContext;

    } catch (Exception e) {
      return null;
View Full Code Here

Examples of javax.net.ssl.TrustManagerFactory

   * @throws NoSuchAlgorithmException In case of an error
   * @throws KeyStoreException In case of an error
   */
  public EasyX509TrustManager(KeyStore keystore) throws NoSuchAlgorithmException, KeyStoreException {
    super();
    TrustManagerFactory factory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
    factory.init(keystore);
    TrustManager[] trustmanagers = factory.getTrustManagers();
    if (trustmanagers.length == 0)
      throw new NoSuchAlgorithmException("No trust manager found"); //$NON-NLS-1$

    this.standardTrustManager = (X509TrustManager) trustmanagers[0];
  }
View Full Code Here

Examples of javax.net.ssl.TrustManagerFactory

  /**
   * Constructor for EasyX509TrustManager.
   */
  public EasyX509TrustManager(KeyStore keystore) throws NoSuchAlgorithmException, KeyStoreException {
    super();
    TrustManagerFactory factory = TrustManagerFactory.getInstance("SunX509");
    factory.init(keystore);
    TrustManager[] trustmanagers = factory.getTrustManagers();
    if (trustmanagers.length == 0) { throw new NoSuchAlgorithmException("SunX509 trust manager not supported"); }
    this.standardTrustManager = (X509TrustManager) trustmanagers[0];
  }
View Full Code Here

Examples of javax.net.ssl.TrustManagerFactory

      {
         sslCtx = SSLContext.getInstance("TLS");
         KeyManagerFactory keyMgr = securityDomain.getKeyManagerFactory();
         if( keyMgr == null )
            throw new IOException("KeyManagerFactory is null for security domain: "+securityDomain.getSecurityDomain());
         TrustManagerFactory trustMgr = securityDomain.getTrustManagerFactory();
         TrustManager[] trustMgrs = null;
         if( trustMgr != null )
            trustMgrs = trustMgr.getTrustManagers();
         sslCtx.init(keyMgr.getKeyManagers(), trustMgrs, null);
         return sslCtx;
      }
      catch(NoSuchAlgorithmException e)
      {
View Full Code Here

Examples of javax.net.ssl.TrustManagerFactory

          .getResource("META-INF/tst.keystore");
      InputStream stream = keyStoreURL.openStream();
      KeyStore keyStore = KeyStore.getInstance("JKS");
      keyStore.load(stream, "unit-tests".toCharArray());
      // Setup the test TrustManagerFactory.
      TrustManagerFactory trustMgr = TrustManagerFactory
          .getInstance(TrustManagerFactory.getDefaultAlgorithm());
      trustMgr.init(keyStore);
      // Setup the test SSLSocketFactory.
      SSLContext sslCtx = SSLContext.getInstance("TLS");
      sslCtx.init(null, trustMgr.getTrustManagers(), null);
      ((HttpsURLConnection) conn).setSSLSocketFactory(sslCtx.getSocketFactory());     
    }
   
    // Connect to the remote HTTP server.
    log.debug("Connecting to URL: " + url);
View Full Code Here

Examples of javax.net.ssl.TrustManagerFactory

         keyStore.load(is, KEYSTORE_PASSWORD.toCharArray());
         String algorithm = KeyManagerFactory.getDefaultAlgorithm();
         KeyManagerFactory keyMgr = KeyManagerFactory.getInstance(algorithm);
         keyMgr.init(keyStore, KEYSTORE_PASSWORD.toCharArray());
         algorithm = TrustManagerFactory.getDefaultAlgorithm();
         TrustManagerFactory trustMgr = TrustManagerFactory.getInstance(algorithm);
         trustMgr.init(keyStore);
         TrustManager[] trustMgrs = trustMgr.getTrustManagers();
         sslCtx.init(keyMgr.getKeyManagers(), trustMgrs, null);
      }
      catch(Exception e)
      {
         log.error("Failed to init SSLContext", e);
View Full Code Here

Examples of javax.net.ssl.TrustManagerFactory

      ks.load(new FileInputStream(filename), passphrase);
 
      KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
      kmf.init(ks, passphrase);
     
      TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
      tmf.init(ks);
 
      SSLContext sslContext = SSLContext.getInstance("TLS");
      sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);

      return sslContext;

    } catch (Exception e) {
      return null;
View Full Code Here

Examples of javax.net.ssl.TrustManagerFactory

        KeyStore ks = KeyStoreManager.getInstance(KeyStoreManager.DEFAULT_KEY_STORE).getKeyStore();
        String pw = ContextHolder.getContext().getConfig().retrieveProperty(new ContextKey("webServer.keystore.sslCertificate.password"));
        KeyManager[] kma = new KeyManager[] { new CustomKeyManager(pw) };
        TrustManager[] tma = null;
        if(trustManager == null) {
            TrustManagerFactory tm = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
            tm.init(ks);
            tma = tm.getTrustManagers();
        }
        else {

            // LDP - Add the existing trust managers so that outgoing certificates are still trusted.
            TrustManagerFactory tm = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
            tm.init(ks);

            tma = new TrustManager[tm.getTrustManagers().length + 1];
            for(int i=0;i<tm.getTrustManagers().length-1;i++) {
                tma[i] = tm.getTrustManagers()[i];
            }
            tma[tma.length-1] = trustManager;
        }
        SSLContext sslc = SSLContext.getInstance("SSL");
        sslc.init(kma, tma, SecureRandom.getInstance("SHA1PRNG"));
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.