I am trying to create a new Web Services connection. This particular system requires a hash-based message authentication code (HMAC) in the header of the API calls. I am attempting to create a Web Service BeforeRule to create the HMAC and add it to the header of the requestEndPoint. When I try to upload the script, I am receiving the following error:
{
"detailCode": "400.1.3 Illegal value",
"trackingId": "9dd0c810a25a4522941ef504ac8e5d2e",
"messages": [
{
"locale": "und",
"localeOrigin": "REQUEST",
"text": "Illegal value \"[{\"line\":25,\"column\":5,\"message\":\"Remove reference to .update(\"},{\"line\":26,\"column\":5,\"message\":\"Remove reference to .update(\"},{\"line\":29,\"column\":5,\"message\":\"Remove reference to .update(\"}]\" for field \"sourceCode.script\"."
},
{
"locale": "en-US",
"localeOrigin": "DEFAULT",
"text": "Illegal value \"[{\"line\":25,\"column\":5,\"message\":\"Remove reference to .update(\"},{\"line\":26,\"column\":5,\"message\":\"Remove reference to .update(\"},{\"line\":29,\"column\":5,\"message\":\"Remove reference to .update(\"}]\" for field \"sourceCode.script\"."
}
],
"causes": []
}
Here is the script:
import java.lang.*;\n
import connector.common.JsonUtil;\n
import java.util.*;\n
import sailpoint.connector.webservices.WebServicesClient;\n
import javax.naming.*;\n
import java.net.*;\n
import org.json.*;\n
import java.text.DateFormat;\n
import java.text.SimpleDateFormat;\n
import org.apache.commons.codec.binary.Base64;\n
import org.apache.commons.codec.digest.*;\n
Map body = requestEndPoint.getBody();\n
Map header = requestEndPoint.getHeader();\n
String fullUri = requestEndPoint.getContextUrl;\n
String operationType = requestEndPoint.getHttpMethodType();\n
String methodURL = operationType + fullUri;\n
byte[] methodURLBytes = methodURL.getBytes();\n
if(header != null) {\n
String HeaderSignature = header.get(\"Signature\");\n
String currentDate = new SimpleDateFormat(\"yyyy-MM-dd'T'h:m:ssZZZZZ\").format(new Date());\n
String currentDateSubstring = currentDate.substring(0,12);\n
byte[] currentDateSubstringBytes = currentDateSubstring.getBytes();\n
byte[] combinedBytes = combined.getBytes();\n
Mac hmac = Mac.getInitializedMac(HmacAlgorithms.HMAC_SHA_384, HeaderSignature.getBytes());\n
hmac.update(methodURLBytes);\n
hmac.update(currentDateSubstringBytes);\n
if(body != null){\n
byte[] bodyBytes = body.getBytes();\n
hmac.update(bodyBytes);\n
}\n
byte[] digest = hmac.doFinal();\n
byte[] digestB64 = Base64.encodeBase64(digest);\n
header.put(\"Signature\",new String(digestB64));\n
header.put(\"RequestDate\",currentDate);\n
requestEndPoint.setHeader(header);\n
}\n
return requestEndPoint;\n
The error refers to:
hmac.update(methodURLBytes);
hmac.update(currentDateSubstringBytes);
hmac.update(bodyBytes);
Is there a way to call .update() without it being marked as illegal value?