Class MiscUtils


  • public class MiscUtils
    extends Object
    • Field Detail

      • integrateLocale

        protected static boolean integrateLocale
    • Constructor Detail

      • MiscUtils

        public MiscUtils()
    • Method Detail

      • getDebugInstance

        public static Debug getDebugInstance()
      • getInternalToken

        public static SSOToken getInternalToken()
        Gets the internal Access Manager user token (dsameuser)
        Returns:
        the internal user token (dsameuser)
      • getUserLocale

        public static String getUserLocale​(SSOToken token)
        Method to get the user locale.
        Parameters:
        token - SSOToken of the authenticated user
        Returns:
        a String value representing the user locale
      • combineAttrSets

        public static AttrSet combineAttrSets​(AttrSet attrSet1,
                                              AttrSet attrSet2)
        Combines 2 AttrSets and returns the result set. The original sets are not modified.
        Parameters:
        attrSet1 - the first AttrSet
        attrSet2 - the second AttrSet
        Returns:
        an AttrSet which has combined values of attrSet1 & attrSet2
      • mergeMaps

        public static Map mergeMaps​(Map mapA,
                                    Map mapB)
        Merge the values in two maps and return the result map. The values in the smaller map are merged with the larger map and the larger map is returned.
        Parameters:
        mapA - the first map
        mapB - the second map
        Returns:
        a result map which the biggest of the two maps with values merged from the smaller one.
      • mapSetToString

        public static String mapSetToString​(Map map)
      • mapByteToString

        public static String mapByteToString​(Map map)
      • getSetCopy

        public static Set getSetCopy​(Set values)
      • stringArrayToSet

        public static Set stringArrayToSet​(String[] strs)
        Method to convert a String array to a set
        Parameters:
        strs - the String array
        Returns:
        a Set representing the String array
      • attrSetToMap

        public static Map attrSetToMap​(AttrSet attrSet)
      • attrSetToMap

        public static Map attrSetToMap​(AttrSet attrSet,
                                       boolean fetchByteValues)
        Method to convert a AttrSet object to Map.
        Parameters:
        attrSet - the AttrSet to be converted to a Map
        fetchByteValues - if false stringValues are added, if true byteValues are added.
        Returns:
        a Map containing attribute names as key's and a Set of attribute values or byte Values
      • mapToAttrSet

        public static AttrSet mapToAttrSet​(Map map)
        Method to convert a Map to AttrSet.
        Parameters:
        map - a map contaning attribute names as keys and a Set of attribute values corresponding to each map key.
        Returns:
        an AttrSet having the contents of the supplied map
      • mapToAttrSet

        public static AttrSet mapToAttrSet​(Map map,
                                           boolean byteValues)
        Method to convert a Map to AttrSet.
        Parameters:
        map - a map contaning attribute names as keys and a Set of attribute values corresponding to each map key.
        byteValues - if true then values are bytes otherwise strings
        Returns:
        an AttrSet having the contents of the supplied map
      • getPrincipalDN

        public static String getPrincipalDN​(SSOToken token)
                                     throws SSOException
        Gets the principal DN String in RFC lowercase format from the SSOToken
        Parameters:
        token - a valid SSOToken
        Returns:
        a principal DN corresponding to token
        Throws:
        SSOException - if the token is not valid
      • combineOCs

        public static Set combineOCs​(Set one,
                                     Set two)
        Combines two sets which contains objectclass values of an entry in a case insensitive manner. OC values are sometimes returned by LDAP in mixed case and when duplicate values for Objectclass exists in a mixed case, there is a Object class violation Note: there is a possibility that this method will return null
      • isObjectClassPresent

        public static boolean isObjectClassPresent​(Set objectClasses,
                                                   String objectClass)
        Method to compare all the object classes in the Set with the specfied object class. Will do a case insensitive comparision.
        Parameters:
        objectClasses - Set of object classes
        objectClass - the specified object class
        Returns:
        true if the specified object class is present. False otherwise.
      • updateAndGetRemovableOCs

        public static Set updateAndGetRemovableOCs​(Set origSet,
                                                   Set removeOCs)
        Method which removes the specified object class from original set and returns the set of object classes that were removed.
        Parameters:
        origSet - the original Set
        removeOCs - the Set of object classes to be removed
        Returns:
        the Set of object classes that were removed.
      • removeEmptyValues

        public static Map removeEmptyValues​(Map attrMap)
        Removes Empty sets from attribute-value maps. So that SDK does not try to remove these attributes from newly created entries. Such empty sets should be ignored, when entry is being created.
        Parameters:
        attrMap -
        Returns:
        map without empty set.
      • toGuidArray

        public static Guid[] toGuidArray​(Set set)
        Convert a Set to Guid object array
        Parameters:
        set - the Set to be converted
        Returns:
        an array of Guid[] objects
      • getGuidArray

        public static Guid[] getGuidArray​(Set set)
        Convert a Set to Guid object array
        Parameters:
        set - the Set to be converted
        Returns:
        an array of Guid[] objects