Hello,
im trying to create a custom Field that uses Data it receives from a REST endpoint. For authentication there is .crt and .key File. How can use Files to authenticate to Rest endpoint via groovy? I have a working python code that looks like that:
def get_attributes(gid, crt_file, key_file, scd_url): headers = {"accept": "application/json"} response = requests.get( f"https://{url}", cert=(crt_file, key_file), headers=headers ) if response.status_code != 200: return (False, response.status_code) else: return (True, response.json())
I also have a Java code to access the rest endpoint via Truststore and Keystroke:
System.setProperty("javax.net.ssl.trustStore", "C:\\{cert path}");
System.setProperty("javax.net.ssl.keyStore", "C:\\{filename}.jks");
System.setProperty("javax.net.ssl.keyStorePassword",
"<your secret password for the jks certificate>");
try {
URL obj = new URL("{Url}");
HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
if (con == null) {
System.out.println("connection cannot be established!");
}
Is there a way to access these files via ScripRunner to create a custom Field?
Thanks for any help.