Search in sources :

Example 11 with CreationTemplate

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);
}
Also used : Set(java.util.Set) OrderedSet(com.sun.identity.shared.datastruct.OrderedSet) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) AttrSet(com.iplanet.services.ldap.AttrSet) Guid(com.iplanet.ums.Guid) StaticGroup(com.iplanet.ums.StaticGroup) Attr(com.iplanet.services.ldap.Attr) AttrSet(com.iplanet.services.ldap.AttrSet) CreationTemplate(com.iplanet.ums.CreationTemplate) StaticGroup(com.iplanet.ums.StaticGroup) TemplateManager(com.iplanet.ums.TemplateManager) HashSet(java.util.HashSet)

Example 12 with CreationTemplate

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);
}
Also used : CreationTemplate(com.iplanet.ums.CreationTemplate) TemplateManager(com.iplanet.ums.TemplateManager) Guid(com.iplanet.ums.Guid) AttrSet(com.iplanet.services.ldap.AttrSet)

Example 13 with CreationTemplate

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);
}
Also used : CreationTemplate(com.iplanet.ums.CreationTemplate) ManagedRole(com.iplanet.ums.ManagedRole) TemplateManager(com.iplanet.ums.TemplateManager) Guid(com.iplanet.ums.Guid) AttrSet(com.iplanet.services.ldap.AttrSet) ManagedRole(com.iplanet.ums.ManagedRole)

Example 14 with CreationTemplate

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;
    }
}
Also used : CreationTemplate(com.iplanet.ums.CreationTemplate) UMSException(com.iplanet.ums.UMSException) Guid(com.iplanet.ums.Guid)

Example 15 with CreationTemplate

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);
}
Also used : CreationTemplate(com.iplanet.ums.CreationTemplate) TemplateManager(com.iplanet.ums.TemplateManager) Guid(com.iplanet.ums.Guid) AssignableDynamicGroup(com.iplanet.ums.AssignableDynamicGroup) AttrSet(com.iplanet.services.ldap.AttrSet)

Aggregations

CreationTemplate (com.iplanet.ums.CreationTemplate)15 Guid (com.iplanet.ums.Guid)13 TemplateManager (com.iplanet.ums.TemplateManager)13 AttrSet (com.iplanet.services.ldap.AttrSet)12 UMSException (com.iplanet.ums.UMSException)4 Attr (com.iplanet.services.ldap.Attr)3 AMEntryExistsException (com.iplanet.am.sdk.AMEntryExistsException)2 AMException (com.iplanet.am.sdk.AMException)2 AMOrganizationalUnit (com.iplanet.am.sdk.AMOrganizationalUnit)2 AccessRightsException (com.iplanet.ums.AccessRightsException)2 AssignableDynamicGroup (com.iplanet.ums.AssignableDynamicGroup)2 EntryAlreadyExistsException (com.iplanet.ums.EntryAlreadyExistsException)2 OrganizationalUnit (com.iplanet.ums.OrganizationalUnit)2 PersistentObject (com.iplanet.ums.PersistentObject)2 AMHashMap (com.iplanet.am.sdk.AMHashMap)1 AMUserEntryProcessed (com.iplanet.am.sdk.AMUserEntryProcessed)1 DynamicGroup (com.iplanet.ums.DynamicGroup)1 FilteredRole (com.iplanet.ums.FilteredRole)1 ManagedRole (com.iplanet.ums.ManagedRole)1 PeopleContainer (com.iplanet.ums.PeopleContainer)1