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

Tags:

  • 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.
  • Thanks for your answer, but it was really a typo in my writing ;-)

    When running the test in the ECMA editior I c
  • 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!