use of com.iplanet.services.ldap.AttrSet in project OpenAM by OpenRock.
the class DirectoryServicesImpl method getAttributesFromDS.
/**
* Gets the specific attributes corresponding to the entryDN. This method
* obtains the DC Tree node attributes and also performs compliance related
* verification checks in compliance mode. Note: In compliance mode you can
* skip the compliance checks by setting ignoreCompliance to "false".
*
* @param token
* a valid SSOToken
* @param entryDN
* the DN of the entry whose attributes need to retrieved
* @param attrNames
* a Set of names of the attributes that need to be retrieved.
* The attrNames should not be null.
* @param ignoreCompliance
* a boolean value specificying if compliance related entries
* need to ignored or not. Ignored if true.
* @return a Map containing attribute names as keys and Set of values
* corresponding to each key.
* @throws AMException
* if an error is encountered in fetching the attributes
*/
public Map getAttributesFromDS(SSOToken token, String entryDN, Set attrNames, boolean ignoreCompliance, boolean byteValues, int profileType) throws AMException, SSOException {
if (attrNames == null) {
return getAttributes(token, entryDN, ignoreCompliance, byteValues, profileType);
}
try {
// Convert the attrNames to String[]
String[] names = (String[]) attrNames.toArray(new String[attrNames.size()]);
PersistentObject po = UMSObject.getObjectHandle(token, new Guid(entryDN));
// Perform compliance related checks
AttrSet attrSet;
if (!ignoreCompliance && ComplianceServicesImpl.isComplianceUserDeletionEnabled()) {
// check for deleted user by getting complaince attributes
attrSet = complianceImpl.verifyAndGetAttributes(po, names);
} else {
attrSet = po.getAttributes(names);
}
AMHashMap attributes = (AMHashMap) CommonUtils.attrSetToMap(attrSet, byteValues);
// Obtain DC tree attributes if applicable
Map dcAttributes = getDCTreeAttributes(token, entryDN, attrNames, byteValues, profileType);
attributes.copy(dcAttributes);
return attributes;
} catch (UMSException e) {
if (debug.warningEnabled()) {
debug.warning("DirectoryServicesImpl.getAttributes(): " + "Unable to get attributes: ", e);
}
// Extract the ldap error code from Exception
throw new AMException(token, "330", e);
}
}
use of com.iplanet.services.ldap.AttrSet in project OpenAM by OpenRock.
the class CallBackHelper method preProcess.
// TODO: Remove this. Use the Maps interface only
public AttrSet preProcess(SSOToken token, String entryDN, String orgDN, AttrSet oldAttrSet, AttrSet newAttrSet, int operation, int objectType, boolean softDelete) throws AMException {
Set implSet = getPrePostImpls(orgDN);
if (implSet != null && !implSet.isEmpty()) {
// Post processing impls present
// Iterate through the Pre-Processing Impls and execute
Iterator itr = implSet.iterator();
Map newAttrMap = CommonUtils.attrSetToMap(newAttrSet);
Map oldAttrMap = CommonUtils.attrSetToMap(oldAttrSet);
while (itr.hasNext()) {
String className = (String) itr.next();
AMCallBack impl = getCallBackObject(className);
if (impl == null) {
continue;
}
try {
Map map;
switch(operation) {
case CREATE:
map = impl.preProcessCreate(token, entryDN, newAttrMap, objectType);
newAttrMap = ((map == null) ? newAttrMap : map);
break;
case MODIFY:
map = impl.preProcessModify(token, entryDN, oldAttrMap, newAttrMap, objectType);
newAttrMap = ((map == null) ? newAttrMap : map);
break;
case DELETE:
impl.preProcessDelete(token, entryDN, oldAttrMap, softDelete, objectType);
break;
}
} catch (AMException ae) {
// Exception thrown by the external impl
debug.error("CallBackHelper.preProcess(): Preprocessing" + "impl " + className + " exception thrown by impl:", ae);
throw ae;
}
}
return CommonUtils.mapToAttrSet(newAttrMap);
}
// not null as newAttrSet will be the latest one needed for updation
return ((newAttrSet != null) ? newAttrSet : oldAttrSet);
}
use of com.iplanet.services.ldap.AttrSet in project OpenAM by OpenRock.
the class MiscUtils method mapToAttrSet.
/**
* Method to convert a Map to AttrSet.
*
* @param map
* a map contaning attribute names as keys and a Set of attribute
* values corresponding to each map key.
* @param byteValues
* if true then values are bytes otherwise strings
* @return an AttrSet having the contents of the supplied map
*/
public static AttrSet mapToAttrSet(Map map, boolean byteValues) {
AttrSet attrSet = new AttrSet();
if (map == null) {
return attrSet;
}
if (!byteValues) {
Iterator itr = map.keySet().iterator();
while (itr.hasNext()) {
String attrName = (String) (itr.next());
Set set = (Set) (map.get(attrName));
String[] attrValues = (set == null ? null : (String[]) set.toArray(new String[set.size()]));
attrSet.replace(new Attr(attrName, attrValues));
}
} else {
Iterator itr = map.keySet().iterator();
while (itr.hasNext()) {
String attrName = (String) (itr.next());
byte[][] attrValues = (byte[][]) (map.get(attrName));
attrSet.replace(new Attr(attrName, attrValues));
}
}
return attrSet;
}
use of com.iplanet.services.ldap.AttrSet in project OpenAM by OpenRock.
the class MiscUtils method combineAttrSets.
/**
* Combines 2 AttrSets and returns the result set. The original sets are not
* modified.
*
* @param attrSet1
* the first AttrSet
* @param attrSet2
* the second AttrSet
* @return an AttrSet which has combined values of attrSet1 & attrSet2
*/
public static AttrSet combineAttrSets(AttrSet attrSet1, AttrSet attrSet2) {
AttrSet retAttrSet = new AttrSet();
if (attrSet1 != null) {
int count = attrSet1.size();
for (int i = 0; i < count; i++) {
Attr attr = attrSet1.elementAt(i);
retAttrSet.add(attr);
}
}
if (attrSet2 != null) {
int count = attrSet2.size();
for (int i = 0; i < count; i++) {
Attr attr = attrSet2.elementAt(i);
retAttrSet.add(attr);
}
}
return retAttrSet;
}
use of com.iplanet.services.ldap.AttrSet in project OpenAM by OpenRock.
the class CommonUtils method combineAttrSets.
/**
* Combines 2 AttrSets and returns the result set. The original sets are not
* modified.
*
* @param attrSet1
* the first AttrSet
* @param attrSet2
* the second AttrSet
* @return an AttrSet which has combined values of attrSet1 & attrSet2
*/
protected static AttrSet combineAttrSets(AttrSet attrSet1, AttrSet attrSet2) {
AttrSet retAttrSet = new AttrSet();
if (attrSet1 != null) {
int count = attrSet1.size();
for (int i = 0; i < count; i++) {
Attr attr = attrSet1.elementAt(i);
retAttrSet.add(attr);
}
}
if (attrSet2 != null) {
int count = attrSet2.size();
for (int i = 0; i < count; i++) {
Attr attr = attrSet2.elementAt(i);
retAttrSet.add(attr);
}
}
return retAttrSet;
}
Aggregations