Class AccessVerifier

java.lang.Object
  |
  +--AccessVerifier

public class AccessVerifier
extends java.lang.Object

Access verifier for hosts. It checks whether access from/to a host should be accepted or denied, by comparing with the tables in memory.


Field Summary
private  java.util.ArrayList accesses
          A table of integer constants (ALLOW or DENY), specifying the access
(package private) static int ALLOW
           
(package private) static int BEGINS_ENDS_META
           
(package private) static int BEGINS_META
           
(package private) static int DENY
           
(package private) static int ENDS_META
           
private  java.util.ArrayList hosts
          A table of Strings, specifying the host
(package private) static int NO_META
           
(package private) static int NOT_FOUND
           
 
Constructor Summary
AccessVerifier(java.lang.String filename)
          Builds a new AccessVerifier following the directives written in the ASCII file passed as parameter.
 
Method Summary
private  int getAccess(java.lang.String hostname)
          Checks the access directive for a given host.
 boolean shouldAcceptThisClient(java.lang.String clientName)
          Checks whether a client is acceptable or not.
 boolean shouldAcceptThisServer(java.lang.String serverName)
          Checks whether a server is acceptable or not.
static void warnDeniedClient(java.io.OutputStream is)
          Sends a message which informs that the proxy refuses connection from client.
static void warnDeniedServer(java.io.OutputStream is, java.lang.String deniedSite)
          Sends a message which informs that the proxy denies access to a server.
private static void writeWarningMsg(java.io.OutputStream is, java.lang.String warnMsg)
          Sends an HTML message into the connection stream.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

ALLOW

static final int ALLOW

DENY

static final int DENY

NOT_FOUND

static final int NOT_FOUND

NO_META

static final int NO_META

BEGINS_META

static final int BEGINS_META

ENDS_META

static final int ENDS_META

BEGINS_ENDS_META

static final int BEGINS_ENDS_META

accesses

private java.util.ArrayList accesses
A table of integer constants (ALLOW or DENY), specifying the access

hosts

private java.util.ArrayList hosts
A table of Strings, specifying the host
Constructor Detail

AccessVerifier

public AccessVerifier(java.lang.String filename)
               throws java.io.IOException,
                      UnrecognizedCfglineException
Builds a new AccessVerifier following the directives written in the ASCII file passed as parameter.
Parameters:
filename - the name of the file containing the directives
Method Detail

getAccess

private int getAccess(java.lang.String hostname)
               throws java.util.NoSuchElementException
Checks the access directive for a given host.
Parameters:
hostname - the host's name
Returns:
a constant (ALLOW, DENY or NOT_FOUND) describing the access, following the directives of this AccessVerifier object

shouldAcceptThisClient

public boolean shouldAcceptThisClient(java.lang.String clientName)
Checks whether a client is acceptable or not.
Parameters:
clientName - the client's name
Returns:
true if the client is acceptable, false elsewhere

shouldAcceptThisServer

public boolean shouldAcceptThisServer(java.lang.String serverName)
Checks whether a server is acceptable or not.
Parameters:
serverName - the server's name
Returns:
true if the server is acceptable, false elsewhere

warnDeniedClient

public static void warnDeniedClient(java.io.OutputStream is)
Sends a message which informs that the proxy refuses connection from client.
Parameters:
is - the stream of the connection

warnDeniedServer

public static void warnDeniedServer(java.io.OutputStream is,
                                    java.lang.String deniedSite)
Sends a message which informs that the proxy denies access to a server.
Parameters:
is - the stream of the connection
deniedSite - the name of the denied server

writeWarningMsg

private static void writeWarningMsg(java.io.OutputStream is,
                                    java.lang.String warnMsg)
Sends an HTML message into the connection stream.
Parameters:
is - the stream of the connection
warnMsg - the body message