Skip to content

Commit bd01ab3

Browse files
committed
Add javadocs to classes and methods that were made public.
1 parent 76d30b9 commit bd01ab3

File tree

5 files changed

+65
-5
lines changed

5 files changed

+65
-5
lines changed

cab-token-generator/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<dependency>
1717
<groupId>com.google.auth</groupId>
1818
<artifactId>google-auth-library-oauth2-http</artifactId>
19+
<version>${project.version}</version>
1920
</dependency>
2021
</dependencies>
2122

oauth2_http/java/com/google/auth/oauth2/OAuth2Credentials.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,15 @@ protected static <T> T newInstance(String className) throws IOException, ClassNo
484484
}
485485
}
486486

487+
/**
488+
* Returns the first service provider from the given service loader.
489+
*
490+
* @param clazz The class of the service provider to load.
491+
* @param defaultInstance The default instance to return if no service providers are found.
492+
* @param <T> The type of the service provider.
493+
* @return The first service provider from the service loader, or the {@code defaultInstance} if no
494+
* service providers are found.
495+
*/
487496
public static <T> T getFromServiceLoader(Class<? extends T> clazz, T defaultInstance) {
488497
return Iterables.getFirst(ServiceLoader.load(clazz), defaultInstance);
489498
}

oauth2_http/java/com/google/auth/oauth2/StsRequestHandler.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,17 @@
5050
import java.util.List;
5151
import javax.annotation.Nullable;
5252

53-
/** Implements the OAuth 2.0 token exchange based on https://tools.ietf.org/html/rfc8693. */
53+
/**
54+
* Implements the OAuth 2.0 token exchange based on
55+
* <a href="https://tools.ietf.org/html/rfc8693">RFC 8693</a>.
56+
*
57+
* <p>This class handles the process of exchanging one type of token for another using the
58+
* Security Token Service (STS). It constructs and sends the token exchange request to the STS
59+
* endpoint and parses the response to create an {@link StsTokenExchangeResponse} object.
60+
*
61+
* <p>Use the {@link #newBuilder(String, StsTokenExchangeRequest, HttpRequestFactory)} method to
62+
* create a new builder for constructing an instance of this class.
63+
*/
5464
public final class StsRequestHandler {
5565
private static final String TOKEN_EXCHANGE_GRANT_TYPE =
5666
"urn:ietf:params:oauth:grant-type:token-exchange";
@@ -85,6 +95,14 @@ private StsRequestHandler(
8595
this.internalOptions = internalOptions;
8696
}
8797

98+
/**
99+
* Returns a new builder for creating an instance of {@link StsRequestHandler}.
100+
*
101+
* @param tokenExchangeEndpoint The STS token exchange endpoint.
102+
* @param stsTokenExchangeRequest The STS token exchange request.
103+
* @param httpRequestFactory The HTTP request factory to use for sending the request.
104+
* @return A new builder instance.
105+
*/
88106
public static Builder newBuilder(
89107
String tokenExchangeEndpoint,
90108
StsTokenExchangeRequest stsTokenExchangeRequest,

oauth2_http/java/com/google/auth/oauth2/StsTokenExchangeRequest.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,16 @@
3838
import javax.annotation.Nullable;
3939

4040
/**
41-
* Defines an OAuth 2.0 token exchange request. Based on
42-
* https://tools.ietf.org/html/rfc8693#section-2.1.
41+
* Represents an OAuth 2.0 token exchange request, as defined in
42+
* <a href="https://tools.ietf.org/html/rfc8693#section-2.1">RFC 8693, Section 2.1</a>.
43+
*
44+
* <p>This class encapsulates the parameters necessary for making a token exchange request to
45+
* Google Security Token Service (STS). It includes the subject token, subject token type, optional
46+
* parameters like acting party, scopes, resource, audience, requested token type, and internal
47+
* options.
48+
*
49+
* <p>Instances of this class are immutable. Use the {@link #newBuilder(String, String)} method to
50+
* create a new builder.
4351
*/
4452
public final class StsTokenExchangeRequest {
4553
private static final String GRANT_TYPE = "urn:ietf:params:oauth:grant-type:token-exchange";
@@ -73,6 +81,15 @@ private StsTokenExchangeRequest(
7381
this.internalOptions = internalOptions;
7482
}
7583

84+
/**
85+
* Returns a new {@link StsTokenExchangeRequest.Builder} instance.
86+
*
87+
* @param subjectToken The token being exchanged. This represents the credentials being used
88+
* to authorize the token exchange request.
89+
* @param subjectTokenType The type of the {@code subjectToken}. For example,
90+
* {@link OAuth2Utils#TOKEN_TYPE_ACCESS_TOKEN}.
91+
* @return A new builder for creating {@code StsTokenExchangeRequest} instances.
92+
*/
7693
public static Builder newBuilder(String subjectToken, String subjectTokenType) {
7794
return new Builder(subjectToken, subjectTokenType);
7895
}

oauth2_http/java/com/google/auth/oauth2/StsTokenExchangeResponse.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,14 @@
4040
import javax.annotation.Nullable;
4141

4242
/**
43-
* Defines an OAuth 2.0 token exchange successful response. Based on
44-
* https://tools.ietf.org/html/rfc8693#section-2.2.1.
43+
* Represents an OAuth 2.0 token exchange request to the Google Security Token Service (STS), as
44+
* defined in <a href="https://tools.ietf.org/html/rfc8693#section-2.1">RFC 8693, Section 2.1</a>.
45+
*
46+
* <p>This class encapsulates the parameters for the request, including the subject token and its
47+
* type, along with optional parameters like acting party, scopes, resource, audience, requested
48+
* token type, and internal options.
49+
*
50+
* <p>Instances are immutable. Use {@link #newBuilder(String, String, String)} to create a builder.
4551
*/
4652
public final class StsTokenExchangeResponse {
4753
private final AccessToken accessToken;
@@ -76,6 +82,15 @@ private StsTokenExchangeResponse(
7682
this.accessBoundarySessionKey = accessBoundarySessionKey;
7783
}
7884

85+
/**
86+
* Returns a new {@link StsTokenExchangeResponse.Builder} instance.
87+
*
88+
* @param accessToken The exchanged access token.
89+
* @param issuedTokenType The issued token type. For example,
90+
* {@link OAuth2Utils#TOKEN_TYPE_ACCESS_TOKEN}.
91+
* @param tokenType The token type (e.g., "Bearer").
92+
* @return A new builder for creating {@link StsTokenExchangeResponse} instances.
93+
*/
7994
public static Builder newBuilder(String accessToken, String issuedTokenType, String tokenType) {
8095
return new Builder(accessToken, issuedTokenType, tokenType);
8196
}

0 commit comments

Comments
 (0)