Search in sources :

Example 1 with PersistentObject

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

the class DCTreeServicesImpl method removeDomain.

/**
     * Method which removes the DC Tree corresponding to the Org
     * 
     * @param token
     *            SSOToken
     * @param orgDN
     *            String representing the DN correponding to the organization
     * 
     * @exception AMException
     *                if error occured in accessing the org corresponding to
     *                orgDN or during the removal of the dc tree corresponding
     *                to the orgDN
     */
protected void removeDomain(SSOToken token, String orgDN) throws AMException {
    // String orgAttribute[] = {IPLANET_DOMAIN_NAME_ATTR};
    try {
        PersistentObject po = UMSObject.getObject(token, new Guid(orgDN));
        if (!(po instanceof com.iplanet.ums.Organization)) {
            if (debug.messageEnabled()) {
                debug.message("DCTree.removeDomain-> " + orgDN + " is not an organization");
            }
            return;
        }
        String domainName = getCanonicalDomain(token, orgDN);
        if (debug.messageEnabled()) {
            debug.message("DCTree.removeDomain-> " + "Obtained canon domain " + domainName);
        }
        if ((domainName != null) && (domainName.length() > 0)) {
            DomainComponentTree dcTree = new DomainComponentTree(token, new Guid(DCTREE_START_DN));
            if (debug.messageEnabled()) {
                debug.message("DCTree.removeDomain: removing domain: " + domainName);
            }
            dcTree.removeDomain(domainName);
        } else {
            if (debug.warningEnabled()) {
                debug.warning("DCTree.removeDomain(): " + " unable to get domain for " + orgDN);
            }
        }
    } catch (UMSException ue) {
        if (debug.warningEnabled()) {
            debug.warning("DCTree.removeDomain(): ", ue);
        }
    }
}
Also used : UMSException(com.iplanet.ums.UMSException) PersistentObject(com.iplanet.ums.PersistentObject) Guid(com.iplanet.ums.Guid) DomainComponentTree(com.iplanet.ums.dctree.DomainComponentTree)

Example 2 with PersistentObject

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

the class ComplianceServicesImpl method addAttributesToEntry.

/**
     * Method to addAttributes to an entry
     */
private void addAttributesToEntry(SSOToken token, String dn, AttrSet attrSet) throws UMSException {
    PersistentObject po = UMSObject.getObjectHandle(token, new Guid(dn));
    int size = attrSet.size();
    for (int i = 0; i < size; i++) {
        Attr attr = attrSet.elementAt(i);
        po.modify(attr, ModificationType.ADD);
    }
    po.save();
}
Also used : PersistentObject(com.iplanet.ums.PersistentObject) Guid(com.iplanet.ums.Guid) Attr(com.iplanet.services.ldap.Attr)

Example 3 with PersistentObject

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

the class DCTreeServicesImpl method updateCacheAndReturnDomain.

/**
     * This is a private method to update cache
     */
private String updateCacheAndReturnDomain(SSOToken token, String canonOrgDN) throws AMException {
    try {
        DomainComponentTree dcTree = new DomainComponentTree(token, new Guid(DCTREE_START_DN));
        SearchControl scontrol = new SearchControl();
        scontrol.setSearchScope(SearchControl.SCOPE_SUB);
        PersistentObject po = UMSObject.getObject(token, new Guid(DCTREE_START_DN));
        String searchFilter = "(inetDomainBaseDN=" + canonOrgDN + ")";
        if (debug.messageEnabled()) {
            debug.message("DCTree.updateCache-> " + "searchFilter= " + searchFilter);
        }
        SearchResults results = po.search(searchFilter, null);
        int count = 0;
        String domainName = null;
        String canonDomain = null;
        while (results.hasMoreElements()) {
            DomainComponent dcNode = (DomainComponent) results.next();
            count++;
            domainName = dcTree.mapDCToDomainName(dcNode);
            if (debug.messageEnabled()) {
                debug.message("DCTree:updateCache-> " + "domainName= " + domainName);
            }
            Attr isCanonical = dcNode.getAttribute(INET_CANONICAL_DOMAIN);
            if (isCanonical != null) {
                /*
                     * if (AMCacheManager.isCachingEnabled()) {
                     * synchronized(canonicalDomainMap) {
                     * canonicalDomainMap.put(canonOrgDN, domainName); } }
                     */
                canonDomain = domainName;
            }
        /*
                 * if (AMCacheManager.isCachingEnabled()) {
                 * synchronized(domainMap) { domainMap.put(canonOrgDN,
                 * domainName); } }
                 */
        }
        results.abandon();
        if (count == 1) {
            canonDomain = domainName;
        /*
                 * if (AMCacheManager.isCachingEnabled()) {
                 * canonicalDomainMap.put(canonOrgDN, domainName); }
                 */
        }
        if (debug.messageEnabled()) {
            debug.message("DCTree.updateCache-> " + "returning domain= " + canonDomain);
        }
        return canonDomain;
    } catch (UMSException umse) {
        debug.error("DCTree:updateCache: UMSException", umse);
        return null;
    }
}
Also used : DomainComponent(com.iplanet.ums.dctree.DomainComponent) UMSException(com.iplanet.ums.UMSException) PersistentObject(com.iplanet.ums.PersistentObject) DomainComponentTree(com.iplanet.ums.dctree.DomainComponentTree) Guid(com.iplanet.ums.Guid) SearchControl(com.iplanet.ums.SearchControl) SearchResults(com.iplanet.ums.SearchResults) Attr(com.iplanet.services.ldap.Attr)

Example 4 with PersistentObject

use of com.iplanet.ums.PersistentObject 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 5 with PersistentObject

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

PersistentObject (com.iplanet.ums.PersistentObject)32 Guid (com.iplanet.ums.Guid)26 UMSException (com.iplanet.ums.UMSException)24 AMException (com.iplanet.am.sdk.AMException)16 Attr (com.iplanet.services.ldap.Attr)12 AttrSet (com.iplanet.services.ldap.AttrSet)10 AccessRightsException (com.iplanet.ums.AccessRightsException)8 SearchResults (com.iplanet.ums.SearchResults)7 AMEntryExistsException (com.iplanet.am.sdk.AMEntryExistsException)5 AMSearchResults (com.iplanet.am.sdk.AMSearchResults)5 EntryAlreadyExistsException (com.iplanet.ums.EntryAlreadyExistsException)5 OrderedSet (com.sun.identity.shared.datastruct.OrderedSet)5 HashSet (java.util.HashSet)5 Set (java.util.Set)5 TreeSet (java.util.TreeSet)5 AMHashMap (com.iplanet.am.sdk.AMHashMap)4 EntryNotFoundException (com.iplanet.ums.EntryNotFoundException)4 SearchControl (com.iplanet.ums.SearchControl)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4