use of com.iplanet.ums.AccessRightsException in project OpenAM by OpenRock.
the class DirectoryServicesImpl method unRegisterService.
// Rename from removeService to unRegisterService
/**
* Un register service for a AMro profile.
*
* @param token
* SSOToken
* @param entryDN
* DN of the profile whose service is to be removed
* @param objectType
* profile type
* @param serviceName
* Service Name
* @param type
* Template type
*/
public void unRegisterService(SSOToken token, String entryDN, int objectType, String serviceName, int type) throws AMException {
if (type == AMTemplate.DYNAMIC_TEMPLATE) {
// TODO:change "cn" to fleasible naming attribute for AMObject.ROLE
try {
PersistentObject po = UMSObject.getObjectHandle(token, new Guid(entryDN));
COSManager cm = null;
// COS Definition to obtaint depends on different profile type
switch(objectType) {
case AMObject.ROLE:
case AMObject.FILTERED_ROLE:
cm = COSManager.getCOSManager(token, po.getParentGuid());
break;
case AMObject.ORGANIZATION:
case AMObject.ORGANIZATIONAL_UNIT:
case AMObject.PEOPLE_CONTAINER:
cm = COSManager.getCOSManager(token, po.getGuid());
break;
default:
// does not have COS
throw new AMException(token, "450");
}
DirectCOSDefinition dcos;
try {
dcos = (DirectCOSDefinition) cm.getDefinition(serviceName);
} catch (COSNotFoundException e) {
if (debug.messageEnabled()) {
debug.message("DirectoryServicesImpl." + "unRegisterService() " + "No COSDefinition found for service: " + serviceName);
}
Object[] args = { serviceName };
String locale = CommonUtils.getUserLocale(token);
throw new AMException(AMSDKBundle.getString("463", args, locale), "463", args);
}
// Remove the COS Definition and Template
dcos.removeCOSTemplates();
cm.removeDefinition(serviceName);
} catch (AccessRightsException e) {
debug.error("DirectoryServicesImpl.unRegisterService() " + "Insufficient Access rights to unRegister service: ", e);
throw new AMException(token, "460");
} catch (UMSException e) {
debug.error("DirectoryServicesImpl.unRegisterService: " + "Unable to unregister service ", e);
throw new AMException(token, "855", e);
}
}
}
use of com.iplanet.ums.AccessRightsException in project OpenAM by OpenRock.
the class DirectoryServicesImpl method removeSingleEntry.
/**
* Private method to delete a single entry
*/
private void removeSingleEntry(SSOToken token, String entryDN, int objectType, boolean softDelete) throws AMException, SSOException {
Map attributes = null;
EmailNotificationHelper mailer = null;
String eDN = entryDN;
if (objectType == AMObject.USER) {
eDN = DN.valueOf(entryDN).parent().toString();
}
String orgDN = getOrganizationDN(internalToken, eDN);
try {
if (objectType == AMObject.USER) {
// Extract a delete notification list
mailer = new EmailNotificationHelper(entryDN);
mailer.setUserDeleteNotificationList();
}
if ((getUserPostPlugin() != null) || (mailer != null && mailer.isPresentUserDeleteNotificationList())) {
// Obtain the attributes needed to send notification and also
// call backs as these won't be available after deletion
attributes = getAttributes(token, entryDN, objectType);
}
processPreDeleteCallBacks(token, entryDN, attributes, orgDN, objectType, softDelete);
// } else {
if (dcTreeImpl.isRequired()) {
String rfcDN = LDAPUtils.formatToRFC(entryDN);
dcTreeImpl.removeDomain(internalToken, rfcDN);
}
Guid guid = new Guid(entryDN);
UMSObject.removeObject(token, guid);
// }
} catch (AccessRightsException e) {
debug.error("DirectoryServicesImpl.removeEntry() Insufficient " + "access rights to remove entry: " + entryDN, e);
throw new AMException(token, "460");
} catch (EntryNotFoundException e) {
String entry = getEntryName(e);
debug.error("DirectoryServicesImpl.removeEntry() Entry not found: " + entry, e);
String msgid = getEntryNotFoundMsgID(objectType);
Object[] args = { entry };
String locale = CommonUtils.getUserLocale(token);
throw new AMException(AMSDKBundle.getString(msgid, args, locale), msgid, args);
} catch (UMSException e) {
debug.error("DirectoryServicesImpl.removeEntry() Unable to remove: " + " Internal error occurred: ", e);
throw new AMException(token, "325", e);
}
processPostDeleteCallBacks(token, entryDN, attributes, orgDN, objectType, softDelete);
if (objectType == AMObject.USER) {
AMUserEntryProcessed postPlugin = getUserPostPlugin();
if (postPlugin != null) {
// TODO: Remove after deprecating interface
postPlugin.processUserDelete(token, entryDN, attributes);
}
if (mailer != null && mailer.isPresentUserDeleteNotificationList()) {
mailer.sendUserDeleteNotification(attributes);
}
}
}
use of com.iplanet.ums.AccessRightsException in project OpenAM by OpenRock.
the class DirectoryServicesImpl method createAMTemplate.
/**
* Create an AMTemplate (COSTemplate)
*
* @param token
* token
* @param entryDN
* DN of the profile whose template is to be set
* @param objectType
* the entry type
* @param serviceName
* Service Name
* @param attributes
* attributes to be set
* @param priority
* template priority
* @return String DN of the newly created template
*/
public String createAMTemplate(SSOToken token, String entryDN, int objectType, String serviceName, Map attributes, int priority) throws AMException {
// TBD, each time a Org/PC is created, need to create default role
COSManager cm = null;
DirectCOSDefinition dCOS = null;
String roleDN = null;
// TBD, change "cn" to flesible naming attrsibute for AMObject.ROLE
try {
PersistentObject po = UMSObject.getObjectHandle(token, new Guid(entryDN));
// get COS Definition depends on different profile type
switch(objectType) {
case AMObject.ROLE:
case AMObject.FILTERED_ROLE:
roleDN = entryDN;
cm = COSManager.getCOSManager(token, po.getParentGuid());
dCOS = (DirectCOSDefinition) cm.getDefinition(serviceName);
break;
case AMObject.ORGANIZATION:
case AMObject.ORGANIZATIONAL_UNIT:
case AMObject.PEOPLE_CONTAINER:
roleDN = "cn=" + CONTAINER_DEFAULT_TEMPLATE_ROLE + "," + entryDN;
cm = COSManager.getCOSManager(token, po.getGuid());
dCOS = (DirectCOSDefinition) cm.getDefinition(serviceName);
break;
default:
// does not have COS
throw new AMException(token, "450");
}
// add template priority
AttrSet attrSet = CommonUtils.mapToAttrSet(attributes);
if (priority != AMTemplate.UNDEFINED_PRIORITY) {
Attr attr = new Attr("cospriority");
attr.addValue("" + priority);
attrSet.add(attr);
}
COSTemplate template = createCOSTemplate(serviceName, attrSet, roleDN);
dCOS.addCOSTemplate(template);
return template.getGuid().toString();
} catch (COSNotFoundException e) {
if (debug.messageEnabled()) {
debug.message("DirectoryServicesImpl.createAMTemplate() " + "COSDefinition for service: " + serviceName + " not found: ", e);
}
Object[] args = { serviceName };
String locale = CommonUtils.getUserLocale(token);
throw new AMException(AMSDKBundle.getString("459", locale), "459", args);
} catch (EntryAlreadyExistsException e) {
if (debug.messageEnabled()) {
debug.message("DirectoryServicesImpl.createAMTemplate: template " + "already exists for " + serviceName, e);
}
String[] params = { serviceName };
String locale = CommonUtils.getUserLocale(token);
throw new AMException(AMSDKBundle.getString("854", params, locale), "854", params);
} catch (AccessRightsException e) {
if (debug.warningEnabled()) {
debug.warning("DirectoryServicesImpl.createAMTemplate() " + "Insufficient access rights to create template for: " + serviceName + " & entryDN: " + entryDN, e);
}
throw new AMException(token, "460");
} catch (UMSException e) {
if (debug.warningEnabled()) {
debug.warning("DirectoryServicesImpl.createAMTemplate() Unable" + " to create AMTemplate for: " + serviceName + " & entryDN: " + entryDN, e);
}
Object[] args = { serviceName };
String locale = CommonUtils.getUserLocale(token);
throw new AMException(AMSDKBundle.getString("459", locale), "459", args, e);
} catch (Exception e) {
if (debug.warningEnabled())
debug.warning("DirectoryServicesImpl.createAMTemplate", e);
throw new AMException(token, "451");
}
}
use of com.iplanet.ums.AccessRightsException in project OpenAM by OpenRock.
the class DirectoryServicesImpl method createEntry.
/**
* Create an entry in the Directory
*
* @param token
* SSOToken
* @param entryName
* name of the entry (naming value), e.g. "sun.com", "manager"
* @param objectType
* Profile Type, ORGANIZATION, AMObject.ROLE, AMObject.USER, etc.
* @param parentDN
* the parent DN
* @param attributes
* the initial attribute set for creation
*/
public void createEntry(SSOToken token, String entryName, int objectType, String parentDN, Map attributes) throws AMEntryExistsException, AMException, SSOException {
try {
if (entryName == null || entryName.length() == 0) {
throw new AMException(token, "320");
} else if (parentDN == null) {
throw new AMException(token, "322");
}
// tmpDN to be used only when validating since the method
// expects a DN.
String tmpDN = getNamingAttribute(objectType) + "=" + entryName + "," + parentDN;
validateAttributeUniqueness(tmpDN, objectType, true, attributes);
// Get handle to the parent object
PersistentObject po = UMSObject.getObjectHandle(token, new Guid(parentDN));
switch(objectType) {
case AMObject.USER:
createUser(token, po, attributes, entryName);
break;
case AMObject.MANAGED_ROLE:
case // same as MANAGED ROLE
AMObject.ROLE:
createRole(token, po, attributes, entryName);
break;
case AMObject.ORGANIZATION:
createOrganization(token, po, attributes, entryName);
break;
case AMObject.STATIC_GROUP:
case AMObject.GROUP:
createGroup(token, po, attributes, entryName);
break;
case AMObject.ASSIGNABLE_DYNAMIC_GROUP:
createAssignDynamicGroup(token, po, attributes, entryName);
break;
case AMObject.DYNAMIC_GROUP:
createDynamicGroup(token, po, attributes, entryName);
break;
case AMObject.PEOPLE_CONTAINER:
createPeopleContainer(po, attributes, entryName);
break;
case AMObject.ORGANIZATIONAL_UNIT:
createOrganizationalUnit(token, po, attributes, entryName);
break;
case AMObject.GROUP_CONTAINER:
createGroupContainer(po, attributes, entryName);
break;
case AMObject.FILTERED_ROLE:
createFilteredRole(token, po, attributes, entryName);
break;
case AMObject.RESOURCE:
createResource(po, attributes, entryName);
break;
case AMObject.UNDETERMINED_OBJECT_TYPE:
case AMObject.UNKNOWN_OBJECT_TYPE:
throw new AMException(token, "326");
default:
// Supported generic type
createEntity(token, po, objectType, attributes, entryName);
}
} catch (AccessRightsException e) {
if (debug.warningEnabled()) {
debug.warning("DirectoryServicesImpl.createEntry() " + "Insufficient access rights to create entry: " + entryName, e);
}
throw new AMException(token, "460");
} catch (EntryAlreadyExistsException e) {
if (debug.warningEnabled()) {
debug.warning("DirectoryServicesImpl.createEntry() Entry: " + entryName + "already exists: ", e);
}
String msgid = getEntryExistsMsgID(objectType);
String name = getEntryName(e);
Object[] args = { name };
throw new AMException(AMSDKBundle.getString(msgid, args), msgid, args);
} catch (UMSException e) {
if (debug.warningEnabled()) {
debug.warning("DirectoryServicesImpl.createEntry() Unable to " + "create entry: " + entryName, e);
}
throw new AMException(token, "324", e);
}
}
use of com.iplanet.ums.AccessRightsException in project OpenAM by OpenRock.
the class DirectoryServicesImpl method renameEntry.
/**
* Renames an entry. Currently used for only user renaming
*
* @param token
* the sso token
* @param objectType
* the type of entry
* @param entryDN
* the entry DN
* @param newName
* the new name (i.e., if RDN is cn=John, the value passed should
* be "John"
* @param deleteOldName
* if true the old name is deleted otherwise it is retained.
* @return new <code>DN</code> of the renamed entry
* @throws AMException
* if the operation was not successful
*/
public String renameEntry(SSOToken token, int objectType, String entryDN, String newName, boolean deleteOldName) throws AMException {
try {
PersistentObject po = UMSObject.getObjectHandle(token, new Guid(entryDN));
String newRDN = getNamingAttribute(objectType) + "=" + newName;
po.rename(newRDN, deleteOldName);
return po.getDN();
} catch (AccessRightsException e) {
if (debug.warningEnabled()) {
debug.warning("DirectoryServicesImpl.renameEntry(): User does " + "not have sufficient access rights ", e);
}
throw new AMException(token, "460");
} catch (EntryNotFoundException e) {
if (debug.warningEnabled()) {
debug.warning("DirectoryServicesImpl.renameEntry(): Entry " + "not found: ", e);
}
String msgid = getEntryNotFoundMsgID(objectType);
String entryName = getEntryName(e);
Object[] args = { entryName };
throw new AMException(AMSDKBundle.getString(msgid, args), msgid, args);
} catch (UMSException ume) {
if (debug.warningEnabled()) {
debug.warning("DirectoryServicesImpl.renameEntry(): Unable to " + "rename entry: ", ume);
}
throw new AMException(token, "360", ume);
}
}
Aggregations