Search in sources :

Example 11 with Guid

use of com.iplanet.ums.Guid in project OpenAM by OpenRock.

the class DCTreeServicesImpl method updateDomainStatus.

/**
     * Method which update attribute inetdomainstatus of the DC Tree
     * corresponding to the Org
     * 
     * @param token
     *            SSOToken
     * @param orgDN
     *            String representing the DN correponding to the organization
     * @param status
     *            inetdomainstatus value
     * 
     * @exception AMException
     *                if error occured in accessing the org corresponding to
     *                orgDN or during the attribute change of the dc tree
     *                corresponding to the orgDN
     */
protected void updateDomainStatus(SSOToken token, String orgDN, String status) throws AMException {
    try {
        String domainName = getCanonicalDomain(token, orgDN);
        if ((domainName != null) && (domainName.length() > 0)) {
            DomainComponentTree dcTree = new DomainComponentTree(token, new Guid(DCTREE_START_DN));
            dcTree.setDomainStatus(domainName, status);
        } else {
            debug.warning("DCTree.updateDomainStatus(): value for " + IPLANET_DOMAIN_NAME_ATTR + " attribute " + "null or empty");
        }
    // }
    } catch (UMSException ue) {
        debug.error("DCTree.removeDomain(): ", ue);
        throw new AMException(AMSDKBundle.getString("356"), "356");
    }
}
Also used : UMSException(com.iplanet.ums.UMSException) AMException(com.iplanet.am.sdk.AMException) DomainComponentTree(com.iplanet.ums.dctree.DomainComponentTree) Guid(com.iplanet.ums.Guid)

Example 12 with Guid

use of com.iplanet.ums.Guid in project OpenAM by OpenRock.

the class DirectoryServicesImpl method modifyAndSaveEntry.

private void modifyAndSaveEntry(SSOToken token, String entryDN, Map stringAttributes, Map byteAttributes, boolean isAdd) throws AccessRightsException, EntryNotFoundException, UMSException {
    PersistentObject po = UMSObject.getObjectHandle(token, new Guid(entryDN));
    // Add string attributes
    if (stringAttributes != null && !stringAttributes.isEmpty()) {
        Iterator itr = stringAttributes.keySet().iterator();
        while (itr.hasNext()) {
            String attrName = (String) (itr.next());
            if (!attrName.equalsIgnoreCase("dn")) {
                Set set = (Set) (stringAttributes.get(attrName));
                String[] attrValues = (set == null) ? null : (String[]) set.toArray(new String[set.size()]);
                Attr attr = new Attr(attrName, attrValues);
                /*
                     * AMObjectImpl.removeAttributes(...) sets the values to be
                     * Collections.EMPTY_SET.
                     */
                modifyPersistentObject(po, attr, isAdd, (set == AMConstants.REMOVE_ATTRIBUTE));
            }
        }
    }
    // Add byte attributes
    if (byteAttributes != null && !byteAttributes.isEmpty()) {
        Iterator itr = byteAttributes.keySet().iterator();
        while (itr.hasNext()) {
            String attrName = (String) (itr.next());
            byte[][] attrValues = (byte[][]) (byteAttributes.get(attrName));
            Attr attr = new Attr(attrName, attrValues);
            modifyPersistentObject(po, attr, isAdd, false);
        }
    }
    po.save();
}
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) Iterator(java.util.Iterator) PersistentObject(com.iplanet.ums.PersistentObject) Guid(com.iplanet.ums.Guid) Attr(com.iplanet.services.ldap.Attr)

Example 13 with Guid

use of com.iplanet.ums.Guid 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 14 with Guid

use of com.iplanet.ums.Guid 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)

Example 15 with Guid

use of com.iplanet.ums.Guid in project OpenAM by OpenRock.

the class DirectoryServicesImpl method createOrganization.

private void createOrganization(SSOToken token, PersistentObject parentObj, Map attributes, String profileName) throws UMSException, AMException, SSOException {
    // Invoke the Pre Processing plugin. Note: we need to obtain
    // the parent org of this organization to obtain the
    // plugin classes for the parent org.
    String orgDN = getOrganizationDN(internalToken, parentObj.getDN());
    String entryDN = getNamingAttribute(AMObject.ORGANIZATION) + "=" + profileName + "," + parentObj.getDN();
    attributes = callBackHelper.preProcess(token, entryDN, orgDN, null, attributes, CallBackHelper.CREATE, AMObject.ORGANIZATION, false);
    AttrSet attrSet = CommonUtils.mapToAttrSet(attributes);
    makeNamingFirst(attrSet, getNamingAttribute(AMObject.ORGANIZATION), profileName);
    TemplateManager tempMgr = TemplateManager.getTemplateManager();
    com.iplanet.ums.Organization org = null;
    CreationTemplate creationTemp = tempMgr.getCreationTemplate("BasicOrganization", new Guid(orgDN), TemplateManager.SCOPE_ANCESTORS);
    attrSet = combineOCs(creationTemp, attrSet);
    // COMPLIANCE: DCTREE
    if (dcTreeImpl.isRequired()) {
        AttrSet[] attrSetArray = dcTreeImpl.splitAttrSet(parentObj.getDN(), attrSet);
        org = new com.iplanet.ums.Organization(creationTemp, attrSetArray[0]);
        // create the DC node first. If it fails then the org node will not
        // be created at all. No clean up needed afterwards then.
        dcTreeImpl.createDomain(token, new Guid(entryDN), attrSet);
    } else {
        org = new com.iplanet.ums.Organization(creationTemp, attrSet);
    }
    try {
        parentObj.addChild(org);
    } catch (UMSException ue) {
        // clean up DC node
        if (dcTreeImpl.isRequired()) {
            dcTreeImpl.removeDomain(token, entryDN);
        }
        if (ComplianceServicesImpl.isComplianceUserDeletionEnabled()) {
            // COMPLIANCE
            // If the existing entry is marked for deletion, then
            // the error message should be different.
            complianceImpl.checkIfDeletedOrg(token, org.getDN());
        }
        throw ue;
    }
    if (ComplianceServicesImpl.isAdminGroupsEnabled(org.getDN())) {
        complianceImpl.createAdminGroups(token, org);
    }
    // mode, the corresponding realm must also be created.
    if (ServiceManager.isCoexistenceMode() && ServiceManager.isRealmEnabled()) {
        try {
            // Check if realm exisits, this throws SMSException
            // if realm does not exist
            new OrganizationConfigManager(token, entryDN);
        } catch (SMSException smse) {
            // Organization does not exist, create it
            if (debug.messageEnabled()) {
                debug.message("DirectoryServicesImpl::createOrganization " + "creating realm: " + org.getDN());
            }
            try {
                OrganizationConfigManager ocm = new OrganizationConfigManager(token, orgDN);
                ocm.createSubOrganization(profileName, null);
            } catch (SMSException se) {
                if (debug.messageEnabled()) {
                    debug.message("DirectoryServicesImpl::" + "createOrganization unable to create realm: " + org.getDN(), se);
                }
            }
        }
    }
    // If in legacy mode, add the default services
    if (ServiceManager.isCoexistenceMode()) {
        try {
            OrganizationConfigManager ocm = new OrganizationConfigManager(token, entryDN);
            OrganizationConfigManager.loadDefaultServices(token, ocm);
        } catch (SMSException smse) {
            // Unable to load default services
            if (debug.warningEnabled()) {
                debug.warning("DirectoryServicesImpl::createOrganization " + "Unable to load services: " + org.getDN());
            }
        }
    }
    // Invoke Post processing impls. Note: orgDN is parent org
    callBackHelper.postProcess(token, org.getDN(), orgDN, null, attributes, CallBackHelper.CREATE, AMObject.ORGANIZATION, false);
}
Also used : CreationTemplate(com.iplanet.ums.CreationTemplate) UMSException(com.iplanet.ums.UMSException) SMSException(com.sun.identity.sm.SMSException) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) TemplateManager(com.iplanet.ums.TemplateManager) Guid(com.iplanet.ums.Guid) AttrSet(com.iplanet.services.ldap.AttrSet)

Aggregations

Guid (com.iplanet.ums.Guid)63 UMSException (com.iplanet.ums.UMSException)41 AMException (com.iplanet.am.sdk.AMException)33 PersistentObject (com.iplanet.ums.PersistentObject)29 AttrSet (com.iplanet.services.ldap.AttrSet)23 Attr (com.iplanet.services.ldap.Attr)16 CreationTemplate (com.iplanet.ums.CreationTemplate)13 TemplateManager (com.iplanet.ums.TemplateManager)13 EntryNotFoundException (com.iplanet.ums.EntryNotFoundException)11 AccessRightsException (com.iplanet.ums.AccessRightsException)10 AssignableDynamicGroup (com.iplanet.ums.AssignableDynamicGroup)9 DomainComponentTree (com.iplanet.ums.dctree.DomainComponentTree)8 AMEntryExistsException (com.iplanet.am.sdk.AMEntryExistsException)6 EntryAlreadyExistsException (com.iplanet.ums.EntryAlreadyExistsException)6 SearchResults (com.iplanet.ums.SearchResults)6 DN (org.forgerock.opendj.ldap.DN)6 LdapException (org.forgerock.opendj.ldap.LdapException)6 AMSearchResults (com.iplanet.am.sdk.AMSearchResults)5 ManagedRole (com.iplanet.ums.ManagedRole)5 OrderedSet (com.sun.identity.shared.datastruct.OrderedSet)5