use of org.apache.http.client.CredentialsProvider in project sling by apache.
the class SmokeIT method newClient.
private CloseableHttpClient newClient() {
CredentialsProvider credsProvider = new BasicCredentialsProvider();
UsernamePasswordCredentials creds = new UsernamePasswordCredentials("admin", "admin");
credsProvider.setCredentials(new AuthScope("localhost", LAUNCHPAD_PORT), creds);
return HttpClientBuilder.create().setDefaultCredentialsProvider(credsProvider).build();
}
use of org.apache.http.client.CredentialsProvider in project ddf by codice.
the class TestSecurity method testAllowedCipherSuites.
@Test
public void testAllowedCipherSuites() throws Exception {
String[] supportedCipherSuites = { "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256", "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256", "TLS_DHE_RSA_WITH_AES_128_CBC_SHA", "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" };
List<String> systemCipherSuites = Arrays.asList(System.getProperty("https.cipherSuites").split(","));
assertThat("Missing a supported cipher suite", systemCipherSuites, equalTo(Arrays.asList(supportedCipherSuites)));
// Used to filter out cipher's that don't use our current key algorithm
KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
keystore.load(new FileInputStream(KEY_STORE_PATH), "changeit".toCharArray());
String keyAlgorithm = keystore.getKey("localhost", "changeit".toCharArray()).getAlgorithm();
String url = SERVICE_ROOT.getUrl() + "/catalog/query?q=*&src=local";
CredentialsProvider credentialsProvider = createBasicAuth("admin", "admin");
for (String cipher : supportedCipherSuites) {
if (cipher.contains("_" + keyAlgorithm + "_")) {
HttpClient client = createHttpClient("TLSv1.2", new String[] { cipher }, credentialsProvider);
assertBasicAuth(client, url, 200);
}
}
}
use of org.apache.http.client.CredentialsProvider in project ddf by codice.
the class TestSecurity method testDisallowedCipherSuites.
@Test(expected = SSLHandshakeException.class)
public void testDisallowedCipherSuites() throws Exception {
String[] disallowedCipherSuites = new String[] { // "TLS_DHE_RSA_WITH_AES_256_GCM_SHA384", "TLS_DHE_DSS_WITH_AES_256_GCM_SHA384",
"TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", "TLS_RSA_WITH_AES_128_CBC_SHA256", "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256", "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256", "TLS_DHE_DSS_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", "TLS_RSA_WITH_AES_128_CBC_SHA", "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA", "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA", "TLS_DHE_DSS_WITH_AES_128_CBC_SHA", "TLS_ECDHE_ECDSA_WITH_RC4_128_SHA", "TLS_ECDHE_RSA_WITH_RC4_128_SHA", "SSL_RSA_WITH_RC4_128_SHA", "TLS_ECDH_ECDSA_WITH_RC4_128_SHA", "TLS_ECDH_RSA_WITH_RC4_128_SHA", "TLS_RSA_WITH_AES_128_GCM_SHA256", "TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256", "TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256", "TLS_DHE_DSS_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA", "TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA", "SSL_RSA_WITH_3DES_EDE_CBC_SHA", "TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA", "TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA", "SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA", "SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA", "SSL_RSA_WITH_RC4_128_MD5", "TLS_EMPTY_RENEGOTIATION_INFO_SCSV" };
List<String> systemCipherSuites = Arrays.asList(System.getProperty("https.cipherSuites").split(","));
List<String> intersection = new ArrayList<>(Arrays.asList(disallowedCipherSuites));
intersection.retainAll(systemCipherSuites);
assertThat("Supported cipher suite in disallowed ciphers", intersection, emptyCollectionOf(String.class));
String url = SERVICE_ROOT.getUrl() + "/catalog/query?q=*&src=local";
CredentialsProvider credentialsProvider = createBasicAuth("admin", "admin");
HttpClient client = createHttpClient("TLSv1.2", disallowedCipherSuites, credentialsProvider);
HttpGet get = new HttpGet(url);
client.execute(get);
}
use of org.apache.http.client.CredentialsProvider in project ddf by codice.
the class TestSecurity method createBasicAuth.
private CredentialsProvider createBasicAuth(String username, String password) {
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
UsernamePasswordCredentials usernamePasswordCredentials = new UsernamePasswordCredentials(username, password);
credentialsProvider.setCredentials(AuthScope.ANY, usernamePasswordCredentials);
return credentialsProvider;
}
Aggregations