Package org.forgerock.openig.el
Class Functions
java.lang.Object
org.forgerock.openig.el.Functions
Methods exposed for EL usage.
-
Method Summary
Modifier and TypeMethodDescriptionstatic String[]
Create an array of String based on the strings given as parameters.static Boolean
static boolean
Returnstrue
if the object contains the value.static String
decodeBase64
(String value) Decode the given Base64 String input.static String
decodeBase64url
(String value) Decode the given Base64url String input.static byte[]
digestSha256
(Object incoming) Calculate the SHA256 hash of the incoming object, which may be a byte array or a string.static String
encodeBase64
(Object value) Encode the given String input into Base64.static String
encodeBase64url
(Object value) Encode the given String input into Base64url.static String
Returns the String representation of the URL denoting the given file.static boolean
Attempts to find the next subsequence of the input sequence that matches the regular expression.static String[]
findGroups
(String input, String regex) Returns an array containing the result of a find on a regular expression against a string, ornull
if no result is found.static int
Returns the index within a string of the first occurrence of a specified substring.static Integer
static Integer
integerWithRadix
(String value, int radix) static boolean
Matches an IP (either v4 or v6) with a IP range using the Classless inter-domain routing (CIDR) formalism.static String
Joins an array orIterable
values into a single string value, using thetoString()
result from each value and separated by the specified separator.static String
Returns the first key found in a map that matches the specified regular expression pattern, ornull
if no such match is found.static int
Returns the number of items in a collection, or the number of characters in a string.static boolean
Deprecated, for removal: This API element is subject to removal in a future version.since 7.2.0, with OPENIG-5793.static boolean
matchesWithRegex
(String input, String regex) Returnstrue
if the string matches the specified regular expression pattern.static String[]
matchingGroups
(String value, String pattern) Deprecated, for removal: This API element is subject to removal in a future version.since 7.2.0, with OPENIG-5957.static String
Returns the String representation of the URL denoting the given path.static Certificate
pemCertificate
(Object incoming) Convert the incoming CharSequence, which is expected to be a PEM format certificate, into a certificate.static String
Returns the content of the given file as a plain String.static Properties
readProperties
(String filename) Returns the content of the given file as aProperties
.static String
readWithCharset
(String filename, String charsetName) Returns the content of the given file as a plain String using a specificCharset
.static String[]
Splits a string into an array of substrings around matches of the given regular expression.static Object
Parse/Un-marshal the input String into a JSON structure.static String
toLowerCase
(String value) Converts all of the characters in a string to lower case.static String
Returns the string value of an arbitrary object.static String
toUpperCase
(String value) Converts all of the characters in a string to upper case.static String
Returns a copy of a string with leading and trailing whitespace omitted.static String
Returns the URL decoding of the provided string.static String
Returns the URL encoding of the provided string.
-
Method Details
-
array
Create an array of String based on the strings given as parameters.- Parameters:
values
- the strings to put in the array.- Returns:
- the array of strings.
-
integer
Transforms aString
to anInteger
. If the parameter is not a valid integer (in radix 10) then it returns null.- Parameters:
value
- theString
containing the integer representation to be parsed- Returns:
- the integer represented by the string argument in the radix 10.
-
integerWithRadix
- Parameters:
value
- theString
containing the integer representation to be parsedradix
- the radix to be used while parsings
.- Returns:
- the integer represented by the string argument in the specified radix.
-
bool
Transforms aString
to anBoolean
. The rules for the transformation are the same as the ones described onBoolean.valueOf(String)
.- Parameters:
value
- theString
containing the boolean representation to be parsed- Returns:
- the boolean represented by the string argument.
-
contains
Returnstrue
if the object contains the value.- Parameters:
object
- the object to be searched.value
- the value to find.- Returns:
- the length of the object, or
0
if length could not be determined.
-
indexOf
Returns the index within a string of the first occurrence of a specified substring.- Parameters:
value
- the string to be searched.substring
- the value to search for within the string- Returns:
- the index of the first instance of substring, or
-1
if not found.
-
join
Joins an array orIterable
values into a single string value, using thetoString()
result from each value and separated by the specified separator.- Parameters:
separator
- the separator to place between joined elements.values
- the values to be joined.- Returns:
- the string containing the joined values.
-
keyMatch
Returns the first key found in a map that matches the specified regular expression pattern, ornull
if no such match is found.- Parameters:
map
- the map whose keys are to be searched.pattern
- a string containing the regular expression pattern to match.- Returns:
- the first matching key, or
null
if no match found.
-
length
Returns the number of items in a collection, or the number of characters in a string.- Parameters:
value
- the object whose length is to be determined.- Returns:
- the length of the object, or
0
if length could not be determined.
-
matches
@Deprecated(since="7.2.0", forRemoval=true) public static boolean matches(String value, String pattern) Deprecated, for removal: This API element is subject to removal in a future version.since 7.2.0, with OPENIG-5793. Usefind(String, String)
ormatchesWithRegex(String, String)
instead.Returnstrue
if the string contains the specified regular expression pattern.- Parameters:
value
- the string to be searched.pattern
- a string containing the regular expression pattern to find.- Returns:
true
if the string contains the specified regular expression pattern.
-
find
Attempts to find the next subsequence of the input sequence that matches the regular expression.- Parameters:
input
- The input on which the regular expression must apply.regex
- A string containing the regular expression.- Returns:
true
if the regular expression is found in the given input,false
if the input is null or if the regular expression does not match.- See Also:
-
matchesWithRegex
Returnstrue
if the string matches the specified regular expression pattern.- Parameters:
input
- The input on which the regular expression must apply.regex
- A string containing the regular expression.- Returns:
true
if the string contains the specified regular expression pattern,false
if the input is null or if the regular expression does not match.
-
matchingGroups
@Deprecated(since="7.2.0", forRemoval=true) public static String[] matchingGroups(String value, String pattern) Deprecated, for removal: This API element is subject to removal in a future version.since 7.2.0, with OPENIG-5957. UsefindGroups(String, String)
instead.Returns an array containing the matches of a regular expression pattern against a string, ornull
if no 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.- Parameters:
value
- the string to be searched.pattern
- a string containing the regular expression pattern to match.- Returns:
- an array of matches, or
null
if no match found.
-
findGroups
Returns an array containing the result of a find on a regular expression against a string, ornull
if no result 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.- Parameters:
input
- The string to be searched.regex
- A string containing the regular expression regex to find.- Returns:
- an array of the found matches, or
null
if no match found. - See Also:
-
split
Splits a string into an array of substrings around matches of the given regular expression.- Parameters:
value
- the string to be split.regex
- the regular expression to split substrings around.- Returns:
- the resulting array of split substrings.
-
toJson
Parse/Un-marshal the input String into a JSON structure.- Parameters:
value
- The stringified-JSON.- Returns:
- an un-marshalled JSON structure or null if anything went wrong during parsing.
-
toLowerCase
Converts all of the characters in a string to lower case.- Parameters:
value
- the string whose characters are to be converted.- Returns:
- the string with characters converted to lower case.
-
toString
Returns the string value of an arbitrary object.- Parameters:
value
- the object whose string value is to be returned.- Returns:
- the string value of the object.
-
toUpperCase
Converts all of the characters in a string to upper case.- Parameters:
value
- the string whose characters are to be converted.- Returns:
- the string with characters converted to upper case.
-
trim
Returns a copy of a string with leading and trailing whitespace omitted.- Parameters:
value
- the string whose white space is to be omitted.- Returns:
- the string with leading and trailing white space omitted.
-
urlEncode
Returns the URL encoding of the provided string.- Parameters:
value
- the string to be URL encoded, which may benull
.- Returns:
- the URL encoding of the provided string, or
null
ifstring
wasnull
.
-
urlDecode
Returns the URL decoding of the provided string.- Parameters:
value
- the string to be URL decoded, which may benull
.- Returns:
- the URL decoding of the provided string, or
null
ifstring
wasnull
.
-
encodeBase64
Encode the given String input into Base64.- Parameters:
value
- the object to be base64 encoded, which may benull
aCharSequence
or abyte
[].- Returns:
- the Base64 encoding of the provided string, or
null
ifstring
wasnull
.
-
decodeBase64
Decode the given Base64 String input.- Parameters:
value
- the string to be Base64 decoded, which may benull
.- Returns:
- the decoding of the provided string, or
null
ifstring
wasnull
or if the input was not a Base64 valid input.
-
encodeBase64url
Encode the given String input into Base64url.- Parameters:
value
- the object to be Base64url encoded, which may benull
aCharSequence
or abyte
[].- Returns:
- the Base64url encoding of the provided string, or
null
ifstring
wasnull
.
-
decodeBase64url
Decode the given Base64url String input.- Parameters:
value
- the string to be Base64url decoded, which may benull
.- Returns:
- the decoding of the provided string, or
null
ifstring
wasnull
or if the input was not a Base64url valid input.
-
read
Returns the content of the given file as a plain String. The file must be UTF-8 encoded.- Parameters:
filename
- The file to read- Returns:
- the file content as a String or null if here was an error (missing file, ...)
-
readWithCharset
Returns the content of the given file as a plain String using a specificCharset
. -
readProperties
Returns the content of the given file as aProperties
.- Parameters:
filename
- file to be read- Returns:
- the file content as
Properties
or null if here was an error (missing file, ...)
-
pathToUrl
Returns the String representation of the URL denoting the given path.- Parameters:
path
- the path to build the URL from.- Returns:
- the String representation of the URL denoting the given path.
-
fileToUrl
Returns the String representation of the URL denoting the given file.- Parameters:
file
- the file to build the URL from.- Returns:
- the String representation of the URL denoting the given file.
-
pemCertificate
Convert the incoming CharSequence, which is expected to be a PEM format certificate, into a certificate.- Parameters:
incoming
- The incoming CharSequence- Returns:
- The certificate or null if
incoming
is either null, not a CharSequence, empty or if certificate reconstruction failed for any reason.
-
digestSha256
Calculate the SHA256 hash of the incoming object, which may be a byte array or a string.- Parameters:
incoming
- The incoming object, which may be a byte array or a CharSequence (anything else returns null).- Returns:
- The SHA256 hash as an array of byte, or null if the hash could not be calculated.
-
ipMatch
Matches an IP (either v4 or v6) with a IP range using the Classless inter-domain routing (CIDR) formalism.- Parameters:
ip
- the IP to check (either v4 or v6)ipPattern
- the CIDR pattern defining an IP range.- Returns:
- whether the IP is included in the specified IP range or not.
-