Skip to content

Commit f875a7f

Browse files
committed
Added docs for public methods
1 parent 0c28dc6 commit f875a7f

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,13 @@ static Map<String, List<String>> addQuotaProjectIdToRequestMetadata(
392392
return Collections.unmodifiableMap(newRequestMetadata);
393393
}
394394

395+
/**
396+
* Refreshes the trust boundary associated with these credentials.
397+
*
398+
* @param newAccessToken The newly refreshed access token to use for the trust boundary request.
399+
* @throws IOException If the refresh fails and no cached trust boundary is available.
400+
* @throws IllegalArgumentException If the provided access token is null or expired.
401+
*/
395402
protected void refreshTrustBoundaries(AccessToken newAccessToken) throws IOException {
396403
if (!(this instanceof TrustBoundaryProvider)) {
397404
return;

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

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ final class TrustBoundary {
6565
private final String encodedLocations;
6666
private final List<String> locations;
6767

68+
/**
69+
* Creates a new TrustBoundary instance.
70+
*
71+
* @param encodedLocations The encoded string representation of the allowed locations.
72+
* @param locations A list of human-readable location strings.
73+
*/
6874
public TrustBoundary(String encodedLocations, List<String> locations) {
6975
this.encodedLocations = encodedLocations;
7076
this.locations =
@@ -75,14 +81,25 @@ public TrustBoundary(String encodedLocations, List<String> locations) {
7581

7682
private static EnvironmentProvider environmentProvider = SystemEnvironmentProvider.getInstance();
7783

84+
/**
85+
* Returns the encoded string representation of the allowed locations.
86+
*/
7887
public String getEncodedLocations() {
7988
return encodedLocations;
80-
}
89+
}
8190

91+
/**
92+
* Returns a list of human-readable location strings.
93+
*/
8294
public List<String> getLocations() {
8395
return locations;
8496
}
8597

98+
/**
99+
* Checks if this TrustBoundary represents a "no-op" (no restrictions).
100+
*
101+
* @return True if the encoded locations indicate no restrictions, false otherwise.
102+
*/
86103
public boolean isNoOp() {
87104
return NO_OP_VALUE.equals(encodedLocations);
88105
}
@@ -95,15 +112,24 @@ public static class TrustBoundaryResponse extends GenericJson {
95112
@Key("locations")
96113
private List<String> locations;
97114

115+
/**
116+
* Returns the encoded string representation of the allowed locations from the API response.
117+
*/
98118
public String getEncodedLocations() {
99119
return encodedLocations;
100120
}
101121

122+
/**
123+
* Returns a list of human-readable location strings from the API response.
124+
*/
102125
public List<String> getLocations() {
103126
return locations;
104127
}
105128

106129
@Override
130+
/**
131+
* Returns a string representation of the TrustBoundaryResponse.
132+
*/
107133
public String toString() {
108134
return MoreObjects.toStringHelper(this)
109135
.add("encodedLocations", encodedLocations)
@@ -117,6 +143,14 @@ static void setEnvironmentProviderForTest(@Nullable EnvironmentProvider provider
117143
environmentProvider = provider == null ? SystemEnvironmentProvider.getInstance() : provider;
118144
}
119145

146+
147+
/**
148+
* Checks if the trust boundary feature is enabled based on an environment variable.
149+
* The feature is enabled if the environment variable is set to "true" or "1" (case-insensitive).
150+
* Any other value, or if the variable is unset, will result in the feature being disabled.
151+
*
152+
* @return True if the trust boundary feature is enabled, false otherwise.
153+
*/
120154
static boolean isTrustBoundaryEnabled() {
121155
String trustBoundaryEnabled =
122156
environmentProvider.getEnv(GOOGLE_AUTH_TRUST_BOUNDARY_ENABLED_ENV_VAR);
@@ -127,6 +161,19 @@ static boolean isTrustBoundaryEnabled() {
127161
return "true".equals(lowercasedTrustBoundaryEnabled) || "1".equals(trustBoundaryEnabled);
128162
}
129163

164+
165+
/**
166+
* Refreshes the trust boundary by making a network call to the trust boundary endpoint.
167+
*
168+
* @param transportFactory The HTTP transport factory to use for the network request.
169+
* @param url The URL of the trust boundary endpoint.
170+
* @param accessToken The access token to authenticate the request.
171+
* @param cachedTrustBoundary An optional previously cached trust boundary, which may be used
172+
* in the request headers.
173+
* @return A new TrustBoundary object containing the refreshed information.
174+
* @throws IllegalArgumentException If the provided access token is null or expired.
175+
* @throws IOException If a network error occurs or the response is malformed.
176+
*/
130177
static TrustBoundary refresh(
131178
HttpTransportFactory transportFactory,
132179
String url,

0 commit comments

Comments
 (0)