eu.xtreemos.xosd.vops.xacml.utils
Class TimeInRangeFunction

java.lang.Object
  extended by com.sun.xacml.cond.FunctionBase
      extended by eu.xtreemos.xosd.vops.xacml.utils.TimeInRangeFunction
All Implemented Interfaces:
com.sun.xacml.cond.Function

public class TimeInRangeFunction
extends com.sun.xacml.cond.FunctionBase

This class implements the proposed time-in-range function, which takes three time values and returns true if the first value falls between the second and the third value. This is not currently a standard XACML function, though it has been proposed to the TC and is being considered for XACML 2.0 (inclusion is quite likely). If approved, this function is likely to be "standard" than the 2.0 release, since this has been proposed as an errata item (this functionality was supposed to be handled in 1.0). This function is not currently in the standard XACML namespace, but will be moved there as soon as it has been approved.

Note that this function allows any time ranges less than 24 hours. In other words, it is not bound by normal day boundries (midnight GMT), but by the minimum time in the range. This means that ranges like 9am-5pm are supported, as are ranges like 5pm-9am.

Since:
1.1
Author:
seth proctor

Field Summary
static long MILLIS_PER_DAY
          The number of milliseconds in a day
static long MILLIS_PER_MINUTE
          The number of milliseconds in a minute
static java.lang.String NAME
          The identifier for this function
 
Fields inherited from class com.sun.xacml.cond.FunctionBase
FUNCTION_NS
 
Constructor Summary
TimeInRangeFunction()
          Default constructor.
 
Method Summary
 com.sun.xacml.cond.EvaluationResult evaluate(java.util.List inputs, com.sun.xacml.EvaluationCtx context)
          Evaluates the time-in-range function, which takes three TimeAttribute values.
private  long handleWrap(long time)
          Private helper method that handles when a time value wraps no more than 24 hours either above 23:59:59 or below 00:00:00.
private  long resolveTime(com.sun.xacml.attr.TimeAttribute middleTime, com.sun.xacml.attr.TimeAttribute otherTime)
          Private helper method that is used to resolve the correct values for min and max.
 
Methods inherited from class com.sun.xacml.cond.FunctionBase
checkInputs, checkInputsNoBag, evalArgs, getFunctionId, getFunctionName, getIdentifier, getReturnType, getReturnTypeAsString, makeProcessingError, returnsBag
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME

public static final java.lang.String NAME
The identifier for this function

See Also:
Constant Field Values

MILLIS_PER_MINUTE

public static final long MILLIS_PER_MINUTE
The number of milliseconds in a minute

See Also:
Constant Field Values

MILLIS_PER_DAY

public static final long MILLIS_PER_DAY
The number of milliseconds in a day

See Also:
Constant Field Values
Constructor Detail

TimeInRangeFunction

public TimeInRangeFunction()
Default constructor.

Method Detail

evaluate

public com.sun.xacml.cond.EvaluationResult evaluate(java.util.List inputs,
                                                    com.sun.xacml.EvaluationCtx context)
Evaluates the time-in-range function, which takes three TimeAttribute values. This function return true if the first value falls between the second and third values (ie., on or after the second time and on or before the third time). If no time zone is specified for the second and/or third time value, then the timezone from the first time value is used. This lets you say time-in-range(current-time, 9am, 5pm) and always have the evaluation happen in your current-time timezone.

Parameters:
inputs - a List of Evaluatable objects representing the arguments passed to the function
context - the respresentation of the request
Returns:
an EvaluationResult containing true or false

resolveTime

private long resolveTime(com.sun.xacml.attr.TimeAttribute middleTime,
                         com.sun.xacml.attr.TimeAttribute otherTime)
Private helper method that is used to resolve the correct values for min and max. If an explicit timezone is provided for either, then that value gets used. Otherwise we need to pick the timezone the middle time is using, and move the other time into that timezone.


handleWrap

private long handleWrap(long time)
Private helper method that handles when a time value wraps no more than 24 hours either above 23:59:59 or below 00:00:00.