@Override public <ReqT, RespT> Listener<ReqT> interceptCall(ServerCall<ReqT, RespT> call, Metadata headers, ServerCallHandler<ReqT, RespT> next) { String clientId = headers.get(CLIENT_ID_HEADER_KEY); if (clientId == null || !authenticator.authenticate(clientId)) { call.close(Status.UNAUTHENTICATED.withDescription("Invalid or unknown client: " + clientId), headers); return NOOP_LISTENER; } Context context = Context.current().withValue(CLIENT_ID_CONTEXT_KEY, clientId); return Contexts.interceptCall(context, call, headers, next); }
@Override public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(ServerCall<ReqT, RespT> call, final Metadata requestHeaders, ServerCallHandler<ReqT, RespT> next) { Context context = Context.current().withValue(MINI_DEVICE_INFO, requestHeaders.get(miniDeviceInfoKey)); return Contexts.interceptCall(context, call, requestHeaders, next); }
@Override public <ReqT, RespT> Listener<ReqT> interceptCall( ServerCall<ReqT, RespT> call, Metadata headers, ServerCallHandler<ReqT, RespT> next) { RequestMetadata meta = headers.get(METADATA_KEY); if (meta == null) { throw new IllegalStateException("RequestMetadata not received from the client."); } Context ctx = Context.current().withValue(CONTEXT_KEY, meta); return Contexts.interceptCall(ctx, call, headers, next); }