Utility Module Reference

The Utility Module in ESB Enterprise Integrator helps to perform basic utility functions such as math, string, date, and signature. The connector will compute the result and save it to a property.

The following operations can be performed with this module.

string.Length

You can use the string.Length operation to retrieve the length of a string.

Operation details

Name Parameter Default Value Description
Input String inputString The string for which you need to identify the length. The string can contain any characters. It will also consider whitespace characters when calculating the length.
Target Property target length Specify the property name to which the result should be saved.

Sample configuration

The following is a sample request, Synapse configuration, and response for the given request.

{"string":"utility module"}
<utility.string.Length>
    <inpuString>{json-eval($.string)}</inputString>
    <target>length</target>
</utility.string.Length>  
length=14

string.LowerCase

You can use the string.LowerCase operation to change the case of the string to lowercase.

Operation details

Name Parameter Default Value Description
Input String inputString The string that needs to be transformed to lowercase.
Target Property target lower Specify the property name to which the result should be saved.

Sample configuration

The following is a sample request, Synapse configuration, and response for the given request.

{"string":"UTILITY MODULE"}
<utility.string.LowerCase>
  <inputString>json-eval($.string)</inputString>
  <target>lowercase</target>
</utility.string.LowerCase>
lowercase="utility module"

string.UpperCase

You can use the string.UpperCase operation to change the case of the string to uppercase.

Operation details

Name Parameter Default Value Description
Input String inputString The string that needs to be transformed to uppercase.
Target Property target upper Specify the property name to which the result should be saved.

Sample configuration

The following is a sample request, Synapse configuration, and response for the given request.

{"string":"utility module"}
<utility.string.UpperCase>
  <inputString>json-eval($.string)</inputString>
  <target>uppercase</target>
</utility.string.UpperCase>
uppercase="UTILITY MODULE"

string.RegexMatcher

You can use the string.RegexMatcher operation to check whether the given string is in the desired format. It returns true if the string matches with the regular expression (Regex).

Operation details

Name Parameter Default Value Description
Input String inputString The string that needs to be checked with the regular expression.
Regular Expression regex The regular expression of the desired string.
Target Property target match Specify the property name to which the result should be saved.

Sample configuration

The following is a sample request, Synapse configuration, and response for the given request.

{"string":"utility module"}
<utility.string.RegexMatcher>
  <regex>u.*m.*e</regex>
  <inputString>json-eval($.string)</inputString>
  <target>isMatching</target>
</utility.string.RegexMatcher>
isMatching="true"

string.UUID

You can use the string.UUID operation to generate a random UUID.

Operation details

Name Parameter Default Value Description
Target Property target uuid Specify the property name to which the generated random UUID should be saved.

Sample configuration

The following is a sample configuration and response.

<utility.string.UUID>
  <target>uuid</target>
</utility.string.UUID>
uuid="07801d34-bbaf-43aa-8d70-98b4ead1b198"

date.GetDate

You can use the date.GetDate operation to get the current date and time in a preferred date format.

Operation details

Name Parameter Default Value Description
Date Format format default value:yyyy-MM-dd HH:mm:ss The format in which the date is needed. Refer to Java date format patterns.
Target Property target date Specify the property name to which the current date should be saved.

Sample configuration

The following is a sample Synapse configuration and response.

<utility.date.GetDate>
  <format>yy/MM/dd HH:mm:ss</format>
  <target>date</target>
</utility.date.GetDate>
date="22/02/01 08:32:40"

math.GetRandomInt

You can use the math.GetRandomInt operation to get a random integer in a given range.

Operation details

Name Parameter Default Value Description
Lower Bound lowerBound Lower bound for the random integer. If it is kept blank, the lower bound will be considered as 0.
Upper Bound upperBound Upper bound for the random integer. If it is kept blank, it will consider the upper bound as infinity.
Target Property target random Specify the property name to which the generated random integer should be saved.

Sample configuration

The following is a sample Synapse configuration and response.

<utility.math.GetRandomInt>
  <lowerBound>100</lowerBound>
  <upperBound>1000</upperBound>
  <target>random</target>
</utility.math.GetRandomInt>
random=785

signature.Generate

You can use the signature.Generate operation to generate a HMAC signature for the payload of the request.

Operation details

Name Parameter Default Value Description
Payload payload Body Dropdown menu to select whether the payload is from the body of the request or a custom payload.
The following are the supported HTTP MIME types.
application/json
application/xml
text/plain
Custom Payload customPayload The field to enter a custom payload when the payload is selected as Custom Payload.
Secret secret The secret used to generate the signature for the payload using an algorithm.
Algorithm algorithm HMACSHA1 The algorithm that is used to generate the signature.
The following are the supported algorithms:
HMACSHA1
HMACSHA256
HMACSHA384
HMACSHA512
HMACMD5
Target Property target sign Specify the property name to which the signature should be saved.

Sample configuration

The following is a sample request, Synapse configuration, and response for the given request.

{"string":"utility module"}
<utility.signature.Generate>
  <payload>Body</payload>
  <secret>123</secret>
  <algorithm>HMACSHA1</algorithm>
  <target>signature</target>
</utility.signature.Generate>
signature="32423411140bdebed0b017e738797be452481dbb"

signature.Verify

You can use the signature.Verify operation to verify the payload using the HMAC signature in the header of the request. Thereby, this is used to ensure that the payload is not modified.

Operation details

Name Parameter Default Value Description
Payload payload Body Dropdown menu to select whether the payload is from the body of the request or a custom payload.
The following are the supported HTTP MIME types.
application/json
application/xml
text/plain
Custom Payload customPayload The field to enter a custom payload when the payload is selected as Custom Payload.
Signature signature The HMAC signature of the payload.
Secret secret The secret used to generate the signature for the payload using an algorithm.
Algorithm algorithm HMACSHA1 The algorithm that is used to genearte the signature.
The following algorithms are supported,
HMACSHA1
HMACSHA256
HMACSHA384
HMACSHA512
HMACMD5
Target Property target verify Specify the property name to which the signature should be saved.

Sample configuration

The following is a sample request, Synapse configuration, and response for the given request.

{"string":"utility module"}
<utility.signature.Verify>
  <payload>Body</payload>
  <signature>32423411140bdebed0b017e738797be452481dbb</signature>
  <secret>123</secret>
  <algorithm>HMACSHA1</algorithm>
  <target>verify</target>
</utility.signature.Verify>
verify="true"
Top