use of com.iplanet.ums.UMSException in project OpenAM by OpenRock.
the class DirectoryServicesImpl method createEntity.
/**
* Method to create a user entry
*/
private void createEntity(SSOToken token, PersistentObject parentObj, int objectType, Map attributes, String profileName) throws UMSException, AMEntryExistsException, AMException {
String orgDN = getOrganizationDN(internalToken, parentObj.getDN());
// Invoke the Pre Processing plugin
AttrSet attrSet = CommonUtils.mapToAttrSet(attributes);
makeNamingFirst(attrSet, getNamingAttribute(objectType), profileName);
String ctName = getCreationTemplateName(objectType);
if (ctName == null) {
// Create a user if no CT defined.
ctName = "BasicUser";
}
TemplateManager tempMgr = TemplateManager.getTemplateManager();
CreationTemplate creationTemp = tempMgr.getCreationTemplate(ctName, new Guid(orgDN), TemplateManager.SCOPE_ANCESTORS);
attrSet = combineOCs(creationTemp, attrSet);
PersistentObject user = new PersistentObject(creationTemp, attrSet);
try {
parentObj.addChild(user);
} catch (AccessRightsException e) {
if (debug.warningEnabled()) {
debug.warning("DirectoryServicesImpl.createEntity():" + " Insufficient Access rights to create entity", e);
}
throw new AMException(token, "460");
} catch (EntryAlreadyExistsException ee) {
if (ComplianceServicesImpl.isComplianceUserDeletionEnabled()) {
// COMPLIANCE
// If the existing entry is marked for deletion, then
// the error message should be different.
complianceImpl.checkIfDeletedUser(token, user.getDN());
}
if (debug.warningEnabled()) {
debug.warning("DirectoryServicesImpl.createEntity() Entity " + "already exists: ", ee);
}
throw new AMEntryExistsException(token, "462", ee);
} catch (UMSException ue) {
if (debug.warningEnabled()) {
debug.warning("DirectoryServicesImpl.createEntity(): Internal " + "Error occurred. Unable to create User Entry", ue);
}
processInternalException(token, ue, "324");
}
}
use of com.iplanet.ums.UMSException in project OpenAM by OpenRock.
the class DirectoryServicesImpl method registerService.
/**
* Register a service for an org or org unit policy to a profile
*
* @param token
* token
* @param orgDN
* DN of the org
* @param serviceName
* Service Name
*/
public void registerService(SSOToken token, String orgDN, String serviceName) throws AMException, SSOException {
try {
// This returns a valid set only if the service has
// Dynamic attributes
Set attrNames = getServiceAttributesWithQualifier(token, serviceName);
if ((attrNames != null) && !attrNames.isEmpty()) {
PersistentObject po = UMSObject.getObjectHandle(token, new Guid(orgDN));
DirectCOSDefinition dcos = createCOSDefinition(serviceName, attrNames);
COSManager cm = COSManager.getCOSManager(token, po.getGuid());
cm.addDefinition(dcos);
}
} catch (AccessRightsException e) {
debug.error("DirectoryServicesImpl.registerService() " + "Insufficient access rights to register service: " + serviceName, e);
throw new AMException(token, "460");
} catch (EntryAlreadyExistsException e) {
if (debug.warningEnabled()) {
debug.warning("DirectoryServicesImpl.registerService() " + "Service " + serviceName + " already registered", e);
}
Object[] args = { serviceName };
String locale = CommonUtils.getUserLocale(token);
throw new AMException(AMSDKBundle.getString("464", args, locale), "464", args);
} catch (SMSException e) {
debug.error("DirectoryServicesImpl.registerService() Unable to " + "register service: " + serviceName, e);
throw new AMException(token, "914");
} catch (UMSException e) {
debug.error("DirectoryServicesImpl.registerService() Unable to " + "register service: " + serviceName, e);
throw new AMException(token, "914", e);
}
}
use of com.iplanet.ums.UMSException 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.ums.UMSException 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.ums.UMSException 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);
}
}
Aggregations