<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
  ~
  ~ WSO2 Inc. 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 version="2.5"
         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_2_5.xsd"
         metadata-complete="true">
    <display-name>WSO2 IoT Server</display-name>
    <description>WSO2 IoT Server</description>

    <servlet>
        <servlet-name>CXFServlet</servlet-name>
        <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>CXFServlet</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>
    <context-param>
        <param-name>doAuthentication</param-name>
        <param-value>true</param-value>
    </context-param>
	<!--This is to support basic auth.-->
	<context-param>
		<param-name>basicAuth</param-name>
		<param-value>true</param-value>
	</context-param>

    <!--publish to apim-->
    <context-param>
        <param-name>managed-api-enabled</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>managed-api-owner</param-name>
        <param-value>admin</param-value>
    </context-param>

    <filter>
        <filter-name>ApiPermissionFilter</filter-name>
        <filter-class>org.wso2.carbon.apimgt.application.extension.api.filter.ApiPermissionFilter</filter-class>
    </filter>

    <filter>
        <filter-name>HttpHeaderSecurityFilter</filter-name>
        <filter-class>org.apache.catalina.filters.HttpHeaderSecurityFilter</filter-class>
        <init-param>
            <param-name>hstsEnabled</param-name>
            <param-value>false</param-value>
        </init-param>
    </filter>

    <filter>
        <filter-name>ContentTypeBasedCachePreventionFilter</filter-name>
        <filter-class>org.wso2.carbon.ui.filters.cache.ContentTypeBasedCachePreventionFilter</filter-class>
        <init-param>
            <param-name>patterns</param-name>
            <param-value>text/html" ,application/json" ,text/plain</param-value>
        </init-param>
        <init-param>
            <param-name>filterAction</param-name>
            <param-value>enforce</param-value>
        </init-param>
        <init-param>
            <param-name>httpHeaders</param-name>
            <param-value>Cache-Control: no-store, no-cache, must-revalidate, private</param-value>
        </init-param>
    </filter>

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

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

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

</web-app>
