use of com.iplanet.am.sdk.AMEntryExistsException in project OpenAM by OpenRock.
the class DirectoryServicesImpl method createUser.
/**
* Method to create a user entry
*/
private void createUser(SSOToken token, PersistentObject parentObj, Map attributes, String profileName) throws UMSException, AMEntryExistsException, AMException {
String orgDN = getOrganizationDN(internalToken, parentObj.getDN());
// Invoke the Pre Processing plugin
String entryDN = getNamingAttribute(AMObject.USER) + "=" + profileName + "," + parentObj.getDN();
attributes = callBackHelper.preProcess(token, entryDN, orgDN, null, attributes, CallBackHelper.CREATE, AMObject.USER, false);
AttrSet attrSet = CommonUtils.mapToAttrSet(attributes);
makeNamingFirst(attrSet, getNamingAttribute(AMObject.USER), profileName);
// Invoke the user password validation plugin
UserPasswordValidationHelper pluginImpl = new UserPasswordValidationHelper(token, orgDN);
try {
pluginImpl.validate(CommonUtils.attrSetToMap(attrSet));
} catch (AMException ame) {
debug.error("DirectoryServicesImpl.createUser(): Invalid " + "characters for user", ame);
throw ame;
}
TemplateManager tempMgr = TemplateManager.getTemplateManager();
CreationTemplate creationTemp = tempMgr.getCreationTemplate("BasicUser", new Guid(orgDN), TemplateManager.SCOPE_ANCESTORS);
attrSet = combineOCs(creationTemp, attrSet);
// User user = new User(creationTemp, attrSet);
PersistentObject user = new PersistentObject(creationTemp, attrSet);
try {
parentObj.addChild(user);
} catch (AccessRightsException e) {
if (debug.warningEnabled()) {
debug.warning("DirectoryServicesImpl.createUser(): Insufficient " + "Access rights to create user", 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.createUser() User " + "already exists: ", ee);
}
throw new AMEntryExistsException(token, "328", ee);
} catch (UMSException ue) {
if (debug.warningEnabled()) {
debug.warning("DirectoryServicesImpl.createUser(): Internal " + "Error occurred. Unable to create User Entry", ue);
}
processInternalException(token, ue, "324");
}
// Invoke Post processing impls
callBackHelper.postProcess(token, user.getDN(), orgDN, null, attributes, CallBackHelper.CREATE, AMObject.USER, false);
// TODO: REMOVE after Portal moves to new API's
AMUserEntryProcessed postPlugin = getUserPostPlugin();
if (postPlugin != null) {
Map attrMap = CommonUtils.attrSetToMap(attrSet);
postPlugin.processUserAdd(token, user.getDN(), attrMap);
}
EmailNotificationHelper mailerObj = new EmailNotificationHelper(user.getDN());
mailerObj.setUserCreateNotificationList();
mailerObj.sendUserCreateNotification(attributes);
}
use of com.iplanet.am.sdk.AMEntryExistsException 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.am.sdk.AMEntryExistsException 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.am.sdk.AMEntryExistsException in project OpenAM by OpenRock.
the class ComplianceServicesImpl method checkIfDeletedUser.
/**
* Method which checks if the entry corresponding to userDN represents a
* deleted user entry (entry with inetuserstatus:deleted)
*
* @param token
* a SSOToken object
* @param userDN
* a String representing a user DN
*
* @exception AMEntryExistsException
* if the userDN corresponds to a deleted user
*/
protected void checkIfDeletedUser(SSOToken token, String userDN) throws AMEntryExistsException {
String[] userAttribute = { USER_STATUS_ATTRIBUTE };
Attr attr;
try {
PersistentObject po = UMSObject.getObject(token, new Guid(userDN), userAttribute);
attr = po.getAttribute(USER_STATUS_ATTRIBUTE);
} catch (UMSException ue) {
if (debug.messageEnabled())
debug.message("Compliance.checkIfDeletedUser(): ", ue);
return;
}
if (attr != null) {
String attrValue = attr.getValue();
if (attrValue != null && attrValue.equalsIgnoreCase("deleted")) {
debug.warning("Compliance.checkIfDeletedUser(): " + "deleted user entry: " + userDN);
throw new AMEntryExistsException(AMSDKBundle.getString("329"), "329");
}
}
}
use of com.iplanet.am.sdk.AMEntryExistsException in project OpenAM by OpenRock.
the class RemoteServicesImpl 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 {
String tokenID = token.getTokenID().toString();
Object[] objs = { tokenID, entryName, new Integer(objectType), parentDN, attributes };
client.send(client.encodeMessage("createEntry", objs), sessionCookies.getLBCookie(tokenID), null);
} catch (AMRemoteException amrex) {
if (getDebug().messageEnabled()) {
getDebug().message("RemoteServicesImpl.createEntry: entryName=" + entryName + "; AMRemoteException caught exception=", amrex);
}
throw convertException(amrex);
} catch (SSOException ssoe) {
throw ssoe;
} catch (RemoteException rex) {
getDebug().error("RemoteServicesImpl.createEntry: caught " + "exception=", rex);
throw new AMException(AMSDKBundle.getString("1000"), "1000");
} catch (Exception ex) {
if (getDebug().messageEnabled()) {
getDebug().message("RemoteServicesImpl.createEntry: entryName=" + entryName + "; caught exception=", ex);
}
throw new AMException(AMSDKBundle.getString("1000"), "1000");
}
}
Aggregations