@Test public void createTrustKeystore() throws Exception { builder = new SSLConnectionSocketFactoryBuilder() { @Override protected KeyStore createKeyStore(final URL url, final String password) { return keyStoreMock; } }; builder.setTrustKeystore("file:" + KEYSTORE) .setTrustPassword(PASSWORD); when(sslContextBuilderMock.loadTrustMaterial(keyStoreMock)).thenReturn(sslContextBuilderMock); builder.createTrustKeystore(sslContextBuilderMock, true); verify(sslContextBuilderMock).loadTrustMaterial(keyStoreMock); }
protected void createTrustKeystore(SSLContextBuilder sslContextBuilder, boolean useTrustCert) { if (useTrustCert) { KeyStore trustKeyStore; try { trustKeyStore = createKeyStore(new URL(trustKeystore), trustPassword); sslContextBuilder.loadTrustMaterial(trustKeyStore); } catch (IOException ioe) { throw new IllegalArgumentException(ioe.getMessage() + ". " + BAD_TRUST_KEYSTORE_ERROR, ioe); } catch (GeneralSecurityException gse) { throw new IllegalArgumentException(gse.getMessage() + ". " + INVALID_TRUST_KEYSTORE_ERROR, gse); } } }
SSLConnectionSocketFactoryBuilder { protected void createTrustKeystore(SSLContextBuilder sslContextBuilder, boolean useTrustCert) { if (useTrustCert) { KeyStore trustKeyStore; try { trustKeyStore = createKeyStore(new URL(trustKeystore), trustPassword); sslContextBuilder.loadTrustMaterial(trustKeyStore); } catch (IOException ioe) { throw new IllegalArgumentException(ioe.getMessage() + ". " + BAD_TRUST_KEYSTORE_ERROR, ioe); } catch (GeneralSecurityException gse) { throw new IllegalArgumentException(gse.getMessage() + ". " + INVALID_TRUST_KEYSTORE_ERROR, gse); } } } }
SSLConnectionSocketFactoryBuilder { protected void createTrustKeystore(SSLContextBuilder sslContextBuilder, boolean useTrustCert) { if (useTrustCert) { KeyStore trustKeyStore; try { trustKeyStore = createKeyStore(new URL(trustKeystore), trustPassword); sslContextBuilder.loadTrustMaterial(trustKeyStore); } catch (IOException ioe) { throw new IllegalArgumentException(ioe.getMessage() + ". " + BAD_TRUST_KEYSTORE_ERROR, ioe); } catch (GeneralSecurityException gse) { throw new IllegalArgumentException(gse.getMessage() + ". " + INVALID_TRUST_KEYSTORE_ERROR, gse); } } }  }
SSLConnectionSocketFactoryBuilder { protected void createTrustKeystore(SSLContextBuilder sslContextBuilder, boolean useTrustCert) { if (useTrustCert) { KeyStore trustKeyStore; try { trustKeyStore = createKeyStore(new URL(trustKeystore), trustPassword); sslContextBuilder.loadTrustMaterial(trustKeyStore); } catch (IOException ioe) { throw new IllegalArgumentException(ioe.getMessage() + ". " + BAD_TRUST_KEYSTORE_ERROR, ioe); } catch (GeneralSecurityException gse) { throw new IllegalArgumentException(gse.getMessage() + ". " + INVALID_TRUST_KEYSTORE_ERROR, gse); } } }  static boolean checkEquality(String[] subArray, String[] largeArray); static boolean checkIfTLS2(String[] arr, String targetValue); SSLConnectionSocketFactory build(); SSLConnectionSocketFactoryBuilder setTrustAllRoots(String trustAllRoots); SSLConnectionSocketFactoryBuilder setInputTLS(String inputTLSversion); SSLConnectionSocketFactoryBuilder setKeystore(String keystore); SSLConnectionSocketFactoryBuilder setKeystorePassword(String keystorePassword); SSLConnectionSocketFactoryBuilder setTrustKeystore(String trustKeystore); SSLConnectionSocketFactoryBuilder setTrustPassword(String trustPassword); SSLConnectionSocketFactoryBuilder setallowedCyphers(String allowedCyphers); SSLConnectionSocketFactoryBuilder setX509HostnameVerifier(String x509HostnameVerifier); }
SSLConnectionSocketFactoryBuilder { protected void createTrustKeystore(SSLContextBuilder sslContextBuilder, boolean useTrustCert) { if (useTrustCert) { KeyStore trustKeyStore; try { trustKeyStore = createKeyStore(new URL(trustKeystore), trustPassword); sslContextBuilder.loadTrustMaterial(trustKeyStore); } catch (IOException ioe) { throw new IllegalArgumentException(ioe.getMessage() + ". " + BAD_TRUST_KEYSTORE_ERROR, ioe); } catch (GeneralSecurityException gse) { throw new IllegalArgumentException(gse.getMessage() + ". " + INVALID_TRUST_KEYSTORE_ERROR, gse); } } }  static boolean checkEquality(String[] subArray, String[] largeArray); static boolean checkIfTLS2(String[] arr, String targetValue); SSLConnectionSocketFactory build(); SSLConnectionSocketFactoryBuilder setTrustAllRoots(String trustAllRoots); SSLConnectionSocketFactoryBuilder setInputTLS(String inputTLSversion); SSLConnectionSocketFactoryBuilder setKeystore(String keystore); SSLConnectionSocketFactoryBuilder setKeystorePassword(String keystorePassword); SSLConnectionSocketFactoryBuilder setTrustKeystore(String trustKeystore); SSLConnectionSocketFactoryBuilder setTrustPassword(String trustPassword); SSLConnectionSocketFactoryBuilder setallowedCyphers(String allowedCyphers); SSLConnectionSocketFactoryBuilder setX509HostnameVerifier(String x509HostnameVerifier); static final String TRUST_ALL_ROOTS_ERROR; static final String SSL_CONNECTION_ERROR; static final String BAD_KEYSTORE_ERROR; static final String INVALID_KEYSTORE_ERROR; static final String BAD_TRUST_KEYSTORE_ERROR; static final String INVALID_TRUST_KEYSTORE_ERROR; static final String SSLv3; static final String TLSv10; static final String TLSv11; static final String TLSv12; static final String[] ARRAY_TLSv12; static final String[] array; static final String[] SUPPORTED_PROTOCOLS; static final String[] SUPPORTED_CYPHERS; public String[] cypherArray; }