Search in sources :

Example 1 with COSTemplate

use of com.iplanet.ums.cos.COSTemplate 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 COSTemplate

use of com.iplanet.ums.cos.COSTemplate in project OpenAM by OpenRock.

the class DirectoryServicesImpl method createAMTemplate.

/**
     * Create an AMTemplate (COSTemplate)
     * 
     * @param token
     *            token
     * @param entryDN
     *            DN of the profile whose template is to be set
     * @param objectType
     *            the entry type
     * @param serviceName
     *            Service Name
     * @param attributes
     *            attributes to be set
     * @param priority
     *            template priority
     * @return String DN of the newly created template
     */
public String createAMTemplate(SSOToken token, String entryDN, int objectType, String serviceName, Map attributes, int priority) throws AMException {
    // TBD, each time a Org/PC is created, need to create default role
    COSManager cm = null;
    DirectCOSDefinition dCOS = null;
    String roleDN = null;
    // TBD, change "cn" to flesible naming attrsibute for AMObject.ROLE
    try {
        PersistentObject po = UMSObject.getObjectHandle(token, new Guid(entryDN));
        // get COS Definition depends on different profile type
        switch(objectType) {
            case AMObject.ROLE:
            case AMObject.FILTERED_ROLE:
                roleDN = entryDN;
                cm = COSManager.getCOSManager(token, po.getParentGuid());
                dCOS = (DirectCOSDefinition) cm.getDefinition(serviceName);
                break;
            case AMObject.ORGANIZATION:
            case AMObject.ORGANIZATIONAL_UNIT:
            case AMObject.PEOPLE_CONTAINER:
                roleDN = "cn=" + CONTAINER_DEFAULT_TEMPLATE_ROLE + "," + entryDN;
                cm = COSManager.getCOSManager(token, po.getGuid());
                dCOS = (DirectCOSDefinition) cm.getDefinition(serviceName);
                break;
            default:
                // does not have COS
                throw new AMException(token, "450");
        }
        // add template priority
        AttrSet attrSet = CommonUtils.mapToAttrSet(attributes);
        if (priority != AMTemplate.UNDEFINED_PRIORITY) {
            Attr attr = new Attr("cospriority");
            attr.addValue("" + priority);
            attrSet.add(attr);
        }
        COSTemplate template = createCOSTemplate(serviceName, attrSet, roleDN);
        dCOS.addCOSTemplate(template);
        return template.getGuid().toString();
    } catch (COSNotFoundException e) {
        if (debug.messageEnabled()) {
            debug.message("DirectoryServicesImpl.createAMTemplate() " + "COSDefinition for service: " + serviceName + " not found: ", e);
        }
        Object[] args = { serviceName };
        String locale = CommonUtils.getUserLocale(token);
        throw new AMException(AMSDKBundle.getString("459", locale), "459", args);
    } catch (EntryAlreadyExistsException e) {
        if (debug.messageEnabled()) {
            debug.message("DirectoryServicesImpl.createAMTemplate: template " + "already exists for " + serviceName, e);
        }
        String[] params = { serviceName };
        String locale = CommonUtils.getUserLocale(token);
        throw new AMException(AMSDKBundle.getString("854", params, locale), "854", params);
    } catch (AccessRightsException e) {
        if (debug.warningEnabled()) {
            debug.warning("DirectoryServicesImpl.createAMTemplate() " + "Insufficient access rights to create template for: " + serviceName + " & entryDN: " + entryDN, e);
        }
        throw new AMException(token, "460");
    } catch (UMSException e) {
        if (debug.warningEnabled()) {
            debug.warning("DirectoryServicesImpl.createAMTemplate() Unable" + " to create AMTemplate for: " + serviceName + " & entryDN: " + entryDN, e);
        }
        Object[] args = { serviceName };
        String locale = CommonUtils.getUserLocale(token);
        throw new AMException(AMSDKBundle.getString("459", locale), "459", args, e);
    } catch (Exception e) {
        if (debug.warningEnabled())
            debug.warning("DirectoryServicesImpl.createAMTemplate", e);
        throw new AMException(token, "451");
    }
}
Also used : AccessRightsException(com.iplanet.ums.AccessRightsException) UMSException(com.iplanet.ums.UMSException) COSTemplate(com.iplanet.ums.cos.COSTemplate) PersistentObject(com.iplanet.ums.PersistentObject) AMException(com.iplanet.am.sdk.AMException) Guid(com.iplanet.ums.Guid) EntryAlreadyExistsException(com.iplanet.ums.EntryAlreadyExistsException) Attr(com.iplanet.services.ldap.Attr) EntryAlreadyExistsException(com.iplanet.ums.EntryAlreadyExistsException) UMSException(com.iplanet.ums.UMSException) AMEventManagerException(com.iplanet.am.sdk.AMEventManagerException) AMEntryExistsException(com.iplanet.am.sdk.AMEntryExistsException) SizeLimitExceededException(com.iplanet.ums.SizeLimitExceededException) AMInvalidDNException(com.iplanet.am.sdk.AMInvalidDNException) TimeLimitExceededException(com.iplanet.ums.TimeLimitExceededException) SSOException(com.iplanet.sso.SSOException) AccessRightsException(com.iplanet.ums.AccessRightsException) LdapException(org.forgerock.opendj.ldap.LdapException) InvalidSearchFilterException(com.iplanet.ums.InvalidSearchFilterException) SMSException(com.sun.identity.sm.SMSException) AMException(com.iplanet.am.sdk.AMException) AMPreCallBackException(com.iplanet.am.sdk.AMPreCallBackException) EntryNotFoundException(com.iplanet.ums.EntryNotFoundException) COSNotFoundException(com.iplanet.ums.cos.COSNotFoundException) AttrSet(com.iplanet.services.ldap.AttrSet) DirectCOSDefinition(com.iplanet.ums.cos.DirectCOSDefinition) COSManager(com.iplanet.ums.cos.COSManager) COSNotFoundException(com.iplanet.ums.cos.COSNotFoundException)

Aggregations

Attr (com.iplanet.services.ldap.Attr)2 COSTemplate (com.iplanet.ums.cos.COSTemplate)2 AMEntryExistsException (com.iplanet.am.sdk.AMEntryExistsException)1 AMEventManagerException (com.iplanet.am.sdk.AMEventManagerException)1 AMException (com.iplanet.am.sdk.AMException)1 AMInvalidDNException (com.iplanet.am.sdk.AMInvalidDNException)1 AMPreCallBackException (com.iplanet.am.sdk.AMPreCallBackException)1 AttrSet (com.iplanet.services.ldap.AttrSet)1 SSOException (com.iplanet.sso.SSOException)1 AccessRightsException (com.iplanet.ums.AccessRightsException)1 CreationTemplate (com.iplanet.ums.CreationTemplate)1 EntryAlreadyExistsException (com.iplanet.ums.EntryAlreadyExistsException)1 EntryNotFoundException (com.iplanet.ums.EntryNotFoundException)1 Guid (com.iplanet.ums.Guid)1 InvalidSearchFilterException (com.iplanet.ums.InvalidSearchFilterException)1 PersistentObject (com.iplanet.ums.PersistentObject)1 SizeLimitExceededException (com.iplanet.ums.SizeLimitExceededException)1 TemplateManager (com.iplanet.ums.TemplateManager)1 TimeLimitExceededException (com.iplanet.ums.TimeLimitExceededException)1 UMSException (com.iplanet.ums.UMSException)1