Interface IdnRuleUtil


public interface IdnRuleUtil
Utility class containing methods you can use within a rule to perform common tasks.

Methods that target a specific source identify that source by its id. The account lookup methods still resolve a source name that is passed in place of an id, so existing rules keep working, but rules should pass the source id. The methods that read entitlement data, source configuration or searchable account attributes require the source id.

  • Field Details

  • Method Details

    • accountExistsByNativeIdentity

      boolean accountExistsByNativeIdentity(String sourceId, String nativeIdentity) throws sailpoint.tools.GeneralException
      Determines if an account currently exists on a source using the native identity.
      Parameters:
      sourceId - The id of the source.
      nativeIdentity - The native identity of the account.
      Returns:
      True if the account exists, false otherwise.
      Throws:
      sailpoint.tools.GeneralException - wrapping underlying DB related errors
    • accountExistsByDisplayName

      boolean accountExistsByDisplayName(String sourceId, String displayName) throws sailpoint.tools.GeneralException
      Determines if an account currently exists on a source using the display name.
      Parameters:
      sourceId - The id of the source.
      displayName - The display name of the account.
      Returns:
      True if the account exists, false otherwise.
      Throws:
      sailpoint.tools.GeneralException - wrapping underlying DB related errors
    • getAccountByNativeIdentity

      Account getAccountByNativeIdentity(String sourceId, String nativeIdentity) throws sailpoint.tools.GeneralException
      Gets an account on a source using the native identity.
      Parameters:
      sourceId - The id of the source.
      nativeIdentity - The native identity of the account.
      Returns:
      The Account representing the account or null if not found. If more than one is found then the first Account found is returned.
      Throws:
      sailpoint.tools.GeneralException - wrapping underlying DB related errors
    • getAccountByDisplayName

      Account getAccountByDisplayName(String sourceId, String displayName) throws sailpoint.tools.GeneralException
      Gets an account on a source using the display name.
      Parameters:
      sourceId - The id of the source.
      displayName - The display name of the account.
      Returns:
      The Account representing the account or null if not found. If more than one is found then the first Account found is returned.
      Throws:
      sailpoint.tools.GeneralException - wrapping underlying DB related errors
    • getAllAccounts

      List<Account> getAllAccounts(String sourceId, String identityName) throws sailpoint.tools.GeneralException
      Given the id of the source and the identity name return the list of Account objects found for the identity.
      Parameters:
      sourceId - The id of the source
      identityName - The name of the identity
      Returns:
      The list of Accounts found for the identity, or null if the identity has no accounts on the source or either parameter is null
      Throws:
      sailpoint.tools.GeneralException - wrapping underlying DB related errors
    • getFirstAccount

      Account getFirstAccount(String sourceId, String identityName) throws sailpoint.tools.GeneralException
      Get the first account found for the source and identityName. If there is more than one account the first account will be returned.
      Parameters:
      sourceId - The id of the source
      identityName - The name of the Identity
      Returns:
      The account object
      Throws:
      sailpoint.tools.GeneralException - wrapping underlying DB related errors
    • getFirstAccountNativeIdentity

      String getFirstAccountNativeIdentity(String sourceId, String identityName) throws sailpoint.tools.GeneralException
      Get the first account for the source and identityName and return the first account's native Identity.
      Parameters:
      sourceId - The id of the source
      identityName - The name of the identity
      Returns:
      The first link's nativeIdentity
      Throws:
      sailpoint.tools.GeneralException - wrapping underlying DB related errors
    • getFirstAccountNativeIdentityByAttribute

      String getFirstAccountNativeIdentityByAttribute(String sourceId, String identityName, String attributeName, Object attributeValue) throws sailpoint.tools.GeneralException
      Method that will find the first nativeIdentity based on the attributeName and attributeValue being passed in. This method will iterate over the list of Accounts associated to the Identity for the Source specified.
      Parameters:
      sourceId - The id of the source
      identityName - The name of the identity we are using
      attributeName - The name of the attribute we are to match
      attributeValue - The value of the attribute we are to match
      Returns:
      The first non-null AND non-empty nativeIdentity that matches the passed in identity, attributeName and attributeValue. When matching attributeValue if the values are both null they are equal, if the value is an empty string it'll be transformed to a null.
      Throws:
      sailpoint.tools.GeneralException - wrapping underlying DB related errors
    • findAccountsByAttribute

      List<Account> findAccountsByAttribute(String sourceId, String identityName, String attributeName, Object attributeValue) throws sailpoint.tools.GeneralException
      Method that will return a list of accounts for the given Identity that matches the attributeName and values passed to the method.
      Parameters:
      sourceId - The id of the source
      identityName - The name of the identity we are using
      attributeName - The name of the attribute we are to match
      attributeValue - The value of the attribute we are to match
      Returns:
      accounts that match the given identity, source, attribute and value, empty list if no accounts are found.
      Throws:
      sailpoint.tools.GeneralException - wrapping underlying DB related errors
    • countAccounts

      int countAccounts(String sourceId) throws sailpoint.tools.GeneralException
      Counts the number of accounts on a source.
      Parameters:
      sourceId - The id of the source.
      Returns:
      The total number of accounts.
      Throws:
      sailpoint.tools.GeneralException - wrapping underlying DB related errors
    • getRawAccountAttribute

      Object getRawAccountAttribute(String sourceId, String nativeIdentity, String attribute) throws sailpoint.tools.GeneralException
      Gets the value of an attribute from an account on a source.
      Parameters:
      sourceId - The id of the source.
      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:
      sailpoint.tools.GeneralException - wrapping underlying DB related errors
    • getRawAccountAttribute

      Object getRawAccountAttribute(Account account, String attribute)
      Gets the value of an attribute from an account.
      Parameters:
      account - The account on the source.
      attribute - The name of the attribute to retrieve.
      Returns:
      The attribute value or null if the attribute does not exist.
    • getAccountAttribute

      String getAccountAttribute(String sourceId, String nativeIdentity, String attribute) throws sailpoint.tools.GeneralException
      Gets the String value of an attribute from an account on a source.
      Parameters:
      sourceId - The id of the source.
      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:
      sailpoint.tools.GeneralException - wrapping underlying DB related errors
    • getAccountAttribute

      String getAccountAttribute(Account account, String attribute)
      Gets the String value of an attribute from an account.
      Parameters:
      account - The account on the source.
      attribute - The name of the attribute to retrieve.
      Returns:
      The attribute value or null if the attribute does not exist.
    • getAccountAttributeBool

      boolean getAccountAttributeBool(String sourceId, String nativeIdentity, String attribute) throws sailpoint.tools.GeneralException
      Gets the boolean value of an attribute from an account on a source.
      Parameters:
      sourceId - The id of the source.
      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:
      sailpoint.tools.GeneralException - wrapping underlying DB related errors
    • getAccountAttributeBool

      boolean getAccountAttributeBool(Account account, String attribute)
      Gets the boolean value of an attribute from an account.
      Parameters:
      account - The account on the source.
      attribute - The name of the attribute to retrieve.
      Returns:
      The attribute value or false if the attribute does not exist.
    • attrSearchCountAccounts

      int attrSearchCountAccounts(List<String> sourceIds, String attributeName, String operation, List<String> values)
      Count the accounts that match the searchable attribute and value.
      Parameters:
      sourceIds - The list of source 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 Equals or StartsWith.
      values - The list of values of that searchable attribute to match. The values parameter is required.
      Returns:
      The number of accounts that match the parameters provided.
      Throws:
      IllegalStateException - wrapping underlying errors
      See Also:
    • attrSearchGetIdentityName

      String attrSearchGetIdentityName(List<String> sourceIds, String attributeName, String operation, List<String> values)
      Get the identity name for the account matching the specified criteria.
      Parameters:
      sourceIds - The list of source 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 Equals or StartsWith.
      values - The list of values of that searchable attribute to match. The values parameter is required.
      Returns:
      The name of the Identity that matched the account that match the parameters provided.
      Throws:
      IllegalStateException - wrapping underlying errors
      See Also:
    • getAccountAttributeInt

      int getAccountAttributeInt(String sourceId, String nativeIdentity, String attribute) throws sailpoint.tools.GeneralException
      Gets the int value of an attribute from an account on a source.
      Parameters:
      sourceId - The id of the source.
      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:
      sailpoint.tools.GeneralException - wrapping underlying DB related errors
    • getAccountAttributeInt

      int getAccountAttributeInt(Account account, String attribute)
      Gets the int value of an attribute from an account.
      Parameters:
      account - The account on the source.
      attribute - The name of the attribute to retrieve.
      Returns:
      The attribute value or zero if the attribute does not exist.
    • getManagedAttributeDescription

      String getManagedAttributeDescription(String sourceId, String name, String value, ManagedAttribute.Type type) throws sailpoint.tools.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:
      sailpoint.tools.GeneralException - wrapping underlying DB related errors
    • getManagedAttributeDetails

      ManagedAttributeDetails getManagedAttributeDetails(String sourceId, String name, String value, ManagedAttribute.Type type) throws sailpoint.tools.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:
      sailpoint.tools.GeneralException - wrapping underlying DB related errors
    • findManagedAttributes

      List<ManagedAttributeDetails> findManagedAttributes(String sourceId, String attributeName, IdnRuleUtil.ManagedAttributeProperty property, IdnRuleUtil.FindOperation operation, String valueToMatch, String entitlementType, IdnRuleUtil.ManagedAttributeProperty sortAttribute) throws sailpoint.tools.GeneralException
      Find the entitlements on a source that match the supplied criteria and return them as ManagedAttributeDetails models.
      Parameters:
      sourceId - The id of the source to query. This parameter is required.
      attributeName - The attribute from the account schema the entitlement belongs to, i.e. memberOf. Pass null to match entitlements of any attribute.
      property - The searchable property to match valueToMatch against. Pass null to match every entitlement on the source.
      operation - The operation to use when matching the property.
      valueToMatch - The value the property is matched against.
      entitlementType - The managed attribute type to query, see TYPE_ENTITLEMENT and TYPE_PERMISSION. When null, every type other than Permission is matched.
      sortAttribute - The property to sort the results by in ascending order. Pass null to leave the results unsorted.
      Returns:
      The matching ManagedAttributeDetails, at most 250 of them. Narrow the criteria to reduce the results. Empty if nothing matched.
      Throws:
      sailpoint.tools.GeneralException - wrapping underlying DB related errors
      NullPointerException - when sourceId is null
      See Also:
    • getIdentityById

      Identity getIdentityById(String id)
      Fetch an identity by the internal id.
      Parameters:
      id - The id to use when fetching an identity object
      Returns:
      A DTO representing the Identity, will throw if identity was not found
    • findIdentitiesBySearchableIdentityAttribute

      List<Identity> findIdentitiesBySearchableIdentityAttribute(String attributeName, String operation, String value, 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; only Equals and StartsWith are supported
      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 limited to 50.
      Throws:
      IllegalStateException - when attribute provided is not searchable, when operation is not StartsWith or Equals, the sortAttribute is not searchable, or if there are issues during the search
      See Also:
    • countIdentitiesBySearchableIdentityAttribute

      int countIdentitiesBySearchableIdentityAttribute(String attributeName, String operation, 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; only Equals and StartsWith are supported
      value - The value that should match and must be non-null
      Returns:
      The number of identities that match the parameters
      Throws:
      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:
    • isUniqueLDAPValue

      boolean isUniqueLDAPValue(String identityNameOrId, String applicationNameOrId, String attributeName, 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 source or identity can't be found an IllegalStateException will be thrown.
    • getSourceAttributeBySourceId

      String getSourceAttributeBySourceId(String sourceId, String attributeName) throws sailpoint.tools.GeneralException
      Get a single Source string attribute from a source using the source id
      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:
      sailpoint.tools.GeneralException - wrapping underlying DB related errors
    • getSourceAttributeBySourceName

      String getSourceAttributeBySourceName(String sourceName, String attributeName) throws sailpoint.tools.GeneralException
      Get a single Source string attribute from a source using the source name
      Parameters:
      sourceName - The internal name of the source, i.e. application.getName() rather than the display name
      attributeName - The name/key of the attribute to return
      Returns:
      The value if found in the attributes
      Throws:
      sailpoint.tools.GeneralException - wrapping underlying DB related errors
    • isUniqueAccountId

      boolean isUniqueAccountId(String identityNameOrId, String applicationNameOrId, 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
    • otoa

      String otoa(Object object)
      Convert an object to a String.
      Parameters:
      object - The object to convert
      Returns:
      The String value for a non-null object, null otherwise
    • otob

      boolean otob(Object object)
      Convert an object to a boolean.
      Parameters:
      object - The object to convert
      Returns:
      True if the object is a true Boolean or the String "true" ignoring case, false otherwise
    • asList

      List asList(Object object)
      Return the given object as a List. A List is returned as is, any other collection is copied into a new List, and a non-collection is wrapped in a new single element List.
      Parameters:
      object - The object to return as a List
      Returns:
      The object as a List, or null if the object is null
    • nullSafeEq

      boolean nullSafeEq(Object o1, Object o2)
      Perform a null-safe equality comparison between two objects. Two null objects are not equal.
      Parameters:
      o1 - The first object to compare
      o2 - The second object to compare
      Returns:
      True if both objects are non-null and equal
    • nullSafeEq

      boolean nullSafeEq(Object o1, Object o2, boolean nullsEq)
      Perform a null-safe equality comparison between two objects, choosing whether two nulls are equal.
      Parameters:
      o1 - The first object to compare
      o2 - The second object to compare
      nullsEq - Whether two null objects should be considered equal
      Returns:
      True if the objects are equal under the rules above
    • nullSafeCaseInsensitiveEq

      boolean nullSafeCaseInsensitiveEq(String o1, String o2)
      Perform a null-safe, case-insensitive equality comparison between two Strings. Two null Strings are equal.
      Parameters:
      o1 - The first String to compare
      o2 - The second String to compare
      Returns:
      True if the Strings are equal ignoring case
    • nullSafeCompareTo

      <T extends Comparable> int nullSafeCompareTo(T o1, T o2)
      Compare two objects that may be null. Two nulls are equal, and a null sorts after a non-null.
      Type Parameters:
      T - The Comparable type of the objects being compared
      Parameters:
      o1 - The first object to compare
      o2 - The second object to compare
      Returns:
      A negative number, zero or a positive number as o1 sorts before, with, or after o2
    • dateToString

      String dateToString(Date src, String format)
      Format a Date as a String using the JVM's default time zone.
      Parameters:
      src - The date to format
      format - The date format to apply
      Returns:
      The formatted date
    • dateToString

      String dateToString(Date src, String format, TimeZone tz)
      Format a Date as a String in the supplied time zone.
      Parameters:
      src - The date to format
      format - The date format to apply
      tz - The time zone to format the date in
      Returns:
      The formatted date