@@ -126,16 +126,35 @@ public final class InstantiatingGrpcChannelProvider implements TransportChannelP
126
126
@ Nullable private final Boolean allowNonDefaultServiceAccount ;
127
127
@ VisibleForTesting final ImmutableMap <String , ?> directPathServiceConfig ;
128
128
@ Nullable private final MtlsProvider mtlsProvider ;
129
+ @ Nullable private final List <HardBoundTokenTypes > allowedHardBoundTokenTypes ;
129
130
@ VisibleForTesting final Map <String , String > headersWithDuplicatesRemoved = new HashMap <>();
130
131
131
132
@ Nullable
132
133
private final ApiFunction <ManagedChannelBuilder , ManagedChannelBuilder > channelConfigurator ;
133
134
135
+ /*
136
+ * Experimental feature
137
+ *
138
+ * <p>{@link HardBoundTokenTypes} specifies if hard bound tokens should be used if DirectPath
139
+ * or S2A is used to estabilsh a connection to Google APIs.
140
+ *
141
+ */
142
+ @ InternalApi
143
+ public enum HardBoundTokenTypes {
144
+ // If DirectPath is used to create the channel, use hard ALTS-bound tokens for requests sent on
145
+ // that channel.
146
+ ALTS ,
147
+ // If MTLS via S2A is used to create the channel, use hard MTLS-bound tokens for requests sent
148
+ // on that channel.
149
+ MTLS_S2A
150
+ }
151
+
134
152
private InstantiatingGrpcChannelProvider (Builder builder ) {
135
153
this .processorCount = builder .processorCount ;
136
154
this .executor = builder .executor ;
137
155
this .headerProvider = builder .headerProvider ;
138
156
this .endpoint = builder .endpoint ;
157
+ this .allowedHardBoundTokenTypes = builder .allowedHardBoundTokenTypes ;
139
158
this .mtlsProvider = builder .mtlsProvider ;
140
159
this .envProvider = builder .envProvider ;
141
160
this .interceptorProvider = builder .interceptorProvider ;
@@ -620,6 +639,7 @@ public static final class Builder {
620
639
@ Nullable private Boolean attemptDirectPathXds ;
621
640
@ Nullable private Boolean allowNonDefaultServiceAccount ;
622
641
@ Nullable private ImmutableMap <String , ?> directPathServiceConfig ;
642
+ @ Nullable private List <HardBoundTokenTypes > allowedHardBoundTokenTypes ;
623
643
624
644
private Builder () {
625
645
processorCount = Runtime .getRuntime ().availableProcessors ();
@@ -700,6 +720,19 @@ public Builder setEndpoint(String endpoint) {
700
720
return this ;
701
721
}
702
722
723
+ /*
724
+ * Sets the allowed hard bound token types for this TransportChannelProvider.
725
+ *
726
+ * <p>The list of
727
+ * {@link HardBoundTokenTypes} indicates for which methods of connecting to Google APIs hard bound tokens should
728
+ * be used. This is optional; if it is not provided, bearer tokens will be used.
729
+ */
730
+ @ InternalApi
731
+ public Builder setAllowHardBoundTokenTypes (List <HardBoundTokenTypes > allowedValues ) {
732
+ this .allowedHardBoundTokenTypes = allowedValues ;
733
+ return this ;
734
+ }
735
+
703
736
@ VisibleForTesting
704
737
Builder setMtlsProvider (MtlsProvider mtlsProvider ) {
705
738
this .mtlsProvider = mtlsProvider ;
0 commit comments