Hi! I have made this simple WS before operation rule, that uses API to get tenant data (in this case, some identity attributes values), and it actually works fine:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;
import org.json.JSONArray;
import org.json.JSONObject;
log.info("TestWS: enter before rule");
try {
String https_url = "https://xxxxxxxxx.api.identitynow-demo.com/beta/identities?filters%3Dname%20eq%20%22someuserlogin%22";
log.info("TestWS: url: " + https_url);
URL url = new URL(https_url);
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
con.setRequestProperty("Authorization",
"Bearer <I_PASTED_TOKEN_FROM_POSTMAN>");
con.setRequestMethod("GET");
con.setRequestProperty("Content-Type", "application/json");
con.setRequestProperty("Accept", "application/json");
con.setUseCaches(false);
con.setDoInput(true);
con.setDoOutput(true);
log.info("TestWS: captura resposta");
String rawResponse = "";
if (con != null) {
BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream()));
String input;
while ((input = br.readLine()) != null) {
rawResponse += input;
}
br.close();
}
log.info("TestWS: resposta do tenant" + rawResponse);
JSONObject resultRoot = (JSONObject) new JSONArray(rawResponse).get(0);
log.info("TestWS: obtain attributes");
String alias = (String) resultRoot.get("alias");
log.info("TestWS: json alias: " + alias);
} catch (Exception e) {
log.info("TestWS: error: " + e.getMessage());
}
I am concient about not connecting to external systems, as established in rules guide:
But in this case, tenant is considered an external system? Can I use this snippet or is among prohibited code?