To run Sailpoint client code from Eclipse the below structure should be there in eclipes
1. src
- spclient .java (given in this blog)
- iiq.properties ( copy from C:\<application server>\webapps\identityiq\WEB-INF\classes\ path)
- iiqBeans.xml ( unzip C:\<application server>\webapps\identityiq\WEB-INF\lib\identityiq.jar and copy iiqBeans.xml in Eclipes Src folder)
2. Lib
- Copy all jar from C:\<application server>\webapps\identityiq\WEB-INF\lib\
- Add all jars in java build path.
Please note: The IIQ path mentioned in the code should be accessible by Eclipse.
Hit the run button :)
Source code:
1. src
- spclient .java (given in this blog)
- iiq.properties ( copy from C:\<application server>\webapps\identityiq\WEB-INF\classes\ path)
- iiqBeans.xml ( unzip C:\<application server>\webapps\identityiq\WEB-INF\lib\identityiq.jar and copy iiqBeans.xml in Eclipes Src folder)
2. Lib
- Copy all jar from C:\<application server>\webapps\identityiq\WEB-INF\lib\
- Add all jars in java build path.
Please note: The IIQ path mentioned in the code should be accessible by Eclipse.
Hit the run button :)
Source code:
import sailpoint.api.SailPointContext;
import sailpoint.api.SailPointFactory;
import sailpoint.object.Identity;
import sailpoint.spring.SpringStarter;
import sailpoint.tools.GeneralException;
public class spclient {
/**
*
Create Sailpoint context
* @return
*/
private SailPointContext getSailpointContext() {
SailPointContext context =null;
String override=null;
SpringStarter ss= new SpringStarter ("iiqBeans.xml",override);
String configFile=ss.getConfigFile();
System.out.println("config File::"+configFile);
String[] services = {"Task","Request"};
SpringStarter.setSuppressedServices(services);
SpringStarter.suppressSchedulers();
SpringStarter.setSuppressVersionChecker(true);
ss.start();
System.out.println("HERE");
try {
context= SailPointFactory.createContext("identityiq");
if(context !=null) {
System.out.println("Got Connection "+context);
context.authenticate("spadmin", "admin"); //Provide
current id password.
}else {
System.out.println("null Connection ");
}
}catch(Exception e) {
e.printStackTrace();
}
return context;
}
/**
*
Search Identity
* @param context
* @param identiyName
* @return
*/
private Identity searchIdentity (SailPointContext context, String identiyName) {
Identity identity =null;
Boolean inactivityflag=true;
System.out.println("Nirupam");
try {
identity= context.getObject(Identity.class,identiyName);
System.out.println("First Name::"+identity.getFirstname());
System.out.println("Last Name::"+identity.getLastname());
inactivityflag=(Boolean) identity.getAttribute("inactive");
System.out.println("inactivityflag::"+inactivityflag);
} catch (GeneralException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return identity;
}
public static void main (String[] args) {
String path= "C:\\Tomcat8\\webapps\\identityiq"; // provide the path from your
install Directory
System.setProperty("SPHOME",path);
System.setProperty("SP_HOME",path);
System.setProperty("sailpoint.home",path);
SailPointContext context =null;
System.out.println("Establishing Connection ");
spclient sc=new spclient();
context =sc.getSailpointContext();
sc.searchIdentity(context,"spadmin");
try {
context.close();
} catch (GeneralException e) {
e.printStackTrace();
}
}
}
hello Nirupam,
ReplyDeleteThanks for the information.
I am new to Sailpoint IIQ. I am getting below error message while trying to connect Sailpoint from Eclipse.
2020-02-20T12:37:50,791 WARN main springframework.context.support.ClassPathXmlApplicationContext:557 - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [iiq.properties] cannot be opened because it does not exist
Exception in thread "main" org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [iiq.properties] cannot be opened because it does not exist
at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:89)
copy iiq.properties file from web-inf/classes and paste under src folder in eclipse
ReplyDeleteHello, i have followed the steps which you have given but still it showing some error
ReplyDeleteError occurred during initialization of boot layer
java.lang.module.FindException: Unable to derive module descriptor for C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps\identityiq\WEB-INF\lib\geronimo-annotation_1.1_spec-1.0.jar
Caused by: java.lang.IllegalArgumentException: geronimo.annotation.1.1.spec: Invalid module name: '1' is not a Java identifier