Class BaseEndpointRestrictionsInterceptor
java.lang.Object
de.hybris.platform.webservicescommons.api.restrictions.interceptor.BaseEndpointRestrictionsInterceptor
- All Implemented Interfaces:
org.springframework.web.servlet.HandlerInterceptor
public class BaseEndpointRestrictionsInterceptor
extends Object
implements org.springframework.web.servlet.HandlerInterceptor
Request interceptor, that verifies whether the endpoint is disabled based on configuration.
In case the endpoint is disabled the 404 (Not Found) error status is set in the HTTP servlet response.
-
Constructor Summary
ConstructorsConstructorDescriptionBaseEndpointRestrictionsInterceptor(String specificConfigPrefix, EndpointRestrictionsService endpointRestrictionsService) Interceptor constructorBaseEndpointRestrictionsInterceptor(String specificConfigPrefix, EndpointRestrictionsService endpointRestrictionsService, int errorStatus) Interceptor constructor -
Method Summary
Modifier and TypeMethodDescriptionprotected EndpointContextDatacreateEndpointContextData(org.springframework.web.method.HandlerMethod handlerMethod) Creates the endpoint context data based on request handler method.protected EndpointRestrictionsServiceprotected intprotected Stringprotected booleanisEndpointDisabled(Object endpointHandler) Verifies whether the endpoint handler is disabled.protected booleanisHandlerSupported(Object endpointHandler) Verifies if the given endpoint endpointHandler is supported.protected voidlogDisabledEndpoint(javax.servlet.http.HttpServletRequest request) Log disable endpoint information for the request.booleanpreHandle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Object endpointHandler) Intercepted REST API controller method.protected voidstopRequestProcessing(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Stops the further request processing by setting error status in the response.protected static intvalidateErrorStatus(int errorStatus) Validate HTTP error status value.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.web.servlet.HandlerInterceptor
afterCompletion, postHandle
-
Constructor Details
-
BaseEndpointRestrictionsInterceptor
public BaseEndpointRestrictionsInterceptor(String specificConfigPrefix, EndpointRestrictionsService endpointRestrictionsService) Interceptor constructor- Parameters:
specificConfigPrefix- prefix of specific configurationendpointRestrictionsService- service, that verifies whether endpoint is disabled
-
BaseEndpointRestrictionsInterceptor
public BaseEndpointRestrictionsInterceptor(String specificConfigPrefix, EndpointRestrictionsService endpointRestrictionsService, int errorStatus) Interceptor constructor- Parameters:
specificConfigPrefix- prefix of specific configurationendpointRestrictionsService- service, that verifies whether endpoint is disablederrorStatus- numeric value of HTTP error status
-
-
Method Details
-
validateErrorStatus
protected static int validateErrorStatus(int errorStatus) Validate HTTP error status value. In case the value is out of range theIllegalArgumentExceptionis thrown, otherwise the valid status is returned- Parameters:
errorStatus- numerical value of error status, that must be validated- Returns:
- validated numerical value of of HTTP error status
-
preHandle
public boolean preHandle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Object endpointHandler) throws Exception Intercepted REST API controller method. Verifies whether the endpoint handler is disabled.- Specified by:
preHandlein interfaceorg.springframework.web.servlet.HandlerInterceptor- Parameters:
request- HTTP servlet requestresponse- HTTP servlet responseendpointHandler- endpoint handler method- Returns:
trueif the request can be further processed,falsein other cases- Throws:
Exception- in case the error status can not be set because of error
-
isEndpointDisabled
Verifies whether the endpoint handler is disabled.- Parameters:
endpointHandler- endpoint handler method- Returns:
trueif the endpoint handler is disabled
-
stopRequestProcessing
protected void stopRequestProcessing(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException Stops the further request processing by setting error status in the response.- Parameters:
request- HTTP requestresponse- HTTP response- Throws:
IOException- throws in case the error status can not be set
-
logDisabledEndpoint
protected void logDisabledEndpoint(javax.servlet.http.HttpServletRequest request) Log disable endpoint information for the request.- Parameters:
request- HTTP request
-
isHandlerSupported
Verifies if the given endpoint endpointHandler is supported.- Parameters:
endpointHandler- endpoint handler- Returns:
trueif endpoint handler is supported
-
createEndpointContextData
protected EndpointContextData createEndpointContextData(org.springframework.web.method.HandlerMethod handlerMethod) Creates the endpoint context data based on request handler method.- Parameters:
handlerMethod- request handler method- Returns:
- endpoint context data
-
getSpecificConfigPrefix
-
getEndpointRestrictionsService
-
getErrorStatus
protected int getErrorStatus()
-