List of usage examples for java.security KeyManagementException printStackTrace
public void printStackTrace()
From source file:Main.java
public static void disableSSLCertificateChecking() { TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { public X509Certificate[] getAcceptedIssuers() { return null; }/* ww w. j ava2 s . c om*/ @Override public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { // Not implemented } @Override public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { // Not implemented } } }; try { SSLContext sc = SSLContext.getInstance("TLS"); sc.init(null, trustAllCerts, new java.security.SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); } catch (KeyManagementException e) { e.printStackTrace(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } }
From source file:Main.java
/** * Disables the SSL certificate checking for new instances of {@link HttpsURLConnection} This has been created to * aid testing on a local box, not for use on production. *//* w w w.j a v a2 s . com*/ private static void disableSSLCertificateChecking() { TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { public X509Certificate[] getAcceptedIssuers() { return null; } @Override public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { // Not implemented } @Override public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { // Not implemented } } }; try { SSLContext sc = SSLContext.getInstance("TLS"); sc.init(null, trustAllCerts, new java.security.SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); } catch (KeyManagementException e) { e.printStackTrace(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } }
From source file:org.eclipse.lyo.oslc4j.bugzilla.utils.BugzillaHttpClient.java
private static SSLContext getTrustingSSLContext() { // Create a trust manager that does not validate certificate chains TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; }/*from w w w .j av a 2 s .c o m*/ public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) { } public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) { } } }; try { SSLContext sc = SSLContext.getInstance("SSL"); sc.init(null, trustAllCerts, new java.security.SecureRandom()); return sc; } catch (KeyManagementException e) { e.printStackTrace(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } return null; }
From source file:mobi.jenkinsci.ci.client.TrustAllSSLSocketFactory.java
public static void trustX509(HttpClient client, int sslPort) { try {//from w w w .j a va 2 s .co m client.getConnectionManager().getSchemeRegistry() .register(new Scheme("https", new TrustAllSSLSocketFactory(null), sslPort)); } catch (KeyManagementException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchAlgorithmException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (KeyStoreException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (UnrecoverableKeyException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.curso.listadapter.net.RESTClient.java
/** * this method utoacepts all certificates in httpsurlconections * *///from w w w .j a va 2 s. co m @SuppressLint("TrulyRandom") private static void disableSSLCertificateChecking() { TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { public X509Certificate[] getAcceptedIssuers() { return null; } @Override public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { } @Override public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { } } }; try { SSLContext sc = SSLContext.getInstance("TLS"); sc.init(null, trustAllCerts, new java.security.SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); } catch (KeyManagementException e) { e.printStackTrace(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } }
From source file:com.guster.skywebservice.library.webservice.SkyHttp.java
public static void trustAllCertificates(boolean yes) { trustAllCertificates = yes;/* w w w .ja va 2 s . c o m*/ if (yes) { TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { public X509Certificate[] getAcceptedIssuers() { return null; } @Override public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { // Not implemented } @Override public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { // Not implemented } } }; try { SSLContext sc = SSLContext.getInstance("TLS"); sc.init(null, trustAllCerts, new java.security.SecureRandom()); sslSocketFactory = sc.getSocketFactory(); } catch (KeyManagementException e) { e.printStackTrace(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } } }
From source file:com.wso2.mobile.mdm.utils.ServerUtilities.java
public static HttpsURLConnection getTrustedConnection(Context context, HttpsURLConnection conn) { HttpsURLConnection urlConnection = conn; try {// ww w. ja va 2 s . c om KeyStore localTrustStore; localTrustStore = KeyStore.getInstance("BKS"); InputStream in = context.getResources().openRawResource(R.raw.emm_truststore); localTrustStore.load(in, CommonUtilities.TRUSTSTORE_PASSWORD.toCharArray()); TrustManagerFactory tmf; tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmf.init(localTrustStore); SSLContext sslCtx; sslCtx = SSLContext.getInstance("TLS"); sslCtx.init(null, tmf.getTrustManagers(), null); urlConnection.setSSLSocketFactory(sslCtx.getSocketFactory()); return urlConnection; } catch (KeyManagementException e) { // TODO Auto-generated catch block e.printStackTrace(); return null; } catch (NoSuchAlgorithmException e) { // TODO Auto-generated catch block e.printStackTrace(); return null; } catch (CertificateException e1) { // TODO Auto-generated catch block e1.printStackTrace(); return null; } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); return null; } catch (KeyStoreException e2) { // TODO Auto-generated catch block e2.printStackTrace(); return null; } }
From source file:com.denimgroup.threadfix.remote.AcceptAllTrustManager.java
private SSLContext createAcceptAllSSLContext() { try {//from w w w . j a va 2 s. c o m AcceptAllTrustManager acceptAllTrustManager = new AcceptAllTrustManager(); SSLContext context = SSLContext.getInstance("TLS"); context.init(null, new AcceptAllTrustManager[] { acceptAllTrustManager }, null); return context; } catch (KeyManagementException e) { e.printStackTrace(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } return null; }
From source file:edu.indiana.d2i.htrc.corpus.retrieve.RetrieveRawCorpusMapper.java
@Override protected void setup(Context context) throws IOException, InterruptedException { Configuration conf = context.getConfiguration(); boolean success = false; try {//ww w. ja v a2 s. c o m dataAPIAgent = new DataAPIWrapper(conf.get(Constants.DATA_API_EPR), conf.get(Constants.DATA_API_PAGE_PREFIX), conf.get(Constants.DATA_API_VOL_PREFIX), conf.get(Constants.DATA_API_DELIMITER), Boolean.parseBoolean(conf.get(Constants.DATA_API_CONCAT)), conf.get(Constants.OAUTH2_EPR), conf.get(Constants.OAUTH2_USER_NAME), conf.get(Constants.OAUTH2_USER_PASSWORD), Boolean.parseBoolean(conf.get(Constants.DATA_API_SELFSIGN))); success = true; } catch (KeyManagementException e) { // TODO Auto-generated catch block e.printStackTrace(); logger.error("KeyManagementException : " + e.getMessage()); } catch (NoSuchAlgorithmException e) { // TODO Auto-generated catch block e.printStackTrace(); logger.error("NoSuchAlgorithmException : " + e.getMessage()); } catch (OAuthSystemException e) { // TODO Auto-generated catch block e.printStackTrace(); logger.error("OAuthSystemException : " + e.getMessage()); } catch (OAuthProblemException e) { // TODO Auto-generated catch block e.printStackTrace(); logger.error("OAuthProblemException : " + e.getMessage()); } if (!success) { System.err.println("Failed to instantiate dataAPI agent"); logger.error("Failed to instantiate dataAPI agent"); System.exit(-1); } // # of volumes per request numVolsPerReq = Integer .parseInt(conf.get(Constants.DATA_API_REQ_SIZE, Constants.DATA_API_DEFAULT_REQ_SIZE)); }
From source file:iristk.speech.nuancecloud.JSpeexNuanceCloudRecognizerListener.java
public JSpeexNuanceCloudRecognizerListener(Language lang) { try {/* w w w . jav a 2 s .c o m*/ this.LANGUAGE = lang.getCode().replaceAll("-", "_"); Properties properties = new Properties(); properties.load(new FileReader(NuanceCloudPackage.PACKAGE.getPath("license.properties"))); this.APP_ID = properties.getProperty("APP_ID"); this.APP_KEY = properties.getProperty("APP_KEY"); httpclient = getHttpClient(); } catch (KeyManagementException e) { e.printStackTrace(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }