Functions
A set of built-in functions that can be called from within expressions, which are described in "Expressions".
array
array(strings...)
Returns an array of the strings given as argument.
- strings
Strings to put in the array.
- array
Resulting array of containing the given strings.
boolean
bool(string)
Returns a Boolean with a value represented by the specified string.
The returned Boolean represents a true value if the string argument is not null
and is equal to the string "true"
, ignoring case.
- string
String containing the boolean representation.
- Boolean
Boolean value represented by the string.
contains
contains(object, value)
Returns true
if the object contains the specified value. If the object is a string, a substring is searched for the value. If the object is a collection or array, its elements are searched for the value.
- object
Object to search for.
- value
Value to search for.
- true
If the object contains the specified value.
decodeBase64
decodeBase64(string)
Returns the base64-decoded string, or null
if the string is not valid base64.
- string
Base64-encoded string to decode.
- string
Base64-decoded string.
decodeBase64url
decodeBase64url(string)
Returns the decoded value of the provided base64url-encoded string, or null
if the string was not valid base64url.
- string
Base64url-encoded string to decode.
- string
Base64url-decoded string.
digestSha256
digestSha256(byte array or string)
Calculates the SHA-256 hash of an incoming object.
- byte array or string
The bytes to be hashed. If a string is provided, this function uses the UTF-8 charset to get the bytes from the string.
- byte array
SHA-256 hash as a byte array, or null if the hash could not be calculated.
encodeBase64
encodeBase64(string)
Returns the base64-encoded string, or null
if the string is null
.
- string
String to encode into base64.
- string
Base64-encoded string.
encodeBase64url
encodeBase64url(string)
Returns the base64url-encoded string, or null
if the string is null
.
- string
String to encode into base64url.
- string
Base64url-encoded string.
fileToUrl
fileToUrl(file)
Converts a java.io.File
into a string representation for the URL of the file or directory.
- file
File or directory for which to build the URL.
For example,
${fileToUrl(openig.configDirectory)}/myProperties.json
.
- file
String representation for the URL of the file or directory, or
null
if the file or directory isnull
.For example,
file:///home/gcostanza/.openig/config/myProperties.json
.
formDecodeParameterNameOrValue
formDecodeParameterNameOrValue(string)
Returns the string that results from decoding the provided form encoded parameter name or value as per application/x-www-form-urlencoded
, which can be null
if the input is null
.
- string
Parameter name or value.
- string
String resulting from decoding the provided form encoded parameter name or value as per
application/x-www-form-urlencoded
.
formEncodeParameterNameOrValue
formEncodeParameterNameOrValue(string)
Returns the string that results from form encoding the provided parameter name or value as per application/x-www-form-urlencoded
, which can be null
if the input is null
.
- string
Parameter name or value.
- string
String resulting from form encoding the provided parameter name or value as per
application/x-www-form-urlencoded
.
indexOf
indexOf(string, substring)
Returns the index within a string of the first occurrence of a specified substring.
- string
String in which to search for the specified substring.
- substring
Value to search for within the string.
- number
Index of the first instance of substring, or -1 if not found.
The index count starts from 1, not 0.
integer
integer(string)
Transforms the string parameter into an integer. If the parameter is not a valid number in radix 10, returns null.
- string
String containing the integer representation.
- integer
Integer value represented by the string.
integerWithRadix
integer(string, radix)
Uses the radix as the base for the string, and transforms the string into a base-10 integer. For example:
("20", 8)
: Transforms20
in base8
, and returns16
.("11", 16)
Transforms11
in base16
, and returns17
.
If either parameter is not a valid number, returns null.
- string
String containing the integer representation, and an integer containing the radix representation.
- integer
Integer value in base-10.
ipMatch
ipMatch(string, string)
Returns true
if the provided IP address matches the range provided by the Classless Inter-Domain Routing (CIDR), or false
otherwise.
- string
IP address of a request sender, in IPv4 or IPv6
- string
CIDR defining an IP address range
- Boolean
true
orfalse
join
join(values, separator)
Returns a string joined with the given separator, using either of the following values:
Array of strings (
String[]
)Iterable value (
Iterable<String>
)
The function uses the toString
result from each value.
- separator
Separator to place between joined values.
- strings
Array of values to be joined.
- string
String containing the joined values.
keyMatch
keyMatch(map, pattern)
Returns the first key found in a map that matches the specified regular expression pattern, or null
if no such match is found.
- map
Map whose keys are to be searched.
- pattern
String containing the regular expression pattern to match.
- string
First matching key, or
null
if no match found.
length
length(object)
Returns the number of items in a collection, or the number of characters in a string.
- object
Object whose length is to be determined.
- number
Length of the object, or 0 if length could not be determined.
matchingGroups
matchingGroups(string, pattern)
Returns an array of matching groups for the specified regular expression pattern applied to the specified string, or null
if no such match is found. The first element of the array is the entire match, and each subsequent element correlates to any capture group specified within the regular expression.
- string
String to be searched.
- pattern
String containing the regular expression pattern to match.
- array
Array of matching groups, or
null
if no such match is found.
matches
matches(string, pattern)
Returns true
if the string contains a match for the specified regular expression pattern.
- string
String to be searched.
- pattern
String containing the regular expression pattern to find.
- true
String contains the specified regular expression pattern.
pathToUrl
pathToUrl(path)
Converts the given path into the string representation of its URL.
- path
Path of a file or directory as a string.
For example,
${pathToUrl(system['java.io.tmpdir'])}
.
- string
String representation for the URL of the path, or
null
if the path isnull
.For example,
file:///var/tmp
.
pemCertificate
(string)
Convert the incoming character sequence into a certificate.
- string
Character sequence representing a PEM-formatted certificate
- string
A
Certificate
instance, or null if the function failed to load a certificate from the incoming object.
read
read(string)
Takes a file name as a string, interprets the content of the file with the UTF-8 character set, and returns the content of the file as a plain string.
Provides the absolute path to the file, or a path relative to the location of the Java system property user.dir
.
- string
Name of the file to read.
- string
Content of the file, or
null
on error.
readProperties
readProperties(string)
Takes a Java Properties file name as a string
, and returns the content of the file as a key/value map of properties, or null
on error (due to the file not being found, for example).
Either provide the absolute path to the file, or a path relative to the location of the Java system property user.dir
.
For example, to get the value of the key
property in the properties file /path/to/my.properties
, use ${readProperties('/path/to/my.properties')['key']}
.
- string
Name of the Java Properties file to read.
- object
Key/value map of properties or
null
on error.
readWithCharset
readWithCharset(string, charset)
Takes a file name as a string, interprets the content of the file with the specified Java character set, and returns the content of the file as a plain string.
- string
Name of the file to read.
Provides the absolute path to the file, or a path relative to the location of the Java system property
user.dir
.- charset
Name of a Java character set with which to interpret the file, as described in Class Charset.
- string
Content of the file, or
null
on error.
split
split(string, pattern)
Splits the specified string into an array of substrings around matches for the specified regular expression pattern.
- string
String to be split.
- pattern
Regular expression to split substrings around.
- array
Resulting array of split substrings.
toJson
toJson(JSON string)
Converts a JSON string to a JSON structure.
- JSON string
JSON string representing a JavaScript object.
For example, the string value contained in
contexts.amSession.properties.userDetails
contains the JSON object{"email":"test@example.com"}
.
- JSON structure
JSON structure, or
null
on error.In the expression
"${toJson(contexts.amSession.properties.userDetails).email}"
, the string value is treated as JSON, and the expression evaluates totest@example.com
.
toLowerCase
toLowerCase(string)
Converts all of the characters in a string to lower case.
- string
String whose characters are to be converted.
- string
String with characters converted to lower case.
toString
toString(object)
Returns the string value of an arbitrary object.
- object
Object whose string value is to be returned.
- string
String value of the object.
toUpperCase
toUpperCase(string)
Converts all of the characters in a string to upper case.
- string
String whose characters are to be converted.
- string
String with characters converted to upper case.
trim
trim(string)
Returns a copy of a string with leading and trailing whitespace omitted.
- string
String whose white space is to be omitted.
- string
String with leading and trailing white space omitted.
urlDecode
urlDecode(string)
Returns the URL decoding of the provided string.
This is equivalent to "formDecodeParameterNameOrValue".
- string
String to be URL decoded, which may be
null
.
- string
URL decoding of the provided string, or
null
if string wasnull
.
urlEncode
urlEncode(string)
Returns the URL encoding of the provided string.
This is equivalent to "formEncodeParameterNameOrValue".
- string
String to be URL encoded, which may be
null
.
- string
URL encoding of the provided string, or
null
if string wasnull
.
urlDecodeFragment
urlDecodeFragment(string)
Returns the string that results from decoding the provided URL encoded fragment as per RFC 3986, which can be null
if the input is null
.
- string
URL encoded fragment.
- string
String resulting from decoding the provided URL encoded fragment as per RFC 3986.
urlDecodePathElement
urlDecodePathElement(string)
Returns the string that results from decoding the provided URL encoded path element as per RFC 3986, which can be null
if the input is null
.
- string
The path element.
- string
String resulting from decoding the provided URL encoded path element as per RFC 3986.
urlDecodeQueryParameterNameOrValue
urlDecodeQueryParameterNameOrValue(string)
Returns the string that results from decoding the provided URL encoded query parameter name or value as per RFC 3986, which can be null
if the input is null
.
- string
Parameter name or value.
- string
String resulting from decoding the provided URL encoded query parameter name or value as per RFC 3986.
urlDecodeUserInfo
urlDecodeUserInfo(string)
Returns the string that results from decoding the provided URL encoded userInfo as per RFC 3986, which can be null
if the input is null
.
- string
URL encoded userInfo.
- string
String resulting from decoding the provided URL encoded userInfo as per RFC 3986.
urlEncodeFragment
urlEncodeFragment(string)
Returns the string that results from URL encoding the provided fragment as per RFC 3986, which can be null
if the input is null
.
- string
Fragment.
- string
The string resulting from URL encoding the provided fragment as per RFC 3986.
urlEncodePathElement
urlEncodePathElement(string)
Returns the string that results from URL encoding the provided path element as per RFC 3986, which can be null
if the input is null
.
- string
Path element.
- string
String resulting from URL encoding the provided path element as per RFC 3986.
urlEncodeQueryParameterNameOrValue
urlEncodeQueryParameterNameOrValue(string)
Returns the string that results from URL encoding the provided query parameter name or value as per RFC 3986, which can be null
if the input is null
.
- string
Parameter name or value.
- string
String resulting from URL encoding the provided query parameter name or value as per RFC 3986.
urlEncodeUserInfo
urlEncodeUserInfo(string)
Returns the string that results from URL encoding the provided userInfo as per RFC 3986, which can be null
if the input is null
.
- string
userInfo.
- string
String resulting from URL encoding the provided userInfo as per RFC 3986.
More Information
Some functions are provided by org.forgerock.openig.el.Functions.
Other functions are provided by org.forgerock.http.util.Uris.