use of com.iplanet.services.ldap.Attr in project OpenAM by OpenRock.
the class ComplianceServicesImpl method verifyAndDeleteObject.
/**
* Method which checks if the entry corresponding to DN represents a user
* entry. If so, it sets the inetuserstatus attribute of the user to
* deleted. Otherwise, it simply deletes the entry corresponding to the DN
*
* @param token
* a SSOToken object
* @param profileDN
* a String representing a DN
*
* @exception AMException
* if an error is encountered while setting the
* intetuserstatus attribute or if an error was encountered
* while performing a delete.
*/
public void verifyAndDeleteObject(SSOToken token, String profileDN) throws AMException {
try {
EmailNotificationHelper mailer = null;
Map attributes = null;
Guid guid = new Guid(profileDN);
PersistentObject po = UMSObject.getObject(token, guid);
if (po instanceof com.iplanet.ums.User) {
Attr attr = new Attr(USER_STATUS_ATTRIBUTE, "deleted");
if (debug.messageEnabled()) {
debug.message("Compliance:verifyAndDeleteObject: " + "Soft-delete mode, setting inetuserstatus " + "to deleted. " + "profileDN=" + profileDN);
}
po.modify(attr, ModificationType.REPLACE);
po.save();
mailer = new EmailNotificationHelper(profileDN);
if (mailer != null) {
mailer.setUserDeleteNotificationList();
attributes = DirectoryServicesFactory.getInstance().getAttributes(token, profileDN, AMObject.USER);
if (mailer.isPresentUserDeleteNotificationList()) {
mailer.sendUserDeleteNotification(attributes);
}
}
return;
}
if (po instanceof com.iplanet.ums.Resource) {
Attr attr = new Attr(RESOURCE_STATUS_ATTRIBUTE, "deleted");
if (debug.messageEnabled()) {
debug.message("Compliance:verifyAndDeleteObject: " + "Soft-delete mode, setting icsstatus " + "to deleted");
}
po.modify(attr, ModificationType.REPLACE);
po.save();
return;
}
if (po instanceof com.iplanet.ums.StaticGroup || po instanceof com.iplanet.ums.AssignableDynamicGroup || po instanceof com.iplanet.ums.DynamicGroup) {
Attr attr = new Attr(GROUP_STATUS_ATTRIBUTE, "deleted");
if (debug.messageEnabled()) {
debug.message("Compliance:verifyAndDeleteObject: " + "Soft-delete mode, setting inetgroupstatus " + "to deleted");
}
po.modify(attr, ModificationType.REPLACE);
po.save();
return;
}
if (po instanceof com.iplanet.ums.Organization) {
if (debug.messageEnabled()) {
debug.message("Compliance:verifyAndDeleteObject: " + "Soft-delete mode, setting inetdomainstatus " + "to deleted");
}
Attr attr = new Attr(ORG_STATUS_ATTRIBUTE, "deleted");
po.modify(attr, ModificationType.REPLACE);
po.save();
DCTreeServicesImpl dcTreeImpl = (DCTreeServicesImpl) DirectoryServicesFactory.getInstance().getDCTreeServicesImpl();
if (dcTreeImpl.isRequired()) {
dcTreeImpl.updateDomainStatus(token, profileDN, "deleted");
}
} else {
UMSObject.removeObject(token, guid);
}
} catch (UMSException ue) {
debug.error("Compliance.deleteObject(): ", ue);
throw new AMException(AMSDKBundle.getString("773"), "773");
} catch (SSOException se) {
debug.error("Compliance.deleteObject(): ", se);
throw new AMException(AMSDKBundle.getString("773"), "773");
}
}
use of com.iplanet.services.ldap.Attr in project OpenAM by OpenRock.
the class ComplianceServicesImpl method checkIfDeletedOrg.
/**
* Method which checks if the entry corresponding to orgDN represents a
* deleted organization entry (entry with inetdomainstatus:deleted).
*
* @param token
* a SSOToken object.
* @param orgDN
* a String representing an organization DN.
*
* @exception AMEntryExistsException
* if the orgDN corresponds to a deleted organization.
*/
protected void checkIfDeletedOrg(SSOToken token, String orgDN) throws AMEntryExistsException {
Attr attr;
try {
PersistentObject po = UMSObject.getObject(token, new Guid(orgDN));
attr = po.getAttribute(ORG_STATUS_ATTRIBUTE);
} catch (UMSException ue) {
if (debug.messageEnabled())
debug.message("Compliance.checkIfDeletedOrg(): ", ue);
return;
}
if (((attr != null) && (attr.size() != 0)) && attr.contains("deleted")) {
// Org is deleted
debug.warning("Compliance.checkIfDeletedOrg(): " + "deleted org entry: " + orgDN);
throw new AMEntryExistsException(AMSDKBundle.getString("361"), "361");
}
}
use of com.iplanet.services.ldap.Attr 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.Attr in project OpenAM by OpenRock.
the class ComplianceServicesImpl method removeAttributesFromEntry.
/**
* Method to remove attributes from an entry
*/
private void removeAttributesFromEntry(SSOToken token, String dn, AttrSet attrSet) throws UMSException {
PersistentObject po = UMSObject.getObjectHandle(token, new Guid(dn));
int size = attrSet.size();
for (int i = 0; i < size; i++) {
Attr attr = attrSet.elementAt(i);
po.modify(attr, ModificationType.DELETE);
}
po.save();
}
use of com.iplanet.services.ldap.Attr 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