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 Details

    • BaseEndpointRestrictionsInterceptor

      public BaseEndpointRestrictionsInterceptor(String specificConfigPrefix, EndpointRestrictionsService endpointRestrictionsService)
      Interceptor constructor
      Parameters:
      specificConfigPrefix - prefix of specific configuration
      endpointRestrictionsService - service, that verifies whether endpoint is disabled
    • BaseEndpointRestrictionsInterceptor

      public BaseEndpointRestrictionsInterceptor(String specificConfigPrefix, EndpointRestrictionsService endpointRestrictionsService, int errorStatus)
      Interceptor constructor
      Parameters:
      specificConfigPrefix - prefix of specific configuration
      endpointRestrictionsService - service, that verifies whether endpoint is disabled
      errorStatus - 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 the IllegalArgumentException is 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:
      preHandle in interface org.springframework.web.servlet.HandlerInterceptor
      Parameters:
      request - HTTP servlet request
      response - HTTP servlet response
      endpointHandler - endpoint handler method
      Returns:
      true if the request can be further processed, false in other cases
      Throws:
      Exception - in case the error status can not be set because of error
    • isEndpointDisabled

      protected boolean isEndpointDisabled(Object endpointHandler)
      Verifies whether the endpoint handler is disabled.
      Parameters:
      endpointHandler - endpoint handler method
      Returns:
      true if 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 request
      response - 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

      protected boolean isHandlerSupported(Object endpointHandler)
      Verifies if the given endpoint endpointHandler is supported.
      Parameters:
      endpointHandler - endpoint handler
      Returns:
      true if 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

      protected String getSpecificConfigPrefix()
    • getEndpointRestrictionsService

      protected EndpointRestrictionsService getEndpointRestrictionsService()
    • getErrorStatus

      protected int getErrorStatus()