Skip to content

Commit ec80618

Browse files
author
ehennum
committed
fixing a few JavaDoc issues #1094
1 parent 4a44969 commit ec80618

File tree

8 files changed

+167
-71
lines changed

8 files changed

+167
-71
lines changed

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

Lines changed: 82 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -572,98 +572,150 @@ public static class SAMLAuthContext implements SecurityContext {
572572
private ExpiringSAMLAuth authorization;
573573
private RenewerCallback renewer;
574574

575-
/**
576-
* @return the X509TrustManagerused for authentication.
577-
*/
578-
public X509TrustManager getTrustManager() {
579-
return trustManager;
580-
}
581-
582-
/**
583-
* Replaces the token with new SAML authorization token.
584-
*/
575+
/**
576+
* Constructs a context for authorization using a SAML assertions token.
577+
* @param authorizationToken the token with the SAML assertions
578+
*/
585579
public SAMLAuthContext(String authorizationToken) {
586580
this.token = authorizationToken;
587581
}
582+
/**
583+
* Constructs a context for authorization using an authorizer callback.
584+
* The authorizer must get a SAML assertions token from the IDP (Identity Provider)
585+
* for the first request and when the current SAML assertions token is expiring.
586+
* @param authorizer the callback returning the assertions token
587+
*/
588588
public SAMLAuthContext(AuthorizerCallback authorizer) {
589589
this.authorizer = authorizer;
590590
}
591+
/**
592+
* Constructs a context for authorization using a SAML assertions token
593+
* and a renewer callback. The renewer callback must renew the SAML
594+
* assertions token with the IDP (Identity Provider) when the SAML assertions
595+
* token is expiring.
596+
* @param authorization the expiring object with the SAML assertions token and expiry
597+
* @param renewer the renewer callback
598+
*/
591599
public SAMLAuthContext(ExpiringSAMLAuth authorization, RenewerCallback renewer) {
592600
this.authorization = authorization;
593601
this.renewer = renewer;
594602
}
595-
596-
/**
603+
604+
/** Gets the SAML authentication token
597605
* @return the SAML authentication token.
598606
*/
599607
public String getToken() {
608+
if (token == null && authorization != null)
609+
return authorization.getAuthorizationToken();
600610
return token;
601611
}
612+
613+
/**
614+
* Gets the authorizer callback when specified during construction of the SAMLAuthContext.
615+
* @return the callback
616+
*/
602617
public AuthorizerCallback getAuthorizer() {
603618
return authorizer;
604619
}
620+
/**
621+
* Gets the renewer callback when specified during construction of the SAMLAuthContext.
622+
* @return the callback
623+
*/
605624
public RenewerCallback getRenewer() {
606625
return renewer;
607626
}
627+
/**
628+
* Gets the object with the SAML assertions token and expiration when specified during
629+
* construction of the SAMLAuthContext or renewed by the renewer callback.
630+
* @return the object with the assertions token and expiration
631+
*/
608632
public ExpiringSAMLAuth getAuthorization() {
609633
return authorization;
610634
}
611635

612636
/**
613-
* ExpiringSAMLAuth is used by SAMLAuthContext for reauthorization.
637+
* ExpiringSAMLAuth is used by SAMLAuthContext when renewing a SAML assertions token.
614638
*/
615639
public interface ExpiringSAMLAuth {
616640
/**
617-
* @return a new SAML assertion token.
641+
* Gets the SAML assertions token
642+
* @return the token.
618643
*/
619644
public String getAuthorizationToken();
620-
621645
/**
622-
* @return the expiration time stamp of the newly generated SAML assertion token.
646+
* Gets the expiration time stamp specified for the SAML assertions token
647+
* @return the expiration time stamp
623648
*/
624649
public Instant getExpiry();
625650
}
626651

627652
/**
628-
* newExpiringSAMLAuth is used to provide a new token with a new expiration time stamp.
653+
* Constructs an ExpiringSAMLAuth with a SAML assertions token and the expiration time stamp
654+
* for the token.
629655
* @param authorizationToken refers to the new SAML token.
630656
* @param expiry refers to the expiration time stamp of authorizationToken.
631657
* @return an ExpiringSAMLAuth instance.
632658
*/
633659
public static ExpiringSAMLAuth newExpiringSAMLAuth(final String authorizationToken, final Instant expiry) {
634660
return new ExpiringSAMLAuth() {
635-
636661
@Override
637662
public Instant getExpiry() {
638663
return expiry;
639664
}
640-
641665
@Override
642666
public String getAuthorizationToken() {
643667
return authorizationToken;
644668
}
645669
};
646670
}
647-
648-
@FunctionalInterface
649-
public interface AuthorizerCallback extends Function<ExpiringSAMLAuth, ExpiringSAMLAuth> { }
650-
651-
@FunctionalInterface
652-
public interface RenewerCallback extends Function<ExpiringSAMLAuth, Instant> { }
653671

672+
/**
673+
* A callback for getting a SAML assertions token from the IDP (Identity Provider).
674+
*/
675+
@FunctionalInterface
676+
public interface AuthorizerCallback extends Function<ExpiringSAMLAuth, ExpiringSAMLAuth> { }
677+
678+
/**
679+
* A callback for renewing the SAML assertions token with the IDP (Identity Provider)
680+
* by extending the expiration time.
681+
*/
682+
@FunctionalInterface
683+
public interface RenewerCallback extends Function<ExpiringSAMLAuth, Instant> { }
684+
685+
/**
686+
* Configures the SSL context and trust manager for a SAML authorization context
687+
* @param context - the SSLContext object required for the SSL connection
688+
* @param trustManager - X509TrustManager with which we initialize the SSLContext
689+
* @return this SAML authorization context for chained configuration
690+
*/
654691
@Override
655692
public SAMLAuthContext withSSLContext(SSLContext context, X509TrustManager trustManager) {
656693
this.sslContext = context;
657694
this.trustManager = trustManager;
658695
return this;
659696
}
660-
697+
/**
698+
* Configures the SSL hostname verifier for a SAML authorization context
699+
* @param verifier the host verifier
700+
* @return this SAML authorization context for chained configuration
701+
*/
661702
@Override
662703
public SAMLAuthContext withSSLHostnameVerifier(SSLHostnameVerifier verifier) {
663704
this.sslVerifier = verifier;
664705
return this;
665706
}
666707

708+
/**
709+
* Gets the trust manager when using SSL.
710+
* @return the X509TrustManager used for authentication
711+
*/
712+
public X509TrustManager getTrustManager() {
713+
return trustManager;
714+
}
715+
/**
716+
* Gets the SSL context when using SSL.
717+
* @return the SSLContext used for authentication
718+
*/
667719
@Override
668720
public SSLContext getSSLContext() {
669721
return sslContext;
@@ -676,6 +728,10 @@ public void setSSLContext(SSLContext context) {
676728

677729
}
678730

731+
/**
732+
* Gets the hostname verifier when using SSL.
733+
* @return the hostname verifier used for authentication
734+
*/
679735
@Override
680736
public SSLHostnameVerifier getSSLHostnameVerifier() {
681737
return sslVerifier;

marklogic-client-api/src/main/java/com/marklogic/client/datamovement/HostAvailabilityListener.java

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -363,28 +363,33 @@ public BatchFailureListener<QueryBatch> initializeRetryListener(QueryBatchListen
363363
* HostAvailabilityListener is returned
364364
* @return the first HostAvailabilityListener instance with the batcher or
365365
* null if there is no HostAvailabilityListener registered
366-
* @throws IllegalStateException if the passed Batcher is neither a
367-
* QueryBatcher nor a WriteBatcher
368366
*/
369367
public static HostAvailabilityListener getInstance(Batcher batcher) {
370368
if ( batcher instanceof WriteBatcher ) {
371-
WriteFailureListener[] writeFailureListeners = ((WriteBatcher) batcher).getBatchFailureListeners();
372-
for(WriteFailureListener writeFailureListener : writeFailureListeners) {
373-
if ( writeFailureListener instanceof HostAvailabilityListener ) {
374-
return (HostAvailabilityListener) writeFailureListener;
375-
}
376-
}
369+
return getInstance((WriteBatcher) batcher);
377370
} else if ( batcher instanceof QueryBatcher ) {
378-
QueryFailureListener[] queryFailureListeners = ((QueryBatcher) batcher).getQueryFailureListeners();
379-
for(QueryFailureListener queryFailureListener : queryFailureListeners) {
380-
if ( queryFailureListener instanceof HostAvailabilityListener ) {
381-
return (HostAvailabilityListener) queryFailureListener;
382-
}
383-
}
371+
return getInstance((QueryBatcher) batcher);
384372
} else {
385373
throw new IllegalStateException(
386374
"The Batcher should be either a QueryBatcher instance or a WriteBatcher instance");
387375
}
376+
}
377+
private static HostAvailabilityListener getInstance(WriteBatcher batcher) {
378+
WriteFailureListener[] writeFailureListeners = batcher.getBatchFailureListeners();
379+
for (WriteFailureListener writeFailureListener : writeFailureListeners) {
380+
if (writeFailureListener instanceof HostAvailabilityListener) {
381+
return (HostAvailabilityListener) writeFailureListener;
382+
}
383+
}
384+
return null;
385+
}
386+
private static HostAvailabilityListener getInstance(QueryBatcher batcher) {
387+
QueryFailureListener[] queryFailureListeners = batcher.getQueryFailureListeners();
388+
for (QueryFailureListener queryFailureListener : queryFailureListeners) {
389+
if (queryFailureListener instanceof HostAvailabilityListener) {
390+
return (HostAvailabilityListener) queryFailureListener;
391+
}
392+
}
388393
return null;
389394
}
390395
}

marklogic-client-api/src/main/java/com/marklogic/client/datamovement/JacksonCSVSplitter.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.marklogic.client.datamovement;
1818

19+
import java.io.IOException;
1920
import java.io.InputStream;
2021
import java.io.Reader;
2122
import java.util.Iterator;
@@ -100,10 +101,10 @@ private CsvMapper configureCsvMapper() {
100101
* and wrapping the JsonNode into JacksonHandle.
101102
* @param input the input stream passed in.
102103
* @return a stream of JacksonHandle.
104+
* @throws IOException if the input cannot be split
103105
*/
104106
@Override
105-
public Stream<JacksonHandle> split(InputStream input) throws Exception {
106-
107+
public Stream<JacksonHandle> split(InputStream input) throws IOException {
107108
if(input == null) {
108109
throw new IllegalArgumentException("InputSteam cannot be null.");
109110
}
@@ -115,9 +116,9 @@ public Stream<JacksonHandle> split(InputStream input) throws Exception {
115116
* and wrapping the JsonNode into JacksonHandle.
116117
* @param input the Reader stream passed in.
117118
* @return a stream of JacksonHandle.
119+
* @throws IOException if the input cannot be split
118120
*/
119-
public Stream<JacksonHandle> split(Reader input) throws Exception {
120-
121+
public Stream<JacksonHandle> split(Reader input) throws IOException {
121122
if(input == null) {
122123
throw new IllegalArgumentException("Input cannot be null.");
123124
}

0 commit comments

Comments
 (0)