Securing Web Application Resources - Order Management Application Readme Securing Web Application Resources - Order Management Sample Application - Readme


Date: 20/03/2004


Table of Contents

Introduction
Application Overview
Application Design
Sample Application Files
Setting Up the Sample Application
Additional References

Introduction 

Prerequisite 

A working knowledge of Servlets and Oracle Application Server security will help you to fully benefit from the techniques employed in this sample application. Refer to the Additional References section for related resource links.

Technical Overview 

The Order Management sample application demonstrates how to secure a web application or web resource by configuring its security attributes, declaratively, in the web application deployment descriptor (namely, web.xml). Securing a web application/resource in this manner will help to prevent unauthorized access. Let's take a more elaborate look into the working of this sample application. 

To prevent unauthorized access, we use the web application deployment descriptor (web.xml) to identify the protected resources (URLS) and to designate a page that has a regular HTML form to collect usernames and passwords. When a user tries to access a protected URL in an application, he/she will be redirected to the page containing the form and be prompted to provide certain necessary credentials. Once the form is submitted, the username and password collected from the user input are sent to the Oracle Application Server, where the server checks the validity of these credentials against a predefined set of usernames, passwords, and roles available in the XML-based repository provided for this web application to ascertain whether the user has been previously authenticated. If the login is successful and the user belongs to a role that is permitted access to the page, the user is granted access to the page originally requested. If the login is unsuccessful, the user is sent to a designated error page. This process is completely transparent to the Servlets and JSP pages.

At times, however, declarative security alone is not sufficient to express the security model of the application. In such situations, Programmatic Security needs to be employed. Programmatic security consists of the following methods of the HttpServletRequest interface:


  • getRemoteUser - this method determines the user name with which the client authenticated
  • isUserInRole - this method determines if a user is in a specific security role
  • getUserPrincipal - method returns a java.security.Principal object

These APIs allow servlets to make business logic decisions based on the logical role of the remote user. They also allow the servlet to determine the principal name and role of the current user.

Application Overview 

The Order Management sample application authorizes two types of users to view data.:
  • The Manager, who can view all the users who have created the orders in the database and also view the orders of each user
  • The Trader, is allowed to view only his/her own orders
No users from other roles are allowed to view any of the resources from this application. Though the application server can authenticate the users under the 'guestusers' role, the application does not allow hem to view any data.

Application Design 

This application is designed to use the declarative and programmatic way of protecting web resources.  As mentioned earlier the sample application allows two user roles or groups to access the protected resources  - the 'manager' who can view all the listed users and their orders in the database, and the 'trader' who can only access his/her own records in the database.
Whenever a user tries to access the protected web resources he/she will be redirected to the login page. Once the user submits the form with his/her username and password,  the application server checks the validity of the user. If the user is not authenticated he/she will be redirected to the error page. Then the SecurityServlet authorizes the user to view the related information, programmatically, based on the user's role.

Sample Application Files 

This section will provide a tabular listing of the sample application files, along with their respective directory locations and a description of what they do in the overall scheme of the application:

Readme File and Stylesheets

Directory File Description
Readme.html

This file

otn.css
Stylesheet used in the Readme.html
Install.html
The sample install instructions document

Servlet and Related Files for the Application

Directory File Description
SecurityServlet.java

This Servlet checks for the  user roles and displays the appropriate content.

web.xml
The web deployment descriptor
login.html
The login page
loginError.html
The error page which is displayed when the login fails
main.html
The main html page which calls the SecurityServlet

Configuration and Build Files for the Application

 Directory File Description
orion-application.xml  

Application server server specific deployment descriptor.

jazn-data.xml.xml
Contains users and user groups
data-sources.xml
Contains the data sources definition used by the application

Setting up the Sample Application 

Refer to the Install.html document for step-by-step instructions on extracting files, installing, and running the sample successfully.

Additional References

We hope you found this README file helpful. Please enter your comments about the Order Management sample application in the OTN Sample Code Discussion Forum.

 

Securing Web Application Resources Sample Application

Please rate this sample application :
Excellent
Good
Average
Below Average
Poor
E-mail this page
Printer View Printer View
Oracle Is The Information Company About Oracle | Oracle RSS Feeds | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Privacy