The JavaScript / ECMAScript code shown below was used in a recent project in order to generate a Unique Identifier when a User created a new Service Provider definition from within a User Application Workflow. When the Service Provider feed was consumed by the JMS Connector, the Connector checked the metadata present in the Identity Vault against the UUID sent as part of the XML file ‘header data’. If the two UUID values matched, the Service Provider long name was equal, and the Service Provider short name was equal, the XML file was accepted; otherwise the XML file was rejected.
print ( "UUID: " + generateUUID() );
function generateUUID()
{
var s = [];
var varFinalString = [];
var varMyString = [];
var hexDigits = "0123456789abcdef";
for (var i = 0; i < 32; i++)
{
s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
}
s[12] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
s[16] = hexDigits.substr((s[16] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
var uuid = s.join("");
var varMyString1 = uuid.substring(0,8);
var varMyString2 = uuid.substring(8,12);
var varMyString3 = uuid.substring(12,16);
var varMyString4 = uuid.substring(16,20);
var varMyString5 = uuid.substring(20,32);
var varMyReturnString = (varMyString1 + '-' + varMyString2 + '-' + varMyString3 + '-' + varMyString4 + '-' + varMyString5);
return varMyReturnString;
}
Two examples are shown below:
- UUID: e4e37411-960e-4c40-8b72-0d39a8c4ee61
- UUID: be221719-c3aa-4a44-8288-9a891e96d7dd