Package com.iplanet.am.sdk.common
Class MiscUtils
- java.lang.Object
-
- com.iplanet.am.sdk.common.MiscUtils
-
public class MiscUtils extends Object
-
-
Field Summary
Fields Modifier and Type Field Description protected static boolean
integrateLocale
-
Constructor Summary
Constructors Constructor Description MiscUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Map
attrSetToMap(AttrSet attrSet)
static Map
attrSetToMap(AttrSet attrSet, boolean fetchByteValues)
Method to convert a AttrSet object to Map.static AttrSet
combineAttrSets(AttrSet attrSet1, AttrSet attrSet2)
Combines 2 AttrSets and returns the result set.static Set
combineOCs(Set one, Set two)
Combines two sets which contains objectclass values of an entry in a case insensitive manner.static Debug
getDebugInstance()
static Guid[]
getGuidArray(Set set)
Convert a Set to Guid object arraystatic SSOToken
getInternalToken()
Gets the internal Access Manager user token (dsameuser)static String
getPrincipalDN(SSOToken token)
Gets the principal DN String in RFC lowercase format from the SSOTokenstatic Set
getSetCopy(Set values)
static String
getUserLocale(SSOToken token)
Method to get the user locale.static boolean
isObjectClassPresent(Set objectClasses, String objectClass)
Method to compare all the object classes in the Set with the specfied object class.static String
mapByteToString(Map map)
static String
mapSetToString(Map map)
static AttrSet
mapToAttrSet(Map map)
Method to convert a Map to AttrSet.static AttrSet
mapToAttrSet(Map map, boolean byteValues)
Method to convert a Map to AttrSet.static Map
mergeMaps(Map mapA, Map mapB)
Merge the values in two maps and return the result map.static Map
removeEmptyValues(Map attrMap)
Removes Empty sets from attribute-value maps.static Set
stringArrayToSet(String[] strs)
Method to convert a String array to a setstatic Guid[]
toGuidArray(Set set)
Convert a Set to Guid object arraystatic 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.
-
-
-
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 AttrSetattrSet2
- 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 mapmapB
- the second map- Returns:
- a result map which the biggest of the two maps with values merged from the smaller one.
-
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, boolean fetchByteValues)
Method to convert a AttrSet object to Map.- Parameters:
attrSet
- the AttrSet to be converted to a MapfetchByteValues
- 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 classesobjectClass
- 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 SetremoveOCs
- 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
-
-