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:
- Name - the unique value
- 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:
- Auto generation xmls of custom objects
- Each custom object - separated java class with properties
- Load/save functionality via classes
To implement java class -> custom xml the following objects were added:
- Annotations: uses for generation xmls
- AbstractCustomObject: super class for all custom object with loading/saving methods
- CustomObjectFactory: factory for creating/loading java-based custom object.
Annotations
There are 2 main annotations:
- @Custom - contains only string value as the name
- @Attribute - contains information about attribute values
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:
- As for collection type can be used: List and Set.
- 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:
- loading properties from context
- saving a custom object
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.
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:
- Auto-generation xmls
- Working with a custom object as a simple java class
- Customization of loading/saving properties to custom object
- Creating/modifying custom object in run-time using a certain java class
- Testing
All sources are in GitHub project.
Thank you and I hope this article was useful for you.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Content to Moderator
This is really cool stuff, nice work
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Content to Moderator
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.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Content to Moderator
?
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Content to Moderator
Please go the below path then you can able to find all details.
C:\TOMCAT_HOME\webapps\identityiq\doc\javadoc
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Content to Moderator
Thanks a lot.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Content to Moderator
My team would love to start using this for custom object interactions.
What jar provides these classes?
We are currently identityiq 8.0p2