Java Code Examples for io.grpc.stub.MetadataUtils

The following examples show how to use io.grpc.stub.MetadataUtils. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: grpc-nebula-java   Source File: AbstractInteropTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void exchangeMetadataUnaryCall() throws Exception {
  TestServiceGrpc.TestServiceBlockingStub stub = blockingStub;

  // Capture the metadata exchange
  Metadata fixedHeaders = new Metadata();
  // Send a context proto (as it's in the default extension registry)
  Messages.SimpleContext contextValue =
      Messages.SimpleContext.newBuilder().setValue("dog").build();
  fixedHeaders.put(Util.METADATA_KEY, contextValue);
  stub = MetadataUtils.attachHeaders(stub, fixedHeaders);
  // .. and expect it to be echoed back in trailers
  AtomicReference<Metadata> trailersCapture = new AtomicReference<>();
  AtomicReference<Metadata> headersCapture = new AtomicReference<>();
  stub = MetadataUtils.captureMetadata(stub, headersCapture, trailersCapture);

  assertNotNull(stub.emptyCall(EMPTY));

  // Assert that our side channel object is echoed back in both headers and trailers
  Assert.assertEquals(contextValue, headersCapture.get().get(Util.METADATA_KEY));
  Assert.assertEquals(contextValue, trailersCapture.get().get(Util.METADATA_KEY));
}
 
Example 2
Source Project: opentelemetry-java   Source File: OtlpGrpcSpanExporter.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Constructs a new instance of the exporter based on the builder's values.
 *
 * @return a new exporter's instance
 */
public OtlpGrpcSpanExporter build() {
  if (endpoint != null) {
    final ManagedChannelBuilder<?> managedChannelBuilder =
        ManagedChannelBuilder.forTarget(endpoint);

    if (useTls) {
      managedChannelBuilder.useTransportSecurity();
    } else {
      managedChannelBuilder.usePlaintext();
    }

    if (metadata != null) {
      managedChannelBuilder.intercept(MetadataUtils.newAttachHeadersInterceptor(metadata));
    }

    channel = managedChannelBuilder.build();
  }
  return new OtlpGrpcSpanExporter(channel, deadlineMs);
}
 
Example 3
Source Project: gcp-token-broker   Source File: BrokerGateway.java    License: Apache License 2.0 6 votes vote down vote up
public void setSPNEGOToken() {
    String encodedToken;
    try {
        encodedToken = BaseEncoding.base64().encode(SpnegoUtils.newSPNEGOToken(serverInfo.getKerberosPrincipal()));
    } catch (GSSException e) {
        // Clean up the channel before re-throwing the exception
        managedChannel.shutdownNow();
        throw new RuntimeException(
            "Failed creating a SPNEGO token. Make sure that you have run kinit and that your Kerberos configuration is correct. See the full Kerberos error message: " + e.getMessage());
    }

    // Set the 'authorization' header with the SPNEGO token
    Metadata metadata = new Metadata();
    Metadata.Key<String> key = Metadata.Key.of("authorization", Metadata.ASCII_STRING_MARSHALLER);
    metadata.put(key, "Negotiate " + encodedToken);
    stub = MetadataUtils.attachHeaders(stub, metadata);
}
 
Example 4
Source Project: dgraph4j   Source File: DgraphAsyncClient.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * getStubWithJwt adds an AttachHeadersInterceptor to the stub, which will eventually attach a
 * header whose key is accessJwt and value is the access JWT stored in the current
 * DgraphAsyncClient object.
 *
 * @param stub the original stub that we should attach JWT to
 * @return the augmented stub with JWT
 */
protected DgraphGrpc.DgraphStub getStubWithJwt(DgraphGrpc.DgraphStub stub) {
  Lock readLock = jwtLock.readLock();
  readLock.lock();
  try {
    if (jwt != null && !jwt.getAccessJwt().isEmpty()) {
      Metadata metadata = new Metadata();
      metadata.put(
          Metadata.Key.of("accessJwt", Metadata.ASCII_STRING_MARSHALLER), jwt.getAccessJwt());
      return MetadataUtils.attachHeaders(stub, metadata);
    }

    return stub;
  } finally {
    readLock.unlock();
  }
}
 
Example 5
Source Project: grpc-java   Source File: AbstractInteropTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void exchangeMetadataUnaryCall() throws Exception {
  TestServiceGrpc.TestServiceBlockingStub stub = blockingStub;

  // Capture the metadata exchange
  Metadata fixedHeaders = new Metadata();
  // Send a context proto (as it's in the default extension registry)
  Messages.SimpleContext contextValue =
      Messages.SimpleContext.newBuilder().setValue("dog").build();
  fixedHeaders.put(Util.METADATA_KEY, contextValue);
  stub = MetadataUtils.attachHeaders(stub, fixedHeaders);
  // .. and expect it to be echoed back in trailers
  AtomicReference<Metadata> trailersCapture = new AtomicReference<>();
  AtomicReference<Metadata> headersCapture = new AtomicReference<>();
  stub = MetadataUtils.captureMetadata(stub, headersCapture, trailersCapture);

  assertNotNull(stub.emptyCall(EMPTY));

  // Assert that our side channel object is echoed back in both headers and trailers
  Assert.assertEquals(contextValue, headersCapture.get().get(Util.METADATA_KEY));
  Assert.assertEquals(contextValue, trailersCapture.get().get(Util.METADATA_KEY));
}
 
Example 6
Source Project: grpc-nebula-java   Source File: AbstractInteropTest.java    License: Apache License 2.0 5 votes vote down vote up
/** Sends a cacheable unary rpc using GET. Requires that the server is behind a caching proxy. */
public void cacheableUnary() {
  // Set safe to true.
  MethodDescriptor<SimpleRequest, SimpleResponse> safeCacheableUnaryCallMethod =
      TestServiceGrpc.getCacheableUnaryCallMethod().toBuilder().setSafe(true).build();
  // Set fake user IP since some proxies (GFE) won't cache requests from localhost.
  Metadata.Key<String> userIpKey = Metadata.Key.of("x-user-ip", Metadata.ASCII_STRING_MARSHALLER);
  Metadata metadata = new Metadata();
  metadata.put(userIpKey, "1.2.3.4");
  Channel channelWithUserIpKey =
      ClientInterceptors.intercept(channel, MetadataUtils.newAttachHeadersInterceptor(metadata));
  SimpleRequest requests1And2 =
      SimpleRequest.newBuilder()
          .setPayload(
              Payload.newBuilder()
                  .setBody(ByteString.copyFromUtf8(String.valueOf(System.nanoTime()))))
          .build();
  SimpleRequest request3 =
      SimpleRequest.newBuilder()
          .setPayload(
              Payload.newBuilder()
                  .setBody(ByteString.copyFromUtf8(String.valueOf(System.nanoTime()))))
          .build();

  SimpleResponse response1 =
      ClientCalls.blockingUnaryCall(
          channelWithUserIpKey, safeCacheableUnaryCallMethod, CallOptions.DEFAULT, requests1And2);
  SimpleResponse response2 =
      ClientCalls.blockingUnaryCall(
          channelWithUserIpKey, safeCacheableUnaryCallMethod, CallOptions.DEFAULT, requests1And2);
  SimpleResponse response3 =
      ClientCalls.blockingUnaryCall(
          channelWithUserIpKey, safeCacheableUnaryCallMethod, CallOptions.DEFAULT, request3);

  assertEquals(response1, response2);
  assertNotEquals(response1, response3);
}
 
Example 7
private ManagedChannel createManagedChannel(String apiKey) {
  Metadata metadata = new Metadata();
  metadata.put(Metadata.Key.of(HEADER_API_KEY, Metadata.ASCII_STRING_MARSHALLER), apiKey);
  return ManagedChannelBuilder.forTarget(SERVICE_URL)
      .intercept(MetadataUtils.newAttachHeadersInterceptor(metadata))
      .build();
}
 
Example 8
Source Project: gcp-token-broker   Source File: BrokerServerTest.java    License: Apache License 2.0 5 votes vote down vote up
public BrokerBlockingStub addSPNEGOTokenToMetadata(BrokerBlockingStub stub, String principal) {
    Metadata metadata = new Metadata();
    Metadata.Key<String> key = Metadata.Key.of("authorization", Metadata.ASCII_STRING_MARSHALLER);
    metadata.put(key, "Negotiate " + principal);
    stub = MetadataUtils.attachHeaders(stub, metadata);
    return stub;
}
 
Example 9
Source Project: gcp-token-broker   Source File: BrokerServerTest.java    License: Apache License 2.0 5 votes vote down vote up
public BrokerBlockingStub addSessionTokenToMetadata(BrokerBlockingStub stub, Session session) {
    Metadata metadata = new Metadata();
    Metadata.Key<String> key = Metadata.Key.of("authorization", Metadata.ASCII_STRING_MARSHALLER);
    metadata.put(key, "BrokerSession " + SessionTokenUtils.marshallSessionToken(session));
    stub = MetadataUtils.attachHeaders(stub, metadata);
    return stub;
}
 
Example 10
Source Project: gcp-token-broker   Source File: BrokerGateway.java    License: Apache License 2.0 5 votes vote down vote up
public void setSessionToken(String sessionToken) {
    // Set the session token in the 'authorization' header
    Metadata metadata = new Metadata();
    Metadata.Key<String> key = Metadata.Key.of("authorization", Metadata.ASCII_STRING_MARSHALLER);
    metadata.put(key, REQUEST_AUTH_HEADER + " " + sessionToken);
    stub = MetadataUtils.attachHeaders(stub, metadata);
}
 
Example 11
Source Project: firebase-android-sdk   Source File: GrpcClientModule.java    License: Apache License 2.0 5 votes vote down vote up
@Provides
@FirebaseAppScope
public InAppMessagingSdkServingBlockingStub providesInAppMessagingSdkServingStub(
    Channel channel, Metadata metadata) {
  return InAppMessagingSdkServingGrpc.newBlockingStub(
      ClientInterceptors.intercept(channel, MetadataUtils.newAttachHeadersInterceptor(metadata)));
}
 
Example 12
Source Project: firebase-android-sdk   Source File: GrpcClientTest.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
  MockitoAnnotations.initMocks(this);
  inAppMessagingSdkServingBlockingStub =
      InAppMessagingSdkServingGrpc.newBlockingStub(
          ClientInterceptors.intercept(
              grpcServerRule.getChannel(),
              MetadataUtils.newAttachHeadersInterceptor(testMetadata)));
  grpcClient = new GrpcClient(inAppMessagingSdkServingBlockingStub);
}
 
Example 13
public JwtAuthBlockingClient(Channel channel, String token) {
    JwtAuthTestServiceGrpc.JwtAuthTestServiceBlockingStub stub = JwtAuthTestServiceGrpc.newBlockingStub(channel);
    //add metadata
    Metadata metadata = new Metadata();
    metadata.put(Metadata.Key.of("Authorization", Metadata.ASCII_STRING_MARSHALLER), token);
    blockingStub = MetadataUtils.attachHeaders(stub,metadata);
}
 
Example 14
public ThrottlingBlockingClient(Channel channel, String token) {
    ThrottlingTestServiceGrpc.ThrottlingTestServiceBlockingStub stub =
            ThrottlingTestServiceGrpc.newBlockingStub(channel);
    //add metadata
    Metadata metadata = new Metadata();
    metadata.put(Metadata.Key.of("Authorization", Metadata.ASCII_STRING_MARSHALLER), token);
    blockingStub = MetadataUtils.attachHeaders(stub,metadata);
}
 
Example 15
Source Project: microbean-helm   Source File: Tiller.java    License: Apache License 2.0 5 votes vote down vote up
public HealthBlockingStub getHealthBlockingStub() {
  HealthBlockingStub returnValue = null;
  if (this.channel != null) {
    returnValue = MetadataUtils.attachHeaders(HealthGrpc.newBlockingStub(this.channel), metadata);
  }
  return returnValue;
}
 
Example 16
Source Project: microbean-helm   Source File: Tiller.java    License: Apache License 2.0 5 votes vote down vote up
public HealthFutureStub getHealthFutureStub() {
  HealthFutureStub returnValue = null;
  if (this.channel != null) {
    returnValue = MetadataUtils.attachHeaders(HealthGrpc.newFutureStub(this.channel), metadata);
  }
  return returnValue;
}
 
Example 17
Source Project: microbean-helm   Source File: Tiller.java    License: Apache License 2.0 5 votes vote down vote up
public HealthStub getHealthStub() {
  HealthStub returnValue = null;
  if (this.channel != null) {
    returnValue = MetadataUtils.attachHeaders(HealthGrpc.newStub(this.channel), metadata);
  }
  return returnValue;
}
 
Example 18
Source Project: concurrency-limits   Source File: Driver.java    License: Apache License 2.0 5 votes vote down vote up
public Driver(Builder builder) {
    this.segments = builder.segments;
    this.runtime = builder.runtimeSeconds;
    this.latencyAccumulator = builder.latencyAccumulator;

    Metadata metadata = new Metadata();
    metadata.put(ID_HEADER, builder.id);

    this.channel = ClientInterceptors.intercept(NettyChannelBuilder.forTarget("localhost:" + builder.port)
            .usePlaintext(true)
            .build(),
                MetadataUtils.newAttachHeadersInterceptor(metadata));
}
 
Example 19
Source Project: africastalking-android   Source File: Service.java    License: MIT License 5 votes vote down vote up
static SdkServerServiceBlockingStub addClientIdentification(SdkServerServiceBlockingStub stub) {
    // Optional client id header
    String clientId = AfricasTalking.getClientId();
    if (clientId != null) {
        Metadata headers = new Metadata();
        headers.put(CLIENT_ID_HEADER_KEY, clientId);
        stub = MetadataUtils.attachHeaders(stub, headers);
    }
    return stub;
}
 
Example 20
@Test
public void debugClientInterceptTest() {
    LinkedList<String> logs = new LinkedList<String>();
    Metadata requestHeaders = new Metadata();
    requestHeaders.put(Metadata.Key.of("request_header", Metadata.ASCII_STRING_MARSHALLER), "request_header_value");
    // Setup
    serverRule.getServiceRegistry().addService(ServerInterceptors.intercept(svc, new ServerInterceptor() {
        @Override
        public <ReqT, RespT> Listener<ReqT> interceptCall(ServerCall<ReqT, RespT> call, Metadata headers,
                ServerCallHandler<ReqT, RespT> next) {
            return next.startCall(new SimpleForwardingServerCall<ReqT, RespT>(call) {
                @Override
                public void sendHeaders(Metadata responseHeaders) {
                    responseHeaders.put(Metadata.Key.of("response_header", Metadata.ASCII_STRING_MARSHALLER),
                            "response_header_value");
                    super.sendHeaders(responseHeaders);
                }
            }, headers);
        }
    }));
    GreeterGrpc.GreeterBlockingStub stub = GreeterGrpc.newBlockingStub(serverRule.getChannel())
            .withInterceptors(new DebugClientInterceptor(Level.STATUS, Level.HEADERS, Level.MESSAGE) {
                @Override
                protected void log(String message) {
                    logs.add(message);
                }

            }, MetadataUtils.newAttachHeadersInterceptor(requestHeaders));

    stub.sayHello(HelloRequest.newBuilder().setName("World").build());
    assertThat(logs.poll()).contains("SayHello"); // request method name
    assertThat(logs.poll()).contains(requestHeaders.toString()); // request header value
    assertThat(logs.poll()).contains("World"); // request message
    assertThat(logs.poll()).contains("response_header_value"); // response header
    assertThat(logs.poll()).contains("Hello World"); // response message
    assertThat(logs.poll()).contains("0 OK"); // response status
}
 
Example 21
@Test
public void debugServerInterceptTest() {
    LinkedList<String> logs = new LinkedList<String>();
    Metadata requestHeaders = new Metadata();
    requestHeaders.put(Metadata.Key.of("request_header", Metadata.ASCII_STRING_MARSHALLER), "request_header_value");
    // Setup
    serverRule.getServiceRegistry().addService(ServerInterceptors.intercept(svc, new ServerInterceptor() {
        @Override
        public <ReqT, RespT> Listener<ReqT> interceptCall(ServerCall<ReqT, RespT> call, Metadata headers,
                ServerCallHandler<ReqT, RespT> next) {
            return next.startCall(new SimpleForwardingServerCall<ReqT, RespT>(call) {
                @Override
                public void sendHeaders(Metadata responseHeaders) {
                    responseHeaders.put(Metadata.Key.of("response_header", Metadata.ASCII_STRING_MARSHALLER),
                            "response_header_value");
                    super.sendHeaders(responseHeaders);
                }
            }, headers);
        }
    }, new DebugServerInterceptor(DebugServerInterceptor.Level.METHOD, DebugServerInterceptor.Level.MESSAGE,
            DebugServerInterceptor.Level.HEADERS) {
        @Override
        protected void log(String logmessage) {
            logs.add(logmessage);
        }
    }));
    GreeterGrpc.GreeterBlockingStub stub = GreeterGrpc.newBlockingStub(serverRule.getChannel())
            .withInterceptors(MetadataUtils.newAttachHeadersInterceptor(requestHeaders));
    stub.sayHello(HelloRequest.newBuilder().setName("World").build());
    assertThat(logs.poll()).contains("SayHello"); // request method name
    assertThat(logs.poll()).contains("request_header_value"); // request header value
    assertThat(logs.poll()).contains("World"); // request message
    assertThat(logs.poll()).contains("SayHello"); // response method name
    assertThat(logs.poll()).contains("response_header_value"); // response header
    assertThat(logs.poll()).contains("Hello World"); // response message

}
 
Example 22
@Test
public void endToEndTest() {
    AtomicReference<List<XForwardedClientCert>> certs = new AtomicReference<>();

    GreeterGrpc.GreeterImplBase svc = new GreeterGrpc.GreeterImplBase() {
        @Override
        public void sayHello(HelloRequest request, StreamObserver<HelloResponse> responseObserver) {
            certs.set(XForwardedClientCert.XFCC_CONTEXT_KEY.get());

            responseObserver.onNext(HelloResponse.newBuilder().setMessage("Hello " + request.getName()).build());
            responseObserver.onCompleted();
        }
    };

    serverRule.getServiceRegistry().addService(ServerInterceptors.intercept(svc, new XfccServerInterceptor()));

    String xfcc = "By=http://frontend.lyft.com;Hash=468ed33be74eee6556d90c0149c1309e9ba61d6425303443c0748a02dd8de688;SAN=http://testclient.lyft.com," +
            "By=http://backend.lyft.com;Hash=9ba61d6425303443c0748a02dd8de688468ed33be74eee6556d90c0149c1309e;SAN=http://frontend.lyft.com";

    Metadata xfccHeader = new Metadata();
    xfccHeader.put(Metadata.Key.of("x-forwarded-client-cert", Metadata.ASCII_STRING_MARSHALLER), xfcc);

    GreeterGrpc.GreeterBlockingStub stub = GreeterGrpc.newBlockingStub(serverRule.getChannel())
            .withInterceptors(MetadataUtils.newAttachHeadersInterceptor(xfccHeader));

    stub.sayHello(HelloRequest.newBuilder().setName("World").build());

    assertThat(certs.get().size()).isEqualTo(2);
    assertThat(certs.get().get(0).getBy()).isEqualTo("http://frontend.lyft.com");
    assertThat(certs.get().get(1).getBy()).isEqualTo("http://backend.lyft.com");
}
 
Example 23
@Test
public void endToEndTestMultiple() {
    AtomicReference<List<XForwardedClientCert>> certs = new AtomicReference<>();

    GreeterGrpc.GreeterImplBase svc = new GreeterGrpc.GreeterImplBase() {
        @Override
        public void sayHello(HelloRequest request, StreamObserver<HelloResponse> responseObserver) {
            certs.set(XForwardedClientCert.XFCC_CONTEXT_KEY.get());

            responseObserver.onNext(HelloResponse.newBuilder().setMessage("Hello " + request.getName()).build());
            responseObserver.onCompleted();
        }
    };

    serverRule.getServiceRegistry().addService(ServerInterceptors.intercept(svc, new XfccServerInterceptor()));

    String xfcc = "By=http://frontend.lyft.com;Hash=468ed33be74eee6556d90c0149c1309e9ba61d6425303443c0748a02dd8de688;SAN=http://testclient.lyft.com," +
            "By=http://backend.lyft.com;Hash=9ba61d6425303443c0748a02dd8de688468ed33be74eee6556d90c0149c1309e;SAN=http://frontend.lyft.com";
    String xfcc2 = "By=http://middle.lyft.com;Hash=468ed33be74eee6556d90c0149c1309e9ba61d6425303443c0748a02dd8de688;" +
            "SAN=http://testclient.lyft.com";

    Metadata xfccHeader = new Metadata();
    Metadata.Key<String> key = Metadata.Key.of("x-forwarded-client-cert", Metadata.ASCII_STRING_MARSHALLER);
    xfccHeader.put(key, xfcc);
    xfccHeader.put(key, xfcc2);

    GreeterGrpc.GreeterBlockingStub stub = GreeterGrpc.newBlockingStub(serverRule.getChannel())
            .withInterceptors(MetadataUtils.newAttachHeadersInterceptor(xfccHeader));

    stub.sayHello(HelloRequest.newBuilder().setName("World").build());

    assertThat(certs.get().size()).isEqualTo(3);
    assertThat(certs.get().get(0).getBy()).isEqualTo("http://frontend.lyft.com");
    assertThat(certs.get().get(1).getBy()).isEqualTo("http://backend.lyft.com");
    assertThat(certs.get().get(2).getBy()).isEqualTo("http://middle.lyft.com");
}
 
Example 24
Source Project: titus-control-plane   Source File: EmbeddedTitusGateway.java    License: Apache License 2.0 5 votes vote down vote up
private <STUB extends AbstractStub<STUB>> STUB attachCallHeaders(STUB client) {
    Metadata metadata = new Metadata();
    metadata.put(V3HeaderInterceptor.CALLER_ID_KEY, "embeddedGatewayClient");
    metadata.put(V3HeaderInterceptor.CALL_REASON_KEY, "test call");
    metadata.put(V3HeaderInterceptor.DEBUG_KEY, "true");
    return client.withInterceptors(MetadataUtils.newAttachHeadersInterceptor(metadata));
}
 
Example 25
private <STUB extends AbstractStub<STUB>> STUB attachCallHeaders(STUB client) {
    Metadata metadata = new Metadata();
    metadata.put(V3HeaderInterceptor.CALLER_ID_KEY, "embeddedFederationClient");
    metadata.put(V3HeaderInterceptor.CALL_REASON_KEY, "test call");
    metadata.put(V3HeaderInterceptor.DEBUG_KEY, "true");
    return client.withInterceptors(MetadataUtils.newAttachHeadersInterceptor(metadata));
}
 
Example 26
public static <STUB extends AbstractStub<STUB>> STUB attachCallHeaders(STUB client) {
    Metadata metadata = new Metadata();
    metadata.put(V3HeaderInterceptor.CALLER_ID_KEY, "testkitClient");
    metadata.put(V3HeaderInterceptor.CALL_REASON_KEY, "test call");
    metadata.put(V3HeaderInterceptor.DEBUG_KEY, "true");
    return client.withInterceptors(MetadataUtils.newAttachHeadersInterceptor(metadata));
}
 
Example 27
Source Project: dgraph4j   Source File: App.java    License: Apache License 2.0 5 votes vote down vote up
private static DgraphClient createDgraphClient(boolean withAuthHeader) {
  ManagedChannel channel =
      ManagedChannelBuilder.forAddress(TEST_HOSTNAME, TEST_PORT).usePlaintext().build();
  DgraphStub stub = DgraphGrpc.newStub(channel);

  if (withAuthHeader) {
    Metadata metadata = new Metadata();
    metadata.put(
        Metadata.Key.of("auth-token", Metadata.ASCII_STRING_MARSHALLER), "the-auth-token-value");
    stub = MetadataUtils.attachHeaders(stub, metadata);
  }

  return new DgraphClient(stub);
}
 
Example 28
Source Project: modeldb   Source File: AuthServiceChannel.java    License: Apache License 2.0 5 votes vote down vote up
private void initUACServiceStubChannel() {
  Metadata requestHeaders = getMetadataHeaders();
  LOGGER.trace("Header attaching with stub : {}", requestHeaders);
  ClientInterceptor clientInterceptor = MetadataUtils.newAttachHeadersInterceptor(requestHeaders);
  uacServiceBlockingStub =
      UACServiceGrpc.newBlockingStub(authServiceChannel).withInterceptors(clientInterceptor);
  LOGGER.trace("Header attached with stub");
}
 
Example 29
Source Project: modeldb   Source File: AuthServiceChannel.java    License: Apache License 2.0 5 votes vote down vote up
private void initRoleServiceStubChannel() {
  Metadata requestHeaders = getMetadataHeaders();
  LOGGER.trace("Header attaching with stub : {}", requestHeaders);
  ClientInterceptor clientInterceptor = MetadataUtils.newAttachHeadersInterceptor(requestHeaders);
  roleServiceBlockingStub =
      RoleServiceGrpc.newBlockingStub(authServiceChannel).withInterceptors(clientInterceptor);
  LOGGER.trace("Header attached with stub");
}
 
Example 30
Source Project: modeldb   Source File: AuthServiceChannel.java    License: Apache License 2.0 5 votes vote down vote up
private void initRoleServiceFutureStubChannel() {
  Metadata requestHeaders = getMetadataHeaders();
  LOGGER.trace("Header attaching with stub : {}", requestHeaders);
  ClientInterceptor clientInterceptor = MetadataUtils.newAttachHeadersInterceptor(requestHeaders);
  roleServiceFutureStub =
      RoleServiceGrpc.newFutureStub(authServiceChannel).withInterceptors(clientInterceptor);
  LOGGER.trace("Header attached with stub");
}