<?xml version="1.0" encoding="UTF-8"?>
<web-app id="docs"
         xmlns="https://jakarta.ee/xml/ns/jakartaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"
         version="5.0"
         metadata-complete="true">
  <display-name>Teedy</display-name>
  
  <!-- Proper loader/unloader of ImageIO plugins -->
  <listener>
    <display-name>ImageIO service provider loader/unloader</display-name>
    <listener-class>com.sismics.util.listener.IIOProviderContextListener</listener-class>
  </listener>

  <!-- This filter handles CORS -->
  <filter>
    <filter-name>corsFilter</filter-name>
    <filter-class>com.sismics.util.filter.CorsFilter</filter-class>
    <async-supported>true</async-supported>
  </filter>

  <filter-mapping>
    <filter-name>corsFilter</filter-name>
    <url-pattern>/api/*</url-pattern>
  </filter-mapping>

  <!-- This filter is used to process a couple of things in the request context -->
  <filter>
    <filter-name>requestContextFilter</filter-name>
    <filter-class>com.sismics.util.filter.RequestContextFilter</filter-class>
    <async-supported>true</async-supported>
  </filter>
  
  <filter-mapping>
    <filter-name>requestContextFilter</filter-name>
    <url-pattern>/api/*</url-pattern>
  </filter-mapping>

  <!-- These filters are used to secure URLs -->
  <filter>
    <filter-name>tokenBasedSecurityFilter</filter-name>
    <filter-class>com.sismics.util.filter.TokenBasedSecurityFilter</filter-class>
    <async-supported>true</async-supported>
  </filter>

  <filter>
    <filter-name>headerBasedSecurityFilter</filter-name>
    <filter-class>com.sismics.util.filter.HeaderBasedSecurityFilter</filter-class>
    <async-supported>true</async-supported>
    <init-param>
      <param-name>enabled</param-name>
      <param-value>false</param-value>
    </init-param>
  </filter>
  
  <filter-mapping>
    <filter-name>tokenBasedSecurityFilter</filter-name>
    <url-pattern>/api/*</url-pattern>
  </filter-mapping>

  <filter-mapping>
    <filter-name>headerBasedSecurityFilter</filter-name>
    <url-pattern>/api/*</url-pattern>
  </filter-mapping>

  <!-- Jersey -->
  <servlet>
    <servlet-name>JerseyServlet</servlet-name>
    <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
    <init-param>
      <param-name>jersey.config.server.provider.packages</param-name>
      <param-value>com.sismics.docs.rest.resource</param-value>
    </init-param>
    <init-param>
      <param-name>jersey.config.server.provider.classnames</param-name>
      <param-value>org.glassfish.jersey.media.multipart.MultiPartFeature</param-value>
    </init-param>
    <init-param>
      <param-name>jersey.config.server.response.setStatusOverSendError</param-name>
      <param-value>true</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
    <async-supported>true</async-supported>
  </servlet>
  
  <servlet-mapping>
    <servlet-name>JerseyServlet</servlet-name>
    <url-pattern>/api/*</url-pattern>
  </servlet-mapping>
  
  <absolute-ordering/>
</web-app>
