Enforcer provides the following cateogries of Oasis functions accessible from ALFA. These functions can be used as part of an expression inside a policy.
To make use of these functions from inside an ALFA file, use the import statement:
import Oasis.Functions
import Enforcer.Functions
Arithmetic Functions
The following arithmetic functions exist:
Integer Modulo
Namespace : Oasis.Functions
function Mod = "urn:oasis:names:tc:xacml:1.0:function:integer-mod" : input:integer mod:integer -> integer
Takes two integers, performs integer division and returns the remainder.
Example
The following function would return 1.
Mod(7, 3)
Integer Absolute
Namespace : Oasis.Functions
function IntegerAbs = "urn:oasis:names:tc:xacml:1.0:function:integer-abs" : input:integer -> integer
Takes an integer value and returns the absolute value as an integer.
Example
The following functions would return 7.
IntegerAbs(-7)
IntegerAbs(7)
Double Absolute
Namespace : Oasis.Functions
function DoubleAbs = "urn:oasis:names:tc:xacml:1.0:function:double-abs" : input:double -> double
Takes a double value and returns the absolute value as a double.
Example
The following functions would return 7.2.
DoubleAbs(-7.2)
DoubleAbs(7.2)
Round
Namespace : Oasis.Functions
function Round = "urn:oasis:names:tc:xacml:1.0:function:round" : input:double -> double
| input:double precision:integer -> double
This signature has two overloads. The first takes a double and rounds to the nearest whole number. The second overload accepts an integer to specify the rounding precision.
Example
The following function would return 7.46.
Round(7.456, 2)
Floor
Namespace : Oasis.Functions
function Floor = "urn:oasis:names:tc:xacml:1.0:function:floor" : input:double -> double
Takes a double and rounds downwards, returning the floor of the value.
Example
The following function would return 7.
Floor(7.456)