use of com.iplanet.ums.CreationTemplate in project OpenAM by OpenRock.
the class DirectoryServicesImpl method createGroup.
private void createGroup(SSOToken token, PersistentObject parentObj, Map attributes, String profileName) throws UMSException, AMException {
// Invoke the Pre Processing 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.GROUP, false);
AttrSet attrSet = CommonUtils.mapToAttrSet(attributes);
makeNamingFirst(attrSet, getNamingAttribute(AMObject.GROUP), profileName);
TemplateManager tempMgr = TemplateManager.getTemplateManager();
CreationTemplate creationTemp = tempMgr.getCreationTemplate("BasicGroup", new Guid(orgDN), TemplateManager.SCOPE_ANCESTORS);
attrSet = combineOCs(creationTemp, attrSet);
com.iplanet.ums.StaticGroup sgroup = new com.iplanet.ums.StaticGroup(creationTemp, attrSet);
parentObj.addChild(sgroup);
Attr um = attrSet.getAttribute(UNIQUE_MEMBER_ATTRIBUTE);
if (um != null) {
String[] values = um.getStringValues();
Set members = new HashSet();
members.addAll(Arrays.asList(values));
updateUserAttribute(token, members, sgroup.getDN(), true);
}
// Invoke Post processing impls
callBackHelper.postProcess(token, sgroup.getDN(), orgDN, null, attributes, CallBackHelper.CREATE, AMObject.GROUP, false);
}
use of com.iplanet.ums.CreationTemplate in project OpenAM by OpenRock.
the class DirectoryServicesImpl method createResource.
private void createResource(PersistentObject parentObj, Map attributes, String profileName) throws UMSException, AMException {
AttrSet attrSet = CommonUtils.mapToAttrSet(attributes);
makeNamingFirst(attrSet, getNamingAttribute(AMObject.RESOURCE), profileName);
TemplateManager tempMgr = TemplateManager.getTemplateManager();
String orgDN = getOrganizationDN(internalToken, parentObj.getDN());
CreationTemplate creationTemp = tempMgr.getCreationTemplate("BasicResource", new Guid(orgDN), TemplateManager.SCOPE_ANCESTORS);
com.iplanet.ums.Resource resource = new com.iplanet.ums.Resource(creationTemp, attrSet);
parentObj.addChild(resource);
}
use of com.iplanet.ums.CreationTemplate in project OpenAM by OpenRock.
the class DirectoryServicesImpl method createRole.
private void createRole(SSOToken token, PersistentObject parentObj, Map attributes, String profileName) throws UMSException, AMException {
// Invoke the Pre Processing plugin
String orgDN = getOrganizationDN(internalToken, parentObj.getDN());
String entryDN = getNamingAttribute(AMObject.ROLE) + "=" + profileName + "," + parentObj.getDN();
attributes = callBackHelper.preProcess(token, entryDN, orgDN, null, attributes, CallBackHelper.CREATE, AMObject.ROLE, false);
AttrSet attrSet = CommonUtils.mapToAttrSet(attributes);
makeNamingFirst(attrSet, getNamingAttribute(AMObject.ROLE), profileName);
TemplateManager tempMgr = TemplateManager.getTemplateManager();
CreationTemplate creationTemp = tempMgr.getCreationTemplate("BasicManagedRole", new Guid(orgDN), TemplateManager.SCOPE_ANCESTORS);
attrSet = combineOCs(creationTemp, attrSet);
com.iplanet.ums.ManagedRole role = new com.iplanet.ums.ManagedRole(creationTemp, attrSet);
parentObj.addChild(role);
// Invoke Post processing impls
callBackHelper.postProcess(token, role.getDN(), orgDN, null, attributes, CallBackHelper.CREATE, AMObject.ROLE, false);
}
use of com.iplanet.ums.CreationTemplate in project OpenAM by OpenRock.
the class NamingAttributeManager method getNamingAttributeFromTemplate.
/**
* Gets the naming attribute after reading it from the corresponding
* creation template. If not found, a default value will be used
*/
private static String getNamingAttributeFromTemplate(int objectType, String orgDN) {
try {
// Intitalize TemplateManager if not already initialized
if (templateMgr == null) {
templateMgr = TemplateManager.getTemplateManager();
}
String templateName = getCreationTemplateName(objectType);
if (templateName == null) {
debug.warning("AMNamingAttrMgr.getNamingAttr(objectType, " + "orgDN): (" + objectType + "," + orgDN + ") Could not determine creation template name. " + "Returning <empty> value");
return "";
}
Guid orgGuid = ((orgDN == null) ? null : new Guid(orgDN));
CreationTemplate creationTemp = templateMgr.getCreationTemplate(templateName, orgGuid, TemplateManager.SCOPE_ANCESTORS);
// get search filter attribute
String namingAttr = creationTemp.getNamingAttribute();
if (namingAttr == null) {
debug.error("AMNamingAttrManager.getNamingAttr()" + " Naming attribute for Object Type:" + objectType + " Org DN: " + orgDN + " is null");
} else if (debug.messageEnabled()) {
debug.message("AMNamingAttrManager.getNamingAttr(): Naming " + "attribute for Object type= " + objectType + ": " + namingAttr);
}
return namingAttr;
} catch (UMSException ue) {
// The right thing would be to propagate this exception back
String defaultAttr = getDefaultNamingAttr(objectType);
debug.warning("Unable to get the naming attribute for " + objectType + " Using default " + defaultAttr);
return defaultAttr;
}
}
use of com.iplanet.ums.CreationTemplate in project OpenAM by OpenRock.
the class DirectoryServicesImpl method createAssignDynamicGroup.
private void createAssignDynamicGroup(SSOToken token, PersistentObject parentObj, Map attributes, String profileName) throws UMSException, AMException {
// Invoke the Pre Processing 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.ASSIGNABLE_DYNAMIC_GROUP, false);
AttrSet attrSet = CommonUtils.mapToAttrSet(attributes);
makeNamingFirst(attrSet, getNamingAttribute(AMObject.ASSIGNABLE_DYNAMIC_GROUP), profileName);
TemplateManager tempMgr = TemplateManager.getTemplateManager();
CreationTemplate creationTemp = tempMgr.getCreationTemplate("BasicAssignableDynamicGroup", new Guid(orgDN), TemplateManager.SCOPE_ANCESTORS);
attrSet = combineOCs(creationTemp, attrSet);
AssignableDynamicGroup adgroup = new AssignableDynamicGroup(creationTemp, attrSet);
adgroup.setSearchFilter("(memberof=" + entryDN + ")");
adgroup.setSearchScope(SearchScope.WHOLE_SUBTREE.intValue());
adgroup.setSearchBase(new Guid(orgDN));
parentObj.addChild(adgroup);
// Invoke Post processing impls
callBackHelper.postProcess(token, adgroup.getDN(), orgDN, null, attributes, CallBackHelper.CREATE, AMObject.ASSIGNABLE_DYNAMIC_GROUP, false);
}
Aggregations