Skip to content

Commit 381efe4

Browse files
committed
getConfig + javadocs.
1 parent e6b6e18 commit 381efe4

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,20 @@ public class SecureSessionAgent {
7272
private static final String MDS_MTLS_ENDPOINT =
7373
ComputeEngineCredentials.getMetadataServerUrl() + S2A_CONFIG_ENDPOINT_POSTFIX;
7474

75-
private SecureSessionAgentConfig config;
76-
7775
private transient HttpTransportFactory transportFactory;
7876

7977
SecureSessionAgent(SecureSessionAgent.Builder builder) {
8078
this.transportFactory = builder.getHttpTransportFactory();
81-
this.config = getSecureSessionAgentConfigFromMDS();
8279
}
8380

84-
/** @return the cached SecureSessionAgentConfig. */
85-
public SecureSessionAgentConfig getConfigFromMDS() {
86-
return config;
81+
/**
82+
* This method makes a network call to MDS to get the {@link SecureSessionAgentConfig} which
83+
* contains the plaintext and mtls address to reach the S2A (Secure Session Agent).
84+
*
85+
* @return the cached SecureSessionAgentConfig.
86+
*/
87+
public SecureSessionAgentConfig getConfig() {
88+
return getSecureSessionAgentConfigFromMDS();
8789
}
8890

8991
public static Builder newBuilder() {

oauth2_http/javatests/com/google/auth/oauth2/MockMetadataServerTransport.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ protected boolean isIdentityDocumentUrl(String url) {
337337
protected boolean isMtlsConfigRequestUrl(String url) {
338338
return url.equals(
339339
String.format(
340-
ComputeEngineCredentials.getMetadataServerUrl() + SecureSessionAgent.S2A_CONFIG_ENDPOINT_POSTFIX));
340+
ComputeEngineCredentials.getMetadataServerUrl()
341+
+ SecureSessionAgent.S2A_CONFIG_ENDPOINT_POSTFIX));
341342
}
342343
}

oauth2_http/javatests/com/google/auth/oauth2/SecureSessionAgentTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public void getS2AAddress_validAddress() {
6161

6262
SecureSessionAgent s2aUtils =
6363
SecureSessionAgent.newBuilder().setHttpTransportFactory(transportFactory).build();
64-
SecureSessionAgentConfig config = s2aUtils.getConfigFromMDS();
64+
SecureSessionAgentConfig config = s2aUtils.getConfig();
6565
String plaintextS2AAddress = config.getPlaintextAddress();
6666
String mtlsS2AAddress = config.getMtlsAddress();
6767
assertEquals(S2A_PLAINTEXT_ADDRESS, plaintextS2AAddress);
@@ -82,7 +82,7 @@ public void getS2AAddress_queryEndpointResponseErrorCode_emptyAddress() {
8282

8383
SecureSessionAgent s2aUtils =
8484
SecureSessionAgent.newBuilder().setHttpTransportFactory(transportFactory).build();
85-
SecureSessionAgentConfig config = s2aUtils.getConfigFromMDS();
85+
SecureSessionAgentConfig config = s2aUtils.getConfig();
8686
String plaintextS2AAddress = config.getPlaintextAddress();
8787
String mtlsS2AAddress = config.getMtlsAddress();
8888
assertTrue(plaintextS2AAddress.isEmpty());
@@ -103,7 +103,7 @@ public void getS2AAddress_queryEndpointResponseEmpty_emptyAddress() {
103103

104104
SecureSessionAgent s2aUtils =
105105
SecureSessionAgent.newBuilder().setHttpTransportFactory(transportFactory).build();
106-
SecureSessionAgentConfig config = s2aUtils.getConfigFromMDS();
106+
SecureSessionAgentConfig config = s2aUtils.getConfig();
107107
String plaintextS2AAddress = config.getPlaintextAddress();
108108
String mtlsS2AAddress = config.getMtlsAddress();
109109
assertTrue(plaintextS2AAddress.isEmpty());
@@ -123,7 +123,7 @@ public void getS2AAddress_queryEndpointResponseInvalidPlaintextJsonKey_plaintext
123123

124124
SecureSessionAgent s2aUtils =
125125
SecureSessionAgent.newBuilder().setHttpTransportFactory(transportFactory).build();
126-
SecureSessionAgentConfig config = s2aUtils.getConfigFromMDS();
126+
SecureSessionAgentConfig config = s2aUtils.getConfig();
127127
String plaintextS2AAddress = config.getPlaintextAddress();
128128
String mtlsS2AAddress = config.getMtlsAddress();
129129
assertTrue(plaintextS2AAddress.isEmpty());
@@ -143,7 +143,7 @@ public void getS2AAddress_queryEndpointResponseInvalidMtlsJsonKey_mtlsEmptyAddre
143143

144144
SecureSessionAgent s2aUtils =
145145
SecureSessionAgent.newBuilder().setHttpTransportFactory(transportFactory).build();
146-
SecureSessionAgentConfig config = s2aUtils.getConfigFromMDS();
146+
SecureSessionAgentConfig config = s2aUtils.getConfig();
147147
String plaintextS2AAddress = config.getPlaintextAddress();
148148
String mtlsS2AAddress = config.getMtlsAddress();
149149
assertEquals(S2A_PLAINTEXT_ADDRESS, plaintextS2AAddress);

0 commit comments

Comments
 (0)