Class AMAdminUtils


  • public class AMAdminUtils
    extends Object
    This provides a set helper methods to access Access and Service Management SDKs.
    • Constructor Detail

      • AMAdminUtils

        public AMAdminUtils()
    • Method Detail

      • getSuperAdminSSOToken

        public static final SSOToken getSuperAdminSSOToken()
                                                    throws SecurityException
        Returns the Single-Sign-On Token of super administrator.
        Returns:
        Single-Sign-On Token of super administrator.
        Throws:
        SecurityException - if security check fails.
      • getValue

        public static Object getValue​(Collection collection)
        Returns the first value of a collection. Returns empty string if set is collection or null.
        Parameters:
        collection - Collection to act on.
      • getIntValue

        public static int getIntValue​(Set set,
                                      int defaultValue)
                               throws NumberFormatException
        Returns the first value of a set. Returns -1 if set is empty or null. Returns int equals of the string.
        Parameters:
        set - Set to act on.
        defaultValue - Default Value of set is empty.
        Throws:
        NumberFormatException - if the item in the set is not an integer
      • wrapInSet

        public static Set wrapInSet​(Object obj)
        Returns a hash set containing a given object.
        Parameters:
        obj - Object to be added in set.
        Returns:
        a hash set containing a given object.
      • toSet

        public static Set<String> toSet​(Object... array)
        Returns a set that contains all items in array, converted to trimmed strings.
        Parameters:
        array - Array which contains the items.
        Returns:
        a set that contains all items in array.
        Throws:
        NullPointerException - if any item in the array is null.
      • toSetIgnoreEmpty

        public static Set<String> toSetIgnoreEmpty​(Object... items)
        Converts an array of objects into a set of strings by calling the Object.toString() method on each item and trimming the result. If the item's trimmed string is empty then it is excluded from the set.
        Parameters:
        items - array of items to add to the set.
        Returns:
        a set of all items in the array, converted to trimmed strings. Excludes any empty string elements.
        Throws:
        NullPointerException - if any item in the array is null.
      • toOrderedSet

        public static Set toOrderedSet​(Object[] array)
        Returns a set that contains all items in array.
        Parameters:
        array - Array which contains the items.
        Returns:
        a set that contains all items in array.
      • toList

        public static List toList​(Object[] array)
        Returns a list that contains all items in array.
        Parameters:
        array - Array which contains the items.
        Returns:
        a list that contains all items in array.
      • getInt

        public static int getInt​(Set set,
                                 int defaultValue)
                          throws NumberFormatException
        Returns integer value of a item in a set.
        Parameters:
        set - Set that contains the item.
        defaultValue - default value if set is null or empty.
        Returns:
        integer value of a item in a set.
        Throws:
        NumberFormatException - if the item in the set in non integer.
      • removeMapEntries

        public static void removeMapEntries​(Map map,
                                            Set set)
        Removes the mapping of which keys matches with items in a given set.
        Parameters:
        map - Map object.
        set - Set of keys to be removed from map.
      • upCaseKeys

        public static Map upCaseKeys​(Map map)
        Returns a map of upper cased keys.
        Parameters:
        map - Map to operate on.
        Returns:
        a map of upper cased keys.
      • getAttribute

        public static Set getAttribute​(ServiceSchemaManager svcSchemaMgr,
                                       SchemaType type,
                                       String attribute)
                                throws SMSException
        Returns the default value of an attribute from the service schema.
        Parameters:
        svcSchemaMgr - Service schema manager.
        type - Schema type.
        attribute - Attribute name.
        Returns:
        values of service schema attribute.
        Throws:
        SMSException - if operations fails.
      • getStringFromInputStream

        public static String getStringFromInputStream​(InputStream is)
      • getInputStreamFromString

        public static InputStream getInputStreamFromString​(String buff)
      • removeAllCaseIgnore

        public static void removeAllCaseIgnore​(Set master,
                                               Set deletingSet)
        Removes a set of string entries in a set with case insensitivity check.
        Parameters:
        master - Master Set.
        deletingSet - Set that contains strings to be removed from master set.
      • lowerCase

        public static Set lowerCase​(Set set)
      • getParent

        public static String getParent​(String dn)
        Returns the parent DN for the given DN.
        Parameters:
        dn - name of the child object
        Returns:
        parent of dn
      • getFirstElement

        public static String getFirstElement​(Set set)
        Returns the first String element from the given set. If the set is empty, or null, an empty string will be returned.
        Parameters:
        set - where element resides
        Returns:
        first String element from the set.
      • getSearchResultWarningMessage

        public static String getSearchResultWarningMessage​(SearchResults results,
                                                           AMModel model)
        Gets search results warning message. SearchResult returns an error code whenever size or time limit is reached. This method interprets the error code and return the appropriate warning message. Empty string is returned if no limits are reached.
        Parameters:
        results - Access Management Search Result object.
        model - to retrieve localized string.
        Returns:
        search results warning message.
      • getString

        public static String getString​(Collection collection,
                                       String delimiter,
                                       boolean reverse)
        Returns a concatenation string of all entries in a collection.
        Parameters:
        collection - Collection.
        delimiter - Delimiter
        reverse - true to traversal the entries from bottom up.
        Returns:
        a concatenation string of all entries in a collection.
      • getStringAttribute

        public static String getStringAttribute​(ServiceSchemaManager svcSchemaMgr,
                                                SchemaType type,
                                                String attribute)
                                         throws SMSException
        Returns the string value of an attribute.
        Parameters:
        svcSchemaMgr - service schema manager
        type - schema type
        attribute - name
        Returns:
        string value of an attribute
        Throws:
        SMSException - if operation fails
      • replaceString

        public static String replaceString​(String string,
                                           String orig,
                                           String substitution)
        Replaces character/s in a string with another.
        Parameters:
        string - String to work on.
        orig - Original character/s.
        substitution - Substitution.
        Returns:
        Manipulated string.
      • replaceString

        public static List replaceString​(List list,
                                         String orig,
                                         String substitution)
        Replaces character/s in a string with another
        Parameters:
        list - List of string.
        orig - Original character/s.
        substitution - Substitution.
        Returns:
        Manipulated list.
      • getValuesFromDelimitedString

        public static Map getValuesFromDelimitedString​(String deString,
                                                       String delimiter)
        Returns a map of String of String from a delimited string. Example key1=x|key2=y.
        Parameters:
        deString - Delimited String
        delimiter - Delimiter.
        Returns:
        a map of String of String from a delimited string.
      • getDelimitedValues

        public static Set getDelimitedValues​(String deString,
                                             String delimiter)
        Returns a set of string from a delimited string. Example val1,val2,...,valN.
        Parameters:
        deString - Delimited String
        delimiter - Delimiter.
        Returns:
        Set of string from a delimited string.
      • getAttributeSchema

        public static AttributeSchema getAttributeSchema​(String serviceName,
                                                         SchemaType schemaType,
                                                         String subSchemaName,
                                                         String attributeName)
        Returns attribute schema object.
        Parameters:
        serviceName - Name of service.
        schemaType - Type of Schema.
        subSchemaName - Name of sub schema.
        attributeName - Name of attribute schema.
        Returns:
        attribute schema object.
      • getDisplayableAttributeNames

        public static Set getDisplayableAttributeNames​(String serviceName,
                                                       SchemaType schemaType)
        Returns a set of attribute schemas that can be displayed in console for a service of a given schema type.
        Parameters:
        serviceName - Name of Service.
        schemaType - Schema Type.
        Returns:
        set of attribute schemas that can be displayed in console.
      • getSchemaSchema

        public static ServiceSchema getSchemaSchema​(String serviceName,
                                                    IdType idType)
        Returns service schema for an IdType.
        Parameters:
        serviceName - Name of Service.
        idType - IdType.
        Returns:
        service schema for an IdType.
      • makeMapValuesEmpty

        public static void makeMapValuesEmpty​(Map map)
      • toList

        public static List toList​(com.iplanet.jato.view.html.OptionList optList)
      • orderByStringLength

        public static List orderByStringLength​(Collection collection)
        Returns a list of strings in the order of string length. Longest string is in front of the list.
        Parameters:
        collection - Collections of String.
        Returns:
        a list of strings in the order of string length.
      • cloneStringToSetMap

        public static Map cloneStringToSetMap​(Map orig)
        Returns a clone map of String to Set.
        Parameters:
        orig - Map to be cloned.
        Returns:
        cloned map.
      • removeAllByDN

        public static void removeAllByDN​(Set<String> originalSet,
                                         Collection<String> toDelete)
        Removes all matching entries from a set if entries exist in another set. entries in the sets are LDAP entries.
        Parameters:
        originalSet - Original Set.
        toDelete - Collection of entries to be deleted.
      • getUserAttributeNames

        public static Set getUserAttributeNames()