Java Code Examples for javax.net.ssl.X509TrustManager
The following code examples are extracted from open source projects. You can click to
vote up the examples that are useful to you.
Example 1
From project sensei, under directory /sensei-core/src/main/java/com/senseidb/dataprovider/http/.
Source file: HttpsClientDecorator.java

public static DefaultHttpClient decorate(DefaultHttpClient base){ try { SSLContext ctx=SSLContext.getInstance("TLS"); X509TrustManager tm=new X509TrustManager(){ public void checkClientTrusted( X509Certificate[] xcs, String string) throws CertificateException { } public void checkServerTrusted( X509Certificate[] xcs, String string) throws CertificateException { } public X509Certificate[] getAcceptedIssuers(){ return null; } } ; ctx.init(null,new TrustManager[]{tm},null); SSLSocketFactory ssf=new SSLSocketFactory(ctx,SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); ClientConnectionManager ccm=base.getConnectionManager(); SchemeRegistry sr=ccm.getSchemeRegistry(); sr.register(new Scheme("https",443,ssf)); return new DefaultHttpClient(ccm,base.getParams()); } catch ( Exception ex) { logger.error(ex.getMessage(),ex); return null; } }
Example 2
From project MobiPerf, under directory /android/src/com/mobiperf/speedometer/.
Source file: Checkin.java

public MySSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { super(truststore); X509TrustManager tm=new X509TrustManager(){ public X509Certificate[] getAcceptedIssuers(){ return null; } @Override public void checkClientTrusted( X509Certificate[] chain, String authType) throws CertificateException { } @Override public void checkServerTrusted( X509Certificate[] chain, String authType) throws CertificateException { } } ; sslContext.init(null,new TrustManager[]{tm},null); }
Example 3
From project rain-workload-toolkit, under directory /src/radlab/rain/util/.
Source file: HttpTransport.java

public static HttpClient wrapClient(HttpClient base){ try { SSLContext ctx=SSLContext.getInstance("TLS"); X509TrustManager tm=new X509TrustManager(){ public void checkClientTrusted( X509Certificate[] xcs, String string) throws CertificateException { } public void checkServerTrusted( X509Certificate[] xcs, String string) throws CertificateException { } public X509Certificate[] getAcceptedIssuers(){ return null; } } ; ctx.init(null,new TrustManager[]{tm},null); SSLSocketFactory ssf=new SSLSocketFactory(ctx,SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); ClientConnectionManager ccm=base.getConnectionManager(); SchemeRegistry sr=ccm.getSchemeRegistry(); sr.register(new Scheme("https",443,ssf)); return new DefaultHttpClient(ccm,base.getParams()); } catch ( Exception ex) { return null; } }
Example 4
From project OpenMEAP, under directory /java-shared/openmeap-shared-jdk5/src/com/openmeap/util/.
Source file: SSLUtils.java

public MySSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { super(truststore); X509TrustManager tm=new X509TrustManager(){ public void checkClientTrusted( X509Certificate[] chain, String authType) throws CertificateException { } public void checkServerTrusted( X509Certificate[] chain, String authType) throws CertificateException { } public X509Certificate[] getAcceptedIssuers(){ return null; } } ; sslContext.init(null,new TrustManager[]{tm},null); }
Example 5
From project twistDemo, under directory /twist-libs/com.thoughtworks.webdriver.recorder_1.0.0.11288/sahi/src/net/sf/sahi/ssl/.
Source file: SSLHelper.java

public static TrustManager[] getAllTrustingManager(){ TrustManager[] trustAllCerts=new TrustManager[]{new X509TrustManager(){ public java.security.cert.X509Certificate[] getAcceptedIssuers(){ return null; } public void checkClientTrusted( java.security.cert.X509Certificate[] certs, String authType){ } public void checkServerTrusted( java.security.cert.X509Certificate[] certs, String authType){ } } }; return trustAllCerts; }
Example 6
From project Speedometer, under directory /android/src/com/google/wireless/speed/speedometer/.
Source file: Checkin.java

public MySSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { super(truststore); X509TrustManager tm=new X509TrustManager(){ public X509Certificate[] getAcceptedIssuers(){ return null; } @Override public void checkClientTrusted( X509Certificate[] chain, String authType) throws CertificateException { } @Override public void checkServerTrusted( X509Certificate[] chain, String authType) throws CertificateException { } } ; sslContext.init(null,new TrustManager[]{tm},null); }
Example 7
From project Weave, under directory /JTDS_SqlServerDriver/src/main/net/sourceforge/jtds/ssl/.
Source file: SocketFactories.java

private static TrustManager[] trustManagers(){ X509TrustManager tm=new X509TrustManager(){ public X509Certificate[] getAcceptedIssuers(){ return new X509Certificate[0]; } public void checkServerTrusted( X509Certificate[] chain, String x){ } public void checkClientTrusted( X509Certificate[] chain, String x){ } } ; return new X509TrustManager[]{tm}; }
Example 8
From project 4308Cirrus, under directory /tendril-android-lib/src/main/java/edu/colorado/cs/cirrus/android/ssl/.
Source file: EasySSLSocketFactory.java

public EasySSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { super(truststore); TrustManager tm=new X509TrustManager(){ public void checkClientTrusted( X509Certificate[] chain, String authType) throws CertificateException { } public void checkServerTrusted( X509Certificate[] chain, String authType) throws CertificateException { } public X509Certificate[] getAcceptedIssuers(){ return null; } } ; sslContext.init(null,new TrustManager[]{tm},null); }
Example 9
From project bitfluids, under directory /src/test/java/at/bitcoin_austria/bitfluids/.
Source file: NetTest.java

public static HttpClient wrapClient(HttpClient base){ try { SSLContext ctx=SSLContext.getInstance("TLS"); X509TrustManager tm=new X509TrustManager(){ @Override public void checkClientTrusted( X509Certificate[] xcs, String string) throws CertificateException { } @Override public void checkServerTrusted( X509Certificate[] xcs, String string) throws CertificateException { } @Override public X509Certificate[] getAcceptedIssuers(){ return null; } } ; ctx.init(null,new TrustManager[]{tm},null); SSLSocketFactory ssf=new SSLSocketFactory(ctx); ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); ClientConnectionManager ccm=base.getConnectionManager(); SchemeRegistry sr=ccm.getSchemeRegistry(); sr.register(new Scheme("https",ssf,443)); return new DefaultHttpClient(ccm,base.getParams()); } catch ( Exception ex) { throw new RuntimeException(ex); } }
Example 10
From project BombusLime, under directory /src/org/bombusim/networking/.
Source file: AndroidSSLSocketFactory.java

public AndroidSSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { super(truststore); TrustManager tm=new X509TrustManager(){ public void checkClientTrusted( X509Certificate[] chain, String authType) throws CertificateException { } public void checkServerTrusted( X509Certificate[] chain, String authType) throws CertificateException { } public X509Certificate[] getAcceptedIssuers(){ return null; } } ; sslContext.init(null,new TrustManager[]{tm},null); }
Example 11
From project cloudify, under directory /rest-client/src/main/java/org/cloudifysource/restclient/.
Source file: RestSSLSocketFactory.java

/** * Ctor. * @param truststore a {@link KeyStore} containing one or several trustedcertificates to enable server authentication. * @throws NoSuchAlgorithmException Reporting failure to create SSLSocketFactory with the given trust-store and algorithm TLS or initialize the SSLContext. * @throws KeyManagementException Reporting failure to create SSLSocketFactory with the given trust-store and algorithm TLS or initialize the SSLContext. * @throws KeyStoreException Reporting failure to create SSLSocketFactory with the given trust-store and algorithm TLS or initialize the SSLContext. * @throws UnrecoverableKeyException Reporting failure to create SSLSocketFactory with the given trust-store and algorithm TLS or initialize the SSLContext. */ public RestSSLSocketFactory(final KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { super(truststore); TrustManager tm=new X509TrustManager(){ @Override public X509Certificate[] getAcceptedIssuers(){ return null; } @Override public void checkClientTrusted( final X509Certificate[] chain, final String authType) throws java.security.cert.CertificateException { } @Override public void checkServerTrusted( final X509Certificate[] chain, final String authType) throws java.security.cert.CertificateException { } } ; sslContext.init(null,new TrustManager[]{tm},null); }
Example 12
From project components-ness-httpclient, under directory /client/src/main/java/com/nesscomputing/httpclient/factory/httpclient4/.
Source file: ApacheHttpClient4Factory.java

/** * @param clientDefaults defaults to read from * @return a trust manager * @throws GeneralSecurityException if the crypto goes wrong * @throws IOException if trust keystore can't be loaded */ @Nonnull private static TrustManager getTrustManager(HttpClientDefaults clientDefaults) throws GeneralSecurityException, IOException { X509TrustManager trustManager; if (clientDefaults.getSSLTruststore() == null || clientDefaults.getSSLTruststorePassword() == null) { LOG.trace("Not using custom truststore"); trustManager=HttpClientTrustManagerFactory.getDefaultTrustManager(); } else { LOG.trace("Using custom truststore at %s",clientDefaults.getSSLTruststore()); final MultiTrustManager multiTrustManager=new MultiTrustManager(); if (clientDefaults.useSSLTruststoreFallback()) { LOG.trace("Adding fallback to default trust manager"); multiTrustManager.addTrustManager(HttpClientTrustManagerFactory.getDefaultTrustManager()); } multiTrustManager.addTrustManager(HttpClientTrustManagerFactory.getTrustManagerForHttpClientDefaults(clientDefaults)); trustManager=multiTrustManager; } if (!clientDefaults.useSSLServerCertVerification()) { LOG.trace("Server cert checking disabled"); trustManager=new AlwaysTrustServerTrustManager(trustManager); } return trustManager; }
Example 13
From project friendica-for-android, under directory /mw-android-friendica-01/src/de/wikilab/android/friendica01/.
Source file: TwAjax.java

public IgnoreCertsSSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { super(truststore); TrustManager tm=new X509TrustManager(){ public void checkClientTrusted( X509Certificate[] chain, String authType) throws CertificateException { } public void checkServerTrusted( X509Certificate[] chain, String authType) throws CertificateException { } public X509Certificate[] getAcceptedIssuers(){ return null; } } ; sslContext.init(null,new TrustManager[]{tm},null); }
Example 14
From project jupload, under directory /src/wjhk/jupload2/upload/.
Source file: InteractiveTrustManager.java

/** * @see javax.net.ssl.X509TrustManager#checkServerTrusted(java.security.cert.X509Certificate[],java.lang.String) */ public void checkServerTrusted(X509Certificate[] chain,String authType) throws CertificateException { if ((this.mode & SERVER) != 0) { if (null == chain || chain.length == 0) throw new IllegalArgumentException("Certificate chain is null or empty"); int i; TrustManager[] mgrs=this.tmf.getTrustManagers(); for (i=0; i < mgrs.length; i++) { if (mgrs[i] instanceof X509TrustManager) { X509TrustManager m=(X509TrustManager)(mgrs[i]); try { m.checkServerTrusted(chain,authType); return; } catch ( Exception e) { } } } CertDialog(chain[0]); } }
Example 15
From project LRJavaLib, under directory /src/com/navnorth/learningregistry/util/.
Source file: SelfSignSSLSocketFactory.java

public SelfSignSSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { super(truststore); TrustManager tm=new X509TrustManager(){ public void checkClientTrusted( X509Certificate[] chain, String authType) throws CertificateException { } public void checkServerTrusted( X509Certificate[] chain, String authType) throws CertificateException { } public X509Certificate[] getAcceptedIssuers(){ return null; } } ; sslContext.init(null,new TrustManager[]{tm},null); }
Example 16
From project Maimonides, under directory /src/com/codeko/apps/maimonides/seneca/.
Source file: ClienteSeneca.java

public HttpClient getCliente(){ if (cliente == null) { try { SSLContext ctx=SSLContext.getInstance("TLS"); X509TrustManager tm=new X509TrustManager(){ @Override public void checkClientTrusted( X509Certificate[] xcs, String string) throws CertificateException { } @Override public void checkServerTrusted( X509Certificate[] xcs, String string) throws CertificateException { } @Override public X509Certificate[] getAcceptedIssuers(){ return null; } } ; ctx.init(null,new TrustManager[]{tm},null); SSLSocketFactory ssf=new SSLSocketFactory(ctx,SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); SchemeRegistry schemeRegistry=new SchemeRegistry(); schemeRegistry.register(new Scheme("http",80,PlainSocketFactory.getSocketFactory())); schemeRegistry.register(new Scheme("https",443,ssf)); HttpParams params=new BasicHttpParams(); HttpProtocolParams.setUserAgent(params,"Mozilla/5.0 (X11; U; Linux i686; es-ES; rv:1.9.2.12) Gecko/20101027 Ubuntu/10.04 (lucid) Firefox/3.6.12"); ThreadSafeClientConnManager cm=new ThreadSafeClientConnManager(schemeRegistry); cm.setDefaultMaxPerRoute(10); cm.setMaxTotal(20); HttpConnectionParams.setConnectionTimeout(params,1000); cliente=new DefaultHttpClient(cm,params); } catch ( Exception ex) { Logger.getLogger(ClienteSeneca.class.getName()).log(Level.SEVERE,null,ex); setUltimoError("Error conectando con S?neca: " + ex.getLocalizedMessage()); setUltimaExcepcion(ex); } } ThreadSafeClientConnManager man=(ThreadSafeClientConnManager)cliente.getConnectionManager(); man.closeExpiredConnections(); man.closeIdleConnections(10,TimeUnit.SECONDS); Logger.getLogger(ClienteSeneca.class.getName()).log(Level.INFO,"Hay {0} conexiones abiertas.",man.getConnectionsInPool()); return cliente; }
Example 17
From project miso-lims, under directory /core/src/main/java/uk/ac/bbsrc/tgac/miso/core/manager/.
Source file: ERASubmissionManager.java

/** * Builds a "trusting" trust manager. This is totally horrible and basically ignores everything that SSL stands for. This allows connection to self-signed certificate hosts, bypassing the normal validation exceptions that occur. <p/> Use at your own risk - again, this is horrible! */ public DefaultHttpClient getEvilTrustingTrustManager(DefaultHttpClient httpClient){ try { X509TrustManager trustManager=new X509TrustManager(){ public void checkClientTrusted( X509Certificate[] chain, String authType) throws CertificateException { log.warn("BYPASSING CLIENT TRUSTED CHECK!"); } public void checkServerTrusted( X509Certificate[] chain, String authType) throws CertificateException { log.warn("BYPASSING SERVER TRUSTED CHECK!"); } public X509Certificate[] getAcceptedIssuers(){ log.warn("BYPASSING CERTIFICATE ISSUER CHECKS!"); return null; } } ; SSLContext sslcontext=SSLContext.getInstance("TLS"); sslcontext.init(null,new TrustManager[]{trustManager},null); SSLSocketFactory sf=new SSLSocketFactory(sslcontext); sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); ClientConnectionManager ccm=httpClient.getConnectionManager(); SchemeRegistry schemeRegistry=ccm.getSchemeRegistry(); schemeRegistry.register(new Scheme("https",sf,443)); return new DefaultHttpClient(ccm,httpClient.getParams()); } catch ( Throwable t) { log.warn("Something nasty happened with the EvilTrustingTrustManager. Warranty is null and void!"); t.printStackTrace(); return null; } }
Example 18
From project PenguinCMS, under directory /PenguinCMS/tests/vendor/sahi/src/net/sf/sahi/ssl/.
Source file: SSLHelper.java

public static TrustManager[] getAllTrustingManager(){ TrustManager[] trustAllCerts=new TrustManager[]{new X509TrustManager(){ public java.security.cert.X509Certificate[] getAcceptedIssuers(){ return null; } public void checkClientTrusted( java.security.cert.X509Certificate[] certs, String authType){ } public void checkServerTrusted( java.security.cert.X509Certificate[] certs, String authType){ } } }; return trustAllCerts; }
Example 19
/** * This function will install a trust manager that will blindly trust all SSL certificates. The reason this code is being added is to enable developers to do development using self signed SSL certificates on their web server. The standard HttpsURLConnection class will throw an exception on self signed certificates if this code is not run. */ private void trustAllHosts(){ TrustManager[] trustAllCerts=new TrustManager[]{new X509TrustManager(){ public java.security.cert.X509Certificate[] getAcceptedIssuers(){ return new java.security.cert.X509Certificate[]{}; } public void checkClientTrusted( X509Certificate[] chain, String authType) throws CertificateException { } public void checkServerTrusted( X509Certificate[] chain, String authType) throws CertificateException { } } }; try { defaultSSLSocketFactory=HttpsURLConnection.getDefaultSSLSocketFactory(); SSLContext sc=SSLContext.getInstance("TLS"); sc.init(null,trustAllCerts,new java.security.SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); } catch ( Exception e) { System.out.println(e.getMessage()); } }
Example 20
From project Pitbull, under directory /pitbull-core/src/main/java/org/jboss/pitbull/client/.
Source file: HttpConnectionFactory.java

public static ClientConnection https(String host,int port,long timeout,TimeUnit unit) throws IOException { java.lang.System.setProperty("sun.security.ssl.allowUnsafeRenegotiation","true"); X509TrustManager trustManager=new X509TrustManager(){ public void checkClientTrusted( X509Certificate[] chain, String authType) throws CertificateException { } public void checkServerTrusted( X509Certificate[] chain, String authType) throws CertificateException { } public X509Certificate[] getAcceptedIssuers(){ return null; } } ; SSLContext sslContext=null; try { sslContext=SSLContext.getInstance("SSL"); sslContext.init(null,new TrustManager[]{trustManager},new SecureRandom()); SSLEngine engine=sslContext.createSSLEngine(); engine.setUseClientMode(true); SocketChannel channel=createSocket(host,port,timeout,unit); ClientSSLChannel sslChannel=new ClientSSLChannel(channel,engine); return new ClientConnectionImpl(sslChannel,host,port); } catch ( Exception e) { throw new RuntimeException(e); } }
Example 21
From project QuotaForAndroid, under directory /Quota/src/com/southfreo/quota/utils/.
Source file: OpenSSLFactory.java

public OpenSSLFactory(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { super(truststore); TrustManager tm=new X509TrustManager(){ public void checkClientTrusted( X509Certificate[] chain, String authType) throws CertificateException { } public void checkServerTrusted( X509Certificate[] chain, String authType) throws CertificateException { } public X509Certificate[] getAcceptedIssuers(){ return null; } } ; sslContext.init(null,new TrustManager[]{tm},null); }
Example 22
From project Vega, under directory /platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/internal/http/requests/.
Source file: AbstractHttpClientFactory.java

protected static SchemeRegistry createSchemeRegistry(){ final SchemeRegistry sr=new SchemeRegistry(); sr.register(new Scheme("http",80,PlainSocketFactory.getSocketFactory())); SSLContext ctx; try { ctx=SSLContext.getInstance("TLS"); X509TrustManager tm=new X509TrustManager(){ public void checkClientTrusted( X509Certificate[] xcs, String string) throws CertificateException { } public void checkServerTrusted( X509Certificate[] xcs, String string) throws CertificateException { } public X509Certificate[] getAcceptedIssuers(){ return null; } } ; ctx.init(null,new X509TrustManager[]{tm},null); SSLSocketFactory ssf=new SSLSocketFactory(ctx,SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); sr.register(new Scheme("https",443,ssf)); } catch ( NoSuchAlgorithmException e) { e.printStackTrace(); } catch ( KeyManagementException e) { e.printStackTrace(); } return sr; }
Example 23
From project weechat-android, under directory /weechat-android/src/com/ubergeek42/WeechatAndroid/service/.
Source file: RelayService.java

private void createKeystore(){ try { sslKeystore.load(null,null); TrustManagerFactory tmf=TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmf.init((KeyStore)null); X509TrustManager xtm=(X509TrustManager)tmf.getTrustManagers()[0]; for ( X509Certificate cert : xtm.getAcceptedIssuers()) { sslKeystore.setCertificateEntry(cert.getSubjectDN().getName(),cert); } } catch ( Exception e) { e.printStackTrace(); } saveKeystore(); }
Example 24
From project cloudbees-api-client, under directory /cloudbees-api-client/src/main/java/com/cloudbees/api/.
Source file: TrustAllSocketFactory.java

public static SSLSocketFactory create(){ try { SSLContext context=SSLContext.getInstance("SSL"); context.init(null,new TrustManager[]{new X509TrustManager(){ public void checkClientTrusted( X509Certificate[] x509Certificates, String authType) throws CertificateException { } public void checkServerTrusted( X509Certificate[] x509Certificates, String authType) throws CertificateException { if (LOGGER.isLoggable(FINE)) LOGGER.fine("Got the certificate: " + Arrays.asList(x509Certificates)); } public X509Certificate[] getAcceptedIssuers(){ return new X509Certificate[0]; } } },new SecureRandom()); return context.getSocketFactory(); } catch ( NoSuchAlgorithmException e) { throw new Error(e); } catch ( KeyManagementException e) { throw new Error(e); } }
Example 25
From project generic-store-for-android, under directory /src/com/wareninja/opensource/common/.
Source file: WareNinjaUtils.java

public static void trustEveryone(){ if (LOGGING.DEBUG) Log.d(TAG,"trustEveryone()"); try { HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier(){ public boolean verify( String hostname, SSLSession session){ return true; } } ); SSLContext context=SSLContext.getInstance("TLS"); context.init(null,new X509TrustManager[]{new X509TrustManager(){ public void checkClientTrusted( X509Certificate[] chain, String authType) throws CertificateException { } public void checkServerTrusted( X509Certificate[] chain, String authType) throws CertificateException { } public X509Certificate[] getAcceptedIssuers(){ return new X509Certificate[0]; } } },new SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(context.getSocketFactory()); } catch ( Exception e) { e.printStackTrace(); } }
Example 26
private void startupSSL(){ try { System.setProperty("java.protocol.handler.pkgs","javax.net.ssl"); TrustManager[] trustAllCerts=new TrustManager[]{new X509TrustManager(){ public java.security.cert.X509Certificate[] getAcceptedIssuers(){ return null; } public void checkClientTrusted( java.security.cert.X509Certificate[] certs, String authType){ } public void checkServerTrusted( java.security.cert.X509Certificate[] certs, String authType){ } } }; SSLContext sc=SSLContext.getInstance("SSL"); sc.init(null,trustAllCerts,new java.security.SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); HostnameVerifier hv=new HostnameVerifier(){ public boolean verify( String urlHostName, SSLSession session){ return true; } } ; HttpsURLConnection.setDefaultHostnameVerifier(hv); } catch ( Exception e) { console.output("! " + e.getMessage() + "\n",true); } }
Example 27
From project lyo.testsuite, under directory /org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/util/.
Source file: OSLCUtils.java

static public void setupLazySSLSupport(HttpClient httpClient){ ClientConnectionManager connManager=httpClient.getConnectionManager(); SchemeRegistry schemeRegistry=connManager.getSchemeRegistry(); schemeRegistry.unregister("https"); TrustManager[] trustAllCerts=new TrustManager[]{new X509TrustManager(){ public void checkClientTrusted( java.security.cert.X509Certificate[] certs, String authType){ } public void checkServerTrusted( java.security.cert.X509Certificate[] certs, String authType){ } public java.security.cert.X509Certificate[] getAcceptedIssuers(){ return null; } } }; SSLContext sc=null; try { sc=SSLContext.getInstance("SSL"); sc.init(null,trustAllCerts,new java.security.SecureRandom()); } catch ( NoSuchAlgorithmException e) { } catch ( KeyManagementException e) { } SSLSocketFactory sf=new SSLSocketFactory(sc); sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); Scheme https=new Scheme("https",sf,443); schemeRegistry.register(https); }
Example 28
From project OpenConext-api, under directory /coin-api-war/src/main/java/nl/surfnet/coin/api/playground/.
Source file: OAuthRequestIgnoreCertificate.java

private void createUnsafeConnection() throws Exception { System.setProperty("http.keepAlive","true"); String completeUrl=getCompleteUrl(); Field connField=getClass().getSuperclass().getSuperclass().getDeclaredField("connection"); connField.setAccessible(true); TrustManager[] trustAllCerts=new TrustManager[]{new X509TrustManager(){ public java.security.cert.X509Certificate[] getAcceptedIssuers(){ return null; } public void checkClientTrusted( java.security.cert.X509Certificate[] certs, String authType){ } public void checkServerTrusted( java.security.cert.X509Certificate[] certs, String authType){ } } }; SSLContext sc=SSLContext.getInstance("SSL"); sc.init(null,trustAllCerts,new java.security.SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); URLConnection openConnection=new URL(completeUrl).openConnection(); connField.set(this,openConnection); }
Example 29
From project osgi-tests, under directory /test/glassfish-derby/src/test/java/org/ancoron/osgi/test/glassfish/.
Source file: GlassfishDerbyTest.java

protected DefaultHttpClient getHTTPClient() throws NoSuchAlgorithmException, KeyManagementException { SSLContext sslContext=SSLContext.getInstance("SSL"); sslContext.init(null,new TrustManager[]{new X509TrustManager(){ @Override public X509Certificate[] getAcceptedIssuers(){ System.out.println("getAcceptedIssuers ============="); return null; } @Override public void checkClientTrusted( X509Certificate[] certs, String authType){ System.out.println("checkClientTrusted ============="); } @Override public void checkServerTrusted( X509Certificate[] certs, String authType){ System.out.println("checkServerTrusted ============="); } } },new SecureRandom()); SSLSocketFactory sf=new SSLSocketFactory(sslContext,SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); Scheme httpsScheme=new Scheme("https",8181,sf); PlainSocketFactory plain=new PlainSocketFactory(); Scheme httpScheme=new Scheme("http",8080,plain); SchemeRegistry schemeRegistry=new SchemeRegistry(); schemeRegistry.register(httpsScheme); schemeRegistry.register(httpScheme); HttpParams params=new BasicHttpParams(); ThreadSafeClientConnManager cm=new ThreadSafeClientConnManager(schemeRegistry); cm.setMaxTotal(200); cm.setDefaultMaxPerRoute(20); DefaultHttpClient httpClient=new DefaultHttpClient(cm,params); httpClient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION,HttpVersion.HTTP_1_1); httpClient.getParams().setParameter(CoreProtocolPNames.HTTP_CONTENT_CHARSET,"UTF-8"); return httpClient; }
Example 30
From project processFlowProvision, under directory /osProvision/src/main/java/org/jboss/processFlow/openshift/.
Source file: ShifterProvisioner.java

private void prepConnection() throws Exception { httpClient=new DefaultHttpClient(); SSLContext sslContext=SSLContext.getInstance("SSL"); sslContext.init(null,new TrustManager[]{new X509TrustManager(){ public X509Certificate[] getAcceptedIssuers(){ System.out.println("getAcceptedIssuers ============="); return null; } public void checkClientTrusted( X509Certificate[] certs, String authType){ System.out.println("checkClientTrusted ============="); } public void checkServerTrusted( X509Certificate[] certs, String authType){ System.out.println("checkServerTrusted ============="); } } },new SecureRandom()); SSLSocketFactory ssf=new SSLSocketFactory(sslContext,SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); ClientConnectionManager ccm=httpClient.getConnectionManager(); SchemeRegistry sr=ccm.getSchemeRegistry(); sr.register(new Scheme("https",443,ssf)); UsernamePasswordCredentials credentials=new UsernamePasswordCredentials(accountId,password); URL urlObj=new URL(openshiftRestURI); AuthScope aScope=new AuthScope(urlObj.getHost(),urlObj.getPort()); httpClient.getCredentialsProvider().setCredentials(aScope,credentials); httpClient.addRequestInterceptor(new PreemptiveAuthInterceptor(),0); }
Example 31
From project recordloader, under directory /src/java/com/marklogic/recordloader/xcc/.
Source file: XccConfiguration.java

protected static SecurityOptions newTrustAnyoneOptions() throws KeyManagementException, NoSuchAlgorithmException { TrustManager[] trust=new TrustManager[]{new X509TrustManager(){ public java.security.cert.X509Certificate[] getAcceptedIssuers(){ return new X509Certificate[0]; } /** * @throws CertificateException */ public void checkClientTrusted( java.security.cert.X509Certificate[] certs, String authType) throws CertificateException { } /** * @throws CertificateException */ public void checkServerTrusted( java.security.cert.X509Certificate[] certs, String authType) throws CertificateException { } } }; SSLContext sslContext=SSLContext.getInstance("SSLv3"); sslContext.init(null,trust,null); return new SecurityOptions(sslContext); }
Example 32
From project restfuse, under directory /com.eclipsesource.restfuse/src/com/github/kevinsawicki/http/.
Source file: HttpRequest.java

private static SSLSocketFactory getTrustedFactory() throws HttpRequestException { if (TRUSTED_FACTORY == null) { final TrustManager[] trustAllCerts=new TrustManager[]{new X509TrustManager(){ public X509Certificate[] getAcceptedIssuers(){ return new X509Certificate[0]; } public void checkClientTrusted( X509Certificate[] chain, String authType){ } public void checkServerTrusted( X509Certificate[] chain, String authType){ } } }; try { SSLContext context=SSLContext.getInstance("TLS"); context.init(null,trustAllCerts,new SecureRandom()); TRUSTED_FACTORY=context.getSocketFactory(); } catch ( GeneralSecurityException e) { IOException ioException=new IOException("Security exception configuring SSL context"); ioException.initCause(e); throw new HttpRequestException(ioException); } } return TRUSTED_FACTORY; }
Example 33
From project sandbox, under directory /xeclipse/org.xwiki.eclipse.core/src/main/java/org/xwiki/eclipse/core/.
Source file: CorePlugin.java

public void start(BundleContext context) throws Exception { super.start(context); plugin=this; TrustManager[] trustAllCertificates=new TrustManager[]{new X509TrustManager(){ public X509Certificate[] getAcceptedIssuers(){ return null; } public void checkClientTrusted( X509Certificate[] arg0, String arg1) throws CertificateException { } public void checkServerTrusted( X509Certificate[] arg0, String arg1) throws CertificateException { } } }; SSLContext sc=SSLContext.getInstance("SSL"); HostnameVerifier hv=new HostnameVerifier(){ public boolean verify( String arg0, SSLSession arg1){ return true; } } ; sc.init(null,trustAllCertificates,new java.security.SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); HttpsURLConnection.setDefaultHostnameVerifier(hv); }
Example 34
protected static SecurityOptions newTrustAnyoneOptions() throws KeyManagementException, NoSuchAlgorithmException { TrustManager[] trust=new TrustManager[]{new X509TrustManager(){ public X509Certificate[] getAcceptedIssuers(){ return new X509Certificate[0]; } /** * @throws CertificateException */ public void checkClientTrusted( X509Certificate[] certs, String authType) throws CertificateException { } /** * @throws CertificateException */ public void checkServerTrusted( X509Certificate[] certs, String authType) throws CertificateException { } } }; SSLContext sslContext=SSLContext.getInstance("SSLv3"); sslContext.init(null,trust,null); return new SecurityOptions(sslContext); }
Example 35
From project xwiki-eclipse, under directory /plugins/org.xwiki.eclipse.core/src/main/java/org/xwiki/eclipse/core/.
Source file: CorePlugin.java

public void start(BundleContext context) throws Exception { super.start(context); plugin=this; TrustManager[] trustAllCertificates=new TrustManager[]{new X509TrustManager(){ public X509Certificate[] getAcceptedIssuers(){ return null; } public void checkClientTrusted( X509Certificate[] arg0, String arg1) throws CertificateException { } public void checkServerTrusted( X509Certificate[] arg0, String arg1) throws CertificateException { } } }; SSLContext sc=SSLContext.getInstance("SSL"); HostnameVerifier hv=new HostnameVerifier(){ public boolean verify( String arg0, SSLSession arg1){ return true; } } ; sc.init(null,trustAllCertificates,new java.security.SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); HttpsURLConnection.setDefaultHostnameVerifier(hv); }
Example 36
From project YandexAPI, under directory /src/ru/elifantiev/yandex/.
Source file: YandexSSLSocketFactory.java

YandexSSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { super(truststore); TrustManager tm=new X509TrustManager(){ public void checkClientTrusted( X509Certificate[] x509Certificates, String authType) throws CertificateException { } public void checkServerTrusted( X509Certificate[] certificates, String authType) throws CertificateException { for ( X509Certificate cert : certificates) cert.checkValidity(); } public X509Certificate[] getAcceptedIssuers(){ return null; } } ; sslContext.init(null,new TrustManager[]{tm},null); }
Example 37
From project AmDroid, under directory /httpclientandroidlib/src/ch/boye/httpclientandroidlib/conn/ssl/.
Source file: SSLSocketFactory.java

private static SSLContext createSSLContext(String algorithm,final KeyStore keystore,final String keystorePassword,final KeyStore truststore,final SecureRandom random,final TrustStrategy trustStrategy) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, KeyManagementException { if (algorithm == null) { algorithm=TLS; } KeyManagerFactory kmfactory=KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); kmfactory.init(keystore,keystorePassword != null ? keystorePassword.toCharArray() : null); KeyManager[] keymanagers=kmfactory.getKeyManagers(); TrustManagerFactory tmfactory=TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmfactory.init(truststore); TrustManager[] trustmanagers=tmfactory.getTrustManagers(); if (trustmanagers != null && trustStrategy != null) { for (int i=0; i < trustmanagers.length; i++) { TrustManager tm=trustmanagers[i]; if (tm instanceof X509TrustManager) { trustmanagers[i]=new TrustManagerDecorator((X509TrustManager)tm,trustStrategy); } } } SSLContext sslcontext=SSLContext.getInstance(algorithm); sslcontext.init(keymanagers,trustmanagers,random); return sslcontext; }
Example 38
From project caseconductor-platform, under directory /utest-webservice/utest-webservice-client/src/main/java/com/utest/webservice/client/rest/.
Source file: AuthSSLProtocolSocketFactory.java

private static TrustManager[] createTrustManagers(final KeyStore keystore) throws KeyStoreException, NoSuchAlgorithmException { if (keystore == null) { throw new IllegalArgumentException("Keystore may not be null"); } TrustManagerFactory tmfactory=TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmfactory.init(keystore); TrustManager[] trustmanagers=tmfactory.getTrustManagers(); for (int i=0; i < trustmanagers.length; i++) { if (trustmanagers[i] instanceof X509TrustManager) { trustmanagers[i]=new AuthSSLX509TrustManager((X509TrustManager)trustmanagers[i]); } } return trustmanagers; }
Example 39
From project chililog-server, under directory /src/main/java/org/chililog/server/pubsub/jsonhttp/.
Source file: JsonHttpSSLTrustManager.java

/** * Constructor */ private JsonHttpSSLTrustManager(){ try { KeyStore ks=KeyStore.getInstance("JKS"); ks.load(new FileInputStream(AppProperties.getInstance().getPubSubJsonHttpTrustStorePath()),AppProperties.getInstance().getPubSubJsonHttpTrustStorePassword().toCharArray()); TrustManagerFactory trustManagerFactory=TrustManagerFactory.getInstance("SunX509","SunJSSE"); trustManagerFactory.init(ks); _trustManagers=trustManagerFactory.getTrustManagers(); for (int i=0; i < _trustManagers.length; i++) { if (_trustManagers[i] instanceof X509TrustManager) { _sunJSSEX509TrustManager=(X509TrustManager)_trustManagers[i]; return; } } throw new Exception("X509TrustManager not found."); } catch ( Exception ex) { _logger.error("Error initializing SSLTrustManager. " + ex.getMessage(),ex); System.exit(1); } }
Example 40
From project cp-common-utils, under directory /src/com/clarkparsia/common/net/.
Source file: BasicX509TrustManager.java

public BasicX509TrustManager(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"); } mDefaultTrustManager=(X509TrustManager)trustmanagers[0]; }
Example 41
From project dreamDroid, under directory /src/net/reichholf/dreamdroid/helpers/.
Source file: EasyX509TrustManager.java

/** * Constructor for EasyX509TrustManager. */ 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.mStandardTrustManager=(X509TrustManager)trustmanagers[0]; }
Example 42
From project ereviewboard, under directory /org.review_board.ereviewboard.core/src/org/apache/commons/httpclient/contrib/ssl/.
Source file: EasyX509TrustManager.java

/** * Constructor for EasyX509TrustManager. */ 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]; }
Example 43
From project groundhog-reader, under directory /src/main/java/com/almarsoft/GroundhogReader/lib/.
Source file: TrustManagerFactory.java

public static X509TrustManager get(String host,boolean secure) throws NoSuchAlgorithmException { if (secure) { String defaultAlgorithm=javax.net.ssl.TrustManagerFactory.getDefaultAlgorithm(); javax.net.ssl.TrustManagerFactory tmf=javax.net.ssl.TrustManagerFactory.getInstance(defaultAlgorithm); TrustManager[] tms=tmf.getTrustManagers(); return new SecureX509TrustManager((X509TrustManager)tms[0],host); } else { return sUnsecureTrustManager; } }
Example 44
From project heritrix3, under directory /commons/src/main/java/org/archive/httpclient/.
Source file: ConfigurableX509TrustManager.java

/** * Constructor. * @param level Level of trust to effect. * @throws NoSuchAlgorithmException * @throws KeyStoreException */ public ConfigurableX509TrustManager(TrustLevel level) throws NoSuchAlgorithmException, KeyStoreException { super(); TrustManagerFactory factory=TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); factory.init((KeyStore)null); TrustManager[] trustmanagers=factory.getTrustManagers(); if (trustmanagers.length == 0) { throw new NoSuchAlgorithmException(TrustManagerFactory.getDefaultAlgorithm() + " trust manager not supported"); } this.standardTrustManager=(X509TrustManager)trustmanagers[0]; this.trustLevel=level; }
Example 45
From project httpClient, under directory /httpclient/src/main/java/org/apache/http/conn/ssl/.
Source file: SSLSocketFactory.java

private static SSLContext createSSLContext(String algorithm,final KeyStore keystore,final String keystorePassword,final KeyStore truststore,final SecureRandom random,final TrustStrategy trustStrategy) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, KeyManagementException { if (algorithm == null) { algorithm=TLS; } KeyManagerFactory kmfactory=KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); kmfactory.init(keystore,keystorePassword != null ? keystorePassword.toCharArray() : null); KeyManager[] keymanagers=kmfactory.getKeyManagers(); TrustManagerFactory tmfactory=TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmfactory.init(truststore); TrustManager[] trustmanagers=tmfactory.getTrustManagers(); if (trustmanagers != null && trustStrategy != null) { for (int i=0; i < trustmanagers.length; i++) { TrustManager tm=trustmanagers[i]; if (tm instanceof X509TrustManager) { trustmanagers[i]=new TrustManagerDecorator((X509TrustManager)tm,trustStrategy); } } } SSLContext sslcontext=SSLContext.getInstance(algorithm); sslcontext.init(keymanagers,trustmanagers,random); return sslcontext; }
Example 46
From project iSpace, under directory /base/httpcrawler/src/main/java/com/villemos/ispace/httpcrawler/.
Source file: EasyX509TrustManager.java

/** * Constructor for EasyX509TrustManager. */ 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]; }
Example 47
From project jentrata-msh, under directory /Ext/ebxml-pkg/src/main/java/hk/hku/cecid/ebms/pkg/.
Source file: SignatureHandler.java

public SignatureHandler(EbxmlMessage message,String username,char[] password,String keyStoreLocation,X509TrustManager trustman) throws SignatureException { this.message=message; this.username=username; this.password=password; this.keyStoreLocation=keyStoreLocation; try { certResolver=new KeyStoreCertResolver(trustman); } catch ( Exception e) { throw new SignatureException("Unable to create signature handler",e); } }
Example 48
From project jftp, under directory /src/main/java/com/myjavaworld/jftp/ssl/.
Source file: JFTPTrustManager.java

/** * Creates a new instance of <code>JFTPTrustManager</code>. * @param jftp JFTP instance * @param hostName Host name against which the host name verification is to be done. * @throws KeyStoreException * @throws NoSuchAlgorithmException */ public JFTPTrustManager(JFTP jftp,String hostName) throws KeyStoreException, NoSuchAlgorithmException { super(); this.jftp=jftp; this.hostName=hostName; TrustManagerFactory tmf=TrustManagerFactory.getInstance("SunX509"); tmf.init(KeyStoreManager.getServerCertificateStore()); tm=(X509TrustManager)tmf.getTrustManagers()[0]; }
Example 49
From project k-9, under directory /src/com/fsck/k9/mail/store/.
Source file: TrustManagerFactory.java

public synchronized static X509TrustManager getInstance(String host){ SecureX509TrustManager trustManager; if (mTrustManager.containsKey(host)) { trustManager=mTrustManager.get(host); } else { trustManager=new SecureX509TrustManager(host); mTrustManager.put(host,trustManager); } return trustManager; }
Example 50
From project Kairos, under directory /src/plugin/protocol-httpclient/src/java/org/apache/nutch/protocol/httpclient/.
Source file: DummyX509TrustManager.java

/** * Constructor for DummyX509TrustManager. */ public DummyX509TrustManager(KeyStore keystore) throws NoSuchAlgorithmException, KeyStoreException { super(); String algo=TrustManagerFactory.getDefaultAlgorithm(); TrustManagerFactory factory=TrustManagerFactory.getInstance(algo); factory.init(keystore); TrustManager[] trustmanagers=factory.getTrustManagers(); if (trustmanagers.length == 0) { throw new NoSuchAlgorithmException(algo + " trust manager not supported"); } this.standardTrustManager=(X509TrustManager)trustmanagers[0]; }
Example 51
From project litle-sdk-for-java, under directory /lib/apache-cxf-2.5.2/samples/jax_rs/basic_https/src/main/java/org/apache/commons/httpclient/contrib/ssl/.
Source file: AuthSSLProtocolSocketFactory.java

private static TrustManager[] createTrustManagers(final KeyStore keystore) throws KeyStoreException, NoSuchAlgorithmException { if (keystore == null) { throw new IllegalArgumentException("Keystore may not be null"); } LOG.debug("Initializing trust manager"); TrustManagerFactory tmfactory=TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmfactory.init(keystore); TrustManager[] trustmanagers=tmfactory.getTrustManagers(); for (int i=0; i < trustmanagers.length; i++) { if (trustmanagers[i] instanceof X509TrustManager) { trustmanagers[i]=new AuthSSLX509TrustManager((X509TrustManager)trustmanagers[i]); } } return trustmanagers; }
Example 52
From project maven-wagon, under directory /wagon-providers/wagon-http-shared4/src/main/java/org/apache/maven/wagon/shared/http4/.
Source file: EasyX509TrustManager.java

/** * Constructor for EasyX509TrustManager. */ 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]; }
Example 53
From project nutch, under directory /src/plugin/protocol-httpclient/src/java/org/apache/nutch/protocol/httpclient/.
Source file: DummyX509TrustManager.java

/** * Constructor for DummyX509TrustManager. */ public DummyX509TrustManager(KeyStore keystore) throws NoSuchAlgorithmException, KeyStoreException { super(); String algo=TrustManagerFactory.getDefaultAlgorithm(); TrustManagerFactory factory=TrustManagerFactory.getInstance(algo); factory.init(keystore); TrustManager[] trustmanagers=factory.getTrustManagers(); if (trustmanagers.length == 0) { throw new NoSuchAlgorithmException(algo + " trust manager not supported"); } this.standardTrustManager=(X509TrustManager)trustmanagers[0]; }
Example 54
From project portal, under directory /portal-core/src/main/java/org/devproof/portal/core/module/common/util/httpclient/ssl/.
Source file: EasyX509TrustManager.java

/** * Constructor for EasyX509TrustManager. */ 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]; }
Example 55
From project QuasselDroid, under directory /src/com/iskrembilen/quasseldroid/io/.
Source file: CustomTrustManager.java

CustomTrustManager(CoreConnection coreConnection) throws GeneralSecurityException { this.coreConnection=coreConnection; KeyStore ks=KeyStore.getInstance(KeyStore.getDefaultType()); TrustManagerFactory tmf=TrustManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); tmf.init(ks); TrustManager tms[]=tmf.getTrustManagers(); for (int i=0; i < tms.length; i++) { if (tms[i] instanceof X509TrustManager) { defaultTrustManager=(X509TrustManager)tms[i]; return; } } throw new GeneralSecurityException("Couldn't initialize certificate management!"); }
Example 56
/** * Constructor for EasyX509TrustManager. */ 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]; }
Example 57
From project SMSSync, under directory /smssync/src/org/addhen/smssync/net/.
Source file: EasyX509TrustManager.java

/** * Constructor for EasyX509TrustManager. */ 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]; }
Example 58
From project subsonic, under directory /subsonic-android/src/github/daneren2005/dsub/service/ssl/.
Source file: SSLSocketFactory.java

private static SSLContext createSSLContext(String algorithm,final KeyStore keystore,final String keystorePassword,final KeyStore truststore,final SecureRandom random,final TrustStrategy trustStrategy) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, KeyManagementException { if (algorithm == null) { algorithm=TLS; } KeyManagerFactory kmfactory=KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); kmfactory.init(keystore,keystorePassword != null ? keystorePassword.toCharArray() : null); KeyManager[] keymanagers=kmfactory.getKeyManagers(); TrustManagerFactory tmfactory=TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmfactory.init(keystore); TrustManager[] trustmanagers=tmfactory.getTrustManagers(); if (trustmanagers != null && trustStrategy != null) { for (int i=0; i < trustmanagers.length; i++) { TrustManager tm=trustmanagers[i]; if (tm instanceof X509TrustManager) { trustmanagers[i]=new TrustManagerDecorator((X509TrustManager)tm,trustStrategy); } } } SSLContext sslcontext=SSLContext.getInstance(algorithm); sslcontext.init(keymanagers,trustmanagers,random); return sslcontext; }
Example 59
From project Subsonic-Android, under directory /src/net/sourceforge/subsonic/androidapp/service/ssl/.
Source file: SSLSocketFactory.java

private static SSLContext createSSLContext(String algorithm,final KeyStore keystore,final String keystorePassword,final KeyStore truststore,final SecureRandom random,final TrustStrategy trustStrategy) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, KeyManagementException { if (algorithm == null) { algorithm=TLS; } KeyManagerFactory kmfactory=KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); kmfactory.init(keystore,keystorePassword != null ? keystorePassword.toCharArray() : null); KeyManager[] keymanagers=kmfactory.getKeyManagers(); TrustManagerFactory tmfactory=TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmfactory.init(keystore); TrustManager[] trustmanagers=tmfactory.getTrustManagers(); if (trustmanagers != null && trustStrategy != null) { for (int i=0; i < trustmanagers.length; i++) { TrustManager tm=trustmanagers[i]; if (tm instanceof X509TrustManager) { trustmanagers[i]=new TrustManagerDecorator((X509TrustManager)tm,trustStrategy); } } } SSLContext sslcontext=SSLContext.getInstance(algorithm); sslcontext.init(keymanagers,trustmanagers,random); return sslcontext; }
Example 60
From project subsonic_1, under directory /subsonic-android/src/net/sourceforge/subsonic/androidapp/service/ssl/.
Source file: SSLSocketFactory.java

private static SSLContext createSSLContext(String algorithm,final KeyStore keystore,final String keystorePassword,final KeyStore truststore,final SecureRandom random,final TrustStrategy trustStrategy) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, KeyManagementException { if (algorithm == null) { algorithm=TLS; } KeyManagerFactory kmfactory=KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); kmfactory.init(keystore,keystorePassword != null ? keystorePassword.toCharArray() : null); KeyManager[] keymanagers=kmfactory.getKeyManagers(); TrustManagerFactory tmfactory=TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmfactory.init(keystore); TrustManager[] trustmanagers=tmfactory.getTrustManagers(); if (trustmanagers != null && trustStrategy != null) { for (int i=0; i < trustmanagers.length; i++) { TrustManager tm=trustmanagers[i]; if (tm instanceof X509TrustManager) { trustmanagers[i]=new TrustManagerDecorator((X509TrustManager)tm,trustStrategy); } } } SSLContext sslcontext=SSLContext.getInstance(algorithm); sslcontext.init(keymanagers,trustmanagers,random); return sslcontext; }
Example 61
From project subsonic_2, under directory /subsonic-android/src/net/sourceforge/subsonic/androidapp/service/ssl/.
Source file: SSLSocketFactory.java

private static SSLContext createSSLContext(String algorithm,final KeyStore keystore,final String keystorePassword,final KeyStore truststore,final SecureRandom random,final TrustStrategy trustStrategy) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, KeyManagementException { if (algorithm == null) { algorithm=TLS; } KeyManagerFactory kmfactory=KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); kmfactory.init(keystore,keystorePassword != null ? keystorePassword.toCharArray() : null); KeyManager[] keymanagers=kmfactory.getKeyManagers(); TrustManagerFactory tmfactory=TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmfactory.init(keystore); TrustManager[] trustmanagers=tmfactory.getTrustManagers(); if (trustmanagers != null && trustStrategy != null) { for (int i=0; i < trustmanagers.length; i++) { TrustManager tm=trustmanagers[i]; if (tm instanceof X509TrustManager) { trustmanagers[i]=new TrustManagerDecorator((X509TrustManager)tm,trustStrategy); } } } SSLContext sslcontext=SSLContext.getInstance(algorithm); sslcontext.init(keymanagers,trustmanagers,random); return sslcontext; }
Example 62
From project Supersonic, under directory /subsonic-android/src/net/sourceforge/subsonic/androidapp/service/ssl/.
Source file: SSLSocketFactory.java

private static SSLContext createSSLContext(String algorithm,final KeyStore keystore,final String keystorePassword,final KeyStore truststore,final SecureRandom random,final TrustStrategy trustStrategy) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, KeyManagementException { if (algorithm == null) { algorithm=TLS; } KeyManagerFactory kmfactory=KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); kmfactory.init(keystore,keystorePassword != null ? keystorePassword.toCharArray() : null); KeyManager[] keymanagers=kmfactory.getKeyManagers(); TrustManagerFactory tmfactory=TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmfactory.init(keystore); TrustManager[] trustmanagers=tmfactory.getTrustManagers(); if (trustmanagers != null && trustStrategy != null) { for (int i=0; i < trustmanagers.length; i++) { TrustManager tm=trustmanagers[i]; if (tm instanceof X509TrustManager) { trustmanagers[i]=new TrustManagerDecorator((X509TrustManager)tm,trustStrategy); } } } SSLContext sslcontext=SSLContext.getInstance(algorithm); sslcontext.init(keymanagers,trustmanagers,random); return sslcontext; }
Example 63
From project SVQCOM, under directory /Core/src/com/ushahidi/android/app/net/.
Source file: EasyX509TrustManager.java

/** * Constructor for EasyX509TrustManager. */ 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]; }
Example 64
From project Ushahidi_Android, under directory /Core/src/com/ushahidi/android/app/net/.
Source file: EasyX509TrustManager.java

/** * Constructor for EasyX509TrustManager. */ 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]; }
Example 65
From project WaarpCommon, under directory /src/main/java/org/waarp/common/crypto/ssl/.
Source file: WaarpX509TrustManager.java

/** * Create a "default" X509TrustManager * @param tmf * @throws CryptoException */ public WaarpX509TrustManager(TrustManagerFactory tmf) throws CryptoException { TrustManager[] tms=tmf.getTrustManagers(); for (int i=0; i < tms.length; i++) { if (tms[i] instanceof X509TrustManager) { defaultX509TrustManager=(X509TrustManager)tms[i]; return; } } throw new CryptoException("Cannot initialize the WaarpX509TrustManager"); }
Example 66
From project zirco-browser, under directory /src/org/emergent/android/weave/client/.
Source file: WeaveSSLSocketFactory.java

public WeaveX509TrustManager(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"); } m_standardTrustManager=(X509TrustManager)trustmanagers[0]; }