Class CorsAllowerWebServiceHandlerPlugin

  • All Implemented Interfaces:
    io.vertigo.core.node.component.CoreComponent, io.vertigo.core.node.component.Plugin, WebServiceHandlerPlugin

    public final class CorsAllowerWebServiceHandlerPlugin
    extends Object
    implements WebServiceHandlerPlugin
    Handler of Cross-Origin Resource Sharing (CORS).
    Author:
    npiedeloup
    See Also:
    "https://www.owasp.org/index.php/CORS_OriginHeaderScrutiny"
    • Field Detail

      • STACK_INDEX

        public static final int STACK_INDEX
        Stack index of the handler for sorting at startup
        See Also:
        Constant Field Values
    • Constructor Detail

      • CorsAllowerWebServiceHandlerPlugin

        @Inject
        public CorsAllowerWebServiceHandlerPlugin​(Optional<String> originCORSFilter,
                                                  Optional<String> methodCORSFilter)
        Parameters:
        originCORSFilter - Origin CORS Allowed
        methodCORSFilter - Method CORS Allowed
    • Method Detail

      • accept

        public boolean accept​(WebServiceDefinition webServiceDefinition)
        Specified by:
        accept in interface WebServiceHandlerPlugin
        Parameters:
        webServiceDefinition - WebServiceDefinition
        Returns:
        If this handler should be use for this webService
      • putCorsResponseHeaders

        public void putCorsResponseHeaders​(javax.servlet.http.HttpServletRequest request,
                                           javax.servlet.http.HttpServletResponse response)
        Parameters:
        request - Request
        response - Response
      • getStackIndex

        public int getStackIndex()
        Description copied from interface: WebServiceHandlerPlugin
        Return an index to compute the order of the handlers stack. Please check the index of the provided handlers by vertigo and choose the index for yours accordingly. Vertigo's handlers start à 10 and leave a space of 10 between each. The last handler must be RestfulServiceWebServiceHandlerPlugin which has the index 120. Therefore the provided index must be between 0 and 119
        Specified by:
        getStackIndex in interface WebServiceHandlerPlugin
        Returns:
        the index (between 0 and 119)