Skip to content

Commit 45f7a09

Browse files
committed
keep default settings
1 parent 07a1912 commit 45f7a09

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ private ServiceAccountJwtAccessCredentials(
112112
privateKeyId,
113113
null,
114114
null,
115-
null);
115+
Credentials.GOOGLE_DEFAULT_UNIVERSE);
116116
}
117117

118118
/**
@@ -123,7 +123,8 @@ private ServiceAccountJwtAccessCredentials(
123123
* @param privateKey RSA private key object for the service account.
124124
* @param privateKeyId Private key identifier for the service account. May be null.
125125
* @param defaultAudience Audience to use if not provided by transport. May be null.
126-
* @param universeDomain universe domain in the format some-domain.xyz.
126+
* @param universeDomain universe domain in the format some-domain.xyz. By default, sets it to
127+
* googleapis.com
127128
*/
128129
private ServiceAccountJwtAccessCredentials(
129130
String clientId,
@@ -140,7 +141,11 @@ private ServiceAccountJwtAccessCredentials(
140141
this.defaultAudience = defaultAudience;
141142
this.credentialsCache = createCache();
142143
this.quotaProjectId = quotaProjectId;
143-
this.universeDomain = universeDomain;
144+
if (universeDomain == null || universeDomain.trim().isEmpty()) {
145+
this.universeDomain = Credentials.GOOGLE_DEFAULT_UNIVERSE;
146+
} else {
147+
this.universeDomain = universeDomain;
148+
}
144149
}
145150

146151
/**
@@ -234,7 +239,7 @@ public static ServiceAccountJwtAccessCredentials fromPkcs8(
234239
privateKeyId,
235240
defaultAudience,
236241
null,
237-
Credentials.GOOGLE_DEFAULT_UNIVERSE);
242+
Credentials.GOOGLE_DEFAULT_UNIVERSE);
238243
}
239244

240245
static ServiceAccountJwtAccessCredentials fromPkcs8(

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public void constructor_allParameters_constructs() throws IOException {
113113
assertEquals(privateKey, credentials.getPrivateKey());
114114
assertEquals(SA_PRIVATE_KEY_ID, credentials.getPrivateKeyId());
115115
assertEquals(QUOTA_PROJECT, credentials.getQuotaProjectId());
116-
assertNull(credentials.getUniverseDomain());
116+
assertEquals(Credentials.GOOGLE_DEFAULT_UNIVERSE, credentials.getUniverseDomain());
117117
}
118118

119119
@Test
@@ -917,7 +917,7 @@ public void builder_defaultUniverseDomain() throws IOException {
917917
.setPrivateKeyId(SA_PRIVATE_KEY_ID)
918918
.setDefaultAudience(URI.create("default-audience"))
919919
.build();
920-
assertNull(credentials.getUniverseDomain());
920+
assertEquals(Credentials.GOOGLE_DEFAULT_UNIVERSE, credentials.getUniverseDomain());
921921
}
922922

923923
@Test

0 commit comments

Comments
 (0)