<?xml version="1.0" encoding="UTF-8"?>
<web-app 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">

  <display-name>Lions Dev - Solutions Digitales Innovantes</display-name>
  <description>Plateforme de services numériques et de développement web</description>

  <!-- Configuration Jakarta Faces -->
  <context-param>
    <param-name>jakarta.faces.PROJECT_STAGE</param-name>
    <param-value>Production</param-value>
  </context-param>

  <context-param>
    <param-name>jakarta.faces.FACELETS_REFRESH_PERIOD</param-name>
    <param-value>-1</param-value>
  </context-param>

  <context-param>
    <param-name>jakarta.faces.VALIDATE_EMPTY_FIELDS</param-name>
    <param-value>true</param-value>
  </context-param>

  <!-- Configuration PrimeFaces -->
  <context-param>
    <param-name>primefaces.THEME</param-name>
    <param-value>saga</param-value>
  </context-param>

  <context-param>
    <param-name>primefaces.FONT_AWESOME</param-name>
    <param-value>true</param-value>
  </context-param>

  <!-- Configuration du Servlet Faces -->
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>jakarta.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    <multipart-config>
      <location>${java.io.tmpdir}</location>
      <max-file-size>5242880</max-file-size>
      <max-request-size>10485760</max-request-size>
      <file-size-threshold>1048576</file-size-threshold>
    </multipart-config>
  </servlet>

  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
  </servlet-mapping>

  <!-- Configuration de Session -->
  <session-config>
    <session-timeout>30</session-timeout>
    <cookie-config>
      <http-only>true</http-only>
      <secure>true</secure>
    </cookie-config>
    <tracking-mode>COOKIE</tracking-mode>
  </session-config>

  <!-- Filtres de Sécurité -->
  <filter>
    <filter-name>SecurityHeadersFilter</filter-name>
    <filter-class>dev.lions.security.SecurityHeadersFilter</filter-class>
    <init-param>
      <param-name>Content-Security-Policy</param-name>
      <param-value>default-src 'self'; script-src 'self' 'unsafe-inline' https://cdnjs.cloudflare.com; style-src 'self' 'unsafe-inline' https://cdnjs.cloudflare.com; img-src 'self' data: https:; font-src 'self' https://cdnjs.cloudflare.com; connect-src 'self'</param-value>
    </init-param>
    <init-param>
      <param-name>Set-Cookie</param-name>
      <param-value>SameSite=Strict</param-value>
    </init-param>
  </filter>

  <filter-mapping>
    <filter-name>SecurityHeadersFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

  <!-- Pages d'Erreur -->
  <error-page>
    <error-code>404</error-code>
    <location>/META-INF/resources/public/error/404.xhtml</location>
  </error-page>

  <error-page>
    <error-code>500</error-code>
    <location>/META-INF/resources/public/error/500.xhtml</location>
  </error-page>

  <error-page>
    <exception-type>jakarta.faces.application.ViewExpiredException</exception-type>
    <location>/META-INF/resources/public/error/expired.xhtml</location>
  </error-page>

  <!-- Configuration des Ressources -->
  <mime-mapping>
    <extension>woff2</extension>
    <mime-type>font/woff2</mime-type>
  </mime-mapping>

  <mime-mapping>
    <extension>webp</extension>
    <mime-type>image/webp</mime-type>
  </mime-mapping>

  <!-- Page d'Accueil -->
  <welcome-file-list>
    <welcome-file>public/index.xhtml</welcome-file>
  </welcome-file-list>

</web-app>