edu.sdsc.inca.protocol
Class MessageHandler

java.lang.Object
  extended by edu.sdsc.inca.protocol.MessageHandler
Direct Known Subclasses:
StandardMessageHandler

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.


Nested Class Summary
static class MessageHandler.Permittee
           
static class MessageHandler.PermitteeGroup
           
 
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(java.io.OutputStream output, java.lang.String msg)
          A convenience method that logs and writes an error message.
abstract  void execute(ProtocolReader reader, java.io.OutputStream output, java.lang.String dn)
          Service an incoming request from a specified client DN, using specified i/o streams.
static java.util.List<MessageHandler.Permittee> getAllPermittees()
           
static java.lang.String getPermissionsAsXml()
           
static java.util.List<MessageHandler.Permittee> getPermittees(MessageHandler.PermitteeGroup group)
           
static java.util.List<MessageHandler.Permittee> getPermittees(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 boolean grantPeerPermission(java.lang.String name)
           
static boolean grantPermission(java.lang.String name, java.lang.String action)
          Indicate that a specified DN may perform a specified action.
static boolean isPermitted(java.lang.String name, java.lang.String action)
          Returns true iff a specified DN may perform a specified action.
static void resetPermissions()
          Removes all permissions--useful for testing.
static boolean revokeAllPermissions(java.lang.String action)
          Indicate that a specified DN may no longer perform a specified action.
static boolean revokePeerPermission(java.lang.String name)
           
static boolean revokePermission(java.lang.String name, java.lang.String action)
          Indicate that a specified DN may no longer perform a specified action.
static void setPermissionsFromXml(java.lang.String xml)
           
static void setPermissionsFromXml(java.lang.String xml, java.lang.String localDn)
           
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 - pathname of the permissions file

grantPermission

public static boolean grantPermission(java.lang.String name,
                                      java.lang.String action)
Indicate that a specified DN may perform a specified action.

Parameters:
name - the entity DN
action - the action to test
Returns:

revokePermission

public static boolean revokePermission(java.lang.String name,
                                       java.lang.String action)
Indicate that a specified DN may no longer perform a specified action.

Parameters:
name - the entity DN
action - the action now forbidden to the DN
Returns:

revokeAllPermissions

public static boolean revokeAllPermissions(java.lang.String action)
Indicate that a specified DN may no longer perform a specified action.

Parameters:
name - the entity DN
action - the action now forbidden to the DN
Returns:

grantPeerPermission

public static boolean grantPeerPermission(java.lang.String name)
Parameters:
name - the entity DN
Returns:

revokePeerPermission

public static boolean revokePeerPermission(java.lang.String name)
Parameters:
name -
Returns:

isPermitted

public static boolean isPermitted(java.lang.String name,
                                  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:
name - the entity DN
action - the action to test
Returns:
true iff the DN may perform the action

getPermittees

public static java.util.List<MessageHandler.Permittee> getPermittees(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

getPermittees

public static java.util.List<MessageHandler.Permittee> getPermittees(MessageHandler.PermitteeGroup group)
Parameters:
group -
Returns:

getAllPermittees

public static java.util.List<MessageHandler.Permittee> getAllPermittees()
Returns:

getPermissionsAsXml

public static java.lang.String getPermissionsAsXml()
Returns:

setPermissionsFromXml

public static void setPermissionsFromXml(java.lang.String xml)
                                  throws javax.xml.parsers.ParserConfigurationException,
                                         javax.xml.xpath.XPathExpressionException,
                                         org.xml.sax.SAXException,
                                         java.io.IOException
Parameters:
xml -
Throws:
javax.xml.parsers.ParserConfigurationException
javax.xml.xpath.XPathExpressionException
java.io.IOException
org.xml.sax.SAXException

setPermissionsFromXml

public static void setPermissionsFromXml(java.lang.String xml,
                                         java.lang.String localDn)
                                  throws javax.xml.parsers.ParserConfigurationException,
                                         javax.xml.xpath.XPathExpressionException,
                                         org.xml.sax.SAXException,
                                         java.io.IOException
Parameters:
xml -
localDn -
Throws:
javax.xml.parsers.ParserConfigurationException
javax.xml.xpath.XPathExpressionException
java.io.IOException
org.xml.sax.SAXException

resetPermissions

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


execute

public abstract void execute(ProtocolReader reader,
                             java.io.OutputStream output,
                             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
output - the output stream connected to the client
dn - the DN of the client, null if no authentication
Throws:
java.lang.Exception

errorReply

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

Parameters:
output - the output stream to use to send the error message
msg - the error message