Hi,
How to fetch user_login_name in a OTDS SAML enabled WebTop once a user is logged in?
When moving across repositories, the user_login_name is appearing as empty and causing the custom functionality fail.
Thanks,
Hari
I have done this in my environment which is OTDS Kerberos based but the requirement is same.
Explore the OTDS REST api , /rest/authentication/oauth/tokeninfo
Hi Mohamed,
Thank you for the response. Can you share more details on the REST Api you are talking about?
May be some sample code that is used on the WebTop side to fetch the login user details will be more helpful.
Thank you,
Code snippet below, you may need to change it to suit your environment and requirements.
String restUrl= getOTDSURL() + "/rest/authentication/oauth/tokeninfo";
otdsToken= getOTDSToken(request); // HttpServletRequest request
jsonInput= new JSONObject().put("token", otdsToken).toString();
connection = (HttpURLConnection)new URL(restUrl).openConnection();
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("Content-Length", String.valueOf(jsonInput.length()));
connection.setRequestProperty("charset", "utf-8");
connection.setUseCaches(false);
org.apache.commons.io.IOUtils.write(jsonInput, connection.getOutputStream());
otdsResponse= org.apache.commons.io.IOUtils.toString(connection.getInputStream());
JSONObject jObj= new JSONObject(otdsResponse);
JSONArray userValues= ((JSONArray)((JSONObject)jObj.get("user")).get("values"));;
for(int i= 0; i< userValues.length(); i++) {
JSONObject oneObj= (JSONObject)userValues.get(i);
if ( oneObj.isNull("name") == false && "uid".equals(oneObj.getString("name")) ) {
userId= oneObj.getJSONArray("values").getString(0);
break;
}
DfLogger.info("your app", "Detected OTDS user " + userId, null, null);