Skip to content

Commit 461121b

Browse files
committed
MLE-21476 Deprecates MarkLogicCloudAuthContext
Deprecates the MarkLogicCloudAuthContext class in favor of ProgressDataCloudAuthContext. This change reflects the rebranding of MarkLogic Cloud to Progress Data Cloud and ensures that the client API aligns with the updated naming convention. The deprecated class will be removed in a future release.
1 parent e072820 commit 461121b

13 files changed

+133
-75
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ mlPassword=admin
1111
# Whether tests should run with the expectation that they'll use a basePath and talk to a reverse proxy server
1212
testUseReverseProxyServer=false
1313

14-
# For testing cloud-based authentication; define in gradle-local.properties with valid values for a MarkLogic Cloud instance
14+
# For testing cloud-based authentication; define in gradle-local.properties with valid values for a Progress Data Cloud instance
1515
cloudHost=
1616
cloudKey=
1717
cloudBasePath=

marklogic-client-api/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ task testRows(type: Test) {
202202
}
203203

204204
task debugCloudAuth(type: JavaExec) {
205-
description = "Test program for manual testing of cloud-based authentication against a MarkLogic Cloud instance"
205+
description = "Test program for manual testing of cloud-based authentication against a Progress Data Cloud instance"
206206
main = 'com.marklogic.client.test.MarkLogicCloudAuthenticationDebugger'
207207
classpath = sourceSets.test.runtimeClasspath
208208
args = [cloudHost, cloudKey, cloudBasePath]

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

Lines changed: 77 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -350,52 +350,113 @@ public SecurityContext withSSLContext(SSLContext context, X509TrustManager trust
350350

351351
/**
352352
* @since 6.1.0
353+
* @deprecated as of 7.2.0; use {@code ProgressDataCloudAuthContext} instead. Will be removed in 8.0.0.
353354
*/
354-
public static class MarkLogicCloudAuthContext extends AuthContext {
355+
@Deprecated
356+
public static class MarkLogicCloudAuthContext extends ProgressDataCloudAuthContext {
357+
358+
/**
359+
* @param apiKey user's API key for accessing Progress Data Cloud
360+
*/
361+
public MarkLogicCloudAuthContext(String apiKey) {
362+
super(apiKey);
363+
}
364+
365+
/**
366+
* @param apiKey user's API key for accessing Progress Data Cloud
367+
* @param tokenDuration length in minutes until the generated access token expires
368+
* @since 6.3.0
369+
*/
370+
public MarkLogicCloudAuthContext(String apiKey, Integer tokenDuration) {
371+
super(apiKey, tokenDuration);
372+
}
373+
374+
/**
375+
* Only intended to be used in the scenario that the token endpoint of "/token" and the grant type of "apikey"
376+
* are not the intended values.
377+
*
378+
* @param apiKey user's API key for accessing Progress Data Cloud
379+
* @param tokenEndpoint for overriding the default token endpoint if necessary
380+
* @param grantType for overriding the default grant type if necessary
381+
*/
382+
public MarkLogicCloudAuthContext(String apiKey, String tokenEndpoint, String grantType) {
383+
super(apiKey, tokenEndpoint, grantType);
384+
}
385+
386+
/**
387+
* Only intended to be used in the scenario that the token endpoint of "/token" and the grant type of "apikey"
388+
* are not the intended values.
389+
*
390+
* @param apiKey user's API key for accessing Progress Data Cloud
391+
* @param tokenEndpoint for overriding the default token endpoint if necessary
392+
* @param grantType for overriding the default grant type if necessary
393+
* @param tokenDuration length in minutes until the generated access token expires
394+
* @since 6.3.0
395+
*/
396+
public MarkLogicCloudAuthContext(String apiKey, String tokenEndpoint, String grantType, Integer tokenDuration) {
397+
super(apiKey, tokenEndpoint, grantType, tokenDuration);
398+
}
399+
400+
@Override
401+
public MarkLogicCloudAuthContext withSSLContext(SSLContext context, X509TrustManager trustManager) {
402+
this.sslContext = context;
403+
this.trustManager = trustManager;
404+
return this;
405+
}
406+
407+
@Override
408+
public MarkLogicCloudAuthContext withSSLHostnameVerifier(SSLHostnameVerifier verifier) {
409+
this.sslVerifier = verifier;
410+
return this;
411+
}
412+
}
413+
414+
/**
415+
* @since 7.2.0 Use this instead of the now-deprecated {@code MarkLogicCloudAuthContext}
416+
*/
417+
public static class ProgressDataCloudAuthContext extends AuthContext {
355418
private String tokenEndpoint;
356419
private String grantType;
357420
private String apiKey;
358421
private Integer tokenDuration;
359422

360423
/**
361-
* @param apiKey user's API key for accessing MarkLogic Cloud
424+
* @param apiKey user's API key for accessing Progress Data Cloud
362425
*/
363-
public MarkLogicCloudAuthContext(String apiKey) {
426+
public ProgressDataCloudAuthContext(String apiKey) {
364427
this(apiKey, null);
365428
}
366429

367430
/**
368-
* @param apiKey user's API key for accessing MarkLogic Cloud
431+
* @param apiKey user's API key for accessing Progress Data Cloud
369432
* @param tokenDuration length in minutes until the generated access token expires
370-
* @since 6.3.0
371433
*/
372-
public MarkLogicCloudAuthContext(String apiKey, Integer tokenDuration) {
434+
public ProgressDataCloudAuthContext(String apiKey, Integer tokenDuration) {
373435
this(apiKey, "/token", "apikey", tokenDuration);
374436
}
375437

376438
/**
377439
* Only intended to be used in the scenario that the token endpoint of "/token" and the grant type of "apikey"
378440
* are not the intended values.
379441
*
380-
* @param apiKey user's API key for accessing MarkLogic Cloud
442+
* @param apiKey user's API key for accessing Progress Data Cloud
381443
* @param tokenEndpoint for overriding the default token endpoint if necessary
382444
* @param grantType for overriding the default grant type if necessary
383445
*/
384-
public MarkLogicCloudAuthContext(String apiKey, String tokenEndpoint, String grantType) {
446+
public ProgressDataCloudAuthContext(String apiKey, String tokenEndpoint, String grantType) {
385447
this(apiKey, tokenEndpoint, grantType, null);
386448
}
387449

388450
/**
389451
* Only intended to be used in the scenario that the token endpoint of "/token" and the grant type of "apikey"
390452
* are not the intended values.
391453
*
392-
* @param apiKey user's API key for accessing MarkLogic Cloud
454+
* @param apiKey user's API key for accessing Progress Data Cloud
393455
* @param tokenEndpoint for overriding the default token endpoint if necessary
394456
* @param grantType for overriding the default grant type if necessary
395457
* @param tokenDuration length in minutes until the generated access token expires
396-
* @since 6.3.0
397458
*/
398-
public MarkLogicCloudAuthContext(String apiKey, String tokenEndpoint, String grantType, Integer tokenDuration) {
459+
public ProgressDataCloudAuthContext(String apiKey, String tokenEndpoint, String grantType, Integer tokenDuration) {
399460
this.apiKey = apiKey;
400461
this.tokenEndpoint = tokenEndpoint;
401462
this.grantType = grantType;
@@ -414,23 +475,19 @@ public String getApiKey() {
414475
return apiKey;
415476
}
416477

417-
/**
418-
* @return
419-
* @since 6.3.0
420-
*/
421478
public Integer getTokenDuration() {
422479
return tokenDuration;
423480
}
424481

425482
@Override
426-
public MarkLogicCloudAuthContext withSSLContext(SSLContext context, X509TrustManager trustManager) {
483+
public ProgressDataCloudAuthContext withSSLContext(SSLContext context, X509TrustManager trustManager) {
427484
this.sslContext = context;
428485
this.trustManager = trustManager;
429486
return this;
430487
}
431488

432489
@Override
433-
public MarkLogicCloudAuthContext withSSLHostnameVerifier(SSLHostnameVerifier verifier) {
490+
public ProgressDataCloudAuthContext withSSLHostnameVerifier(SSLHostnameVerifier verifier) {
434491
this.sslVerifier = verifier;
435492
return this;
436493
}
@@ -1277,10 +1334,10 @@ static public DatabaseClient newClient(String host, int port, String basePath, S
12771334
DatabaseClient.ConnectionType connectionType) {
12781335
RESTServices services = new OkHttpServices();
12791336
// As of 6.1.0, the following optimization is made as it's guaranteed that if the user is connecting to a
1280-
// MarkLogic Cloud instance, then port 443 will be used. Every path for constructing a DatabaseClient goes through
1337+
// Progress Data Cloud instance, then port 443 will be used. Every path for constructing a DatabaseClient goes through
12811338
// this method, ensuring that this optimization will always be applied, and thus freeing the user from having to
1282-
// worry about what port to configure when using MarkLogic Cloud.
1283-
if (securityContext instanceof MarkLogicCloudAuthContext) {
1339+
// worry about what port to configure when using Progress Data Cloud.
1340+
if (securityContext instanceof MarkLogicCloudAuthContext || securityContext instanceof ProgressDataCloudAuthContext) {
12841341
port = 443;
12851342
}
12861343
services.connect(host, port, basePath, database, securityContext);

marklogic-client-api/src/main/java/com/marklogic/client/impl/DatabaseClientPropertySource.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ private DatabaseClientFactory.SecurityContext newCloudAuthContext() {
259259
throw new IllegalArgumentException("Cloud token duration must be numeric");
260260
}
261261
}
262-
return new DatabaseClientFactory.MarkLogicCloudAuthContext(apiKey, duration);
262+
return new DatabaseClientFactory.ProgressDataCloudAuthContext(apiKey, duration);
263263
}
264264

265265
private DatabaseClientFactory.SecurityContext newCertificateAuthContext(SSLUtil.SSLInputs sslInputs, String sslProtocol) {
@@ -315,7 +315,7 @@ private DatabaseClientFactory.SSLHostnameVerifier determineHostnameVerifier() {
315315
* Uses the given propertySource to construct the inputs pertaining to constructing an SSLContext and an
316316
* X509TrustManager.
317317
*
318-
* @param authType used for applying "default" as the SSL protocol for MarkLogic cloud authentication in
318+
* @param authType used for applying "default" as the SSL protocol for Progress Data Cloud authentication in
319319
* case the user does not define their own SSLContext or SSL protocol
320320
* @return
321321
*/
@@ -398,8 +398,8 @@ private String getSSLProtocol(String authType) {
398398
if (sslProtocol != null) {
399399
sslProtocol = sslProtocol.trim();
400400
}
401-
// For convenience for MarkLogic Cloud users, assume the JVM's default SSLContext should trust the certificate
402-
// used by MarkLogic Cloud. A user can always override this default behavior by providing their own SSLContext.
401+
// For convenience for Progress Data Cloud users, assume the JVM's default SSLContext should trust the certificate
402+
// used by Progress Data Cloud. A user can always override this default behavior by providing their own SSLContext.
403403
if ((sslProtocol == null || sslProtocol.length() == 0) && DatabaseClientBuilder.AUTH_TYPE_MARKLOGIC_CLOUD.equalsIgnoreCase(authType)) {
404404
sslProtocol = "default";
405405
}

marklogic-client-api/src/main/java/com/marklogic/client/impl/okhttp/OkHttpUtil.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ public static OkHttpClient.Builder newOkHttpClientBuilder(String host, DatabaseC
5454
} else if (securityContext instanceof DatabaseClientFactory.CertificateAuthContext) {
5555
} else if (securityContext instanceof DatabaseClientFactory.SAMLAuthContext) {
5656
configureSAMLAuth((DatabaseClientFactory.SAMLAuthContext) securityContext, clientBuilder);
57-
} else if (securityContext instanceof DatabaseClientFactory.MarkLogicCloudAuthContext) {
58-
authenticationConfigurer = new MarkLogicCloudAuthenticationConfigurer(host);
57+
} else if (securityContext instanceof DatabaseClientFactory.ProgressDataCloudAuthContext ||
58+
securityContext instanceof DatabaseClientFactory.MarkLogicCloudAuthContext) {
59+
authenticationConfigurer = new ProgressDataCloudAuthenticationConfigurer(host);
5960
} else if (securityContext instanceof DatabaseClientFactory.OAuthContext) {
6061
authenticationConfigurer = new OAuthAuthenticationConfigurer();
6162
} else {
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@
55

66
import com.fasterxml.jackson.databind.JsonNode;
77
import com.fasterxml.jackson.databind.ObjectMapper;
8-
import com.marklogic.client.DatabaseClientFactory.MarkLogicCloudAuthContext;
8+
import com.marklogic.client.DatabaseClientFactory;
99
import okhttp3.*;
1010
import org.slf4j.Logger;
1111
import org.slf4j.LoggerFactory;
1212

1313
import java.io.IOException;
1414

15-
class MarkLogicCloudAuthenticationConfigurer implements AuthenticationConfigurer<MarkLogicCloudAuthContext> {
15+
class ProgressDataCloudAuthenticationConfigurer implements AuthenticationConfigurer<DatabaseClientFactory.ProgressDataCloudAuthContext> {
1616

17-
private String host;
17+
private final String host;
1818

19-
MarkLogicCloudAuthenticationConfigurer(String host) {
19+
ProgressDataCloudAuthenticationConfigurer(String host) {
2020
this.host = host;
2121
}
2222

2323
@Override
24-
public void configureAuthentication(OkHttpClient.Builder clientBuilder, MarkLogicCloudAuthContext securityContext) {
24+
public void configureAuthentication(OkHttpClient.Builder clientBuilder, DatabaseClientFactory.ProgressDataCloudAuthContext securityContext) {
2525
final String apiKey = securityContext.getApiKey();
2626
if (apiKey == null || apiKey.trim().length() < 1) {
2727
throw new IllegalArgumentException("No API key provided");
@@ -38,16 +38,16 @@ public interface TokenGenerator {
3838
}
3939

4040
/**
41-
* Knows how to call the "/token" endpoint in MarkLogic Cloud to generate a new token based on the
41+
* Knows how to call the "/token" endpoint in Progress Data Cloud to generate a new token based on the
4242
* user-provided API key.
4343
*/
4444
static class DefaultTokenGenerator implements TokenGenerator {
4545

4646
private final static Logger logger = LoggerFactory.getLogger(DefaultTokenGenerator.class);
47-
private String host;
48-
private MarkLogicCloudAuthContext securityContext;
47+
private final String host;
48+
private final DatabaseClientFactory.ProgressDataCloudAuthContext securityContext;
4949

50-
public DefaultTokenGenerator(String host, MarkLogicCloudAuthContext securityContext) {
50+
public DefaultTokenGenerator(String host, DatabaseClientFactory.ProgressDataCloudAuthContext securityContext) {
5151
this.host = host;
5252
this.securityContext = securityContext;
5353
}
@@ -65,7 +65,7 @@ private Response callTokenEndpoint() {
6565
final HttpUrl tokenUrl = buildTokenUrl();
6666
OkHttpClient.Builder clientBuilder = OkHttpUtil.newClientBuilder();
6767
// Current assumption is that the SSL config provided for connecting to MarkLogic should also be applicable
68-
// for connecting to MarkLogic Cloud's "/token" endpoint.
68+
// for connecting to Progress Data Cloud's "/token" endpoint.
6969
OkHttpUtil.configureSocketFactory(clientBuilder, securityContext.getSSLContext(), securityContext.getTrustManager());
7070
OkHttpUtil.configureHostnameVerifier(clientBuilder, securityContext.getSSLHostnameVerifier());
7171

@@ -89,7 +89,7 @@ private Response callTokenEndpoint() {
8989
}
9090

9191
protected HttpUrl buildTokenUrl() {
92-
// For the near future, it's guaranteed that https and 443 will be required for connecting to MarkLogic Cloud,
92+
// For the near future, it's guaranteed that https and 443 will be required for connecting to Progress Data Cloud,
9393
// so providing the ability to customize this would be misleading.
9494
HttpUrl.Builder builder = new HttpUrl.Builder()
9595
.scheme("https")
@@ -134,7 +134,7 @@ static class TokenAuthenticationInterceptor implements Interceptor {
134134

135135
private final static Logger logger = LoggerFactory.getLogger(TokenAuthenticationInterceptor.class);
136136

137-
private TokenGenerator tokenGenerator;
137+
private final TokenGenerator tokenGenerator;
138138
private String token;
139139

140140
public TokenAuthenticationInterceptor(TokenGenerator tokenGenerator) {

marklogic-client-api/src/test/java/com/marklogic/client/impl/DatabaseClientPropertySourceTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ void cloudAuthWithNoSslInputs() {
8181
bean = buildBean();
8282

8383
assertEquals("/my/path", bean.getBasePath());
84-
assertTrue(bean.getSecurityContext() instanceof DatabaseClientFactory.MarkLogicCloudAuthContext);
84+
assertTrue(bean.getSecurityContext() instanceof DatabaseClientFactory.ProgressDataCloudAuthContext);
8585

86-
DatabaseClientFactory.MarkLogicCloudAuthContext context = (DatabaseClientFactory.MarkLogicCloudAuthContext) bean.getSecurityContext();
86+
DatabaseClientFactory.ProgressDataCloudAuthContext context = (DatabaseClientFactory.ProgressDataCloudAuthContext) bean.getSecurityContext();
8787
assertEquals("abc123", context.getApiKey());
8888

8989
assertNotNull(context.getSSLContext(), "If cloud is chosen with no SSL protocol or context, the default JVM " +
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
import static org.junit.jupiter.api.Assertions.assertEquals;
1111

1212
/**
13-
* Since we don't yet have a reliable way to test against a MarkLogic cloud instance, including some small unit tests
13+
* Since we don't yet have a reliable way to test against a Progress Data Cloud instance, including some small unit tests
1414
* to ensure that certain things are built as expected.
1515
*/
16-
public class MarkLogicCloudAuthenticationConfigurerTest {
16+
public class ProgressDataCloudAuthenticationConfigurerTest {
1717

1818
@Test
1919
void buildTokenUrl() throws Exception {
20-
MarkLogicCloudAuthenticationConfigurer.DefaultTokenGenerator client = new MarkLogicCloudAuthenticationConfigurer.DefaultTokenGenerator("somehost",
21-
new DatabaseClientFactory.MarkLogicCloudAuthContext("doesnt-matter")
20+
ProgressDataCloudAuthenticationConfigurer.DefaultTokenGenerator client = new ProgressDataCloudAuthenticationConfigurer.DefaultTokenGenerator("somehost",
21+
new DatabaseClientFactory.ProgressDataCloudAuthContext("doesnt-matter")
2222
.withSSLContext(SSLContext.getDefault(), null)
2323
);
2424

@@ -32,8 +32,8 @@ void buildTokenUrl() throws Exception {
3232
*/
3333
@Test
3434
void buildTokenUrlWithCustomTokenPath() throws Exception {
35-
MarkLogicCloudAuthenticationConfigurer.DefaultTokenGenerator client = new MarkLogicCloudAuthenticationConfigurer.DefaultTokenGenerator("otherhost",
36-
new DatabaseClientFactory.MarkLogicCloudAuthContext("doesnt-matter", "/customToken", "doesnt-matter")
35+
ProgressDataCloudAuthenticationConfigurer.DefaultTokenGenerator client = new ProgressDataCloudAuthenticationConfigurer.DefaultTokenGenerator("otherhost",
36+
new DatabaseClientFactory.ProgressDataCloudAuthContext("doesnt-matter", "/customToken", "doesnt-matter")
3737
.withSSLContext(SSLContext.getDefault(), null)
3838
);
3939

@@ -44,8 +44,8 @@ void buildTokenUrlWithCustomTokenPath() throws Exception {
4444
@Test
4545
void buildTokenUrlWithDuration() throws Exception {
4646
Integer duration = 10;
47-
MarkLogicCloudAuthenticationConfigurer.DefaultTokenGenerator client = new MarkLogicCloudAuthenticationConfigurer.DefaultTokenGenerator("somehost",
48-
new DatabaseClientFactory.MarkLogicCloudAuthContext("doesnt-matter", duration)
47+
ProgressDataCloudAuthenticationConfigurer.DefaultTokenGenerator client = new ProgressDataCloudAuthenticationConfigurer.DefaultTokenGenerator("somehost",
48+
new DatabaseClientFactory.ProgressDataCloudAuthContext("doesnt-matter", duration)
4949
.withSSLContext(SSLContext.getDefault(), null)
5050
);
5151

@@ -56,8 +56,8 @@ void buildTokenUrlWithDuration() throws Exception {
5656
@Test
5757
void buildTokenUrlWithDurationAndCustomPath() throws Exception {
5858
Integer duration = 10;
59-
MarkLogicCloudAuthenticationConfigurer.DefaultTokenGenerator client = new MarkLogicCloudAuthenticationConfigurer.DefaultTokenGenerator("somehost",
60-
new DatabaseClientFactory.MarkLogicCloudAuthContext("doesnt-matter", "/customToken", "doesnt-matter", duration)
59+
ProgressDataCloudAuthenticationConfigurer.DefaultTokenGenerator client = new ProgressDataCloudAuthenticationConfigurer.DefaultTokenGenerator("somehost",
60+
new DatabaseClientFactory.ProgressDataCloudAuthContext("doesnt-matter", "/customToken", "doesnt-matter", duration)
6161
.withSSLContext(SSLContext.getDefault(), null)
6262
);
6363

@@ -67,8 +67,8 @@ void buildTokenUrlWithDurationAndCustomPath() throws Exception {
6767

6868
@Test
6969
void newFormBody() {
70-
FormBody body = new MarkLogicCloudAuthenticationConfigurer.DefaultTokenGenerator("host-doesnt-matter",
71-
new DatabaseClientFactory.MarkLogicCloudAuthContext("myKey"))
70+
FormBody body = new ProgressDataCloudAuthenticationConfigurer.DefaultTokenGenerator("host-doesnt-matter",
71+
new DatabaseClientFactory.ProgressDataCloudAuthContext("myKey"))
7272
.newFormBody();
7373
assertEquals("grant_type", body.name(0));
7474
assertEquals("apikey", body.value(0));
@@ -82,8 +82,8 @@ void newFormBody() {
8282
*/
8383
@Test
8484
void newFormBodyWithOverrides() {
85-
FormBody body = new MarkLogicCloudAuthenticationConfigurer.DefaultTokenGenerator("host-doesnt-matter",
86-
new DatabaseClientFactory.MarkLogicCloudAuthContext("myKey", "doesnt-matter", "custom-grant-type"))
85+
FormBody body = new ProgressDataCloudAuthenticationConfigurer.DefaultTokenGenerator("host-doesnt-matter",
86+
new DatabaseClientFactory.ProgressDataCloudAuthContext("myKey", "doesnt-matter", "custom-grant-type"))
8787
.newFormBody();
8888
assertEquals("grant_type", body.name(0));
8989
assertEquals("custom-grant-type", body.value(0));

0 commit comments

Comments
 (0)