Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi ,
i have this script i want to use it in tjava component , how can i do this !!!
<cfset dtGMT = DateAdd("s", GetTimeZoneInfo().UTCTotalOffset, now() ) />
<cfset timestamp = Int((dtGMT.getTime() / 1000)/60)>
<cfset signature = Hash("# apiKey# # password# # timestamp# ", "SHA-256")>
any help please !
Hello,
It seems you are showing ColdFusion code. https://helpx.adobe.com/coldfusion/developing-applications/using-web-elements-and-ex[…]nd-java-eleme...
What are you trying to achieve? Do you want to extract the Java logic from this ColdFusion page?
Best regards
Sabrina
yes ...
i got the the code in java,
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.Timestamp;
import java.util.Date;
String apiKey = "test";
String secret = "test";
Date date= new java.util.Date();
Long timestamp = (date.getTime() / 1000);
String signature = null;
try {
String toBeHashed = apiKey + secret + timestamp;
MessageDigest md = MessageDigest.getInstance("SHA-512");
byte[] bytes = md.digest(toBeHashed.getBytes("UTF-8"));
StringBuilder sb = new StringBuilder();
for(int i=0; i< bytes.length ;i++){
sb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1));
}
signature = sb.toString();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
String authHeaderValue = "EAN APIKey=" + apiKey + ",Signature=" + signature + ",timestamp=" + timestamp;
then i want to call the variable "signature" in the header of "tRestClient" (for authentification"
but i got error
Hello
Move the import xxxx code to Advanced settings panel of tJava component.
In addition, there are two issues in your job design.
1 Use OncomponentOK or OnsubjobOK connector from tJava to tRestClient.
2 You should initialize the global variable before it is used, eg: in the end of tJava,
globalMap.put("signature",signature );
Regards
Shong
Hi @Shicong Hong
thanks for reply
Still can't get the variable in tRestClient.
the variable "sig" is a dynamic variable ..for every call to the routine "sig" will have a new value