issrg.test.rbac
Class PermisRBACTest

java.lang.Object
  extended by issrg.pba.rbac.Time
      extended by issrg.pba.rbac.Clock
          extended by issrg.test.rbac.PermisRBACTest
All Implemented Interfaces:
java.lang.Comparable
Direct Known Subclasses:
PMITest

public class PermisRBACTest
extends Clock

This class is an application that processes a batch of user/target/action requests in a fashion very similar to SamleAEF. It outputs the results of processing the batch line by line. It is possible to compare the results of processing with different versions of PERMIS RBAC. If the results differ, then the code changed inconsistently.

The batch file has the following format: # comments
# and empty lines are allowed
[instruction]: [what to do]

An instruction can be: "inc" - include another batch file; "ini" - initialise Permis RBAC, "env" - set an environmental parameter, "usr" - getCreds for the given user, "arg" - set an argument, "act" - set an action name, "tgt" - set a target name, "..." - same instruction as above, which is used to group multi-line settings.

E.g.:
env: clock=2005-10-23T0:0
...: balance=0
env: clock=2005-01-01T0:0

In the above example the first two environmental settings relate to the same environment. The third line is in another environment. Later the application will try both environments individually.

The application will try the specified environments, users, actions and targets in the sequence that the file states them.

The algorithm of processing the batch is as follows:
"ini:", "env:" and "arg:"+"act:" are multi-line settings. The settings are grouped into one collection as described above for "ini:". Other settings are one-line, and are collected irrespective of whether they are grouped or not. The settings between one "ini:" group and another "ini:" group are treated as a single test suite.


Field Summary
static java.io.PrintWriter out
           
 
Fields inherited from class issrg.pba.rbac.Time
log, s_defaultTimeZone, TIME_TYPE
 
Constructor Summary
PermisRBACTest()
           
 
Method Summary
 java.util.Date getTime()
          This method returns the time returned by the last call to latch, so all calculations will be consistent.
 PermisRBAC init(java.util.Map setup, java.io.File parentDir)
          This method is called to create a PermisRBAC object using the current setup.
 java.util.Date latch()
          The time is stopped forever, so the latch returns the same as getTime()
static void main(java.lang.String[] args)
           
 void process(java.lang.String[] args, java.lang.String encoding)
           
 void setInitValue(java.util.Map setup, java.lang.String var, java.lang.String val)
          This method is called to set init values for Permis RBAC in this test.
 void setTime(java.util.Date time)
          This method sets the current time.
static void test(java.lang.String[] args, PermisRBACTest pt, boolean append)
           
static java.util.Date toTime(java.lang.String timeString)
          This method returns the time encoded as a string.
 
Methods inherited from class issrg.pba.rbac.Clock
getEvaluationTime
 
Methods inherited from class issrg.pba.rbac.Time
calendarToTime, calendarToTime, compareTo, equals, getDefaultTimeZone, parse, register, setDefaultTimeZone, setDefaultTimeZone, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

out

public static java.io.PrintWriter out
Constructor Detail

PermisRBACTest

public PermisRBACTest()
Method Detail

main

public static void main(java.lang.String[] args)

test

public static void test(java.lang.String[] args,
                        PermisRBACTest pt,
                        boolean append)

process

public void process(java.lang.String[] args,
                    java.lang.String encoding)

init

public PermisRBAC init(java.util.Map setup,
                       java.io.File parentDir)
                throws java.lang.Exception
This method is called to create a PermisRBAC object using the current setup. After this the work of PermisRBAC object will be tested using the standard methods to getCreds and decision.

Parameters:
setup - the Map of values collected prior to init
parentDir - the directory in which the config file is located and all relative paths should be computed relative to it
Throws:
java.lang.Exception

setInitValue

public void setInitValue(java.util.Map setup,
                         java.lang.String var,
                         java.lang.String val)
                  throws PbaException
This method is called to set init values for Permis RBAC in this test. The strings are guaranteed to be intern() values, so they can be compared using ==, which is faster.

Throws:
PbaException

latch

public java.util.Date latch()
The time is stopped forever, so the latch returns the same as getTime()

Specified by:
latch in class Clock
Returns:
the current time

getTime

public java.util.Date getTime()
Description copied from class: Clock
This method returns the time returned by the last call to latch, so all calculations will be consistent.

Specified by:
getTime in class Clock
Returns:
the time returned by the last call to latch

toTime

public static java.util.Date toTime(java.lang.String timeString)
                             throws java.lang.IllegalArgumentException
This method returns the time encoded as a string.

Parameters:
timeString - - the time to set; the format is the same as the string representation of time in the policy, e.g. "2005-09-25T23:59:59"
Returns:
the Date representing the specified time.
Throws:
java.lang.IllegalArgumentException

setTime

public void setTime(java.util.Date time)
This method sets the current time. Initially the time is set to the time of the application startup.

Parameters:
time - - the time to set.