tschloesser
New Member.
412 views

Problems testing ECMAScript functiotions in Designer 4.7.2

Running Designer 4.7.2 on MacOS 10.14.4 I fond some strange issue:

We created a simple new ECMAScript object containing the following code:

importClass(java.security.MessageDigest);
importClass(javax.xml.bind.DatatypeConverter);

var JString = java.lang.String;


/**
* Returns a hexadecimal encoded SHA-256 hash for the input String.
* @param data
* @return
*/
function getSHA256Hash(data) {
var strdata = new JString(data);
var digest = MessageDigest.getInstance("SHA-256");
var hash = digest.digest(strdata.getBytes("UTF-8"));
return bytesToHex(hash); // make it printable
}


/**
* Use javax.xml.bind.DatatypeConverter class in JDK to convert byte array
* to a hexadecimal string. Note that this generates hexadecimal in upper case.
* @param hash
* @return
*/
function bytesToHex(hash) {
return DatatypeConverter.printHexBinary(hash);
}

running the function getSHA256Hasch() did work at the beginning of the week, but when we used it later in a policy the simulation was not possible, due to a JAVA NULL-pointer exception at the point this function was called.

So we went back to the ECMAScript editor to test the function there again, and found it was not working anymore.

More testing showed, that the ECMAScript engine is not possible to import JAVA packages and/or classes anymore!

Does anybody saw the same issue so far and possibly found a solution?

Kind regards,

Thorsten
Labels (1)
0 Likes
3 Replies
Knowledge Partner
Knowledge Partner

Re: Problems testing ECMAScript functiotions in Designer 4.7.2

Just to be sure, this is a typo in your retelling, not in your actual
testing attempt, right?

> getSHA256Hasch()


Should be getSHA256Hash()

--
Good luck.

If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below.

If you want to send me a private message, please let me know in the
forum as I do not use the web interface often.
0 Likes
tschloesser
New Member.

Re: Problems testing ECMAScript functiotions in Designer 4.7

Thanks for your answer, but it was really a typo in my writing 😉

When running the test in the ECMA editior I c&p the function just to be sure and I saw the issue!
0 Likes
Knowledge Partner
Knowledge Partner

Re: Problems testing ECMAScript functiotions in Designer 4.7

ab;2500011 wrote:
Just to be sure, this is a typo in your retelling, not in your actual
testing attempt, right?

> getSHA256Hasch()


Should be getSHA256Hash()

--
Good luck.

If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below.

If you want to send me a private message, please let me know in the
forum as I do not use the web interface often.


Good catch, Aaron!
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.