Fetching the user details from OIM through SCIM/Rest Services-
--------------------------------------------------------------------------------------------------------------Required Jar File-
java-json.jar
sun.misc.BASE64Decoder.jar
=======================================================
package oracle.iam.webservice;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;
public class ViewUser {
public static void main(String args[])
{
String name = "xelsysadm";
String password = "Welcome1";
String authString = name + ":" + password;
String authStringEnc = "Basic "+ new String(new Decoder.BASE64Encoder().encode(authString.getBytes()));
System.out.println("Base64 encoded auth string: " + authStringEnc);
URL url = null;
try {
url = new URL(" http://localhost:14000/idaas/im/scim/v1/Users?filter=(userName co TestS01)"); //Fetch User Details through User Login
//url = new URL("http://localhost:14000/idaas/im/scim/v1/Users/3006"); //Fetch user details through User Key
HttpURLConnection connection = null;
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET"); //For Fetching User details GET Operation
connection.setRequestProperty("Accept", "application/scim+json");
connection.setRequestProperty("Authorization", authStringEnc);
connection.setConnectTimeout(5000);
connection.setReadTimeout(5000);
// OutputStreamWriter out = null;
BufferedReader in = null;
in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
System.out.println(in.readLine());
System.out.println("\n REST Service Invoked Successfully..");
in.close();
} catch (ProtocolException e) {
e.printStackTrace();
}catch (MalformedURLException e) {
e.printStackTrace();
}catch (IOException e) {
e.printStackTrace();
}
}
}