Search Java Code Snippets


  Help us in improving the repository. Add new snippets through 'Submit Code Snippet ' link.





Java - Code Samples

 Sample 1. Code Sample / Example / Snippet of javax.net.ssl.TrustManager

    public SSLContextBuilder loadTrustMaterial(

final KeyStore truststore,

final TrustStrategy trustStrategy) throws NoSuchAlgorithmException, KeyStoreException {

final TrustManagerFactory tmfactory = TrustManagerFactory.getInstance(

TrustManagerFactory.getDefaultAlgorithm());

tmfactory.init(truststore);

final TrustManager[] tms = tmfactory.getTrustManagers();

if (tms != null) {

if (trustStrategy != null) {

for (int i = 0; i < tms.length; i++) {

final TrustManager tm = tms[i];

if (tm instanceof X509TrustManager) {

tms[i] = new TrustManagerDelegate(

(X509TrustManager) tm, trustStrategy);

}

}

}

for (final TrustManager tm : tms) {

this.trustmanagers.add(tm);

}

}

return this;

}


   Like      Feedback      javax.net.ssl.TrustManager



Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner