Servertec   Realm
Content
Introduction
Release Notes
Features
FAQs
Requirements
Installation
Change Log
Future Plans
Knowledge Base
Documentation
Conventions
Users
Reference
iServer API
AccessLogEntry
Codecs
Connection
ConnectionPool...
DString
ErrorLogEntry
EventLogEntry
FileUpload
iws
Logger
MultiPartForm
QuickSort
Realm
Utils

Servlet API
CGI
SSI
Servlets
Logs

Samples
Sales
Legal
Feedback

 

java.lang.Object
 |
 +--stec.iws.HttpServlet
     |
     +--stec.iws.Realm

public abstract class Realm extends HttpServlet

Defines methods used by security realms.

Methods

Method Description
run Called by iServer for each client request to check security privileges.

run

Called by iServer for each client request to check security privileges.

Syntax

public abstract Object run(HttpServletRequest request,
                           HttpServletResponse reponse)
                           throws Exception

Parameters

request the client's request.
response the client's response.

Returns

Object any access rights, null if unauthorized.

Throws

Exception any exception thrown.

Example

public void run(HttpServletRequest request,
                   HttpServletResponse response)
                   throws Exception
{
  String rights = null;

  String authorization = request.getHeader("Authorization");
  if(authorization != null)
  {
    String scheme = DString.extract(authorization, " ", 0);
    if(scheme.equals(Constants.DEFAULT_SCHEME))
    {
      int offset = authorization.indexOf(' ');

      String sValue = authorization.substring(offset + 1);
      sValue = Codecs.base64Decode(sValue);

      String username = DString.extract(sValue, ":", 0);

      String password = DString.extract(sValue, ":", 1);
      if(password == null)
      {
        password = "";
      }

      if(username.equals("admin") && password.equals("admin"))
      {
        rights = "*";
      }
    }
  }

  if(rights == null)
  {
    response.setHeader("WWW-Authenticate",
                       "Basic realm=\"default\"");

    response.sendError(response.SC_UNAUTHORIZED);
  }

  return rights;
}

 top of page
 Built with iScript Copyright © 1997-1999 Servertec. All rights reserved.
Last Modified: Mon Jun 28 23:14:48 EDT 1999