Saturday, August 25, 2018

Run Sailpoint Client Code from Eclipse

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:

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();
              }
       }

}

Saturday, February 10, 2018

Start a Service in windows using script

Save the below lines of code in a .bat file. I am trying to start MySQL57 service if its not running already.


for /F "tokens=3 delims=: " %%H in ('sc query MySQL57 ^| findstr " STATE"') do ( if /I "%%H" NEQ "RUNNING" ( net start MySQL57 ) )

Wednesday, October 5, 2016

Run query form java code using OIM Client login

import Thor.API.Security.XLClientSecurityAssociation;
import com.thortech.xl.client.dataobj.tcDataBaseClient;
import com.thortech.xl.dataaccess.tcClientDataAccessException;
import com.thortech.xl.dataaccess.tcDataProvider;
import com.thortech.xl.dataaccess.tcDataSet;
import com.thortech.xl.dataaccess.tcDataSetException;
import com.thortech.xl.orb.dataaccess.tcDataAccessException;

public void connectOIMDB(OIMClient oimClient){
XLClientSecurityAssociation.setClientHandle(oimClient);
tcDataProvider dataProvider = new tcDataBaseClient() ;        
        String query ="SELECT * FROM USR WHERE USR_LOGIN = 'XELSYSADM'";        
  tcDataSet dataSet = new tcDataSet();
  dataSet.setQuery(dataProvider, query);
  dataSet.executeQuery();
  System.out.println("Login ID: "+dataSet.getString("USR_LOGIN"));

}

Saturday, April 16, 2016

Event Handler to update Display Name

public EventResult execute(long processId, long eventId, Orchestration orchestration) {

HashMap<String, Serializable> parameters = orchestration.getParameters();
HashMap<String, Object> mapAttrs = new HashMap<String, Object>();

String firstName = (String)parameters.get(UserManagerConstants.AttributeName.FIRSTNAME.getId());
String lastName = (String)parameters.get(UserManagerConstants.AttributeName.LASTNAME.getId());


mapAttrs.put("base", "Mr."+firstName+" "+lastName);


orchestration.addParameter("Display Name", mapAttrs);

return new EventResult();
}

Thursday, April 14, 2016

Table contains all the Schedule tasks

QRTZ92_JOB_DETAILS - contains list of all schedule task
JOB_HISTORY- Contains the details about the execution history

Thursday, January 7, 2016

SQL: Put more than 1000 items inside an IN Clause

some time we need to provide more than 1000 items inside IN clause.  To achieve this, we need to split values across multiple INs using OR

Sample Query:

select * from USR where usr_key in (1,2,3,----1000) OR usr_key in (1001,1002,...,2000)

Tuesday, December 1, 2015

weblogic.socket.MaxMessageSizeExceededException

when  we execute some java code (OIM api) form Eclipse, we may face the below issue :
Caused by: weblogic.socket.MaxMessageSizeExceededException: Incoming message of size: '10000080' bytes exceeds the configured maximum of: '10000000' bytes for protocol: 't3'

to resolve the issue we can just add a system property in the java code

System.setProperty("weblogic.MaxMessageSize", "300000000"); and you are done :)

sample code:

public OIMClient envContext(String oimUserName, String oimPassword, String oimURL ){
/*String oimUserName = "xelsysadm";   
String oimPassword = "xxxxxxxxxxxxxxxxxxx";
String oimURL = "t3://xxxxxxxxxxxxxxxxxxxxxxxt:14000"; */

String oimInitialContextFactory = "weblogic.jndi.WLInitialContextFactory";
OIMClient oimClient= null;
Hashtable<Object, Object> env = new Hashtable<Object, Object>();
env.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL, oimInitialContextFactory);
env.put(OIMClient.JAVA_NAMING_PROVIDER_URL,oimURL);
System.setProperty("java.security.auth.login.config", "./config/authwl.conf");
System.setProperty("java.security.policy", "./config/xl.policy"); 
System.setProperty("OIM.AppServerType", "wls");
System.setProperty("APPSERVER_TYPE", "wls");
System.setProperty("weblogic.Name", "oim_server1");
System.setProperty("weblogic.MaxMessageSize", "300000000");
System.setProperty("weblogic.security.SSL.trustedCAKeyStore", "./config/xxxxxxx.jks");
oimClient = new OIMClient(env);
try {
oimClient.login(oimUserName, oimPassword.toCharArray());
System.out.println("Successfully Connected with OIM ");
} catch (LoginException e) {
System.out.println("Login Exception"+ e);
}
return oimClient;
}