1414 * limitations under the License.
1515 */
1616
17- package io .grpc .xds . internal . grpcservice ;
17+ package io .grpc .xds ;
1818
1919import com .google .auth .oauth2 .AccessToken ;
2020import com .google .auth .oauth2 .OAuth2Credentials ;
3333import io .grpc .SecurityLevel ;
3434import io .grpc .alts .GoogleDefaultChannelCredentials ;
3535import io .grpc .auth .MoreCallCredentials ;
36- import io .grpc .xds .XdsChannelCredentials ;
36+ import io .grpc .xds .client .AllowedGrpcServices ;
37+ import io .grpc .xds .client .AllowedGrpcServices .AllowedGrpcService ;
3738import io .grpc .xds .client .Bootstrapper ;
39+ import io .grpc .xds .client .ConfiguredChannelCredentials ;
40+ import io .grpc .xds .internal .grpcservice .GrpcServiceConfig ;
41+ import io .grpc .xds .internal .grpcservice .GrpcServiceParseException ;
42+ import io .grpc .xds .internal .grpcservice .HeaderValue ;
43+ import io .grpc .xds .internal .grpcservice .HeaderValueValidationUtils ;
3844import java .net .URI ;
3945import java .net .URISyntaxException ;
4046import java .time .Duration ;
@@ -65,7 +71,7 @@ public final class GrpcServiceConfigParser {
6571 "type.googleapis.com/envoy.extensions.grpc_service.channel_credentials."
6672 + "google_default.v3.GoogleDefaultCredentials" ;
6773
68- private GrpcServiceConfigParser () {}
74+
6975
7076 /**
7177 * Parses the {@link io.envoyproxy.envoy.config.core.v3.GrpcService} proto to create a
@@ -75,9 +81,8 @@ private GrpcServiceConfigParser() {}
7581 * @return A {@link GrpcServiceConfig} instance.
7682 * @throws GrpcServiceParseException if the proto is invalid or uses unsupported features.
7783 */
78- public static GrpcServiceConfig parse (
79- GrpcService grpcServiceProto , Bootstrapper .BootstrapInfo bootstrapInfo ,
80- Bootstrapper .ServerInfo serverInfo )
84+ public static GrpcServiceConfig parse (GrpcService grpcServiceProto ,
85+ Bootstrapper .BootstrapInfo bootstrapInfo , Bootstrapper .ServerInfo serverInfo )
8186 throws GrpcServiceParseException {
8287 if (!grpcServiceProto .hasGoogleGrpc ()) {
8388 throw new GrpcServiceParseException (
@@ -125,15 +130,16 @@ public static GrpcServiceConfig parse(
125130 */
126131 public static GrpcServiceConfig .GoogleGrpcConfig parseGoogleGrpcConfig (
127132 GrpcService .GoogleGrpc googleGrpcProto , Bootstrapper .BootstrapInfo bootstrapInfo ,
128- Bootstrapper .ServerInfo serverInfo )
129- throws GrpcServiceParseException {
133+ Bootstrapper .ServerInfo serverInfo ) throws GrpcServiceParseException {
130134
131135 String targetUri = googleGrpcProto .getTargetUri ();
132136
133- AllowedGrpcServices allowedGrpcServices = bootstrapInfo .allowedGrpcServices ()
134- .filter (AllowedGrpcServices .class ::isInstance )
135- .map (AllowedGrpcServices .class ::cast )
136- .orElse (AllowedGrpcServices .empty ());
137+ AllowedGrpcServices allowedGrpcServices =
138+ bootstrapInfo .implSpecificObject ()
139+ .filter (GrpcBootstrapImplConfig .class ::isInstance )
140+ .map (GrpcBootstrapImplConfig .class ::cast )
141+ .map (GrpcBootstrapImplConfig ::allowedGrpcServices )
142+ .orElse (AllowedGrpcServices .empty ());
137143
138144 boolean isTrustedControlPlane = serverInfo .isTrustedXdsServer ();
139145 Optional <AllowedGrpcService > override =
@@ -165,8 +171,7 @@ public static GrpcServiceConfig.GoogleGrpcConfig parseGoogleGrpcConfig(
165171 }
166172
167173 GrpcServiceConfig .GoogleGrpcConfig .Builder builder =
168- GrpcServiceConfig .GoogleGrpcConfig .builder ()
169- .target (targetUri )
174+ GrpcServiceConfig .GoogleGrpcConfig .builder ().target (targetUri )
170175 .configuredChannelCredentials (override .get ().configuredChannelCredentials ());
171176 if (override .get ().callCredentials ().isPresent ()) {
172177 builder .callCredentials (override .get ().callCredentials ().get ());
@@ -189,19 +194,18 @@ public static GrpcServiceConfig.GoogleGrpcConfig parseGoogleGrpcConfig(
189194 return builder .build ();
190195 }
191196
192- private static Optional <ConfiguredChannelCredentials > channelCredsFromProto (
193- Any cred ) throws GrpcServiceParseException {
197+ private static Optional <ConfiguredChannelCredentials > channelCredsFromProto (Any cred )
198+ throws GrpcServiceParseException {
194199 String typeUrl = cred .getTypeUrl ();
195200 try {
196201 switch (typeUrl ) {
197202 case GOOGLE_DEFAULT_CREDENTIALS_TYPE_URL :
198- return Optional . of ( ConfiguredChannelCredentials . create (
199- GoogleDefaultChannelCredentials .create (),
200- new ProtoChannelCredsConfig (typeUrl , cred )));
203+ return Optional
204+ . of ( ConfiguredChannelCredentials . create ( GoogleDefaultChannelCredentials .create (),
205+ new ProtoChannelCredsConfig (typeUrl , cred )));
201206 case INSECURE_CREDENTIALS_TYPE_URL :
202207 return Optional .of (ConfiguredChannelCredentials .create (
203- InsecureChannelCredentials .create (),
204- new ProtoChannelCredsConfig (typeUrl , cred )));
208+ InsecureChannelCredentials .create (), new ProtoChannelCredsConfig (typeUrl , cred )));
205209 case XDS_CREDENTIALS_TYPE_URL :
206210 XdsCredentials xdsConfig = cred .unpack (XdsCredentials .class );
207211 Optional <ConfiguredChannelCredentials > fallbackCreds =
@@ -292,7 +296,8 @@ public void applyRequestMetadata(RequestInfo requestInfo, Executor appExecutor,
292296 }
293297 }
294298
295- static final class ProtoChannelCredsConfig implements ChannelCredsConfig {
299+ static final class ProtoChannelCredsConfig
300+ implements ConfiguredChannelCredentials .ChannelCredsConfig {
296301 private final String type ;
297302 private final Any configProto ;
298303
0 commit comments