@@ -126,16 +126,35 @@ public final class InstantiatingGrpcChannelProvider implements TransportChannelP
126126 @ Nullable private final Boolean allowNonDefaultServiceAccount ;
127127 @ VisibleForTesting final ImmutableMap <String , ?> directPathServiceConfig ;
128128 @ Nullable private final MtlsProvider mtlsProvider ;
129+ @ Nullable private final List <HardBoundTokenTypes > allowedHardBoundTokenTypes ;
129130 @ VisibleForTesting final Map <String , String > headersWithDuplicatesRemoved = new HashMap <>();
130131
131132 @ Nullable
132133 private final ApiFunction <ManagedChannelBuilder , ManagedChannelBuilder > channelConfigurator ;
133134
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+
134152 private InstantiatingGrpcChannelProvider (Builder builder ) {
135153 this .processorCount = builder .processorCount ;
136154 this .executor = builder .executor ;
137155 this .headerProvider = builder .headerProvider ;
138156 this .endpoint = builder .endpoint ;
157+ this .allowedHardBoundTokenTypes = builder .allowedHardBoundTokenTypes ;
139158 this .mtlsProvider = builder .mtlsProvider ;
140159 this .envProvider = builder .envProvider ;
141160 this .interceptorProvider = builder .interceptorProvider ;
@@ -620,6 +639,7 @@ public static final class Builder {
620639 @ Nullable private Boolean attemptDirectPathXds ;
621640 @ Nullable private Boolean allowNonDefaultServiceAccount ;
622641 @ Nullable private ImmutableMap <String , ?> directPathServiceConfig ;
642+ @ Nullable private List <HardBoundTokenTypes > allowedHardBoundTokenTypes ;
623643
624644 private Builder () {
625645 processorCount = Runtime .getRuntime ().availableProcessors ();
@@ -700,6 +720,19 @@ public Builder setEndpoint(String endpoint) {
700720 return this ;
701721 }
702722
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+
703736 @ VisibleForTesting
704737 Builder setMtlsProvider (MtlsProvider mtlsProvider ) {
705738 this .mtlsProvider = mtlsProvider ;
0 commit comments