Search in sources :

Example 1 with CreationTemplate

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

Example 2 with CreationTemplate

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

Example 3 with CreationTemplate

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

Example 4 with CreationTemplate

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

Example 5 with CreationTemplate

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);
}
Also used : AccessRightsException(com.iplanet.ums.AccessRightsException) UMSException(com.iplanet.ums.UMSException) AMException(com.iplanet.am.sdk.AMException) PersistentObject(com.iplanet.ums.PersistentObject) Guid(com.iplanet.ums.Guid) EntryAlreadyExistsException(com.iplanet.ums.EntryAlreadyExistsException) AttrSet(com.iplanet.services.ldap.AttrSet) AMEntryExistsException(com.iplanet.am.sdk.AMEntryExistsException) CreationTemplate(com.iplanet.ums.CreationTemplate) TemplateManager(com.iplanet.ums.TemplateManager) AMUserEntryProcessed(com.iplanet.am.sdk.AMUserEntryProcessed) Map(java.util.Map) AMHashMap(com.iplanet.am.sdk.AMHashMap) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap)

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