use of com.iplanet.services.ldap.AttrSet in project OpenAM by OpenRock.
the class ComplianceServicesImpl method createAdminGroups.
/**
* Method which creates Admin Groups for an organization.
*
* @param token
* a SSOToken object
* @param org
* an organization object
* @exception AMException
* if an error is encountered
*/
protected void createAdminGroups(SSOToken token, PersistentObject org) throws AMException, SSOException {
String gcDN = NamingAttributeManager.getNamingAttribute(AMObject.GROUP_CONTAINER) + "=groups," + org.getDN();
AttrSet attrSet = new AttrSet();
Attr attr = new Attr("objectclass", INET_ADMIN_OBJECT_CLASS);
attrSet.add(attr);
attr = new Attr(ADMIN_ROLE_ATTR, DOMAIN_ADMINISTRATORS);
attrSet.add(attr);
Map attributes = CommonUtils.attrSetToMap(attrSet);
DirectoryServicesFactory.getInstance().createEntry(token, DOMAIN_ADMINISTRATORS, AMObject.ASSIGNABLE_DYNAMIC_GROUP, gcDN, attributes);
attrSet = new AttrSet();
attr = new Attr("objectclass", INET_ADMIN_OBJECT_CLASS);
attrSet.add(attr);
attr = new Attr(ADMIN_ROLE_ATTR, DOMAIN_ADMINISTRATORS);
attrSet.add(attr);
attributes = CommonUtils.attrSetToMap(attrSet);
DirectoryServicesFactory.getInstance().createEntry(token, DOMAIN_HELP_DESK_ADMINISTRATORS, AMObject.ASSIGNABLE_DYNAMIC_GROUP, gcDN, attributes);
}
use of com.iplanet.services.ldap.AttrSet in project OpenAM by OpenRock.
the class DirectoryServicesImpl method createPeopleContainer.
private void createPeopleContainer(PersistentObject parentObj, Map attributes, String profileName) throws UMSException, AMException {
AttrSet attrSet = CommonUtils.mapToAttrSet(attributes);
makeNamingFirst(attrSet, getNamingAttribute(AMObject.PEOPLE_CONTAINER), profileName);
TemplateManager tempMgr = TemplateManager.getTemplateManager();
String orgDN = getOrganizationDN(internalToken, parentObj.getDN());
CreationTemplate creationTemp = tempMgr.getCreationTemplate("BasicPeopleContainer", new Guid(orgDN), TemplateManager.SCOPE_ANCESTORS);
attrSet = combineOCs(creationTemp, attrSet);
com.iplanet.ums.PeopleContainer pc = new PeopleContainer(creationTemp, attrSet);
parentObj.addChild(pc);
}
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;
}
Aggregations