@@ -146,17 +146,36 @@ public final class InstantiatingGrpcChannelProvider implements TransportChannelP
146
146
@ VisibleForTesting final ImmutableMap <String , ?> directPathServiceConfig ;
147
147
@ Nullable private final MtlsProvider mtlsProvider ;
148
148
@ Nullable private final SecureSessionAgent s2aConfigProvider ;
149
+ @ Nullable private final List <HardBoundTokenTypes > allowedHardBoundTokenTypes ;
149
150
@ VisibleForTesting final Map <String , String > headersWithDuplicatesRemoved = new HashMap <>();
150
151
151
152
@ Nullable
152
153
private final ApiFunction <ManagedChannelBuilder , ManagedChannelBuilder > channelConfigurator ;
153
154
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
+
154
172
private InstantiatingGrpcChannelProvider (Builder builder ) {
155
173
this .processorCount = builder .processorCount ;
156
174
this .executor = builder .executor ;
157
175
this .headerProvider = builder .headerProvider ;
158
176
this .useS2A = builder .useS2A ;
159
177
this .endpoint = builder .endpoint ;
178
+ this .allowedHardBoundTokenTypes = builder .allowedHardBoundTokenTypes ;
160
179
this .mtlsProvider = builder .mtlsProvider ;
161
180
this .s2aConfigProvider = builder .s2aConfigProvider ;
162
181
this .envProvider = builder .envProvider ;
@@ -799,6 +818,7 @@ public static final class Builder {
799
818
@ Nullable private Boolean attemptDirectPathXds ;
800
819
@ Nullable private Boolean allowNonDefaultServiceAccount ;
801
820
@ Nullable private ImmutableMap <String , ?> directPathServiceConfig ;
821
+ @ Nullable private List <HardBoundTokenTypes > allowedHardBoundTokenTypes ;
802
822
803
823
private Builder () {
804
824
processorCount = Runtime .getRuntime ().availableProcessors ();
@@ -885,6 +905,18 @@ Builder setUseS2A(boolean useS2A) {
885
905
this .useS2A = useS2A ;
886
906
return this ;
887
907
}
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
+ }
888
920
889
921
@ VisibleForTesting
890
922
Builder setMtlsProvider (MtlsProvider mtlsProvider ) {
0 commit comments