List of usage examples for javax.net.ssl TrustManagerFactory init
public final void init(ManagerFactoryParameters spec) throws InvalidAlgorithmParameterException
From source file:test.unit.be.fedict.eid.idp.protocol.openid.OpenIDTrustManager.java
public OpenIDTrustManager(X509Certificate serverCertificate) throws NoSuchAlgorithmException, KeyStoreException { this.serverCertificate = serverCertificate; String algorithm = TrustManagerFactory.getDefaultAlgorithm(); TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(algorithm); trustManagerFactory.init((KeyStore) null); TrustManager[] trustManagers = trustManagerFactory.getTrustManagers(); for (TrustManager trustManager : trustManagers) { if (trustManager instanceof X509TrustManager) { this.defaultTrustManager = (X509TrustManager) trustManager; break; }/*from w w w.ja va 2 s . com*/ } if (null == this.defaultTrustManager) { throw new IllegalStateException("no default X509 trust manager found"); } }
From source file:com.manning.androidhacks.hack023.net.SimpleX509TrustManager.java
public SimpleX509TrustManager(KeyStore keystore) throws NoSuchAlgorithmException, KeyStoreException { TrustManagerFactory factory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); factory.init(keystore); TrustManager[] trustmanagers = factory.getTrustManagers(); if (trustmanagers.length == 0) { throw new NoSuchAlgorithmException("No trust manager found"); }//from w w w .jav a 2s . co m this.standardTrustManager = (X509TrustManager) trustmanagers[0]; }
From source file:org.jivesoftware.sparkimpl.updater.EasyX509TrustManager.java
public EasyX509TrustManager(KeyStore keystore) throws NoSuchAlgorithmException, KeyStoreException { super();//from w w w . j ava2s.co m 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]; }
From source file:com.thoughtworks.go.security.AuthSSLX509TrustManagerFactory.java
private TrustManager[] setStoreOnTrustManagers(KeyStore keystore) throws KeyStoreException, NoSuchAlgorithmException { if (keystore == null) { throw new IllegalArgumentException("Keystore may not be null"); }/*from w w w. ja v a2s. c om*/ LOG.trace("Initializing trust manager"); TrustManagerFactory tmfactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmfactory.init(keystore); return selfSignedX509WrappedTrustManagers(keystore, tmfactory); }
From source file:org.devproof.portal.core.module.common.util.httpclient.ssl.EasyX509TrustManager.java
/** * Constructor for EasyX509TrustManager. */// w w w .j a v a 2s . c om 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"); } standardTrustManager = (X509TrustManager) trustmanagers[0]; }
From source file:be.fedict.eid.idp.sp.protocol.openid.OpenIDTrustManager.java
/** * Trust only the given server certificate, and the default trusted server * certificates.//w w w. j a v a 2 s. c om * * @param serverCertificate * SSL certificate to trust * @throws NoSuchAlgorithmException * could not get an SSLContext instance * @throws KeyStoreException * failed to intialize the {@link OpenIDTrustManager} */ public OpenIDTrustManager(X509Certificate serverCertificate) throws NoSuchAlgorithmException, KeyStoreException { this.serverCertificate = serverCertificate; String algorithm = TrustManagerFactory.getDefaultAlgorithm(); TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(algorithm); trustManagerFactory.init((KeyStore) null); TrustManager[] trustManagers = trustManagerFactory.getTrustManagers(); for (TrustManager trustManager : trustManagers) { if (trustManager instanceof X509TrustManager) { this.defaultTrustManager = (X509TrustManager) trustManager; break; } } if (null == this.defaultTrustManager) { throw new IllegalStateException("no default X509 trust manager found"); } }
From source file:ddf.security.sts.claimsHandler.ClaimsHandlerManager.java
public static TrustManagerFactory createTrustManagerFactory(String trustStoreLoc, String trustStorePass) throws IOException { TrustManagerFactory tmf; try {//from w w w . ja v a 2 s . c o m // truststore stuff KeyStore trustStore = KeyStore.getInstance(System.getProperty("javax.net.ssl.keyStoreType")); LOGGER.debug("trustStoreLoc = {}", trustStoreLoc); FileInputStream trustFIS = new FileInputStream(trustStoreLoc); try { LOGGER.debug("Loading trustStore"); trustStore.load(trustFIS, trustStorePass.toCharArray()); } catch (CertificateException e) { throw new IOException("Unable to load certificates from truststore. " + trustStoreLoc, e); } finally { IOUtils.closeQuietly(trustFIS); } tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmf.init(trustStore); LOGGER.debug("trust manager factory initialized"); } catch (NoSuchAlgorithmException e) { throw new IOException( "Problems creating SSL socket. Usually this is " + "referring to the certificate sent by the server not being trusted by the client.", e); } catch (KeyStoreException e) { throw new IOException("Unable to read keystore. " + trustStoreLoc, e); } return tmf; }
From source file:com.sun.socialsite.util.LeniantX509TrustManager.java
/** * Constructor for LeniantX509TrustManager. *//*from ww w .ja v a 2 s . c o m*/ public LeniantX509TrustManager(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"); } this.standardTrustManager = (X509TrustManager) trustmanagers[0]; }
From source file:au.edu.monash.merc.capture.util.httpclient.ssl.EasyX509TrustManager.java
/** * Constructor for EasyX509TrustManager. *///from ww w .jav a2s.c om 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"); } this.standardTrustManager = (X509TrustManager) trustmanagers[0]; }
From source file:org.imogene.client.ssl.EasyX509TrustManager.java
/** * Constructor for EasyX509TrustManager. *//* w w w . j a v a 2s.c o m*/ 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]; }