<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright 2012 SURFnet bv, The Netherlands
  ~
  ~ Licensed 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 id="authorization-server"
         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"
         version="2.5">

    <display-name>Authorization server</display-name>

    <!-- Do not use an XML-based Spring configuration, but annotation only. -->
    <context-param>
        <param-name>contextClass</param-name>
        <param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value>
    </context-param>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>eu.dnetlib.oauth.config.SpringConfiguration</param-value>
    </context-param>
    <listener>
        <listener-class>eu.dnetlib.oauth.logging.LogbackConfigLocationListener</listener-class>
    </listener>
    <listener>
        <listener-class>
            org.springframework.web.context.ContextLoaderListener
        </listener-class>
    </listener>

    <filter>
        <filter-name>adminAuthorizationFilter</filter-name>
        <filter-class>org.surfnet.oaaas.auth.AuthorizationServerFilter</filter-class>
        <init-param>
            <param-name>apis-resource-server.properties.file</param-name>
            <param-value>apis.application.properties</param-value>
        </init-param>
    </filter>

    <filter-mapping>
        <filter-name>adminAuthorizationFilter</filter-name>
        <url-pattern>/admin/*</url-pattern>
    </filter-mapping>

    <filter>
        <filter-name>oauth2AuthenticationFilter</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>oauth2AuthenticationFilter</filter-name>
        <url-pattern>/oauth2/authorize</url-pattern>
    </filter-mapping>

    <filter>
        <filter-name>oauth2UserConsentFilter</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>oauth2UserConsentFilter</filter-name>
        <url-pattern>/oauth2/authorize</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>oauth2UserConsentFilter</filter-name>
        <url-pattern>/oauth2/consent</url-pattern>
    </filter-mapping>

    <servlet>
        <servlet-name>jersey</servlet-name>
        <servlet-class>
            com.sun.jersey.spi.spring.container.servlet.SpringServlet
        </servlet-class>
        <init-param>
            <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
            <param-value>true</param-value>
            <param-name>com.sun.jersey.config.property.packages</param-name>
            <param-value>org.surfnet.oaaas.resource</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>jersey</servlet-name>
        <url-pattern>/oauth2/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>jersey</servlet-name>
        <url-pattern>/v1/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>jersey</servlet-name>
        <url-pattern>/admin/*</url-pattern>
    </servlet-mapping>
</web-app>