cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Java class as 'custom' object

Java class as 'custom' object

 

Hi sailors,

Custom objects are really useful and important part in IdentityIQ. You can use them as properties holders or independent objects, in other words: customer decides 'what', 'when' and 'why' to use it.

There are 2 main parts of custom object:

  1. Name - the unique value
  2. Attributes - properties for object. To get properties value developers usually use one of its function: get(), getInt(), getList(), etc.

 

After implementing (all rule`s types) generating rule`s xmls from java classes (article in LinkedIn, GitHub project) the custom objects were next. Aims:

  1. Auto generation xmls of custom objects
  2. Each custom object - separated java class with properties
  3. Load/save functionality via classes

To implement java class -> custom xml the following objects were added:

  1. Annotations: uses for generation xmls
  2. AbstractCustomObject: super class for all custom object with loading/saving methods
  3. CustomObjectFactory: factory for creating/loading java-based custom object.

 

Annotations

There are 2 main annotations:

  1. @Custom - contains only string value as the name
    clipboard_image_1.png
  2. @Attribute - contains information about attribute values
    clipboard_image_2.png

The most important part is generation xml. As for name it is not really interesting, but as for attributes and with values -it  is not so trivial. Annotation can have only constant types as properties and as values uses String. For generation the current type uses type of a field in an java class and the XMLSerializer from identityiq.jar, so we can use all supported types for properties. But using annotations has several limitations:

  1. As for collection type can be used: List and Set.
  2. You cannot use complex structure like: Map<String, Map<String, List<String>>

AbstractCustomObject

This is a super class for all java-based custom objects. Ii contains the following functionality:

  1. loading properties from context
  2. saving a custom object
clipboard_image_0.png

 You can override them and add some additional stuff (e.g.): loading a transient property (identity) according to an annotated string field identityName.

 

CustomObjectFactory

Uses for loading/creating java-based custom object.

clipboard_image_1.png

 

Example

Java class source:

/**
 * Test class for simple custom object
 */
@Data
@Custom("Test simple custom object")
public class SimpleCustomObject extends AbstractCustomObject {

    /**
     * Test string value
     */
    @Attribute(@AttributeValue("single"))
    private String stringValue;
    /**
     * Test string value as collection
     */
    @Attribute(@AttributeValue("stringCollection"))
    private List<String> stringCollection;
    /**
     * Test strings values
     */
    @Attribute({
            @AttributeValue("string1"),
            @AttributeValue("string2")
    })
    private List<String> stringsCollectionNatural;
    /**
     * Test boolean value
     */
    @Attribute(@AttributeValue("true"))
    private Boolean booleanValue;
    /**
     * Test long value
     */
    @Attribute(@AttributeValue("5"))
    private Long longValue;
    /**
     * Test date value
     */
    @Attribute(@AttributeValue("02/15/2019 10:35:45"))
    private Date dateValue;
    /**
     * Test date map
     */
    @Attribute({
            @AttributeValue(key = "now", value = "now"),
            @AttributeValue(key = "02/15/2019 10:35:45", value = "02/15/2019 10:35:45")
    })
    private Map<String, Date> dateMap;
    /**
     * Test boolean map
     */
    @Attribute({
            @AttributeValue(key = "false", value = "false"),
            @AttributeValue(key = "true", value = "true")
    })
    private Map<String, Boolean> booleanMap;
    /**
     * Test set of string
     */
    @Attribute({
            @AttributeValue(value = "1"),
            @AttributeValue(value = "2"),
            @AttributeValue(value = "1")
    })
    private Set<String> setValue;

    /**
     * Test attribute name
     */
    @Attribute(name = "attributeName", value = @AttributeValue("nameTest"))
    private String fieldName;

    /**
     * Test transient attribute name
     */
    private String transientField;
}

Output xml:

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE Custom PUBLIC "sailpoint.dtd" "sailpoint.dtd">
<Custom name="Test simple custom object">
  <Attributes>
    <Map>
      <entry key="attributeName" value="nameTest"/>
      <entry key="booleanMap">
        <value>
          <Map>
            <entry key="false">
              <value>
                <Boolean></Boolean>
              </value>
            </entry>
            <entry key="true">
              <value>
                <Boolean>true</Boolean>
              </value>
            </entry>
          </Map>
        </value>
      </entry>
      <entry key="booleanValue">
        <value>
          <Boolean>true</Boolean>
        </value>
      </entry>
      <entry key="dateMap">
        <value>
          <Map>
            <entry key="02/15/2019 10:35:45">
              <value>
                <Date>1550223345000</Date>
              </value>
            </entry>
            <entry key="now">
              <value>
                <Date>1564044670418</Date>
              </value>
            </entry>
          </Map>
        </value>
      </entry>
      <entry key="dateValue">
        <value>
          <Date>1550223345000</Date>
        </value>
      </entry>
      <entry key="longValue">
        <value>
          <Long>5</Long>
        </value>
      </entry>
      <entry key="setValue">
        <value>
          <Set>
            <String>1</String>
            <String>2</String>
          </Set>
        </value>
      </entry>
      <entry key="stringCollection">
        <value>
          <List>
            <String>stringCollection</String>
          </List>
        </value>
      </entry>
      <entry key="stringValue" value="single"/>
      <entry key="stringsCollectionNatural">
        <value>
          <List>
            <String>string1</String>
            <String>string2</String>
          </List>
        </value>
      </entry>
    </Map>
  </Attributes>
  <Description>Test class for simple custom object</Description>
</Custom>

Just calling: CustomObjectFactory.load(SimpleCustomObject.class) will return an instance of SimpleCustomObject with all properties.

 

Summary

Using this approach with custom object gives us:

  1. Auto-generation xmls
  2. Working with a custom object as a simple java class
  3. Customization of loading/saving properties to custom object
  4. Creating/modifying custom object in run-time using a certain java class
  5. Testing

All sources are in GitHub project.

Thank you and I hope this article was useful for you.

Labels (2)
Comments

This is really cool stuff, nice work Looks like the sort of thing I'd do!

Could you please suggest me the document where I could find java packages developed by SailPoint and description of each package along with its classes, interfaces, methods with examples, elaborating its use.

?

Please go the below path then you can able to find all details.

C:\TOMCAT_HOME\webapps\identityiq\doc\javadoc

Thanks a lot.

My team would love to start using this for custom object interactions.

What jar provides these classes?

We are currently identityiq 8.0p2

Version history
Revision #:
10 of 10
Last update:
‎Apr 15, 2023 12:00 AM
Updated by:
 
Contributors