static private SecurityContext makeSecurityContext(String user, String password, Authentication type, SSLContext context, SSLHostnameVerifier verifier) { if ( Authentication.BASIC == type ) { return new BasicAuthContext(user, password) .withSSLContext(context) .withSSLHostnameVerifier(verifier); } else if ( Authentication.DIGEST == type ) { return new DigestAuthContext(user, password) .withSSLContext(context) .withSSLHostnameVerifier(verifier); } else { throw new IllegalStateException("makeSecurityContext should only be called with BASIC or DIGEST Authentication"); } }
SecurityContext secContext = new DatabaseClientFactory.DigestAuthContext("rest-admin", "foo").withSSLContext(sslContext, new X509TrustManager() {
SecurityContext secContext = new DatabaseClientFactory.DigestAuthContext("rest-admin", "x").withSSLContext(sslContext, new X509TrustManager() {
SecurityContext secContext = new DatabaseClientFactory.DigestAuthContext("rest-admin", "x").withSSLContext(sslContext, new X509TrustManager() {
case DIGEST: return DatabaseClientFactory.newClient(host, port, dbName, new DatabaseClientFactory.DigestAuthContext(user, password) .withSSLHostnameVerifier(SSLHostnameVerifier.ANY) .withSSLContext(SimpleX509TrustManager.newSSLContext(), new SimpleX509TrustManager()), DatabaseClient.ConnectionType.GATEWAY); case BASIC: return DatabaseClientFactory.newClient(host, port, dbName, new DatabaseClientFactory.BasicAuthContext(user, password).withSSLHostnameVerifier(SSLHostnameVerifier.ANY), case DIGEST: return DatabaseClientFactory.newClient(host, port, dbName, new DatabaseClientFactory.DigestAuthContext(user, password) .withSSLHostnameVerifier(SSLHostnameVerifier.ANY) .withSSLContext(SimpleX509TrustManager.newSSLContext(), new SimpleX509TrustManager())); case BASIC: return DatabaseClientFactory.newClient(host, port, dbName, new DatabaseClientFactory.BasicAuthContext(user, password) .withSSLHostnameVerifier(SSLHostnameVerifier.ANY)
.withSSLContext(sslContext) .withSSLHostnameVerifier(SSLHostnameVerifier.ANY));