SK.gnome.dwarf.mail.sample
Class ConsoleCommand

java.lang.Object
  extended bySK.gnome.dwarf.GenericService
      extended bySK.gnome.dwarf.GenericServer
          extended bySK.gnome.dwarf.thread.ThreadServer
              extended bySK.gnome.dwarf.mail.smtp.proc.MailAgent
                  extended bySK.gnome.dwarf.mail.sample.ConsoleCommand
All Implemented Interfaces:
Preprocessing, SK.gnome.dwarf.Reportable, java.lang.Runnable, SK.gnome.dwarf.Server, SK.gnome.dwarf.Service

public class ConsoleCommand
extends MailAgent
implements Preprocessing

Provides agent for remote execution of console commands.

The agent is activated by a message to postmaster's address with subject equal to the "console command" string. The message body must consist of two lines with the authentication information (username and password) and one or more lines with the console commands to be executed. The output from executed commands is sent back to the sender address in a new mail message.

Please note that this agent is only for testing purposes since it may open a security hole, therefore do not use it in a production server!


Field Summary
 
Fields inherited from class SK.gnome.dwarf.mail.smtp.proc.MailAgent
context, required
 
Fields inherited from class SK.gnome.dwarf.thread.ThreadServer
daemon, thread
 
Fields inherited from class SK.gnome.dwarf.GenericService
initParameters, parent
 
Fields inherited from interface SK.gnome.dwarf.Service
INITIALIZED, LOG_DEBUG, LOG_ERROR, LOG_FATAL, LOG_INFO, LOG_TRACE, LOG_WARN, LOG_XFER, SHUTDOWN, STARTED, STOPPED
 
Constructor Summary
ConsoleCommand(java.lang.String name)
          Creates a new ConsoleCommand agent.
 
Method Summary
protected  void preprocess(MailAgentMessage message, java.util.Collection recipients)
          Processes the message.
 
Methods inherited from class SK.gnome.dwarf.mail.smtp.proc.MailAgent
destroy, filter, init, init, isRequired, postprocess, setRequired, storeMessage
 
Methods inherited from class SK.gnome.dwarf.thread.ThreadServer
enableThread, finish, loop, run, setDaemon, shutdown, start, stop
 
Methods inherited from class SK.gnome.dwarf.GenericServer
addService, addService, getAuthenticator, getLogger, getParameters, getService, getServices, getServices, removeService, report
 
Methods inherited from class SK.gnome.dwarf.GenericService
getAuthFacility, getFullName, getInitParameter, getInitParameterNames, getLogFacility, getName, getPrincipal, getShutdownTimeout, getState, log, log, login, logout, setAuthFacility, setInitParameters, setLogFacility, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface SK.gnome.dwarf.Service
getFullName, getName, getState, log, log, login, logout
 

Constructor Detail

ConsoleCommand

public ConsoleCommand(java.lang.String name)
Creates a new ConsoleCommand agent.

Parameters:
name - the service name
Method Detail

preprocess

protected void preprocess(MailAgentMessage message,
                          java.util.Collection recipients)
                   throws java.io.IOException,
                          MailException
Description copied from class: MailAgent
Processes the message.

This method is called on the agent only once for each message, just after it has arrived to the mail queue. In order to let this happen, the agent must implement the Preprocessing interface.

The recipients argument is a collection of Recipient objects representing the message recipients, as returned after processing by the mail filter chain. This collection is always non-empty.

Overrides:
preprocess in class MailAgent
Parameters:
message - the queued message
recipients - collection of recipients
Throws:
MailException - if an error occured
java.io.IOException - if an I/O error occured


Copyright (c) 2004-2005, Gnome Ltd. All rights reserved.