Variable Modifiers

Modifiers can be used when working with variables. Modifiers can alter the value of variables or otherwise modify the way variables are managed and values assigned. Using variable modifiers requires a special syntax. You must place modifiers within square brackets ([ ]) following the variable name inside the curly braces ({ }) as shown below:

${prefix.Variable-Name[Modifier]}

For example, the toLower modifier tells the server to use lower case when looking up a user regardless of the case used when the username was entered. A property definition that uses this modifier to set the variable User-Name to lower case is defined as follows:

ReadUserFile-SearchKey = ${packet.Base-User-Name[toLower]}

When using modifiers in a search list, the modifier applies only to the current variable in the list and must be applied to each variable as required. For example:

${request.User-Name[toLower]:request.Called-Station-Id} ${request.User-Name:request.Called-Station-Id[toLower]}
The first statement lowers only the User-Name variable, the second statement lowers only the Called-Station-Id variable.

The variable modifiers available are listed in the following table:

Modifier Description
asString Converts any value, scalar, list, or map, into a simple string.
count Evaluates the the count of values for an attribute. The count is one for scalar and map values, and is the count of elements in a list (multi-value) value.
length Returns the number of characters in the string representation of the variable.

Example

'abc' ==> '3'

exists The modifier returns a boolean (false or true) depending on whether the reference exists.
missingIsError The modifier causes mapping error if attribute is missing. Otherwise, it evalutes as the input value.
emptyIsMissing The modifier returns missing (null) if attribute value is an empty string.
emptyIsError The modifier causes mapping error if attribute value is an empty string.
indirect The variable contains text that names a different variable. This text does not include the ${ and } markers. The new value is the contents of the named variable.

Example

user.varname

eval The variable contains text that gives a complete reference expression . This text requires the ${ and } markers. The new value is the evaluated reference expression.

Example

${user.nas-ip-address:user.nas-identifier:0.0.0.0}

isDiameter Returns the value if the work item is a diameter item else returns null. Can be used in maps where different values are set based on the AAA protocol in use.
isRadius Returns the value if the work item is a RADIUS item else returns null. Can be used in maps where different values are set based on the AAA protocol in use.
toLower Converts a string to lower case.

Example

'This is a TEST' => 'this is a test'

toUpper Converts a string to upper case.

Example

'This is a TEST' => 'THIS IS A TEST'

trim Removes leading and trailing characters in the range 0x00 through 0x20. These are C0 control characters, and the space character.

Example

' stuff ' => 'stuff'

reverse Reverses characters in a string.

Example

'123 ' => ' 321'

toHex Converts a string into a hexadecimal representation. This only works properly if each character in the string is in the range 0x00 through 0xFF. Characters above this range will have the top byte ignored in this conversion.

Example

0x01 0x02 0xDE 0xAD => '0102DEAD'

fromHex Converts a string from hexadecimal notation. If an odd number characters is given, a leading zero is assumed.

Examples

'FF00EE11' => 0xFF 0x00 0xEE 0x11

'12345' => 0x01 0x23 0x45

toUnsigned64 Formats a string of exactly eight characters into a decimal string. The characters in the input string must be in the range 0x00 through 0xFF to work properly. The input represents the binary value of a unsigned 64 bit integer.

Example

0xFE 0xDC 0xBA 0x98 0x76 0x54 0x32 0x10 => '18364758544493064720'

fromUnsigned64 Converts a decimal formated string into exactly eight characters that contain the binary value of the unsigned 64 bit integer.

Example

'18364758544493064720' => 0xFE 0xDC 0xBA 0x98 0x76 0x54 0x32 0x10

toInteger64 Formats a string of exactly eight characters into a decimal string. The characters in the input string must be in the range 0x00 through 0xFF to work properly. The input represents the binary value of a signed 64 bit integer.

Example

0xFE 0xDC 0xBA 0x98 0x76 0x54 0x32 0x10 => '-81985529216486896'

fromInteger64 Converts a decimal formated string into exactly eight characters that contain the binary value of a signed 64 bit integer.

Example

'-81985529216486896' => 0xFE 0xDC 0xBA 0x98 0x76 0x54 0x32 0x10

toUnsigned32 Formats a string of exactly four characters into a decimal string. The characters in the input string must be in the range 0x00 through 0xFF to work properly. The input represents the binary value of a unsigned 32 bit integer.

Example

0xFE 0xDC 0xBA 0x98 => '4275878552'

fromUnsigned32 Converts a decimal formated string into exactly four characters that contain the binary value of the unsigned 32 bit integer.

Example

'4275878552' => 0xFE 0xDC 0xBA 0x98

toInteger32 Formats a string of exactly four characters into a decimal string. The characters in the input string must be in the range 0x00 through 0xFF to work properly. The input represents the binary value of a signed 32 bit integer.

Example

0xFE 0xDC 0xBA 0x98 => '-19088744'

fromInteger32 Converts a decimal formated string into exactly four characters that contain the binary value of the signed 32 bit integer.

Example

'-19088744' => 0xFE 0xDC 0xBA 0x98

toUnsigned16 Formats a string of exactly two characters into a decimal string. The characters in the input string must be in the range 0x00 through 0xFF to work properly. The input represents the binary value of a unsigned 16 bit integer.

Example

0xFE 0xDC => '65244'

fromUnsigned16 Converts a decimal formated string into exactly two characters that contain the binary value of the unsigned 16 bit integer.

Example

'65244' => 0xFE 0xDC

toInteger16 Formats a string of exactly two characters into a decimal string. The characters in the input string must be in the range 0x00 through 0xFF to work properly. The input represents the binary value of a signed 16 bit integer.

Example

0xFE 0xDC => '-292'

fromInteger16 Converts a decimal formated string into exactly two characters that contain the binary value of the signed 16 bit integer.

Example

'-292' => 0xFE 0xDC

toUnsigned8 Formats a string of exactly one character into a decimal string. The character of the input string must be in the range 0x00 through 0xFF in order to work properly. The input represents the binary value of a unsigned 8 bit integer.

Example

0xFE => '254'

fromUnsigned8 Converts a string in decimal format to exactly one character in the range 0x00 through 0xFF. The characters contain the binary representation of the unsigned 8 bit integer.

Example

'254' => 0xFE

toInteger8 Formats a string of exactly one character into a decimal string. The characters in the input string must be in the range 0x00 through 0xFF to work properly. The input represents the binary value of a signed 8 bit integer.

Example

0xFE => '-2'

fromInteger8 Converts a decimal formated string into exactly one character that contains the binary value of the signed 8 bit integer.

Example

'-2' => 0xFE

toFloat32 Formats a string of exactly four characters into a decimal string. The characters in the input string must be in the range 0x00 through 0xFF to work properly. The input represents the binary value of a signed 32 bit floating point number.
fromFloat32 Converts a string in decimal format to exactly four characters in the range 0x00 through 0xFF. The characters contain the binary representation of the 32 bit floating point number.
toFloat64 Formats a string of exactly eight characters into a decimal string. The characters in the input string must be in the range 0x00 through 0xFF to work properly. The input represents the binary value of a signed 64 bit floating point number.
fromFloat64 Converts a string in decimal format to exactly eight characters in the range 0x00 through 0xFF. The characters contain the binary representation of the 64 bit floating point number.
toLocalTimestamp Converts a string of exactly four characters into a timestamp. The characters in the input string must be in the range 0x00 through 0xFF in order to work properly. The four characters are assumed to be the big-endian binary representation of the number of seconds since the epoch. (Jan 1, 1970 GMT). The resulting date will be in the Java SimpleDateFormat pattern 'yyyy/MM/dd HH:mm:ss'. The date is displayed in the local timezone for the server Java Virtual Machine.

Example

0x00 0x00 0x00 0x00 => '1969/12/31 16:00:00' when executed in timezone GMT-8.

fromLocalTimestamp Converts a string in local timezone date format to exactly four characters in the range 0x00 through 0xFF. These bytes represent the big-endian binary value of seconds since the epoch (Jan 1, 1970 GMT).

Example

'1969/12/31 16:00:00' => 0x00 0x00 0x00 0x00 when executed in timezone GMT-8.

toGmtTimestamp Converts a string of exactly four characters into a timestamp. The characters in the input string must be in the range 0x00 through 0xFF in order to work properly. The four characters are assumed to be the big-endian binary representation of the number of seconds since the epoch. (Jan 1, 1970 GMT). The resulting date will be in the Java SimpleDateFormat pattern 'yyyy/MM/dd HH:mm:ss'. The date is displayed in the GMT timezone.

Example

0x00 0x00 0x00 0x00 => '1970/01/01 00:00:00'

fromGmtTimestamp Converts a string in GMT timezone date format to exactly four characters in the range 0x00 through 0xFF. These bytes represent the big-endian binary value of seconds since the epoch (Jan 1, 1970 GMT).

Example

'1970/01/01 00:00:00' => 0x00 0x00 0x00 0x00

toNtpLocalTimestamp Converts a string of exactly four characters into a timestamp. The characters in the input string must be in the range 0x00 through 0xFF in order to work properly. The four characters are assumed to be the big-endian binary representation of the number of seconds using the NTP epoch. The resulting date will be in the Java SimpleDateFormat pattern 'yyyy/MM/dd HH:mm:ss'. The date is displayed in the local timezone.

Example

0x83 0xAA 0x7E 0x80 => '1969/12/31 16:00:00'

fromNtpLocalTimestamp Converts a string in local timezone date format to exactly four characters in the range 0x00 through 0xFF. These bytes represent the big-endian binary value of seconds using the NTP epoch.

Example

'1969/12/31 16:00:00' => 0x83 0xAA 0x7E 0x80 when executed in timezone GMT-8.

toNtpGmtTimestamp Converts a string of exactly four characters into a timestamp. The characters in the input string must be in the range 0x00 through 0xFF in order to work properly. The four characters are assumed to be the big-endian binary representation of the number of seconds using the NTP epoch. The resulting date will be in the Java SimpleDateFormat pattern 'yyyy/MM/dd HH:mm:ss'. The date is displayed in the GMT timezone.

Example

0x83 0xAA 0x7E 0x80 => '1970/01/01 00:00:00'

fromNtpGmtTimestamp Converts a string in GMT timezone date format to exactly four characters in the range 0x00 through 0xFF. These bytes represent the big-endian binary value of seconds using the NTP epoch.

Example

'1970/01/01 00:00:00' => 0x83 0xAA 0x7E 0x80

toIPv4Addr Converts a string of exactly four characters into a dotted quad IP address. The characters in the input string must be in the range 0x00 through 0xFF in order to work properly.

Example

0x0A 0x00 0x00 0x01 => '10.0.0.1'

fromIPv4Addr Converts a dotted quad IP address into exactly four characters in the range 0x00 through 0xFF. These bytes represent the binary value of the IP address.

Example

'10.0.0.1' => 0x0A 0x00 0x00 0x01

toIPv6Addr Converts a string of exactly sixteen characters into human-readable IPv6 address. The characters in the input string must be in the range 0x00 through 0xFF in order to work properly.

Example

0x11 0x11 0x22 0x22 0x33 0x33 0x44 0x44 0x55 0x55 0x66 0x66 0x77 0x77 0x88 0x88 => '1111:2222:3333:4444:5555:6666:7777:8888'

fromIPv6Addr Converts an IPv6 address into exactly sixteen characters in the range 0x00 through 0xFF. These bytes represent the binary value of the IP address.

Example

'1111:2222:3333:4444:5555:6666:7777:8888' => 0x11 0x11 0x22 0x22 0x33 0x33 0x44 0x44 0x55 0x55 0x66 0x66 0x77 0x77 0x88 0x88

toNetworkAddress Converts a string of either 6 or 18 characters into a IPv4 or IPv6 address. The characters in the input string must be in the range 0x00 through 0xFF in order to work properly. The first two characters are 0x00, 0x01 for IPv4 and 0x00, 0x02 for IPv6.

Example

0x00 0x02 0xFF 0x02 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x01 => 'ff02::1'

fromNetworkAddress Converts an IP address into either 6 or 18 characters in the range 0x00 through 0xFF. These bytes represent the binary value of the IP address with the first two characters as 0x00, 0x01 for IPv4 and 0x00, 0x02 for IPv6.

Example

'ff02::1' => 0x00 0x02 0xFF 0x02 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x01

toBase64 Convert a string of any any length into a Base64 encoded string. (per RFC-1521). The characters of the input string should be in the range 0x00 through 0xFF in order to work properly.

Example

'This is a test.' => 'VGhpcyBpcyBhIHRlc3Qu'

fromBase64 Converts a string encoded in Base64 format into a decoded string. (per RFC-1521).

Example

'VGhpcyBpcyBhIHRlc3Qu' => 'This is a test.'

increment Increments a string in decimal format by one. An optional integer parameter can over-ride the increment value.

Examples

'1234' => '1235'

"100"[increment(10)] => '110'

decrement Decrements a string in decimal format by one. An optional integer parameter can over-ride the decrement value.

Examples

'1235' => '1234'

"100"[decrement(10)] => '90'

multiply Multiply a string in decimal format by the required single parameter.

Example

"6"[multiply(7)] => '42'

divide Divide a string in decimal format by the required single parameter.

Example

"256"[divide(16)] => '16'

escape Applies escaping to an input string.

Example

0x61 0x0D 0x0A 0x5C 0x20 => 'a\r\n\\ '

unescape Applies unescaped to an input string.

Example

'a\r\n\\ ' => 0x61 0x0D 0x0A 0x5C 0x20

quote Applies quoting to an input string.

Example

0x41 0x20 0x42 0x0A => '"A B\n"'

unquote Applies unquoting to an input string.

Example

'"A B\n"' => 0x41 0x20 0x42 0x0A

toMnId Converts a string of decimal digits to a packed decimal format used for modile node identifiers.

Example

'123456789012345' => 0x1E 0x32 0x54 0x76 0x98 0x10 0x32 0x54

fromMnId Converts a packed decimal format used for modile node identifiers to a string of decimal digits.

Example

0x1E 0x32 0x54 0x76 0x98 0x10 0x32 0x54 => '123456789012345'

toTbcd Converts a string of decimal digits to a packed decimal format used for telephone numbers.

Example

'1915306727577' => 0x91 0x51 0x03 0x76 0x72 0x75 0xF7

fromTbcd Converts a packed decimal format used for telephone numbers to a string of decimal digits.

Example

0x91 0x51 0x03 0x76 0x72 0x75 0xF7 => '1915306727577'

toUnicodeBigUnmarked Converts a string to a byte array using UnicodeBigUnmarked character encoding. Byte array is then converted to a string using Latin-1 character encoding.

Example

'password' => '\000p\000a\000s\000s\000w\000o\000r\000d'

fromUnicodeBigUnmarked Converts a string to a byte array using Latin-1 character encoding. Byte array is then converted to a string using UnicodeBigUnmarked character encoding.

Example

'\000p\000a\000s\000s\000w\000o\000r\000d' => 'password'

toUnicodeLitteUnmarked Converts a string to a byte array using UnicodeLittleUnmarked character encoding. Byte array is then converted to a string using Latin-1 character encoding.

Example

'password' => 'p\000a\000s\000s\000w\000o\000r\000d\000'

fromUnicodeLittleUnmarked Converts a string to a byte array using Latin-1 character encoding. Byte array is then converted to a string using UnicodeLittleUnmarked character encoding.

Example

'p\000a\000s\000s\000w\000o\000r\000d\000' => 'password'

toUtf8 Converts a string to a byte array using UTF-8 character encoding. Byte array is then converted to a string using Latin-1 character encoding.

Example

'u\u010denik' => 'u\304\215enik'

fromUtf8 Converts a string to a byte array using Latin-1 character encoding. Byte array is then converted to a string using UTF-8 character encoding.

Example

'u\304\215enik' => 'u\u010denik'

not Parses value as a boolean and returns the negated value.

Example

'true' => 'false'

toCode This modifier converts an EnumerationValue or a BooleanValue to an integer representation.
dLeft Split a input string on a delimiter and return the left portion.

Example

"user@realm"[dLeft(@)] => 'user'

dRight Split a input string on a delimiter and return the right portion.

Example

"user@realm"[dRight(@)] => 'realm'

nLeft Extracts the leftmost count of characters from a string.

Example

"1234567890"[nLeft(3)] => '123'

nRight Extracts the rightmost count of characters from a string.

Example

"1234567890"[nRight(3)] => '890'

substring Extracts the new string that is a substring of this string. Note that index starts from zero. If there are two parameters present, the substring begins with the character at the specified index and extends till the end index(excluding end index). If there is only one parameter present, the substring begins with the character at the specified index and extends to the end of the string. This is similar to java API's substring function.

Examples

"1234567890"[substring(3)] => '4567890'

"1234567890"[substring(3,6)] => '456'

formatLocalTimeStampWithMillis Formats a value of type TimestampValue into a string like the 'toLocalTimestamp' execept that a dot and three digits of milliseconds are appended. The format used is 'YYYY/MM/DD HH:mm:ss.SSS'.

Example

Timestamp => '1970/01/01 00:00:00.000'

formatGmtTimeStampWithMillis Formats a value of type TimestampValue into a string like the 'toGmtTimestamp' execept that a dot and three digits of milliseconds are appended. The format used is 'YYYY/MM/DD HH:mm:ss.SSS'.

Example

Timestamp => '1969/12/31 16:00:00.000'

toList Converts a value as a string into a list of values. The separator must be one of WS, LS, or a single character. If WS, then any number whitespace characters separate the input. If LS, then the system native end-of-line convention is used. Otherwise the parameter is used as-is.

Example

"a,b,c"[toList(",")] => list value containing values "a", "b", "c"

fromList Converts a list of values to a single string separated by a character. The separator must be one of WS, LS, or a single character. If WS, then any number whitespace characters separate the input. IF LS, then any end-of-line convention separates the input. (\n, \r\n, \r). Otherwise the parameter must be a single character.

Example

list value containing values "a", "b", "c" [fromList(",")] => "a,b,c"

removeDuplicates Removes duplicate values from a list of scalar values.

Example

list value containing values "a", "a", "b", "c" [removeDuplicates] => list value containing values "a", "b", "c"

require This modifier campares the first and only parameter to the reference value and either returns the value if equal, or null, if not equal. This modifier allows conditional assignment of a reference.
prohibit This modifier campares the first and only parameter to the reference value and either returns null if equal, or the value, if not equal. This modifier allows conditional assignment of a reference.
require-range This modifier uses two parameters to define a range: low and high. It then returns either the original value, if within the range, or null, if not. If the parameters can be parsed as numbers, the ranges will be applied numerically, otherwise, lexicographically.
prohibit-range This modifier uses two parameters to define a range: low and high. It then returns either the original value, if outside the range, or null, if not. If the parameters can be parsed as numbers, the ranges will be applied numerically, otherwise, lexicographically.
convert Allow conditional conversion of a value to a different value. If there are two parameters present, if the value equals the first parameter, the value is converted to the second parameter, otherwise, null is returned. If there are three parameters present, if the value equals the first parameter, the value is converted to the second parameter, otherwise the third parameter is returned.

Examples

"red"[convert(red,blue)] => 'blue'

"yellow"[convert(red,blue)] => null

"red"[convert(red,blue,green)] => 'blue'

"yellow"[convert(red,blue,green)] => 'green'

if Much like the 'convert' modifier, but only works with boolean values. If there is one parameter, return that parameter if input is true, else return null. If there are two paraameters, return the first parameter if the input is true, else return the second.

Examples

"true"[if(@)] => '@'

"false"[if(@)] => null

"true"[if(@,#)] => '@'

"false"[if(@,#)] => '#'

contains This modifier checks whether the input value contains the first and only parameter.

Examples

"the lazy dog"[contains(dog)] => true

"the lazy dog"[contains(frisky)] => false

within This modifier checks whether the input value is within the first and only parameter.

Examples

"dog"[within(the lazy dog)] => true

"frisky"[within(the lazy dog)] => false

isNumeric Return a boolean value, true if all decimal digits, false if otherwise.

Examples

"abc"[isNumeric] => 'false'

"123"[isNumeric] => 'true'

isName Returns a boolean value, true if all alphanumeric, dash, underscore, period, or at-sign.

Examples

"test-case"[isName] => 'true'

"favorite color"[isName] => 'false'

lettersOrDigits Returns a string containing only letters and digits from the input.

Example

"00-11-22-33-44-55"[lettersOrDigits] => '001122334455'

normalizeMacAddress Returns a string in a dash seperated format promoted by RFC 3580 for MAC addresses in Calling-Station-Id attribute. Input string needs to be 6 characters binary, 12 hex characters, or the 17 character format supported by RFC 3580.

Example

"001122aabbcc"[normalizeMacAddress] => '00-11-22-AA-BB-CC'

millisBeforeNow For attributes defined in the dictionary as one of the timestamp value types, this modifier returns the number of milliseconds the timestamp occured before the current time.
millisAfterNow For attributes defined in the dictionary as one of the timestamp value types, this modifier returns the number of milliseconds the timestamp occured after the current time.
localRadiusSockets Given a desired number of slots (outstanding requests) for RADIUS proxy, build a list of local socket descriptors for the Radius plug-in. A minium of one descriptor will be returned.

Examples

"0"[localRadiusSockets] => '*'

"256"[localRadiusSockets] => '*'

"500"[localRadiusSockets] => '*,*'

AAA-AVPair Build text for tunneling in the VA-AVPair attribute.

Examples

"bar"[AAA-AVPair(foo)] => 'foo=bar'

"bar,bar"[AAA-AVPair(foo)] => 'foo="bar,bar"'

FromDuration Converts a duration string into exactly four characters that contain the binary value of the unsigned 32 bit integer in seconds. The optional parameter is the default units for the duration, if none are specified. These consist of 'ms', 's', 'm', 'h'. It is an error if no default is specified, and the input string doesn't include a units indication.

Examples

"1000"[fromDuration(ms)] => 0x00 0x00 0x00 0x01

"10m"[fromDuration] => 0x00 0x00 0x02 0x58

toCert Convert a Base64 encoded string to a X509CertificateValue.
details Convert a X509CertificateValue to a string describing the fields contined in the certificate.
field Extracts a field from a X509CertificateValue. Valid fields are: version, serialNumber, subjectDN, issuerDN, notAfter, notBefore, sigAlgName, sigAlgOID, cRLDistributionPoint, subjectAltName, issuerALtName, and authorityInfoAccess.
get Returns a value from a list of values. Requires a single numeric index parameter greater than zero. If index paramter is greater than the number of value in the list a null value is returned causing the assignment to be skipped.

Example

"a,b,c"[toList(","),get(2)] => b

toNumeric Attempts to convert a value to a numeric value. Useful when attempt to compare untyped variables in the new mapping language.
first Returns the first value from a multi-value value.
last Returns the last value from a multi-value value.
random Returns a random value from a multi-value value.
shuffle Randomly orders a multi-value value.
keepStructure Makes a copy of a multi-value value, and marks it such that when added to a group value, the structure is maintained as multi-value value, rather than flattening.
getPlaintextPassword Given a user, retrieves a plaintext password from the security_users file. If not available, returns null.

Examples

'bob' -> 'bob-secret'

'unknown-user' -> null

logValueClass Logs the Java class of the value being modified at DEBUG log level. Used to debug value conversion issues in policy flow.
replace Replaced by the ':=' assignment operator.

Right-hand Side Allowed: false

No Longer Used: true

weak Replaced by the '?=' assignment operator.

Right-hand Side Allowed: false

No Longer Used: true

append Replaced by the '+=' assignment operator.

Right-hand Side Allowed: false

No Longer Used: true

toPrime Converts CK and IK in an AKA-Quintet value to CK' and IK' using original CK, IK, AUTN, and the provided access network identity per 3GPP TS 33.402.