com.cafesoft.core.http
Class HttpAuthorization

java.lang.Object
  |
  +--com.cafesoft.core.http.HttpAuthorization

public class HttpAuthorization
extends Object

This class supports HTTP Basic authentication via username/password. If an HTTP 'Authorization' header is provided in the HttpServletRequest, then it's associated username and password can be accessed using methods in this class.

The Authorization header value is: "Basic username:password" (not including the double quotes). In addition, the 'username:password' portion of the the header value are "BASE64 encoded", which provides a feeble attempt at password obfuscation.

To use this class:

 HttpAuthorization httpAuth = new HttpAuthorization(req);
 String username = httpAuth.getUser();
 String password = httpAuth.getPassword();
 

You can check for existence of the 'Authorization' header yourself prior to using this class if a username and password are required. If the header is not specified with the request, then getUser() and getPassword() will return null values.

Since:
11/7/01

Constructor Summary
HttpAuthorization(javax.servlet.http.HttpServletRequest req)
          Create an Authorization object by parsing the "Authorization:" header of the specified HttpServletRequest object.
 
Method Summary
 String getPassword()
          Get the password associated with the Authorization.
 String getUser()
          Get the user associated with the Authorization.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpAuthorization

public HttpAuthorization(javax.servlet.http.HttpServletRequest req)
Create an Authorization object by parsing the "Authorization:" header of the specified HttpServletRequest object.

Parameters:
req - The HttpServletRequest object.
Method Detail

getUser

public String getUser()
Get the user associated with the Authorization.

Returns:
the user or null if no user name was found.

getPassword

public String getPassword()
Get the password associated with the Authorization.

Returns:
the password or null if no password was found.


Generated on 10:40:31 AM September 10, 2003, © 1996-2003 Cafésoft LLC. All rights reserved.