CA Identity Portal exposes API methods, which enable external processes to update the requests.
To update the request using the following REST service API:
<Identity_Portal_Server_IP:Server_Port>/sigma/rest/protected/request/updateRequestInfo
you have to have an authenticated session.
Please find below the Java code to perform this operation using Apache HttpClient and Jason Payload.
--------------------------------------------------------------------------------------------------------------------------------------------
package com.test.sigma;
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.StringRequestEntity;
public class SigmaTest2 {
public String sigmalogin(String username, String password) throws Exception {
String serverIPPort = "http://***.***.***.***:8081";
String sigmaUrl = serverIPPort + "/sigma/rest/public/login";
String authCookie = null;
String payload = "{" +
"\"username\": \"" + username + "\", " +
"\"password\": \"" + password + "\"" +
"}";
StringRequestEntity requestEntity = new StringRequestEntity(
payload,
"application/json",
"UTF-8");
HttpClient httpClient = new HttpClient();
PostMethod postMethod = new PostMethod(sigmaUrl);
postMethod.setRequestEntity(requestEntity);
int loginResult = httpClient.executeMethod(postMethod);
System.out.println("Login post returned Http Status: [" + loginResult + "]");
if (loginResult == 200) {
Header cookiedata = postMethod.getResponseHeader("Set-Cookie");
System.out.println("cookiedata ==> " + cookiedata);
if(cookiedata != null) {
String[] cookieList = cookiedata.toString().split(";");
for(String cookie:cookieList) {
//System.out.println("cookie ==> " + cookie);
int idx = cookie.indexOf("JSESSIONID=");
if(idx >= 0) {
authCookie = cookie.substring(idx + "JSESSIONID=".length());
System.out.println("AuthCookie ==> " + authCookie);
}
}
}
}
return authCookie;
}
public int updateRequestID(String authCookie, String requestId, String infoToAppend) throws Exception {
String serverIPPort = "http://***.***.***.***:8081";
String sigmaUrl = serverIPPort + "/sigma/rest/protected/request/updateRequestInfo";
String protectedValue = "false";
int returnCode = -1;
String payload = "[{" +
"\"requestId\": \"" + requestId + "\", " +
"\"infoToAppend\": \"" + infoToAppend + "\", " +
"\"protectedValue\": " + protectedValue + "" +
"}]";
StringRequestEntity requestEntity = new StringRequestEntity(
payload,
"application/json",
"UTF-8");
HttpClient httpClient = new HttpClient();
PostMethod postMethod = new PostMethod(sigmaUrl);
postMethod.setRequestEntity(requestEntity);
postMethod.setRequestHeader("Cookie", "JSESSIONID=" + authCookie);
returnCode = httpClient.executeMethod(postMethod);
System.out.println("Http post returned http Status: [" + returnCode + "]");
if (returnCode == 200) {
Header cookiedata = postMethod.getResponseHeader("Set-Cookie");
System.out.println("cookiedata ==> " + cookiedata);
if(cookiedata != null) {
String[] cookieList = cookiedata.toString().split(";");
for(String cookie:cookieList) {
//System.out.println("cookie ==> " + cookie);
int idx = cookie.indexOf("JSESSIONID=");
if(idx >= 0) {
authCookie = cookie.substring(idx + "JSESSIONID=".length());
System.out.println("AuthCookie ==> " + authCookie);
}
}
}
}
return returnCode;
}
public static void main(String[] args) throws Exception {
SigmaTest2 obj = new SigmaTest2();
String authCookie = obj.sigmalogin("<username>", "<password>");
System.out.println("Test :: AuthCookie ==> " + authCookie);
obj.updateRequestID(authCookie, "<Request Id>", "< Additional Request Information>");
}
}
--------------------------------------------------------------------------------------------------------------------------------------------------------