Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
vendors:cisco:uc:ucce:cvp [2025/03/12 15:17] – [Local value Examples] gerardorourkevendors:cisco:uc:ucce:cvp [2025/10/17 17:00] (current) – gerardorourke
Line 35: Line 35:
   *[[vendors:cisco:uc:ucce:cvp:java|Call Studio Java Examples]]   *[[vendors:cisco:uc:ucce:cvp:java|Call Studio Java Examples]]
   *[[https://www.cisco.com/c/en/us/products/collateral/collaboration/white-paper-c11-743494.html|Cisco Virtual Assistant / Cisco Answers]]   *[[https://www.cisco.com/c/en/us/products/collateral/collaboration/white-paper-c11-743494.html|Cisco Virtual Assistant / Cisco Answers]]
 +  *[[vendors:cisco:uc:cvp:ftps|CVP FTPS - Call Studio Element]]
 +
  
 ==== CVP FTP ==== ==== CVP FTP ====
Line 85: Line 87:
 [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Apache Software Foundation\Procrun 2.0\VXMLServer\Parameters\Java\Options]  [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Apache Software Foundation\Procrun 2.0\VXMLServer\Parameters\Java\Options] 
  
-==== Local value Examples====+===== Set Value - Local Variables ===== 
 + 
 +Create Local variables (similar to session variables) by using the JavaScript node "Set value" 
 + 
 +==== SHA 256 Example ==== 
 +<code> 
 +// CVP Rhino: SHA-256 via Java MessageDigest 
 +function sha256_sql(accountNum) { 
 +    if (!accountNum) return null; 
 + 
 +    // Convert JS string to UTF-8 bytes 
 +    var javaStr = new java.lang.String(accountNum); 
 +    var bytes = javaStr.getBytes("UTF-8"); 
 + 
 +    // Create SHA-256 digest 
 +    var md = java.security.MessageDigest.getInstance("SHA-256"); 
 +    md.update(bytes); 
 +    var digest = md.digest(); 
 + 
 +    // Convert byte array to hex string 
 +    var hex = ''; 
 +    for (var i = 0; i < digest.length; i++) { 
 +        var h = (digest[i] & 0xFF).toString(16); 
 +        if (h.length === 1) h = '0' + h; 
 +        hex += h; 
 +    } 
 + 
 +    return hex.toUpperCase(); 
 +} 
 + 
 +// Example usage 
 +var accountNum = "4111111111111111"; 
 +var hash = sha256_sql(accountNum); 
 + 
 +// Expected output: 9BBEF19476623CA56C17DA75FD57734DBF82530686043A6E491C6D71BEFE8F6E 
 +</code> 
 + 
 +  * Uses Java’s MessageDigest, which handles byte arrays directly. 
 +  * Converts the string to UTF-8 bytes, matching SQL Server’s NVARCHAR behavior in HASHBYTES('SHA2_256', NVARCHAR). 
 +  * Outputs a hex string in uppercase, exactly like SQL Server’s CONVERT(VARCHAR(64), HASHBYTES(...), 2). 
 + 
 +CVP’s JavaScript engine (Rhino) runs on the JVM. That means every Java class is accessible from your JS code using the Packages namespace. Example: java.security.MessageDigest becomes Packages.java.security.MessageDigest in JS. 
 +So in the above code, it is calling the Java MessageDigest.getInstance method to get a SHA-256 digest object. 
  
-Use Local vars (Set value) and use the below JavaScript+You can instantiate objects, call methods, and access constants just like in Java.
  
 ===Retrieving the Length of a Session Variable in Call Studio=== ===Retrieving the Length of a Session Variable in Call Studio===
  • vendors/cisco/uc/ucce/cvp.1741792659.txt.gz
  • Last modified: 2025/03/12 15:17
  • by gerardorourke