sailpoint.server

## Class IdnRuleUtil

- java.lang.Object
- - sailpoint.server.IdnRuleUtil

    public class IdnRuleUtil
    extends java.lang.Object

Utility class containing methods customers can use within a rules to perform common tasks. This utility class allows us to abstract out the use of SailPointContext in rules so that we can one day not pass a context to the rule at all.

### Field Summary

Fields
`static java.lang.String` `EQUALS_FILTER`
`static java.lang.String` `STARTS_WITH_FILTER`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`boolean` `accountExistsByDisplayName(java.lang.String applicationName, java.lang.String displayName)` Determines if an account currently exists on an application using the display name.
`boolean` `accountExistsByNativeIdentity(java.lang.String applicationName, java.lang.String nativeIdentity)` Determines if an account currently exists on an application using the native identity.
`static java.util.List` `asList(java.lang.Object object)` Return a List with the given object.
`int` `attrSearchCountAccounts(java.util.List<java.lang.String> sourceIds, java.lang.String attributeName, java.lang.String operation, java.util.List<java.lang.String> values)` Count the accounts that match the searchable attribute and value.
`java.lang.String` `attrSearchGetIdentityName(java.util.List<java.lang.String> sourceIds, java.lang.String attributeName, java.lang.String operation, java.util.List<java.lang.String> values)` Get the identity name for the account matching the specified criteria.
`int` `countAccounts(java.lang.String applicationName)` Counts the number of accounts on an application.
`int` `countIdentitiesBySearchableIdentityAttribute(java.lang.String attributeName, java.lang.String operation, java.lang.String value)` Count and return the number of users that match the incoming attributeName, operation and value.
`protected QueryOptions` `createIdentityAttributeQueryOptions(java.lang.String attributeName, java.lang.String operation, java.lang.String value)` Create the QueryOptions for the given parameters.
`static java.lang.String` `dateToString(java.util.Date src, java.lang.String format)` Format a Date value as a String, using the JVMs default timezone.
`static java.lang.String` `dateToString(java.util.Date src, java.lang.String format, java.util.TimeZone tz)` Format a Date value as a String, using the JVMs default timezone.
`java.util.List<Identity>` `findIdentitiesBySearchableIdentityAttribute(java.lang.String attributeName, java.lang.String operation, java.lang.String value, java.lang.String sortAttribute)` Find and return the users that match the incoming attributeName, operation, value ordered by the specified sortAttribute
`java.lang.String` `getAccountAttribute(Account account, java.lang.String attribute)` Gets the String value of an attribute from an account on an application.
`java.lang.String` `getAccountAttribute(java.lang.String applicationName, java.lang.String nativeIdentity, java.lang.String attribute)` Gets the String value of an attribute from an account on an application.
`boolean` `getAccountAttributeBool(Account account, java.lang.String attribute)` Gets the boolean value of an attribute from an account on an application.
`boolean` `getAccountAttributeBool(java.lang.String applicationName, java.lang.String nativeIdentity, java.lang.String attribute)` Gets the boolean value of an attribute from an account on an application.
`int` `getAccountAttributeInt(Account account, java.lang.String attribute)` Gets the int value of an attribute from an account on an application.
`int` `getAccountAttributeInt(java.lang.String applicationName, java.lang.String nativeIdentity, java.lang.String attribute)` Gets the int value of an attribute from an account on an application.
`Account` `getAccountByDisplayName(java.lang.String applicationName, java.lang.String displayName)` Gets an account on an application using the display name.
`Account` `getAccountByNativeIdentity(java.lang.String applicationName, java.lang.String nativeIdentity)` Gets an account on an application using the native identity.
`java.util.List<Account>` `getAllAccounts(java.lang.String applicationName, java.lang.String identityName)` Given the name of the application and the identity name return the list of Account objects found for the identity.
`protected ConnectorServiceResolver` `getConnectorService()` Method is separate from main code to allow me to mock out the connector interaction as part of an integration test.
`Account` `getFirstAccount(java.lang.String applicationName, java.lang.String identityName)` Get the first account found for the application and identityName.
`java.lang.String` `getFirstAccountNativeIdentity(java.lang.String applicationName, java.lang.String identityName)` Get the first account for the application and identityName and return the first accounts native Identity.
`Identity` `getIdentityById(java.lang.String id)` Fetch an identity by the internal id.
`protected LDAPConnectorServiceResolver` `getLDAPConnectorService()` Method is separate from main code to allow me to mock out the connector interaction as part of an integration test.
`java.lang.String` `getManagedAttributeDescription(java.lang.String sourceId, java.lang.String name, java.lang.String value, ManagedAttribute.Type type)` Finds ManagedAttribute description by provided sourceId/name/value/type.
`ManagedAttributeDetails` `getManagedAttributeDetails(java.lang.String sourceId, java.lang.String name, java.lang.String value, ManagedAttribute.Type type)` Finds ManagedAttribute by sourceId/name/value/type and returns its details in ManagedAttributeDetails model.
`java.lang.Object` `getRawAccountAttribute(Account account, java.lang.String attribute)` Gets the value of an attribute from an account on an application.
`java.lang.Object` `getRawAccountAttribute(java.lang.String applicationName, java.lang.String nativeIdentity, java.lang.String attribute)` Gets the value of an attribute from an account on an application.
`java.lang.String` `getSourceAttributeBySourceId(java.lang.String sourceId, java.lang.String attributeName)` Get a single Source string attribute from an Application using the applicationId
`java.lang.String` `getSourceAttributeBySourceName(java.lang.String sourceName, java.lang.String attributeName)` Get a single Source string attribute from an Application using the applicationId
`boolean` `isUniqueAccountId(java.lang.String identityNameOrId, java.lang.String applicationNameOrId, java.lang.String accountId)` A method that will call getObject() on the connector for the Account type and test if an account with the given accountId exists.
`boolean` `isUniqueLDAPValue(java.lang.String identityNameOrId, java.lang.String applicationNameOrId, java.lang.String attributeName, java.lang.String attributeValue)` A method that can be used to call LDAP type connectors to look for unique values.
`static boolean` `nullSafeCaseInsensitiveEq(java.lang.String o1, java.lang.String o2)` This method performs a null-safe equality comparison between the two strings.
`static <T extends java.lang.Comparable> int` `nullSafeCompareTo(T o1, T o2)` Return the compareTo() value for two objects that may be null.
`static boolean` `nullSafeEq(java.lang.Object o1, java.lang.Object o2)` This method performs a null-safe equality comparison between the two given objects.
`static boolean` `nullSafeEq(java.lang.Object o1, java.lang.Object o2, boolean nullsEq)` This method performs a null-safe equality comparison between the two given objects.
`java.lang.String` `otoa(java.lang.Object object)` Convert object to a string.
`static boolean` `otob(java.lang.Object object)` Convert object to a boolean.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### STARTS_WITH_FILTER

    public static final java.lang.String STARTS_WITH_FILTER

See Also:
  Constant Field Values

#### EQUALS_FILTER

    public static final java.lang.String EQUALS_FILTER

See Also:
  Constant Field Values

### Method Detail

#### accountExistsByNativeIdentity

    public boolean accountExistsByNativeIdentity(java.lang.String applicationName,
                                                 java.lang.String nativeIdentity)
                                          throws GeneralException

Determines if an account currently exists on an application using the native identity.

Parameters:
  `applicationName` - The application name.
  `nativeIdentity` - The native identity of the account.
Returns:
  True if the account exists, false otherwise.
Throws:
  `GeneralException`

#### accountExistsByDisplayName

    public boolean accountExistsByDisplayName(java.lang.String applicationName,
                                              java.lang.String displayName)
                                       throws GeneralException

Determines if an account currently exists on an application using the display name.

Parameters:
  `applicationName` - The application name.
  `displayName` - The display name of the account.
Returns:
  True if the account exists, false otherwise.
Throws:
  `GeneralException`

#### getAccountByNativeIdentity

    public Account getAccountByNativeIdentity(java.lang.String applicationName,
                                              java.lang.String nativeIdentity)
                                       throws GeneralException

Gets an account on an application using the native identity.

Parameters:
  `applicationName` - The application name.
  `nativeIdentity` - The native identity of the account.
Returns:
  The Account representing the account or null if not found. If more than one found then the first Account in the exists is returned.
Throws:
  `GeneralException`

#### getAccountByDisplayName

    public Account getAccountByDisplayName(java.lang.String applicationName,
                                           java.lang.String displayName)
                                    throws GeneralException

Gets an account on an application using the display name.

Parameters:
  `applicationName` - The application name.
  `displayName` - The display name of the account.
Returns:
  The Account representing the account or null if not found. If more than one found then the first Account in the exists is returned.
Throws:
  `GeneralException`

#### getAllAccounts

    public java.util.List<Account> getAllAccounts(java.lang.String applicationName,
                                                  java.lang.String identityName)
                                           throws GeneralException

Given the name of the application and the identity name return the list of Account objects found for the identity.

Parameters:
  `applicationName` - The name of the application
  `identityName` - The name of the identity
Returns:
  List of AccountObjects required
Throws:
  `GeneralException` - wrapping underlying DB related errors

#### getFirstAccount

    public Account getFirstAccount(java.lang.String applicationName,
                                   java.lang.String identityName)
                            throws GeneralException

Get the first account found for the application and identityName. IF there is more then on e account the first account will be returned.

Parameters:
  `applicationName` - The name of the application
  `identityName` - The name of the Identity
Returns:
  The account object
Throws:
  `GeneralException` - wrapping underlying DB related errors

#### getFirstAccountNativeIdentity

    public java.lang.String getFirstAccountNativeIdentity(java.lang.String applicationName,
                                                          java.lang.String identityName)
                                                   throws GeneralException

Get the first account for the application and identityName and return the first accounts native Identity.

Parameters:
  `applicationName` - The name of the application
  `identityName` - The name of the identity
Returns:
  The first link's nativeIdentity
Throws:
  `GeneralException` - wrapping underlying DB related errors

#### countAccounts

    public int countAccounts(java.lang.String applicationName)
                      throws GeneralException

Counts the number of accounts on an application.

Parameters:
  `applicationName` - The application name.
Returns:
  The total number of accounts.
Throws:
  `GeneralException`

#### getRawAccountAttribute

    public java.lang.Object getRawAccountAttribute(java.lang.String applicationName,
                                                   java.lang.String nativeIdentity,
                                                   java.lang.String attribute)
                                            throws GeneralException

Gets the value of an attribute from an account on an application.

Parameters:
  `applicationName` - The application name.
  `nativeIdentity` - The native identity of the account.
  `attribute` - The name of the attribute to retrieve.
Returns:
  The attribute value or null if the attribute does not exist.
Throws:
  `GeneralException`

#### getRawAccountAttribute

    public java.lang.Object getRawAccountAttribute(Account account,
                                                   java.lang.String attribute)

Gets the value of an attribute from an account on an application.

Parameters:
  `account` - The account on the application.
  `attribute` - The name of the attribute to retrieve.
Returns:
  The attribute value or null if the attribute does not exist.

#### getAccountAttribute

    public java.lang.String getAccountAttribute(java.lang.String applicationName,
                                                java.lang.String nativeIdentity,
                                                java.lang.String attribute)
                                         throws GeneralException

Gets the String value of an attribute from an account on an application.

Parameters:
  `applicationName` - The application name.
  `nativeIdentity` - The native identity of the account.
  `attribute` - The name of the attribute to retrieve.
Returns:
  The attribute value or null if the attribute does not exist.
Throws:
  `GeneralException`

#### getAccountAttribute

    public java.lang.String getAccountAttribute(Account account,
                                                java.lang.String attribute)

Gets the String value of an attribute from an account on an application.

Parameters:
  `account` - The account on the application.
  `attribute` - The name of the attribute to retrieve.
Returns:
  The attribute value or null if the attribute does not exist.

#### getAccountAttributeBool

    public boolean getAccountAttributeBool(java.lang.String applicationName,
                                           java.lang.String nativeIdentity,
                                           java.lang.String attribute)
                                    throws GeneralException

Gets the boolean value of an attribute from an account on an application.

Parameters:
  `applicationName` - The application name.
  `nativeIdentity` - The native identity of the account.
  `attribute` - The name of the attribute to retrieve.
Returns:
  The attribute value or false if the attribute does not exist.
Throws:
  `GeneralException`

#### getAccountAttributeBool

    public boolean getAccountAttributeBool(Account account,
                                           java.lang.String attribute)

Gets the boolean value of an attribute from an account on an application.

Parameters:
  `account` - The account on the application.
  `attribute` - The name of the attribute to retrieve.
Returns:
  The attribute value or false if the attribute does not exist.

#### attrSearchCountAccounts

    public int attrSearchCountAccounts(java.util.List<java.lang.String> sourceIds,
                                       java.lang.String attributeName,
                                       java.lang.String operation,
                                       java.util.List<java.lang.String> values)

Count the accounts that match the searchable attribute and value.

Parameters:
  `sourceIds` - The list of Application ids that represent the sources of the data.
  `attributeName` - The name of the searchable account attribute. The name parameter is required.
  `operation` - The operation to use when matching, it'll either be Operation.Equal OR Operation.StartsWith
  `values` - The value of that searchable attribute to math. The value parameter is required.
Returns:
  The number of accounts that match the parameters provided.

#### attrSearchGetIdentityName

    public java.lang.String attrSearchGetIdentityName(java.util.List<java.lang.String> sourceIds,
                                                      java.lang.String attributeName,
                                                      java.lang.String operation,
                                                      java.util.List<java.lang.String> values)

Get the identity name for the account matching the specified criteria.

Parameters:
  `sourceIds` - The list of Application ids that represent the sources of the data
  `attributeName` - The name of the searchable account attribute. The name parameter is required.
  `operation` - The operation to use when matching, it'll either be Operation.Equal OR Operation.StartsWith
  `values` - The value of that searchable attribute to math. The value parameter is required.
Returns:
  The name of the Identity that matched the account that match the parameters provided.

#### getIdentityById

    public Identity getIdentityById(java.lang.String id)

Fetch an identity by the internal id.

Parameters:
  `id` - The id to use when fetching
Returns:
  A DTO representing the Identity, will throw if identity was not found.

#### findIdentitiesBySearchableIdentityAttribute

    public java.util.List<Identity> findIdentitiesBySearchableIdentityAttribute(java.lang.String attributeName,
                                                                                java.lang.String operation,
                                                                                java.lang.String value,
                                                                                java.lang.String sortAttribute)

Find and return the users that match the incoming attributeName, operation, value ordered by the specified sortAttribute

Parameters:
  `attributeName` - The attribute that should be searched, must be searchable and non-null.
  `operation` - The operation to be used when searching and only allowed equals and starts with
  `value` - The value that should match and must be non-null
  `sortAttribute` - The attribute that should be used while sorting. Default ordering will be on uid if not specified and this also must be searchable. Sort will always be in ascending order
Returns:
  The List of users that match the passed in parameters. The max number returned values will be 50 refine search to reduce results.
Throws:
  `java.lang.IllegalStateException` - when attribute provided is not searchable, when operation is not StartsWith or Equals, the sortAttribute is not searahable, or if there are issues during the search
See Also:
  `EQUALS_FILTER`, `STARTS_WITH_FILTER`

#### countIdentitiesBySearchableIdentityAttribute

    public int countIdentitiesBySearchableIdentityAttribute(java.lang.String attributeName,
                                                            java.lang.String operation,
                                                            java.lang.String value)

Count and return the number of users that match the incoming attributeName, operation and value.

Parameters:
  `attributeName` - The attribute that should be searched, must be searchable and non-null.
  `operation` - The operation to be used when searching and only allowed equals and starts with
  `value` - The value that should match and must be non-null
Returns:
  The number of identities that match the parameters
Throws:
  `java.lang.IllegalStateException` - when attribute provided is not searchable, when operation is not StartsWith or Equals, or if there are issues during the count operation
See Also:
  `EQUALS_FILTER`, `STARTS_WITH_FILTER`

#### createIdentityAttributeQueryOptions

    protected QueryOptions createIdentityAttributeQueryOptions(java.lang.String attributeName,
                                                               java.lang.String operation,
                                                               java.lang.String value)

Create the QueryOptions for the given parameters. Used for both searching and counting Identities.

Parameters:
  `attributeName` - The attribute that should be searched, must be searchable and non-null.
  `operation` - The operation to be used when searching and only allowed equals and starts with
  `value` - The value that should match and must be non-null
Returns:
  The QueryOptions of Identity search and counting:w

#### getAccountAttributeInt

    public int getAccountAttributeInt(java.lang.String applicationName,
                                      java.lang.String nativeIdentity,
                                      java.lang.String attribute)
                               throws GeneralException

Gets the int value of an attribute from an account on an application.

Parameters:
  `applicationName` - The application name.
  `nativeIdentity` - The native identity of the account.
  `attribute` - The name of the attribute to retrieve.
Returns:
  The attribute value or zero if the attribute does not exist.
Throws:
  `GeneralException`

#### getAccountAttributeInt

    public int getAccountAttributeInt(Account account,
                                      java.lang.String attribute)

Gets the int value of an attribute from an account on an application.

Parameters:
  `account` - The account on the application.
  `attribute` - The name of the attribute to retrieve.
Returns:
  The attribute value or zero if the attribute does not exist.

#### getManagedAttributeDescription

    public java.lang.String getManagedAttributeDescription(java.lang.String sourceId,
                                                           java.lang.String name,
                                                           java.lang.String value,
                                                           ManagedAttribute.Type type)
                                                    throws GeneralException

Finds ManagedAttribute description by provided sourceId/name/value/type.

Parameters:
  `sourceId` - The sourceId used to query the ManagedAttribute.
  `name` - The name of the attribute used to query the ManagedAttribute.
  `value` - The value of the attribute used to query the ManagedAttribute.
  `type` - The type of the attribute used to query the ManagedAttribute (see enum ManagedAttribute.Type). Defaults to Entitlement (if null provided).
Returns:
  ManagedAttribute's description if found or else null.
Throws:
  `GeneralException` - wrapping underlying DB related errors

#### getManagedAttributeDetails

    public ManagedAttributeDetails getManagedAttributeDetails(java.lang.String sourceId,
                                                              java.lang.String name,
                                                              java.lang.String value,
                                                              ManagedAttribute.Type type)
                                                       throws GeneralException

Finds ManagedAttribute by sourceId/name/value/type and returns its details in ManagedAttributeDetails model.

Parameters:
  `sourceId` - The sourceId used to query the ManagedAttribute.
  `name` - The name of the attribute used to query the ManagedAttribute.
  `value` - The value of the attribute used to query the ManagedAttribute.
  `type` - The type of the attribute used to query the ManagedAttribute (see enum ManagedAttribute.Type). Defaults to Entitlement (if null provided).
Returns:
  ManagedAttributeDetails if found or else null.
Throws:
  `GeneralException` - wrapping underlying DB related errors

#### getSourceAttributeBySourceId

    public java.lang.String getSourceAttributeBySourceId(java.lang.String sourceId,
                                                         java.lang.String attributeName)
                                                  throws GeneralException

Get a single Source string attribute from an Application using the applicationId

Parameters:
  `sourceId` - The id of the source
  `attributeName` - The name/key of the attribute to return
Returns:
  The value if found in the attributes
Throws:
  `GeneralException` - wrapping underlying DB related errors

#### getSourceAttributeBySourceName

    public java.lang.String getSourceAttributeBySourceName(java.lang.String sourceName,
                                                           java.lang.String attributeName)
                                                    throws GeneralException

Get a single Source string attribute from an Application using the applicationId

Parameters:
  `sourceName` - (internal name i.e. application.getName() vs displayName of the application
  `attributeName` - The name/key of the attribute to return
Returns:
  The value if found in the attributes
Throws:
  `GeneralException` - wrapping underlying DB related errors

#### isUniqueLDAPValue

    public boolean isUniqueLDAPValue(java.lang.String identityNameOrId,
                                     java.lang.String applicationNameOrId,
                                     java.lang.String attributeName,
                                     java.lang.String attributeValue)

A method that can be used to call LDAP type connectors to look for unique values. The connector is called with a specific search filter based on the attributeName and value that is passed into this method. If there is a value returned the values is considered to be non-unique.

Parameters:
  `identityNameOrId` - The name or ID of the identity we are using
  `applicationNameOrId` - The name or ID of the source we are targeting
  `attributeName` - The name of the attribute we want to validate
  `attributeValue` - The value of the attribute we want to validate
Returns:
  true if the value is unique AND false otherwise. If the application or identity can't be found an IllegalStateException will be thrown.

#### getLDAPConnectorService

    protected LDAPConnectorServiceResolver getLDAPConnectorService()

Method is separate from main code to allow me to mock out the connector interaction as part of an integration test.

Returns:
  An instance of the LDAPConnectorServiceResolver which will be plugged into the system on the mantis platform size.

#### isUniqueAccountId

    public boolean isUniqueAccountId(java.lang.String identityNameOrId,
                                     java.lang.String applicationNameOrId,
                                     java.lang.String accountId)

A method that will call getObject() on the connector for the Account type and test if an account with the given accountId exists. If the account exists the method will return false, otherwise true.

Parameters:
  `identityNameOrId` - The name or ID of the identity we are using
  `applicationNameOrId` - The name or ID of the source we are targeting
  `accountId` - The accountId we are trying to validate
Returns:
  true if the account is unique, false otherwise

#### getConnectorService

    protected ConnectorServiceResolver getConnectorService()

Method is separate from main code to allow me to mock out the connector interaction as part of an integration test.

Returns:
  An instance of the ConnectorServiceResolver which will be plugged into the system on the mantis platform size.

#### otoa

    public java.lang.String otoa(java.lang.Object object)

Convert object to a string.

Parameters:
  `object` - object to convert
Returns:
  String value for non null objects, null otherwise

#### otob

    public static boolean otob(java.lang.Object object)

Convert object to a boolean.

Parameters:
  `object` - object to convert
Returns:
  Returns true if object is found true value or the String value "true" (ignoring case).

#### asList

    public static java.util.List asList(java.lang.Object object)

Return a List with the given object. If the object is a List, it is returned. If the object is a collection, a List with all of the elements of the collection is returned. If the object is a non-collection, a new List containing the given object is returned. If the object is null, null is returned.

Parameters:
  `object` - The object to return as a list.

#### nullSafeEq

    public static boolean nullSafeEq(java.lang.Object o1,
                                     java.lang.Object o2)

This method performs a null-safe equality comparison between the two given objects. If both objects are null, this returns false.

Parameters:
  `o1` - The first object to compare.
  `o2` - The second object to compare.
Returns:
  True if both objects are non-null and equal.

#### nullSafeEq

    public static boolean nullSafeEq(java.lang.Object o1,
                                     java.lang.Object o2,
                                     boolean nullsEq)

This method performs a null-safe equality comparison between the two given objects. This will return true if both objects are null and nullsEq is true. Empty or "null" strings will be converted to null before checking if emptyStringToNull is true.

#### nullSafeCaseInsensitiveEq

    public static boolean nullSafeCaseInsensitiveEq(java.lang.String o1,
                                                    java.lang.String o2)

This method performs a null-safe equality comparison between the two strings. This will return true if both objects are null and nullsEq is true. Empty or "null" strings will be converted to null before checking if emptyStringToNull is true.

#### nullSafeCompareTo

    public static <T extends java.lang.Comparable> int nullSafeCompareTo(T o1,
                                                                         T o2)

Return the compareTo() value for two objects that may be null. Nulls are considered equal, and null is greater than non-null.

#### dateToString

    public static java.lang.String dateToString(java.util.Date src,
                                                java.lang.String format)

Format a Date value as a String, using the JVMs default timezone.

Parameters:
  `src` - The source String
  `format` - The date format to apply
Returns:
  The formatted date in String format specified

#### dateToString

    public static java.lang.String dateToString(java.util.Date src,
                                                java.lang.String format,
                                                java.util.TimeZone tz)

Format a Date value as a String, using the JVMs default timezone.

Parameters:
  `src` - The source String
  `format` - The date format to apply
  `tz` -
Returns:
  The formatted date in String format specified