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 Booleanstatic booleanReturnstrueif the object contains the value.static StringdecodeBase64(String value) Decode the given Base64 String input.static StringdecodeBase64url(String value) Decode the given Base64url String input.static CertificatederCertificate(Object incoming) Convert the incomingCharSequence, which is expected to be a DER format certificate as defined in rfc9440, into aCertificate.static byte[]digestSha256(Object incoming) Calculate the SHA256 hash of the incoming object, which may be a byte array or a string.static StringencodeBase64(Object value) Encode the given String input into Base64.static StringencodeBase64url(Object value) Encode the given String input into Base64url.static StringReturns the String representation of the URL denoting the given file.static booleanAttempts 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, ornullif no result is found.static intReturns the index within a string of the first occurrence of a specified substring.static Integerstatic IntegerintegerWithRadix(String value, int radix) static booleanMatches an IP (either v4 or v6) with a IP range using the Classless inter-domain routing (CIDR) formalism.static StringJoins an array orIterablevalues into a single string value, using thetoString()result from each value and separated by the specified separator.static StringReturns the first key found in a map that matches the specified regular expression pattern, ornullif no such match is found.static intReturns the number of items in a collection, or the number of characters in a string.static booleanDeprecated, for removal: This API element is subject to removal in a future version.since 7.2.0, with OPENIG-5793.static booleanmatchesWithRegex(String input, String regex) Returnstrueif 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 StringReturns the String representation of the URL denoting the given path.static CertificatepemCertificate(Object incoming) Convert the incomingCharSequence, which is expected to be a PEM format certificate, into aCertificate.static StringReturns the content of the given file as a plain String.static PropertiesreadProperties(String filename) Returns the content of the given file as aProperties.static StringreadWithCharset(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 ObjectParse/Un-marshal the input String into a JSON structure.static StringtoLowerCase(String value) Converts all of the characters in a string to lower case.static StringReturns the string value of an arbitrary object.static StringtoUpperCase(String value) Converts all of the characters in a string to upper case.static StringReturns a copy of a string with leading and trailing whitespace omitted.static StringReturns the URL decoding of the provided string.static StringReturns 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 aStringto anInteger. If the parameter is not a valid integer (in radix 10) then it returns null.- Parameters:
value- theStringcontaining the integer representation to be parsed- Returns:
- the integer represented by the string argument in the radix 10.
-
integerWithRadix
- Parameters:
value- theStringcontaining 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 aStringto anBoolean. The rules for the transformation are the same as the ones described onBoolean.valueOf(String).- Parameters:
value- theStringcontaining the boolean representation to be parsed- Returns:
- the boolean represented by the string argument.
-
contains
Returnstrueif the object contains the value.- Parameters:
object- the object to be searched.value- the value to find.- Returns:
- the length of the object, or
0if 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
-1if not found.
-
join
Joins an array orIterablevalues 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, ornullif 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
nullif 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
0if 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.Returnstrueif 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:
trueif 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:
trueif the regular expression is found in the given input,falseif the input is null or if the regular expression does not match.- See Also:
-
matchesWithRegex
Returnstrueif 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:
trueif the string contains the specified regular expression pattern,falseif 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, ornullif 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
nullif no match found.
-
findGroups
Returns an array containing the result of a find on a regular expression against a string, ornullif 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
nullif 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
nullifstringwasnull.
-
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
nullifstringwasnull.
-
encodeBase64
Encode the given String input into Base64.- Parameters:
value- the object to be base64 encoded, which may benullaCharSequenceor abyte[].- Returns:
- the Base64 encoding of the provided string, or
nullifstringwasnull.
-
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
nullifstringwasnullor 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 benullaCharSequenceor abyte[].- Returns:
- the Base64url encoding of the provided string, or
nullifstringwasnull.
-
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
nullifstringwasnullor 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
Propertiesor 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 incomingCharSequence, which is expected to be a PEM format certificate, into aCertificate.- Parameters:
incoming- The incoming CharSequence.- Returns:
- The certificate or null if
incomingis either null, not aCharSequence, empty or if certificate reconstruction failed for any reason.
-
derCertificate
Convert the incomingCharSequence, which is expected to be a DER format certificate as defined in rfc9440, into aCertificate.- Parameters:
incoming- The incoming object that represents a DER certificate.- Returns:
- The certificate or null if
incomingis either null, not aCharSequence, does not have a valid prefix and suffix, 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.
-