Thursday, August 6, 2020

Custom Tasks

 # Custom Tasks can be a powerful way to extend Sailpoint's functionality to perform certain actions that can't be achieved using default tasks or OOTB configurations.

# Custom tasks speeds up the process if the code is written accurately.

Steps to build custom task    :

1. Create a task definition

2. Create java class to define the method for custom task

3. Deploy the custom task and execute it

1. Create a task definition    

e.g :

Below information is Task Definition :


The task definition with required parameters (I/P and O/P) needs to be created first, which is required for the custom class java method which executes in background.

Login to Debug page, navigate to Object browser    --->    select  Task definition    ---> select appropriate task

<?xml version='1.0' encoding='UTF-8'?>

<!DOCTYPE TaskDefinition PUBLIC "sailpoint.dtd" "sailpoint.dtd">

<TaskDefinition executor="sailpoint.task.MultiAggregation" name="CustomMultiAggregation" 

progressInterval="5000" progressMode="String" template="true" resultAction="Delete" type="Generic">

  <Description>Task template for application group scanning</Description>

  <Signature>

    <Inputs>

      <Argument name="application" required="true" type="Application">

        <Prompt>Search Application</Prompt>

      </Argument>      

    </Inputs>

    <Returns>

      <Argument name="output" type="String">

        <Prompt>Result</Prompt>

      </Argument>

    </Returns>

  </Signature>

</TaskDefinition>

Task Definition Object    -    Explanation    :

# TaskDefinition executor ="sailpoint.custom.MutliAggregation" this defines the name of the class which will be execute the task>

template="true"    -    template="true" is set to get the TaskDefinition listed in “New Task” List

# <Argument name="application" required="true" type="Application"> this defines the I/P parameter of the task. the custom java code MultiAggregation will take I/P parameters as "application" variable. The type="Application" will create a drop down for application. similarly you can have a type text for simple text I/P.

# <Prompt>Search Application</Prompt>  this defines the text which will be displayed in UI to the user.

# <Returns> <Argument name = "output" type="String"> this defines the output parameter, in the custom java code all output result will be passed to this output string.

2. Create java class to define the method for custom task

import sailpoint.api.SailPointContext;
import sailpoint.object.Attributes;
import sailpoint.object.TaskResult;
import sailpoint.object.TaskSchedule;
import sailpoint.AbstractTaskResult;

public class MultiAggregation extends AbstractTaskExecutor {

    public void execute (SailPointContext context, TaskSchedule tsch, TaskResult result, Attributes args) throws Exception {
            String output = "output";
            String appname = (String) args.get(application);
             result.setAttribute(output,"Custom task executed : " + appname);
             }
public boolean terminate(){
           return false;
    }
}

Execute :    


Terminate    : go to Task Results
While task is running we can terminate

NOTE :

AbstractTaskExecutor    -    class will override two methods i.e., execute () and terminate()
SailPointContext    -    starting point contains (identities, accounts and applications etc.,)
TaskSchedule    -    we can schedule task in code itself
TaskResult    -    we will set output in Sailpoint
Attributes    -    contain I/P parameters (HashMap in Scheduler (OIM))

3. Deploy the custom task

# To deploy the custom task, the TaskDefinition file needs to be imported into IIQ. This can be done in two ways.

1. Login to IIQ.
    Navigate to Global settings    --->    Import from file    --->    choose xml file    --->    click on import
2. From within IIQ console. use the import command    :    import ReportTask.xml
    IIQ console path    :    C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps\idenityiq\WEB-INF\bin\

# After importing the TaskDefinition, the java class file has to be placed in the appropriate location.

# The java class file needs to be placed in the classes.sailpoint.custom directory on the IIQ server.
   Finally the application server needs to be restarted (bounce the server) and the custom task is ready to execute


            


No comments:

Post a Comment

Fetch Members from Workgroup

  import java.util.ArrayList;   import java.util.Iterator;   import java.util.List;   import sailpoint.api.ObjectUtil;   import sailpoint.ob...