@@ -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 ) {
0 commit comments