Skip to content

Commit 6921f8c

Browse files
#784 - Removed the new newClient methods
1 parent d0dca6b commit 6921f8c

File tree

3 files changed

+15
-128
lines changed

3 files changed

+15
-128
lines changed

src/main/java/com/marklogic/client/DatabaseClientFactory.java

Lines changed: 10 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
import javax.net.ssl.SSLContext;
2323
import javax.net.ssl.SSLException;
24-
import javax.net.ssl.TrustManager;
2524

2625
import okhttp3.OkHttpClient;
2726
import org.slf4j.Logger;
@@ -213,7 +212,7 @@ private DatabaseClientFactory() {
213212
* @return a new client for making database requests
214213
*/
215214
static public DatabaseClient newClient(String host, int port) {
216-
return newClient(host, port, null, null, null, null, null, null, null);
215+
return newClient(host, port, null, null, null, null, null, null);
217216
}
218217

219218
/**
@@ -227,7 +226,7 @@ static public DatabaseClient newClient(String host, int port) {
227226
* @return a new client for making database requests
228227
*/
229228
static public DatabaseClient newClient(String host, int port, String database) {
230-
return newClient(host, port, database, null, null, null, null, null, null);
229+
return newClient(host, port, database, null, null, null, null, null);
231230
}
232231

233232
/**
@@ -241,7 +240,7 @@ static public DatabaseClient newClient(String host, int port, String database) {
241240
* @return a new client for making database requests
242241
*/
243242
static public DatabaseClient newClient(String host, int port, String user, String password, Authentication type) {
244-
return newClient(host, port, null, user, password, type, null, null, null);
243+
return newClient(host, port, null, user, password, type, null, null);
245244
}
246245
/**
247246
* Creates a client to access the database by means of a REST server.
@@ -255,7 +254,7 @@ static public DatabaseClient newClient(String host, int port, String user, Strin
255254
* @return a new client for making database requests
256255
*/
257256
static public DatabaseClient newClient(String host, int port, String database, String user, String password, Authentication type) {
258-
return newClient(host, port, database, user, password, type, null, null, null);
257+
return newClient(host, port, database, user, password, type, null, null);
259258
}
260259
/**
261260
* Creates a client to access the database by means of a REST server.
@@ -267,26 +266,9 @@ static public DatabaseClient newClient(String host, int port, String database, S
267266
* @param type the type of authentication applied to the request
268267
* @param context the SSL context for authenticating with the server
269268
* @return a new client for making database requests
270-
* @deprecated use {@link DatabaseClientFactory#newClient(String, int, String, String, Authentication, SSLContext, TrustManager)}}
271269
*/
272270
static public DatabaseClient newClient(String host, int port, String user, String password, Authentication type, SSLContext context) {
273-
return newClient(host, port, null, user, password, type, context, null, SSLHostnameVerifier.COMMON);
274-
}
275-
/**
276-
* Creates a client to access the database by means of a REST server.
277-
*
278-
* @param host the host with the REST server
279-
* @param port the port for the REST server
280-
* @param user the user with read, write, or administrative privileges
281-
* @param password the password for the user
282-
* @param type the type of authentication applied to the request
283-
* @param context the SSL context for authenticating with the server
284-
* @param trustManager the TrustManager object which is responsible for
285-
* deciding if a credential should be trusted or not.
286-
* @return a new client for making database requests
287-
*/
288-
static public DatabaseClient newClient(String host, int port, String user, String password, Authentication type, SSLContext context, TrustManager trustManager) {
289-
return newClient(host, port, null, user, password, type, context, trustManager, SSLHostnameVerifier.COMMON);
271+
return newClient(host, port, null, user, password, type, context, SSLHostnameVerifier.COMMON);
290272
}
291273
/**
292274
* Creates a client to access the database by means of a REST server.
@@ -299,27 +281,9 @@ static public DatabaseClient newClient(String host, int port, String user, Strin
299281
* @param type the type of authentication applied to the request
300282
* @param context the SSL context for authenticating with the server
301283
* @return a new client for making database requests
302-
* @deprecated use {@link DatabaseClientFactory#newClient(String, int, String, String, String, Authentication, SSLContext, TrustManager)}}
303284
*/
304285
static public DatabaseClient newClient(String host, int port, String database, String user, String password, Authentication type, SSLContext context) {
305-
return newClient(host, port, database, user, password, type, context, null, SSLHostnameVerifier.COMMON);
306-
}
307-
/**
308-
* Creates a client to access the database by means of a REST server.
309-
*
310-
* @param host the host with the REST server
311-
* @param port the port for the REST server
312-
* @param database the database to access (default: configured database for the REST server)
313-
* @param user the user with read, write, or administrative privileges
314-
* @param password the password for the user
315-
* @param type the type of authentication applied to the request
316-
* @param context the SSL context for authenticating with the server
317-
* @param trustManager the TrustManager object which is responsible for
318-
* deciding if a credential should be trusted or not.
319-
* @return a new client for making database requests
320-
*/
321-
static public DatabaseClient newClient(String host, int port, String database, String user, String password, Authentication type, SSLContext context, TrustManager trustManager) {
322-
return newClient(host, port, database, user, password, type, context, trustManager, SSLHostnameVerifier.COMMON);
286+
return newClient(host, port, database, user, password, type, context, SSLHostnameVerifier.COMMON);
323287
}
324288
/**
325289
* Creates a client to access the database by means of a REST server.
@@ -332,29 +296,9 @@ static public DatabaseClient newClient(String host, int port, String database, S
332296
* @param context the SSL context for authenticating with the server
333297
* @param verifier a callback for checking hostnames
334298
* @return a new client for making database requests
335-
* @deprecated use {@link DatabaseClientFactory#newClient(String, int, String, String, Authentication, SSLContext, TrustManager, SSLHostnameVerifier)}
336299
*/
337300
static public DatabaseClient newClient(String host, int port, String user, String password, Authentication type, SSLContext context, SSLHostnameVerifier verifier) {
338-
DatabaseClientImpl client = newClientImpl(host, port, null, user, password, type, context, null, verifier);
339-
client.setHandleRegistry(getHandleRegistry().copy());
340-
return client;
341-
}
342-
/**
343-
* Creates a client to access the database by means of a REST server.
344-
*
345-
* @param host the host with the REST server
346-
* @param port the port for the REST server
347-
* @param user the user with read, write, or administrative privileges
348-
* @param password the password for the user
349-
* @param type the type of authentication applied to the request
350-
* @param context the SSL context for authenticating with the server
351-
* @param trustManager the TrustManager object which is responsible for
352-
* deciding if a credential should be trusted or not.
353-
* @param verifier a callback for checking hostnames
354-
* @return a new client for making database requests
355-
*/
356-
static public DatabaseClient newClient(String host, int port, String user, String password, Authentication type, SSLContext context, TrustManager trustManager, SSLHostnameVerifier verifier) {
357-
DatabaseClientImpl client = newClientImpl(host, port, null, user, password, type, context, trustManager, verifier);
301+
DatabaseClientImpl client = newClientImpl(host, port, null, user, password, type, context, verifier);
358302
client.setHandleRegistry(getHandleRegistry().copy());
359303
return client;
360304
}
@@ -370,34 +314,13 @@ static public DatabaseClient newClient(String host, int port, String user, Strin
370314
* @param context the SSL context for authenticating with the server
371315
* @param verifier a callback for checking hostnames
372316
* @return a new client for making database requests
373-
* @deprecated use {@link DatabaseClientFactory#newClient(String, int, String, String, String, Authentication, SSLContext, TrustManager, SSLHostnameVerifier)}}
374317
*/
375318
static public DatabaseClient newClient(String host, int port, String database, String user, String password, Authentication type, SSLContext context, SSLHostnameVerifier verifier) {
376-
DatabaseClientImpl client = newClientImpl(host, port, database, user, password, type, context, null, verifier);
377-
client.setHandleRegistry(getHandleRegistry().copy());
378-
return client;
379-
}
380-
/**
381-
* Creates a client to access the database by means of a REST server.
382-
*
383-
* @param host the host with the REST server
384-
* @param port the port for the REST server
385-
* @param database the database to access (default: configured database for the REST server)
386-
* @param user the user with read, write, or administrative privileges
387-
* @param password the password for the user
388-
* @param type the type of authentication applied to the request
389-
* @param context the SSL context for authenticating with the server
390-
* @param trustManager the TrustManager object which is responsible for
391-
* deciding if a credential should be trusted or not.
392-
* @param verifier a callback for checking hostnames
393-
* @return a new client for making database requests
394-
*/
395-
static public DatabaseClient newClient(String host, int port, String database, String user, String password, Authentication type, SSLContext context, TrustManager trustManager, SSLHostnameVerifier verifier) {
396-
DatabaseClientImpl client = newClientImpl(host, port, database, user, password, type, context, trustManager, verifier);
319+
DatabaseClientImpl client = newClientImpl(host, port, database, user, password, type, context, verifier);
397320
client.setHandleRegistry(getHandleRegistry().copy());
398321
return client;
399322
}
400-
static private DatabaseClientImpl newClientImpl(String host, int port, String database, String user, String password, Authentication type, SSLContext context, TrustManager trustManager, SSLHostnameVerifier verifier) {
323+
static private DatabaseClientImpl newClientImpl(String host, int port, String database, String user, String password, Authentication type, SSLContext context, SSLHostnameVerifier verifier) {
401324
logger.debug("Creating new database client for server at "+host+":"+port);
402325
OkHttpServices services = new OkHttpServices();
403326
services.connect(host, port, database, user, password, type, context, verifier);
@@ -498,7 +421,6 @@ static public class Bean implements Serializable {
498421

499422
transient private SSLContext context;
500423
transient private SSLHostnameVerifier verifier;
501-
transient private TrustManager trustManager;
502424

503425
/**
504426
* Zero-argument constructor for bean applications. Other
@@ -613,22 +535,6 @@ public SSLContext getContext() {
613535
public void setContext(SSLContext context) {
614536
this.context = context;
615537
}
616-
/**
617-
* Returns the TrustManager for SSL clients created with a
618-
* DatabaseClientFactory.Bean object.
619-
* @return the TrustManager
620-
*/
621-
public TrustManager getTrustManager() {
622-
return trustManager;
623-
}
624-
/**
625-
* Specifies the TrustManager for clients created with a
626-
* DatabaseClientFactory.Bean object that authenticate with SSL.
627-
* @param trustManager the TrustManager
628-
*/
629-
public void setTrustManager(TrustManager trustManager) {
630-
this.trustManager = trustManager;
631-
}
632538
/**
633539
* Returns the host verifier for clients created with a
634540
* DatabaseClientFactory.Bean object.
@@ -680,7 +586,7 @@ public void registerDefaultHandles() {
680586
* @return a new client for making database requests
681587
*/
682588
public DatabaseClient newClient() {
683-
DatabaseClientImpl client = newClientImpl(host, port, database, user, password, authentication, context, trustManager, verifier);
589+
DatabaseClientImpl client = newClientImpl(host, port, database, user, password, authentication, context, verifier);
684590
client.setHandleRegistry(getHandleRegistry().copy());
685591

686592
return client;

src/main/java/com/marklogic/client/impl/OkHttpServices.java

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@
124124
import javax.net.ssl.SSLContext;
125125
import javax.net.ssl.SSLException;
126126
import javax.net.ssl.SSLSession;
127-
import javax.net.ssl.TrustManager;
128-
import javax.net.ssl.X509TrustManager;
129127
import javax.ws.rs.core.NewCookie;
130128
import java.io.ByteArrayInputStream;
131129
import java.io.Closeable;
@@ -284,17 +282,10 @@ private FailedRequest extractErrorFields(Response response) {
284282
}
285283
}
286284

287-
@Deprecated
288-
public void connect(String host, int port, String database, String user, String password,
289-
Authentication authenType, SSLContext sslContext,
290-
SSLHostnameVerifier verifier) {
291-
connect(host, port, database, user, password, authenType, sslContext, null, verifier);
292-
}
293285
@Override
294-
295286
public void connect(String host, int port, String database, String user, String password,
296-
Authentication authenType, SSLContext sslContext, TrustManager trustManager,
297-
SSLHostnameVerifier verifier) {
287+
Authentication authenType, SSLContext sslContext,
288+
SSLHostnameVerifier verifier) {
298289
HostnameVerifier hostnameVerifier = null;
299290
if (verifier == SSLHostnameVerifier.ANY) {
300291
hostnameVerifier = new HostnameVerifier() {
@@ -313,11 +304,11 @@ public boolean verify(String hostname, SSLSession session) {
313304
// throw new IllegalArgumentException(
314305
// "Null SSLContext but non-null SSLHostnameVerifier for client");
315306
//}
316-
connect(host, port, database, user, password, authenType, sslContext, trustManager, hostnameVerifier);
307+
connect(host, port, database, user, password, authenType, sslContext, hostnameVerifier);
317308
}
318309

319310
private void connect(String host, int port, String database, String user, String password,
320-
Authentication authenType, SSLContext sslContext, TrustManager trustManager,
311+
Authentication authenType, SSLContext sslContext,
321312
HostnameVerifier verifier) {
322313
logger.debug("Connecting to {} at {} as {}", new Object[]{host, port, user});
323314

@@ -368,13 +359,7 @@ private void connect(String host, int port, String database, String user, String
368359
.readTimeout(0, TimeUnit.SECONDS)
369360
.writeTimeout(0, TimeUnit.SECONDS);
370361

371-
if(sslContext != null) {
372-
if(trustManager == null) {
373-
clientBldr.sslSocketFactory(sslContext.getSocketFactory());
374-
} else {
375-
clientBldr.sslSocketFactory(sslContext.getSocketFactory(), (X509TrustManager) trustManager);
376-
}
377-
}
362+
if(sslContext != null) clientBldr.sslSocketFactory(sslContext.getSocketFactory());
378363

379364
if ( authenticator != null ) {
380365
clientBldr = clientBldr.authenticator(new CachingAuthenticatorDecorator(authenticator, authCache));

src/main/java/com/marklogic/client/impl/RESTServices.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import java.util.Set;
2222

2323
import javax.net.ssl.SSLContext;
24-
import javax.net.ssl.TrustManager;
2524

2625
import com.marklogic.client.DatabaseClient;
2726
import com.marklogic.client.DatabaseClientFactory.Authentication;
@@ -103,11 +102,8 @@ public interface RESTServices {
103102
String MAX_DELAY_PROP = "com.marklogic.client.maximumRetrySeconds";
104103
String MIN_RETRY_PROP = "com.marklogic.client.minimumRetries";
105104

106-
@Deprecated
107105
public void connect(String host, int port, String database, String user, String password, Authentication type,
108106
SSLContext context, SSLHostnameVerifier verifier);
109-
public void connect(String host, int port, String database, String user, String password, Authentication type,
110-
SSLContext context, TrustManager trustManager, SSLHostnameVerifier verifier);
111107
public DatabaseClient getDatabaseClient();
112108
public void setDatabaseClient(DatabaseClient client);
113109
public void release();

0 commit comments

Comments
 (0)