/** * Creates a random cnonce value based on the current time. * * @return The cnonce value as String. * @throws HttpClientError if MD5 algorithm is not supported. */ public static String createCnonce() { LOG.trace("enter DigestScheme.createCnonce()"); String cnonce; final String digAlg = "MD5"; MessageDigest md5Helper; try { md5Helper = MessageDigest.getInstance(digAlg); } catch (NoSuchAlgorithmException e) { throw new HttpClientError( "Unsupported algorithm in HTTP Digest authentication: " + digAlg); } cnonce = Long.toString(System.currentTimeMillis()); cnonce = encode(md5Helper.digest(EncodingUtil.getAsciiBytes(cnonce))); return cnonce; }
protected SSLContext createEasySSLContext(ApplicationConfiguration applicationConfiguration) { try { String password = applicationConfiguration.getCaCertsPassphrase(); char[] passphrase = null; if (password != null) { passphrase = StringEncrypter.defaultInstance().decrypt(password, cryptoConfigurationSalt).toCharArray(); } KeyStore cacerts = null; String cacertsFN = applicationConfiguration.getCaCertsLocation(); if (cacertsFN != null) { cacerts = KeyStore.getInstance(KeyStore.getDefaultType()); FileInputStream cacertsFile = new FileInputStream(cacertsFN); cacerts.load(cacertsFile, passphrase); cacertsFile.close(); } SSLContext context = SSLContext.getInstance("SSL"); context.init(null, new TrustManager[] { new EasyX509TrustManager(cacerts) }, null); return context; } catch (Exception e) { LOG.error(e.getMessage(), e); throw new HttpClientError(e.toString()); } }
private static SSLContext createEasySSLContext() { try { SSLContext context = SSLContext.getInstance("SSL"); context.init(null, new TrustManager[]{new EasyX509TrustManager(null)}, null); return context; } catch (Exception e) { if (Trace.ssl) { Trace.trace(e.getMessage()); } throw new HttpClientError(e.toString()); } }
protected SSLContext createEasySSLContext(AppConfiguration appConfiguration) { try { String password = appConfiguration.getCaCertsPassphrase(); char[] passphrase = null; if (password != null) { passphrase = encryptionService.decrypt(password).toCharArray(); } KeyStore cacerts = null; String cacertsFN = appConfiguration.getCaCertsLocation(); if (cacertsFN != null) { cacerts = KeyStore.getInstance(KeyStore.getDefaultType()); FileInputStream cacertsFile = new FileInputStream(cacertsFN); cacerts.load(cacertsFile, passphrase); cacertsFile.close(); } SSLContext context = SSLContext.getInstance("SSL"); context.init(null, new TrustManager[] { new EasyX509TrustManager(cacerts) }, null); return context; } catch (Exception e) { log.error(e.getMessage(), e); throw new HttpClientError(e.toString()); } }
private SSLContext getSSLContext(String host) { if (this.sslcontext == null) { try { TrustManager tm = null; if (level == Session.SecurityLevel.Low) { tm = new LowSecurityX509TrustManager(null); } else if (level == Session.SecurityLevel.Medium) { tm = new MediumSecurityX509TrustManager(host, handler, null); } else { tm = new HighSecurityX509TrustManager(null); } SSLContext context = SSLContext.getInstance("SSL"); context.init( null, new TrustManager[] {tm}, null); this.sslcontext = context; } catch (Exception e) { throw new HttpClientError(e.toString()); } } return this.sslcontext; }
/** * Converts the specified string to byte array of ASCII characters. * * @param data the string to be encoded * @return The string as a byte array. * * @since 3.0 */ public static byte[] getAsciiBytes(final String data) { if (data == null) { throw new IllegalArgumentException("Parameter may not be null"); } try { return data.getBytes("US-ASCII"); } catch (UnsupportedEncodingException e) { throw new HttpClientError("HttpClient requires ASCII support"); } }
/** * Converts the byte array of ASCII characters to a string. This method is * to be used when decoding content of HTTP elements (such as response * headers) * * @param data the byte array to be encoded * @param offset the index of the first byte to encode * @param length the number of bytes to encode * @return The string representation of the byte array * * @since 3.0 */ public static String getAsciiString(final byte[] data, int offset, int length) { if (data == null) { throw new IllegalArgumentException("Parameter may not be null"); } try { return new String(data, offset, length, "US-ASCII"); } catch (UnsupportedEncodingException e) { throw new HttpClientError("HttpClient requires ASCII support"); } }
private static SSLContext createEasySSLContext() { try { SSLContext context = SSLContext.getInstance("SSL"); context.init( null, new TrustManager[] {new EasyX509TrustManager(null)}, null); return context; } catch (Exception e) { LOG.error(e.getMessage(), e); throw new HttpClientError(e.toString()); } }
private static SSLContext createEasySSLContext() { try { SSLContext context = SSLContext.getInstance("SSL"); context.init(null, new TrustManager[] { new DummyX509TrustManager(null) }, null); return context; } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error(e.getMessage(), e); } throw new HttpClientError(e.toString()); } }
private static SSLContext createEasySSLContext() { try { SSLContext context = SSLContext.getInstance("SSL"); context.init( null, new TrustManager[] { new EasyX509TrustManager(null) }, null); return context; } catch (Exception e) { LOG.error(e.getMessage(), e); throw new HttpClientError(e.toString()); } }
private static SSLContext createEasySSLContext() { try { SSLContext context = SSLContext.getInstance("SSL"); context.init( null, new TrustManager[] {new EasyX509TrustManager(null)}, null); return context; } catch (Exception e) { log.error(e.getMessage(), e); throw new HttpClientError(e.toString()); } }
private static SSLContext createEasySSLContext() { try { SSLContext context = SSLContext.getInstance("SSL"); context.init( null, new TrustManager[]{new EasyX509TrustManager(null)}, null); return context; } catch (Exception e) { LOG.error(e.getMessage(), e); throw new HttpClientError(e.toString()); } }
private static SSLContext createEasySSLContext() { try { SSLContext context = SSLContext.getInstance("TLS"); context.init(null, new TrustManager[] { new DefaultX509TrustManager(null) }, null); return context; } catch (Exception e) { logger.error(e.getMessage(), e); throw new HttpClientError(e.toString()); } }
/** * * @return */ private static SSLContext createEasySSLContext() { try { SSLContext context = SSLContext.getInstance("SSL"); context.init(null, new TrustManager[] { new MyX509TrustManager() }, null); return context; } catch (Exception e) { throw new HttpClientError(e.toString()); } }
private static SSLContext createEasySSLContext() { try { SSLContext context = SSLContext.getInstance("SSL"); context.init(null, new TrustManager[] {new EasyX509TrustManager(null)}, null); return context; } catch (Exception e) { LOG.error(e.getMessage(), e); throw new HttpClientError(e.toString()); } }
private static SSLContext createEasySSLContext() { try { SSLContext context = SSLContext.getInstance("SSL"); context.init(null, new TrustManager[] { new EasyX509TrustManager(null) }, null); return context; } catch (Exception e) { LOG.error(e.getMessage(), e); throw new HttpClientError(e.toString()); } }
private static SSLContext createEasySSLContext() { try { SSLContext context = SSLContext.getInstance("SSL"); context.init( null, new TrustManager[]{new EasyX509TrustManager(null)}, null); return context; } catch (NoSuchAlgorithmException | KeyStoreException | KeyManagementException e) { LOG.error(e.getMessage(), e); throw new HttpClientError(e.toString()); } }
private static SSLContext createEasySSLContext() { try { SSLContext context = SSLContext.getInstance("TLS"); context.init(null, new TrustManager[] { new DefaultX509TrustManager(null) }, null); return context; } catch (Exception e) { LOG.error(e.getMessage(), e); throw new HttpClientError(e.toString()); } }
private SSLContext createSSLContext(String host) { try { SSLContext context = SSLContext.getInstance("SSL"); context.init( null, new TrustManager[]{new ClearspaceX509TrustManager(host, manager.getProperties(), SSLConfig.gets2sTrustStore())}, null); return context; } catch (Exception e) { Log.error(e.getMessage(), e); throw new HttpClientError(e.toString()); } }
protected SSLContext createEasySSLContext() { try { SSLContext context = SSLContext.getInstance("SSL"); context.init(null, new TrustManager[] { new EasyX509TrustManager(null) }, null); return context; } catch (Exception e) { LOG.error(e.getMessage(), e); throw new HttpClientError(e.toString()); } }
private static SSLContext createEasySSLContext() { try { SSLContext context = SSLContext.getInstance("SSL"); context.init( null, new TrustManager[] {new EwsX509TrustManager(null, trustManager)}, null); return context; } catch (Exception e) { System.out.println(e.getMessage()+e); throw new HttpClientError(e.toString()); } }
private static SSLContext createEasySSLContext() { try { SSLContext context = SSLUtils.getSSLContext(); context.init(null, new TrustManager[] {new EasyX509TrustManager(null)}, null); return context; } catch (Exception e) { LOG.error(e.getMessage(), e); throw new HttpClientError(e.toString()); } }
private static SSLContext createEasySSLContext() { try { SSLContext context = SSLContext.getInstance("SSL"); context.init( null, new TrustManager[] {new EasyX509TrustManager(null)}, null); return context; } catch (Exception e) { throw new HttpClientError(e.toString()); } }