@GrpcGlobalServerInterceptor public class ExceptionTranslatingServerInterceptor extends Object implements ServerInterceptor
AuthenticationException
and AccessDeniedException
to
appropriate grpc status responses.Modifier and Type | Field and Description |
---|---|
static String |
ACCESS_DENIED_DESCRIPTION |
static String |
UNAUTHENTICATED_DESCRIPTION |
Constructor and Description |
---|
ExceptionTranslatingServerInterceptor() |
Modifier and Type | Method and Description |
---|---|
protected void |
closeCallAccessDenied(ServerCall<?,?> call,
AccessDeniedException aex)
Close the call with
Status.PERMISSION_DENIED . |
protected void |
closeCallUnauthenticated(ServerCall<?,?> call,
AuthenticationException aex)
Close the call with
Status.UNAUTHENTICATED . |
<ReqT,RespT> |
interceptCall(ServerCall<ReqT,RespT> call,
Metadata headers,
ServerCallHandler<ReqT,RespT> next) |
protected <ReqT> ServerCall.Listener<ReqT> |
noOpCallListener()
Creates a new no-op call listener because you can neither return null nor throw an exception in
interceptCall(ServerCall, Metadata, ServerCallHandler) . |
public static final String UNAUTHENTICATED_DESCRIPTION
public static final String ACCESS_DENIED_DESCRIPTION
public ExceptionTranslatingServerInterceptor()
public <ReqT,RespT> ServerCall.Listener<ReqT> interceptCall(ServerCall<ReqT,RespT> call, Metadata headers, ServerCallHandler<ReqT,RespT> next)
interceptCall
in interface ServerInterceptor
protected <ReqT> ServerCall.Listener<ReqT> noOpCallListener()
interceptCall(ServerCall, Metadata, ServerCallHandler)
.ReqT
- The type of the request.protected void closeCallUnauthenticated(ServerCall<?,?> call, AuthenticationException aex)
Status.UNAUTHENTICATED
.call
- The call to close.aex
- The exception that was the cause.protected void closeCallAccessDenied(ServerCall<?,?> call, AccessDeniedException aex)
Status.PERMISSION_DENIED
.call
- The call to close.aex
- The exception that was the cause.