COP 4610L (Spring 2004)
Operating Systems Lab (Distributed Applications in the Enterprise)
Dr. R. Lent

Programming Assignment 1

DUE: January 23, 8:00 PM

Your first assignment is to extend the basic web server discussed in class and support basic authentication. It must provide the following functionality:

1. (30pt) Respond with an error message if a client attempts to access a non-existent page. For this, you must change the program to include HTTP/1.0 404 Not Found in the header of the HTTP message and send in addition a dynamically generated HTML page that indicates that file "x" does not exist. Note that your web server needs to indicate the name of the file in the error page.

2. (30pt) Create a functional non-persistent web server: create a loop to avoid exiting the program after processing one request and insert Connection: close in the HTTP header to indicate non-persistency (check class notes). After that, your web server should be able to serve multi-object pages.

3. (20pt) Check for an Authorization: line in the header of incoming HTTP requests. If no such a line exists, reply with a HTTP/1.0 401 Unauthorized HTTP response. In addition, include a line WWW-Authenticate: Basic realm="COP4610L Project 1" to force the client browser request a username and password.

4. (20pt) If an Authorization: line exists, retrieve the user name and password and check if a valid combination was received. Valid combinations will be stored in file "users.txt". Each line in the file indicates a username followed by a ":" and then the password. If no valid combination is found, reply with a 401 message as before.

Tips

After installing JDK:

  • define environment variable JAVA_HOME pointing to your base JDK directory
  • Be sure to modify your PATH varible with %JAVA_HOME%/bin first in the line

    When using "basic" HTTP authentication, user names and passwords are base64 encoded. Decoding is possible via class Base64 (provided by tomcat-util.jar). The right method to use is base64Decode(string).

    Required software

    1. Java 2 Platform standard edition 1.4.x, optionally an IDE

    2. Netscape 7.1

    3. Copy file tomcat-util.jar to {jdk dir}/jre/lib/ext

    Useful references

    1. A quick reference on HTTP authentication

    2. Base64 API documentation

    3. I/O tutorial

    4. Socket programming tutorial Socket programming tutorial from java.sun.com

    Instructions and comments

    1. Insert appropriate comments to facilitate the grading of your work. You may attach an extra text file explaining your program.

    2. Pack (zip, rar, tar) your java source files with the name (no need to submit example files):

    first_initial last_name-assignment_number.zip

    e.g. rlent-1.zip

    3. A creative, clear, and good written solution may give you extra points

    4. Submit your assignment before the due time/date via WebCT