Skip to content

Commit b046dc9

Browse files
committed
resolve merge conflict.
2 parents 22562d6 + 38431a2 commit b046dc9

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProvider.java

+32
Original file line numberDiff line numberDiff line change
@@ -146,17 +146,36 @@ public final class InstantiatingGrpcChannelProvider implements TransportChannelP
146146
@VisibleForTesting final ImmutableMap<String, ?> directPathServiceConfig;
147147
@Nullable private final MtlsProvider mtlsProvider;
148148
@Nullable private final SecureSessionAgent s2aConfigProvider;
149+
@Nullable private final List<HardBoundTokenTypes> allowedHardBoundTokenTypes;
149150
@VisibleForTesting final Map<String, String> headersWithDuplicatesRemoved = new HashMap<>();
150151

151152
@Nullable
152153
private final ApiFunction<ManagedChannelBuilder, ManagedChannelBuilder> channelConfigurator;
153154

155+
/*
156+
* Experimental feature
157+
*
158+
* <p>{@link HardBoundTokenTypes} specifies if hard bound tokens should be used if DirectPath
159+
* or S2A is used to estabilsh a connection to Google APIs.
160+
*
161+
*/
162+
@InternalApi
163+
public enum HardBoundTokenTypes {
164+
// If DirectPath is used to create the channel, use hard ALTS-bound tokens for requests sent on
165+
// that channel.
166+
ALTS,
167+
// If MTLS via S2A is used to create the channel, use hard MTLS-bound tokens for requests sent
168+
// on that channel.
169+
MTLS_S2A
170+
}
171+
154172
private InstantiatingGrpcChannelProvider(Builder builder) {
155173
this.processorCount = builder.processorCount;
156174
this.executor = builder.executor;
157175
this.headerProvider = builder.headerProvider;
158176
this.useS2A = builder.useS2A;
159177
this.endpoint = builder.endpoint;
178+
this.allowedHardBoundTokenTypes = builder.allowedHardBoundTokenTypes;
160179
this.mtlsProvider = builder.mtlsProvider;
161180
this.s2aConfigProvider = builder.s2aConfigProvider;
162181
this.envProvider = builder.envProvider;
@@ -799,6 +818,7 @@ public static final class Builder {
799818
@Nullable private Boolean attemptDirectPathXds;
800819
@Nullable private Boolean allowNonDefaultServiceAccount;
801820
@Nullable private ImmutableMap<String, ?> directPathServiceConfig;
821+
@Nullable private List<HardBoundTokenTypes> allowedHardBoundTokenTypes;
802822

803823
private Builder() {
804824
processorCount = Runtime.getRuntime().availableProcessors();
@@ -885,6 +905,18 @@ Builder setUseS2A(boolean useS2A) {
885905
this.useS2A = useS2A;
886906
return this;
887907
}
908+
/*
909+
* Sets the allowed hard bound token types for this TransportChannelProvider.
910+
*
911+
* <p>The list of
912+
* {@link HardBoundTokenTypes} indicates for which methods of connecting to Google APIs hard bound tokens should
913+
* be used. This is optional; if it is not provided, bearer tokens will be used.
914+
*/
915+
@InternalApi
916+
public Builder setAllowHardBoundTokenTypes(List<HardBoundTokenTypes> allowedValues) {
917+
this.allowedHardBoundTokenTypes = allowedValues;
918+
return this;
919+
}
888920

889921
@VisibleForTesting
890922
Builder setMtlsProvider(MtlsProvider mtlsProvider) {

gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProviderTest.java

+5
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,10 @@ void testToBuilder() {
229229
throw new UnsupportedOperationException();
230230
};
231231
Map<String, ?> directPathServiceConfig = ImmutableMap.of("loadbalancingConfig", "grpclb");
232+
List<InstantiatingGrpcChannelProvider.HardBoundTokenTypes> hardBoundTokenTypes =
233+
new ArrayList<>();
234+
hardBoundTokenTypes.add(InstantiatingGrpcChannelProvider.HardBoundTokenTypes.ALTS);
235+
hardBoundTokenTypes.add(InstantiatingGrpcChannelProvider.HardBoundTokenTypes.MTLS_S2A);
232236

233237
InstantiatingGrpcChannelProvider provider =
234238
InstantiatingGrpcChannelProvider.newBuilder()
@@ -242,6 +246,7 @@ void testToBuilder() {
242246
.setChannelConfigurator(channelConfigurator)
243247
.setChannelsPerCpu(2.5)
244248
.setDirectPathServiceConfig(directPathServiceConfig)
249+
.setAllowHardBoundTokenTypes(hardBoundTokenTypes)
245250
.build();
246251

247252
InstantiatingGrpcChannelProvider.Builder builder = provider.toBuilder();

0 commit comments

Comments
 (0)