<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation=
         "http://java.sun.com/xml/ns/j2ee 
          http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
         version="2.4"> 

  <!-- Give name to FinalizePurchaseServlet. This servlet
       is mapped to the URL /ssl/FinalizePurchase 
       (by means of servlet-mapping and url-pattern). 
       Then, that URL will later be designated as one requiring 
       SSL (by means of security-constraint and 
       transport-guarantee). -->
  <servlet>
    <servlet-name>
      FinalizePurchaseServlet
    </servlet-name>
    <servlet-class>
      hotdotcom.FinalizePurchaseServlet
    </servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>
      FinalizePurchaseServlet
    </servlet-name>
    <url-pattern>
      /ssl/FinalizePurchase
    </url-pattern>
  </servlet-mapping>
  
  <!-- Servlet to logout the user. -->
  <servlet>
    <servlet-name>Logout</servlet-name>
    <servlet-class>hotdotcom.LogoutServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>Logout</servlet-name>
    <url-pattern>/admin/logout</url-pattern>
  </servlet-mapping>
  
  <error-page>
    <error-code>403</error-code>
    <location>/WEB-INF/jspPages/forbidden.jsp</location>
  </error-page>
  
  <!-- Protect everything within the "investing" directory. -->
  <security-constraint>
    <web-resource-collection>
      <web-resource-name>Investing</web-resource-name>
      <url-pattern>/investing/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
      <role-name>registered-user</role-name>
      <role-name>administrator</role-name>
    </auth-constraint>
  </security-constraint>
  
  <!-- URLs of the form http://host/webAppPrefix/ssl/blah
       require SSL and are thus redirected to
       https://host/webAppPrefix/ssl/blah. -->
  <security-constraint>
    <web-resource-collection>
      <web-resource-name>Purchase</web-resource-name>
      <url-pattern>/ssl/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
      <role-name>registered-user</role-name>
    </auth-constraint>
    <user-data-constraint>
      <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
  </security-constraint>
  
  <!-- Only users in the administrator role can access
       the delete-account.jsp page within the admin
       directory. -->
  <security-constraint>
    <web-resource-collection>
      <web-resource-name>Account Deletion</web-resource-name>
      <url-pattern>/admin/delete-account.jsp</url-pattern>
    </web-resource-collection>
    <auth-constraint>
      <role-name>administrator</role-name>
    </auth-constraint>
  </security-constraint>
  
  <!-- Declare security roles used in this app. -->
  <security-role>
  	<role-name>administrator</role-name>
  </security-role>
  <security-role>
    <role-name>registered-user</role-name>
  </security-role>
  
  <!-- Tell the server to use form-based authentication. -->
  <login-config>
    <auth-method>FORM</auth-method>
    <form-login-config>
      <form-login-page>/admin/login.jsp</form-login-page>
      <form-error-page>/admin/login-error.jsp</form-error-page>
    </form-login-config>
  </login-config>
  
  <!-- Disable the invoker servlet. -->
  <servlet>
    <servlet-name>NoInvoker</servlet-name>
    <servlet-class>coreservlets.NoInvokerServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>NoInvoker</servlet-name>
    <url-pattern>/servlet/*</url-pattern>
  </servlet-mapping>
  
  <!-- If URL gives a directory but no filename, try index.jsp
       first and index.html second. If neither is found,
       the result is server specific (e.g., a directory 
       listing). -->
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>
</web-app>
