issrg.pba.rbac
Class RelativeValidityPeriod

java.lang.Object
  extended by issrg.pba.rbac.SubsetCredentials
      extended by issrg.pba.rbac.DefaultValidityPeriodBehaviour
          extended by issrg.pba.rbac.RelativeValidityPeriod
All Implemented Interfaces:
Credentials, ValidityPeriod, java.lang.Cloneable
Direct Known Subclasses:
AdjustedValidityPeriod, NowValidityPeriod

public class RelativeValidityPeriod
extends DefaultValidityPeriodBehaviour

This is a class representing a ValidityPeriod relative to the current time. Its notBefore and notAfter time depend on the time of evaluation and are specified as an offset from the current time.

A positive offset to the notBefore end of the period means it is in the past from now (and a negative means it is in the future from now). A positive offset to the notAfter end of the period means it is in the future from now (and a negative means it is in the past from now).


Field Summary
protected  RelativeDate na
           
protected  RelativeDate nb
           
protected  boolean notAfter
           
protected  Clock theClock
          This is the actual clock used for calculating relative periods.
protected  boolean unlimited
           
 
Constructor Summary
protected RelativeValidityPeriod()
           
  RelativeValidityPeriod(int years, int months, int days, int hours, int minutes, int seconds, boolean notAfter)
          The integers specify how many years, months, etc to add (you can use negative values as well) to Now to get notBefore or notAfter date.
  RelativeValidityPeriod(int nbYears, int nbMonths, int nbDays, int nbHours, int nbMinutes, int nbSeconds, int naYears, int naMonths, int naDays, int naHours, int naMinutes, int naSeconds)
          This constructor lets build a RelativeValidityPeriod by specifying offsets for both the notBefore and notAfter ends explicitly.
  RelativeValidityPeriod(RelativeDate rd, boolean notAfter)
          This constructor builds the object using a reference to a ready to use RelativeDate object.
  RelativeValidityPeriod(RelativeDate notBefore, RelativeDate notAfter)
          This constructor specifies a RelativeValidityPeriod with the given RelativeDates of the notBefore and notAfter ends.
 
Method Summary
 java.lang.Object clone()
          This method creates a copy of the credentials object.
 java.util.Date getNotAfter()
          This method returns the notAfter time offset from current time (as provided by the Clock).
 java.util.Date getNotBefore()
          This method returns the notBefore time offset from current time (as provided by the Clock).
 java.lang.String toString()
           
 
Methods inherited from class issrg.pba.rbac.DefaultValidityPeriodBehaviour
contains, intersection
 
Methods inherited from class issrg.pba.rbac.SubsetCredentials
equals, union
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface issrg.pba.Credentials
union
 

Field Detail

theClock

protected Clock theClock
This is the actual clock used for calculating relative periods. At construction time it is copied from the CustomisePERMIS.systemClock variable.


unlimited

protected boolean unlimited

notAfter

protected boolean notAfter

nb

protected RelativeDate nb

na

protected RelativeDate na
Constructor Detail

RelativeValidityPeriod

protected RelativeValidityPeriod()

RelativeValidityPeriod

public RelativeValidityPeriod(int years,
                              int months,
                              int days,
                              int hours,
                              int minutes,
                              int seconds,
                              boolean notAfter)
The integers specify how many years, months, etc to add (you can use negative values as well) to Now to get notBefore or notAfter date. If notAfter flag is true, the integers will specify a notAfter; otherwise it specifies notBefore. The other end of the period is infinite.

Parameters:
years - - the offset in years
months - - the offset in months
days - - the offset in days
hours - - the offset in hours
minutes - - the offset in minutes
seconds - - the offset in seconds
notAfter - - the flag specifying whether this is the offset for notAfter or notBefore; if true, the specified offset is for notAfter, otherwise for notBefore; the other end of the period is infinite.

RelativeValidityPeriod

public RelativeValidityPeriod(RelativeDate rd,
                              boolean notAfter)
This constructor builds the object using a reference to a ready to use RelativeDate object. The meaning of the notAfter flag is the same, as in RelativeValidityPeriod(int,int,int,int,int,int,boolean) constructor.

Parameters:
rd - - the RelativeDate
notAfter - - the flag telling if it is the RelativeDate of the notAfter or notBefore

RelativeValidityPeriod

public RelativeValidityPeriod(int nbYears,
                              int nbMonths,
                              int nbDays,
                              int nbHours,
                              int nbMinutes,
                              int nbSeconds,
                              int naYears,
                              int naMonths,
                              int naDays,
                              int naHours,
                              int naMinutes,
                              int naSeconds)
This constructor lets build a RelativeValidityPeriod by specifying offsets for both the notBefore and notAfter ends explicitly. All nb* parameters specify the notBefore offset, all na* parameters specify the notAfter offset.


RelativeValidityPeriod

public RelativeValidityPeriod(RelativeDate notBefore,
                              RelativeDate notAfter)
This constructor specifies a RelativeValidityPeriod with the given RelativeDates of the notBefore and notAfter ends.

Parameters:
notBefore - - the RelativeDate of the notBefore end of the period
notAfter - - the RelativeDate of the notAfter end of the period
Method Detail

getNotBefore

public java.util.Date getNotBefore()
This method returns the notBefore time offset from current time (as provided by the Clock). The offset is subtracted from now, i.e. the positive offset moves the end into the past.

Returns:
the absolute Date computed from now, or null, if the validity period is unlimited on this end (lasts since the time immemorial)

getNotAfter

public java.util.Date getNotAfter()
This method returns the notAfter time offset from current time (as provided by the Clock). The offset is added to now, i.e. the positive offset moves the end into the future.

Returns:
the absolute Date computed from now, or null, if the validity period is unlimited on this end (lasts forever)

clone

public java.lang.Object clone()
Description copied from class: SubsetCredentials
This method creates a copy of the credentials object. Requires overriding in implementations of subclasses.

Specified by:
clone in interface Credentials
Specified by:
clone in class SubsetCredentials
Returns:
a copy of the credentials object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object