edu.sdsc.inca.protocol
Class MessageHandler

java.lang.Object
  extended by edu.sdsc.inca.protocol.MessageHandler
Direct Known Subclasses:
GetLog, LogConfig, Permit, Ping, VerifyProtocolVersion

public abstract class MessageHandler
extends java.lang.Object

The MessageHandler class should help guide the creation of all of the message handlers for each Inca server.


Field Summary
protected static org.apache.log4j.Logger logger
          logger that can be used by all MessageHandlers.
 
Constructor Summary
MessageHandler()
           
 
Method Summary
static void errorReply(ProtocolWriter writer, java.lang.String msg)
          A convenience method that logs and writes an error message.
abstract  void execute(ProtocolReader reader, ProtocolWriter writer, java.lang.String dn)
          Service an incoming request from a specified client DN, using specified i/o streams.
static void forbid(java.lang.String dn, java.lang.String action)
          Indicate that a specified DN may no longer perform a specified action.
static boolean isPermitted(java.lang.String dn, java.lang.String action)
          Returns true iff a specified DN may perform a specified action.
static void permit(java.lang.String dn, java.lang.String action)
          Indicate that a specified DN may perform a specified action.
static java.lang.String[] permittees(java.lang.String action)
          Returns the set of DNs permitted to perform a specified action, or null if no permissions have been registered for that action.
static void resetPermissions()
          Removes all permissions--useful for testing.
static void setPermissionsPath(java.lang.String path)
          Sets the path where DN permissions should be stored.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final org.apache.log4j.Logger logger
logger that can be used by all MessageHandlers.

Constructor Detail

MessageHandler

public MessageHandler()
Method Detail

setPermissionsPath

public static void setPermissionsPath(java.lang.String path)
Sets the path where DN permissions should be stored.

Parameters:
path - path to the permissions file

forbid

public static void forbid(java.lang.String dn,
                          java.lang.String action)
Indicate that a specified DN may no longer perform a specified action.

Parameters:
dn - the entity DN
action - the action now forbidden to the DN

isPermitted

public static boolean isPermitted(java.lang.String dn,
                                  java.lang.String action)
Returns true iff a specified DN may perform a specified action. All DNs are allowed to perform all actions by default; specific permission is required only for actions where some entity has been granted specific permission.

Parameters:
dn - the entity DN
action - the action to test
Returns:
true iff the DN may perform the action

permit

public static void permit(java.lang.String dn,
                          java.lang.String action)
Indicate that a specified DN may perform a specified action.

Parameters:
dn - the entity DN
action - the action to test

permittees

public static java.lang.String[] permittees(java.lang.String action)
Returns the set of DNs permitted to perform a specified action, or null if no permissions have been registered for that action.

Parameters:
action - the action to test
Returns:
an array of DNs permitted to perform the action, or null if no DNs have been registered for the action

resetPermissions

public static void resetPermissions()
Removes all permissions--useful for testing.


execute

public abstract void execute(ProtocolReader reader,
                             ProtocolWriter writer,
                             java.lang.String dn)
                      throws java.lang.Exception
Service an incoming request from a specified client DN, using specified i/o streams. Close the reader and writer to indicate that the client connection should be closed.

Parameters:
reader - the reader connected to the client
writer - the writer connected to the client
dn - the DN of the client, null if no authentication
Throws:
java.lang.Exception

errorReply

public static void errorReply(ProtocolWriter writer,
                              java.lang.String msg)
A convenience method that logs and writes an error message.

Parameters:
writer - the writer to use to send the error message
msg - the error message