<?xml version="1.0" encoding="UTF-8"?>
<!--
 This file is part of the Meeds project (https://meeds.io/).

 Copyright (C) 2020 - 2025 Meeds Association contact@meeds.io

 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
 License as published by the Free Software Foundation; either
 version 3 of the License, or (at your option) any later version.
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 Lesser General Public License for more details.

 You should have received a copy of the GNU Lesser General Public License
 along with this program; if not, write to the Free Software Foundation,
 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-->
<web-app version="3.0" metadata-complete="true"
	xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

  <display-name>portal</display-name>

  <absolute-ordering/>

  <distributable/>

  <!-- ================================================================== -->
  <!--   RESOURCE FILTER TO CACHE MERGED JAVASCRIPT AND CSS               -->
  <!-- ================================================================== -->
  <filter>
    <filter-name>LocalizationFilter</filter-name>
    <filter-class>org.exoplatform.portal.application.localization.LocalizationFilter</filter-class>
  </filter>
  <filter>
    <filter-name>GenericFilter</filter-name>
    <filter-class>org.exoplatform.web.filter.GenericFilter</filter-class>
  </filter>

  <filter>
    <filter-name>SetCurrentIdentityFilter</filter-name>
    <filter-class>org.exoplatform.services.security.web.SetCurrentIdentityFilter</filter-class>
    <init-param>
      <param-name>restoreIdentity</param-name>
      <param-value>true</param-value>
    </init-param>
  </filter>

  <filter>
    <filter-name>ConversationStateUpdateFilter</filter-name>
    <filter-class>org.exoplatform.web.login.ConversationStateUpdateFilter</filter-class>
  </filter>

  <filter>
    <filter-name>RestEncodingFilter</filter-name>
    <filter-class>org.exoplatform.services.rest.servlet.RestEncodingFilter</filter-class>
    <init-param>
      <param-name>REQUEST_ENCODING</param-name>
      <param-value>UTF-8</param-value>
    </init-param>
  </filter>

  <filter>
    <filter-name>CacheUserProfileFilter</filter-name>
    <filter-class>org.exoplatform.web.CacheUserProfileFilter</filter-class>
  </filter>

  <filter>
    <filter-name>RememberMeFilter</filter-name>
    <filter-class>org.exoplatform.web.login.RememberMeFilter</filter-class>
    <init-param>
      <param-name>ignoredPaths</param-name>
      <param-value>/skins,/scripts,/favicon.ico</param-value>
    </init-param>
  </filter>

  <filter>
    <filter-name>PortalContainerFilter</filter-name>
    <filter-class>org.exoplatform.container.web.PortalContainerFilter</filter-class>
  </filter>

  <filter>
    <filter-name>SSODelegateFilter</filter-name>
    <filter-class>org.gatein.sso.integration.SSODelegateFilter</filter-class>
  </filter>

  <filter>
    <filter-name>OAuthDelegateFilter</filter-name>
    <filter-class>io.meeds.oauth.webapi.OAuthDelegateFilter</filter-class>
  </filter>
  
  <filter>
    <filter-name>PortalCheckInitFilter</filter-name>
    <filter-class>org.gatein.portal.init.PortalCheckInitFilter</filter-class>
  </filter>

  <filter>
    <filter-name>JSFAjaxRedirectFilter</filter-name>
    <filter-class>org.exoplatform.portal.application.JSFAjaxRedirectFilter</filter-class>
  </filter>

  <filter-mapping>
    <filter-name>PortalCheckInitFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>  
  
  <filter-mapping>
    <filter-name>PortalContainerFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

  <filter-mapping>
    <filter-name>SSODelegateFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <filter-mapping>
    <filter-name>OAuthDelegateFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

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

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

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

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

  <filter-mapping>
    <filter-name>LocalizationFilter</filter-name>
    <url-pattern>*.jsp</url-pattern>
    <url-pattern>/login</url-pattern>
    <url-pattern>/rest/*</url-pattern>
    <dispatcher>INCLUDE</dispatcher>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>ERROR</dispatcher>
  </filter-mapping>

  <filter-mapping>
    <filter-name>RestEncodingFilter</filter-name>
    <url-pattern>/rest/*</url-pattern>
  </filter-mapping>

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

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

  <!-- ================================================================== -->
  <!--           LISTENER                                                 -->
  <!-- ================================================================== -->
  <listener>
    <listener-class>org.exoplatform.web.GenericHttpListener</listener-class>
  </listener>
  <listener>
    <listener-class>org.exoplatform.services.security.web.JAASConversationStateListener</listener-class>
  </listener>
  <listener>
    <listener-class>org.exoplatform.web.security.AuthenticationRegistryListener</listener-class>
  </listener>

  <!-- ================================================================== -->
  <!--           SERVLET                                                  -->
  <!-- ================================================================== -->
  <servlet>
    <servlet-name>portal</servlet-name>
    <servlet-class>org.exoplatform.portal.application.PortalController</servlet-class>
    <init-param>
      <param-name>webui.configuration</param-name>
      <param-value>app:/WEB-INF/webui-configuration.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>

  <servlet>
    <servlet-name>RestServer</servlet-name>
    <servlet-class>org.exoplatform.services.rest.servlet.RestServlet</servlet-class>
    <load-on-startup>4</load-on-startup>
  </servlet>

  <servlet>
    <servlet-name>GateInServlet</servlet-name>
    <servlet-class>org.gatein.wci.api.GateInServlet</servlet-class>
    <load-on-startup>0</load-on-startup>
  </servlet>

  <servlet>
    <servlet-name>accountSetup</servlet-name>
    <servlet-class>org.exoplatform.account.setup.web.AccountSetup</servlet-class>
  </servlet>
  
  <servlet>
    <servlet-name>accountSetupViewServlet</servlet-name>
    <servlet-class>org.exoplatform.account.setup.web.AccountSetupViewServlet</servlet-class>
  </servlet>
  
  
  <!--  =================================================================  -->
  
  <servlet-mapping>
    <servlet-name>accountSetup</servlet-name>
    <url-pattern>/accountSetupAction</url-pattern>
  </servlet-mapping>
  
  <servlet-mapping>
    <servlet-name>accountSetupViewServlet</servlet-name>
    <url-pattern>/accountSetup</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
    <servlet-name>RestServer</servlet-name>
    <url-pattern>/rest/*</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
    <servlet-name>portal</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
    <servlet-name>GateInServlet</servlet-name>
    <url-pattern>/gateinservlet</url-pattern>
  </servlet-mapping>

  <!-- Define a security constraint that gives unlimited access to CSS and JS files. -->
  <security-constraint>
      <web-resource-collection>
          <web-resource-name>CSS</web-resource-name>
          <url-pattern>/skins/*</url-pattern>
      </web-resource-collection>
      <web-resource-collection>
          <web-resource-name>JS</web-resource-name>
          <url-pattern>/scripts/*</url-pattern>
      </web-resource-collection>
  </security-constraint>

  <security-constraint>
    <web-resource-collection>
      <web-resource-name>user authentication</web-resource-name>
      <url-pattern>/dologin</url-pattern>
    </web-resource-collection>
    <auth-constraint>
      <role-name>users</role-name>
    </auth-constraint>
    <user-data-constraint>
      <transport-guarantee>NONE</transport-guarantee>
    </user-data-constraint>
  </security-constraint>
  <login-config>
    <auth-method>FORM</auth-method>
    <realm-name>gatein-domain</realm-name>
    <form-login-config>
      <form-login-page>/login</form-login-page>
      <form-error-page>/login</form-error-page>
    </form-login-config>
  </login-config>
  <security-role>
    <description>a simple user role</description>
    <role-name>users</role-name>
  </security-role>

  <session-config>
    <tracking-mode>COOKIE</tracking-mode>
  </session-config>

</web-app>
