org.owasp.orizon.core
Class Engine

java.lang.Object
  extended by org.owasp.orizon.core.Trackable
      extended by org.owasp.orizon.core.Engine
Direct Known Subclasses:
Dawn, Dusk, Library, Mirage, Osh, Tornado, Twilight

public abstract class Engine
extends Trackable

This is the abstract class that must be implemented from the Orizon's engines.

Since:
1.1.0
Author:
thesp0nge

Field Summary
static int engineCantTrace
           
static int engineMissingTraceName
           
static int engineStartErrno
           
protected  int errno
           
protected  java.lang.String errstr
           
protected  java.util.Vector<Reportable> faults
           
protected  boolean has_faults
           
protected  boolean has_output
           
protected  boolean initialized
           
protected  java.lang.String inputName
           
static int O_E_DELIVER
           
static int O_E_ERROR
           
static int O_E_IDLE
           
static int O_E_PAUSED
           
static int O_E_READY
           
static int O_E_RUNNING
           
static int O_E_STOPPED
           
protected  java.lang.String prompt
           
protected  java.lang.String ps1
           
protected  ConsoleReader reader
           
protected  java.util.Vector<Rule> rules
           
protected  Stats s
           
protected  boolean silence
           
protected  int status
           
protected  long t0
           
protected  long t1
           
protected  long time
           
 
Fields inherited from class org.owasp.orizon.core.Trackable
trace, traceName
 
Constructor Summary
Engine()
           
 
Method Summary
 void addFault(Reportable r)
           
 boolean canOutput()
          Check if this engine can output something or not.
 boolean canPause()
          Check if the engine can be paused.
 boolean canRun()
          Check if the engine can be run.
 boolean canStop()
          Check if the engine can be stopped.
 void debug(java.lang.String s)
           
 java.lang.String errorString()
           
abstract  boolean exec(java.lang.String command)
          Engine specific execute command routine.
protected  boolean exitOnFailure(int code, java.lang.String message)
           
 void feed(java.util.Vector<Rule> rules)
           
 java.lang.String getAppName()
           
 java.lang.String getElapsedStatement()
           
 int getErrno()
           
 java.util.Vector<Reportable> getFaults()
           
 java.util.HashMap<java.lang.String,java.lang.String> getProperties()
           
 long getScanMills()
           
 Stats getStats()
           
 long getTimer()
           
 boolean hasFaults()
           
 boolean hasOutput()
          Check if the engine has some output ready to be delivered.
abstract  boolean init()
          Initialize the engine.
 boolean isPaused()
           
protected  boolean isRunning()
           
 boolean isStopped()
           
 boolean isTestMode()
           
 boolean isTurnedOn()
          Check if the engine has been properly initialized.
abstract  boolean pause()
          Pause the engine.
 long pauseTimer()
           
protected abstract  boolean process(java.lang.Object n)
          Engine specific freecc tree generated root node management routine.
 void reset()
          Resets the engine to its ready status.
 void resetTimer()
           
 void setAppName(java.lang.String appname)
           
 void setErrorString(java.lang.String s)
           
 void setProperties(java.util.HashMap<java.lang.String,java.lang.String> properties)
           
 void setReader(ConsoleReader reader)
           
 void setStats(Stats s)
           
 void setTestMode()
           
abstract  boolean shell()
          Engine specific interactive shell.
abstract  boolean start()
          Start the engine.
 long startTimer()
           
abstract  boolean stop()
          Stop the engine.
 long stopTimer()
           
 
Methods inherited from class org.owasp.orizon.core.Trackable
getTraceName, isTrace, setTrace, setTraceName, trace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

O_E_IDLE

public static final int O_E_IDLE
See Also:
Constant Field Values

O_E_ERROR

public static final int O_E_ERROR
See Also:
Constant Field Values

O_E_RUNNING

public static final int O_E_RUNNING
See Also:
Constant Field Values

O_E_STOPPED

public static final int O_E_STOPPED
See Also:
Constant Field Values

O_E_PAUSED

public static final int O_E_PAUSED
See Also:
Constant Field Values

O_E_DELIVER

public static final int O_E_DELIVER
See Also:
Constant Field Values

O_E_READY

public static final int O_E_READY
See Also:
Constant Field Values

engineStartErrno

public static final int engineStartErrno
See Also:
Constant Field Values

engineMissingTraceName

public static final int engineMissingTraceName
See Also:
Constant Field Values

engineCantTrace

public static final int engineCantTrace
See Also:
Constant Field Values

initialized

protected boolean initialized

has_output

protected boolean has_output

t0

protected long t0

t1

protected long t1

time

protected long time

status

protected int status

errno

protected int errno

errstr

protected java.lang.String errstr

prompt

protected java.lang.String prompt

ps1

protected java.lang.String ps1

silence

protected boolean silence

inputName

protected java.lang.String inputName

rules

protected java.util.Vector<Rule> rules

has_faults

protected boolean has_faults

faults

protected java.util.Vector<Reportable> faults

reader

protected ConsoleReader reader

s

protected Stats s
Constructor Detail

Engine

public Engine()
Method Detail

init

public abstract boolean init()
Initialize the engine. The initialization status must be stored in the initialized variable.

Returns:
true if the engine can be initialized, or false otherwise.

start

public abstract boolean start()
Start the engine. Each engine will implement in this method its task.

Returns:
true if the engine started and performed its task, or false otherwise

pause

public abstract boolean pause()
Pause the engine.

Returns:
true if the engine can be paused, or false otherwise.

stop

public abstract boolean stop()
Stop the engine. Freeze engine's activities preparing it to release results.

Returns:
true if the engine can be stopped, or false otherwise

shell

public abstract boolean shell()
Engine specific interactive shell. OSH will permit users to interact with Orizon engines direct issuing them commands. For such a reason an interactive shell needs to be spawned.

Returns:
true if the shell can be spawned, or false otherwise.

exec

public abstract boolean exec(java.lang.String command)
Engine specific execute command routine. Each engine has to be able to receive commands from the outside (the shell o the SkyLine object), process them and giving back a result. This method will executes a command.

Parameters:
command - the command to execute
Returns:
true if the command has been executed, or false otherwise

process

protected abstract boolean process(java.lang.Object n)
Engine specific freecc tree generated root node management routine. This method will be called in exec() or shell() method giving the root node from the tree generated by each engine parser.

Parameters:
n - the root node
Returns:
true or false if the caller routine has to exit upon return.

reset

public void reset()
Resets the engine to its ready status.


isTurnedOn

public boolean isTurnedOn()
Check if the engine has been properly initialized.

Returns:
true if the engine can be used, or false otherwise.

canOutput

public boolean canOutput()
Check if this engine can output something or not.

Returns:
true if the engine is able to output something, or false otherwise.

canStop

public final boolean canStop()
Check if the engine can be stopped.

Returns:
true if the engine can be stopped, or false otherwise.

canPause

public final boolean canPause()
Check if the engine can be paused. Pausing a stopped engine has not meaning but... indeed for architectural consistency, actually you can.

Returns:
true if the engine can be paused, or false otherwise.

canRun

public final boolean canRun()
Check if the engine can be run.

Returns:
true if the engine can be run, or false otherwise.

hasOutput

public final boolean hasOutput()
Check if the engine has some output ready to be delivered.

Returns:
true if some output is ready to be delivered, or false otherwise.

isRunning

protected boolean isRunning()

isPaused

public boolean isPaused()

isStopped

public boolean isStopped()

setTestMode

public final void setTestMode()

isTestMode

public final boolean isTestMode()

debug

public final void debug(java.lang.String s)

startTimer

public final long startTimer()

pauseTimer

public final long pauseTimer()

resetTimer

public final void resetTimer()

stopTimer

public final long stopTimer()

getTimer

public final long getTimer()

getElapsedStatement

public final java.lang.String getElapsedStatement()

getScanMills

public final long getScanMills()

getErrno

public final int getErrno()

setErrorString

public final void setErrorString(java.lang.String s)

errorString

public final java.lang.String errorString()

setAppName

public final void setAppName(java.lang.String appname)

getAppName

public final java.lang.String getAppName()

exitOnFailure

protected final boolean exitOnFailure(int code,
                                      java.lang.String message)

feed

public final void feed(java.util.Vector<Rule> rules)

addFault

public final void addFault(Reportable r)

getFaults

public final java.util.Vector<Reportable> getFaults()

hasFaults

public final boolean hasFaults()

getProperties

public java.util.HashMap<java.lang.String,java.lang.String> getProperties()

setProperties

public void setProperties(java.util.HashMap<java.lang.String,java.lang.String> properties)

setReader

public final void setReader(ConsoleReader reader)

getStats

public final Stats getStats()

setStats

public final void setStats(Stats s)