<?xml version="1.0" encoding="UTF-8"?>

<!--
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
-->

<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_6_0.xsd"
         version="6.0">

  <display-name>Tobago Demo Application</display-name>

  <!-- for local development you can set a Maven profile with -Pdev to set the
  jakarta.faces.PROJECT_STAGE to Development -->

  <context-param>
    <param-name>com.sun.faces.validateXml</param-name>
    <param-value>true</param-value>
  </context-param>

<!-- enable for websockets -->
  <context-param>
    <param-name>jakarta.faces.ENABLE_WEBSOCKET_ENDPOINT</param-name>
    <param-value>true</param-value>
  </context-param>

   <!-- disable error handling from myfaces, needed for the demo -->
  <context-param>
    <param-name>org.apache.myfaces.ERROR_HANDLING</param-name>
    <param-value>false</param-value>
  </context-param>

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

  <context-param>
    <param-name>jakarta.faces.FACELETS_VIEW_MAPPINGS</param-name>
    <param-value>*.xhtml</param-value>
  </context-param>

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

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

  <context-param>
    <param-name>org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION</param-name>
    <param-value>20</param-value>
  </context-param>

  <context-param>
    <param-name>org.apache.myfaces.NUMBER_OF_SEQUENTIAL_VIEWS_IN_SESSION</param-name>
    <param-value>4</param-value>
  </context-param>

  <context-param>
    <param-name>jakarta.faces.CLIENT_WINDOW_MODE</param-name>
    <param-value>url</param-value>
  </context-param>

  <listener>
    <listener-class>org.apache.myfaces.tobago.example.demo.info.ActivitySessionListener</listener-class>
  </listener>

  <!-- activate this for some containers -->
  <!--
  <listener>
    <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
  </listener>
  -->

  <!-- activate this for some containers -->
  <!--
  <listener>
    <listener-class>org.apache.webbeans.servlet.WebBeansConfigurationListener</listener-class>
  </listener>
  -->

  <filter>
    <filter-name>LoggingMdcFilter</filter-name>
    <filter-class>org.apache.myfaces.tobago.internal.webapp.LoggingMdcFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>LoggingMdcFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

  <!-- Error handling, see also these classes:
       org.apache.myfaces.tobago.example.demo.TobagoExceptionHandler
   -->

  <error-page>
    <error-code>404</error-code>
    <location>/error/404.xhtml</location>
  </error-page>

  <error-page>
    <error-code>500</error-code>
    <location>/error/exception.xhtml</location>
  </error-page>

  <error-page>
    <exception-type>java.lang.Exception</exception-type>
    <location>/error/exception.xhtml</location>
  </error-page>

  <!-- The Usual Welcome File List -->
  <welcome-file-list>
    <welcome-file>init.xhtml</welcome-file>
  </welcome-file-list>

  <session-config>
    <!-- for WebSphere you need to comment out this block, because WebSphere want to set it himself -->
    <cookie-config>
      <http-only>true</http-only>
      <!-- with secure=true you can only use https, not http -->
      <!--<secure>true</secure>-->
    </cookie-config>
  </session-config>

  <security-constraint>
    <display-name>Security Constraint</display-name>
    <web-resource-collection>
      <web-resource-name>Application Area</web-resource-name>
      <url-pattern>/content/280-security/20-roles/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
      <role-name>demo-admin</role-name>
      <role-name>demo-guest</role-name>
    </auth-constraint>
  </security-constraint>

  <login-config>
    <auth-method>FORM</auth-method>
    <realm-name>demo-realm</realm-name>
    <form-login-config>
      <form-login-page>/login.xhtml</form-login-page>
      <form-error-page>/login.xhtml</form-error-page>
    </form-login-config>
  </login-config>

  <security-role>
    <role-name>demo-admin</role-name>
  </security-role>
  <security-role>
    <role-name>demo-guest</role-name>
  </security-role>

</web-app>
