5.6 Understanding Custom Attributes in History SQL Database

The Risk module enables you to save historical data of the user login to the external database. Custom rule examples explain how to read the existing parameters from an historical database. To create a new attribute in the database for your custom rules, perform the following steps:

  1. 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)
    )
  2. Specify the of the table as 'extra'.

  3. The column name (attribute) should start with 'custom' followed by the data type of the column, like custom_<datatype>_<name of the attribute>

    For example, custom_string_userlogintime

  4. Ensure that the attribute name matches with the database column name.

    Access Manager supports the following data types for custom attributes:

    • String

    • Int

    • Char

    • Boolean

    • Date

5.6.1 Custom Rule example

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 follows:

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 follows:

(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.