use of com.iplanet.ums.CreationTemplate in project OpenAM by OpenRock.
the class DirectoryServicesImpl method createCOSTemplate.
/**
* create COS Template from attribute set for a service, this will involve
* UMS Creation template for COSTemplate
*
* @param serviceID
* Service name
* @param attrSet
* the attribute set
* @param entryDN
* DN of the role
* @return COSTemplate COS Template created
*/
private COSTemplate createCOSTemplate(String serviceID, AttrSet attrset, String entryDN) throws UMSException {
TemplateManager tempMgr = TemplateManager.getTemplateManager();
CreationTemplate basicCOSTemplate = tempMgr.getCreationTemplate("BasicCOSTemplate", null);
// Now need to add the service object for the "serviceID" to the
// required attribute set of the cos creatation template
// need to use schema manager and service manager (TBD)
// But for now just add "extensibleObject" to it
COSTemplate cosTemplate = new COSTemplate(basicCOSTemplate, "\"" + entryDN + "\"");
cosTemplate.addTemplateAttribute("objectclass", "extensibleObject");
if (debug.messageEnabled()) {
debug.message("DirectoryServicesImpl.newCOSTemplate: cn = " + entryDN + " COSTemplate = " + cosTemplate);
}
int size = attrset.size();
for (int i = 0; i < size; i++) {
Attr attr = attrset.elementAt(i);
cosTemplate.modify(attr, ModificationType.ADD);
}
return cosTemplate;
}
use of com.iplanet.ums.CreationTemplate in project OpenAM by OpenRock.
the class DirectoryServicesImpl method createDynamicGroup.
private void createDynamicGroup(SSOToken token, PersistentObject parentObj, Map attributes, String profileName) throws UMSException, AMException {
// Invoke the Pre Process plugin
String orgDN = getOrganizationDN(internalToken, parentObj.getDN());
String entryDN = getNamingAttribute(AMObject.GROUP) + "=" + profileName + "," + parentObj.getDN();
attributes = callBackHelper.preProcess(token, entryDN, orgDN, null, attributes, CallBackHelper.CREATE, AMObject.DYNAMIC_GROUP, false);
AttrSet attrSet = CommonUtils.mapToAttrSet(attributes);
makeNamingFirst(attrSet, getNamingAttribute(AMObject.DYNAMIC_GROUP), profileName);
TemplateManager tempMgr = TemplateManager.getTemplateManager();
CreationTemplate creationTemp = tempMgr.getCreationTemplate("BasicDynamicGroup", new Guid(orgDN), TemplateManager.SCOPE_ANCESTORS);
attrSet = combineOCs(creationTemp, attrSet);
com.iplanet.ums.DynamicGroup dgroup = new com.iplanet.ums.DynamicGroup(creationTemp, attrSet);
String filter = dgroup.getSearchFilter();
if ("(objectClass=*)".equalsIgnoreCase(filter)) {
dgroup.setSearchFilter(SearchFilterManager.getSearchFilter(AMObject.USER, orgDN));
}
dgroup.setSearchScope(SearchScope.WHOLE_SUBTREE.intValue());
dgroup.setSearchBase(new Guid(orgDN));
parentObj.addChild(dgroup);
// Invoke Post processing impls
callBackHelper.postProcess(token, dgroup.getDN(), orgDN, null, attributes, CallBackHelper.CREATE, AMObject.DYNAMIC_GROUP, false);
}
use of com.iplanet.ums.CreationTemplate in project OpenAM by OpenRock.
the class Validation method validateAttribute.
/**
* Determines whether attribute is valid. Check the attribute if there is a
* validation method that needs to execute.
*
* @param attr
* attribute to test
* @param cls
* Class associatd with this attribute
* @param guid
* the guid of the Organization where the config data is stored
* @exception UMSException
* failure
* @exception DataConstraintException
* data validation failure
*/
public static void validateAttribute(Attr attr, Class cls, Guid guid) throws UMSException, DataConstraintException {
if (attr == null) {
return;
}
String validatorClass = null;
String rule = null;
String attrName = attr.getName();
// Gets the Template associates with the Class
CreationTemplate ct = TemplateManager.getTemplateManager().getCreationTemplate(cls, guid);
if (ct != null) {
// Gets an enumeration of ValidationElements of this attriubte
Enumeration en = ct.getValidation(attrName);
while (en.hasMoreElements()) {
ValidationElement vElement = (ValidationElement) en.nextElement();
validatorClass = vElement.getValidator();
rule = vElement.getRule();
if (validatorClass != null) {
validateAttribute(attr, validatorClass, rule);
}
}
}
}
use of com.iplanet.ums.CreationTemplate in project OpenAM by OpenRock.
the class DirectoryServicesImpl method createGroupContainer.
private void createGroupContainer(PersistentObject parentObj, Map attributes, String profileName) throws UMSException, AMException {
AttrSet attrSet = CommonUtils.mapToAttrSet(attributes);
makeNamingFirst(attrSet, getNamingAttribute(AMObject.GROUP_CONTAINER), profileName);
TemplateManager tempMgr = TemplateManager.getTemplateManager();
String orgDN = getOrganizationDN(internalToken, parentObj.getDN());
CreationTemplate creationTemp = tempMgr.getCreationTemplate("BasicGroupContainer", new Guid(orgDN), TemplateManager.SCOPE_ANCESTORS);
OrganizationalUnit gc = new OrganizationalUnit(creationTemp, attrSet);
parentObj.addChild(gc);
}
use of com.iplanet.ums.CreationTemplate 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);
}
Aggregations