Risk module enables you to save historical data of the user login to the SQL database. Custom rule examples explain how to read the existing parameters from the historical database. If you want to create a new attribute in the database for your custom rules, then perform the following steps:
Create the custom tables as follows:
CREATE TABLE netiq_risk.extra ( id VARCHAR(32) NOT NULL, custom_string_entry1 VARCHAR2(100), custom_int_entry2 INTEGER, custom_char_entry3 CHAR(1), CONSTRAINT fk_extra_id FOREIGN KEY (id) REFERENCES netiq_risk.usr(id) )
The table name should be 'extra'.
The column name (attribute) should start with 'custom' followed by the data type of the column, like custom_<datatype>_<name of the attribute>
e.g) custom_string_userlogintime
The attribute name should match the database column name.
Currently the following data types are supported for the custom attributes:
String
Int
Char
Boolean
Date
As part of your customer class constructor, set the type of the history you are looking for.
//Get the last login time of the user setType(HistoricalAttributeEntries.LASTLOGGEDINTIME.name()); //Get the custom string user login time of the user setType("custom_string_userlogintime");
As part of the evaluate() method, you can access these custom values as below:
HistoryRecord records = (HistoryRecord)uContext.get("custom_string_userlogintime"); String value = (String)records.getValue().get(0);
At the end of the evaluate() method, you can set the value of the custom attribute as below:
(ResponseObject)rspObject.setUserAttr("custom_string_userlogintime","12:02:01");
Post evaluation of the risk, this will be set to the extra table on the SQL database.