@GrpcGlobalServerInterceptor public class ExceptionTranslatingServerInterceptor extends java.lang.Object implements io.grpc.ServerInterceptor
AuthenticationException
and AccessDeniedException
to
appropriate grpc status responses.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ACCESS_DENIED_DESCRIPTION |
static java.lang.String |
UNAUTHENTICATED_DESCRIPTION |
Constructor and Description |
---|
ExceptionTranslatingServerInterceptor() |
Modifier and Type | Method and Description |
---|---|
protected void |
closeCallAccessDenied(io.grpc.ServerCall<?,?> call,
org.springframework.security.access.AccessDeniedException aex)
Close the call with
Status.PERMISSION_DENIED . |
protected void |
closeCallUnauthenticated(io.grpc.ServerCall<?,?> call,
org.springframework.security.core.AuthenticationException aex)
Close the call with
Status.UNAUTHENTICATED . |
<ReqT,RespT> |
interceptCall(io.grpc.ServerCall<ReqT,RespT> call,
io.grpc.Metadata headers,
io.grpc.ServerCallHandler<ReqT,RespT> next) |
protected <ReqT> io.grpc.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 java.lang.String UNAUTHENTICATED_DESCRIPTION
public static final java.lang.String ACCESS_DENIED_DESCRIPTION
public ExceptionTranslatingServerInterceptor()
public <ReqT,RespT> io.grpc.ServerCall.Listener<ReqT> interceptCall(io.grpc.ServerCall<ReqT,RespT> call, io.grpc.Metadata headers, io.grpc.ServerCallHandler<ReqT,RespT> next)
interceptCall
in interface io.grpc.ServerInterceptor
protected <ReqT> io.grpc.ServerCall.Listener<ReqT> noOpCallListener()
interceptCall(ServerCall, Metadata, ServerCallHandler)
.ReqT
- The type of the request.protected void closeCallUnauthenticated(io.grpc.ServerCall<?,?> call, org.springframework.security.core.AuthenticationException aex)
Status.UNAUTHENTICATED
.call
- The call to close.aex
- The exception that was the cause.protected void closeCallAccessDenied(io.grpc.ServerCall<?,?> call, org.springframework.security.access.AccessDeniedException aex)
Status.PERMISSION_DENIED
.call
- The call to close.aex
- The exception that was the cause.