issrg.pba.rbac
Class IntersectionValidityPeriod

java.lang.Object
  extended by issrg.pba.rbac.SubsetCredentials
      extended by issrg.pba.rbac.DefaultValidityPeriodBehaviour
          extended by issrg.pba.rbac.IntersectionValidityPeriod
All Implemented Interfaces:
Credentials, ValidityPeriod, java.lang.Cloneable

public class IntersectionValidityPeriod
extends DefaultValidityPeriodBehaviour

This class is an intersection of ValidityPeriods. It is used when the intersection cannot be precomputed, e.g. when a AdjustedValidityPeriod is intersected with another ValidityPeriod, or when RelativeValidityPeriods are intersected - the results of both intersections will depend on the current time.


Constructor Summary
protected IntersectionValidityPeriod()
           
  IntersectionValidityPeriod(ValidityPeriod v1, ValidityPeriod v2)
          This constructor builds an intersection of two ValidityPeriods.
 
Method Summary
 java.lang.Object clone()
          This method creates a copy of the credentials object.
 boolean contains(Credentials c)
          Generally, this method tests that both ValidityPeriods contain the given ValidityPeriod (the condition that the intersection of sets contains the given value).
 java.util.Date getNotAfter()
          Generally this method returns the earliest notAfter time of the two ValidityPeriods.
 java.util.Date getNotBefore()
          Generally, this method returns the latest of the notBefore times of the ValidityPeriods.
 boolean isNull()
          This method tells the caller if this intersection of validity periods is null or not.
 java.lang.String toString()
           
 
Methods inherited from class issrg.pba.rbac.DefaultValidityPeriodBehaviour
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
 

Constructor Detail

IntersectionValidityPeriod

protected IntersectionValidityPeriod()

IntersectionValidityPeriod

public IntersectionValidityPeriod(ValidityPeriod v1,
                                  ValidityPeriod v2)
This constructor builds an intersection of two ValidityPeriods. They are treated equally, and any of them can be null. If either of them is null, then the result of getNotBefore and getNotAfter is provided by the non-null ValidityPeriod.

Parameters:
v1 - - one ValidityPeriod
v2 - - another ValidityPeriod
Method Detail

getNotBefore

public java.util.Date getNotBefore()
Generally, this method returns the latest of the notBefore times of the ValidityPeriods.

If either of the ValidityPeriods is a AdjustedValidityPeriod, the result is the notBefore time of the periods adjusted against each other. If neither of the ValidityPeriods is an AdjustedValidityPeriod, then the latest notBefore time of the two is returned.

Returns:
the Date specifying the latest notBefore time of the two periods, or null, if it is not constrained ("valid from time immemorial")

getNotAfter

public java.util.Date getNotAfter()
Generally this method returns the earliest notAfter time of the two ValidityPeriods.

If either of the ValidityPeriods is a AdjustedValidityPeriod, then the notAfter time of the result of adjusting one period against the other is returned. If neither of them is an AdjustedValidityPeriod, then the earliest notAfter time of the two ValidityPeriods is returned.

Returns:
the Date specifying the earliest notAfter time of the two periods, or null, if it is not constrained ("valid forever")

contains

public boolean contains(Credentials c)
Generally, this method tests that both ValidityPeriods contain the given ValidityPeriod (the condition that the intersection of sets contains the given value).

This method overrides the inherited behaviour of the contains method to treat the AdjustedValidityPeriods differently. If neither of the Validity Periods in the intersection is an AdjustedValidityPeriod, or the given Credentials is not a ValidityPeriod, the inherited method determines whether the given Credentials is contained in this ValidityPeriod.

If either of the ValidityPeriods in the intersection is an AdjustedValidityPeriod, such validity period is adjusted against the given ValidityPeriod. The result of adjustment must still contain the given ValidityPeriod.

Specified by:
contains in interface Credentials
Overrides:
contains in class DefaultValidityPeriodBehaviour
Parameters:
c - - the Credentials that must be contained in the intersection of the ValidityPeriods (e.g. another ValidityPeriod or a SetOfSubsetsCredentials containing multiple ValidityPeriods)
Returns:
true, if the intersection of the validity periods contains the given Credentials
See Also:
SetOfSubsetsCredentials

isNull

public boolean isNull()
This method tells the caller if this intersection of validity periods is null or not.


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