Search in sources :

Example 1 with DomainComponent

use of com.iplanet.ums.dctree.DomainComponent in project OpenAM by OpenRock.

the class DCTreeServicesImpl method setDomainAttributes.

protected void setDomainAttributes(SSOToken token, String orgDN, AttrSet attrSet) throws AMException {
    String domainName = null;
    try {
        domainName = getCanonicalDomain(token, orgDN);
        DomainComponentTree dcTree = new DomainComponentTree(token, new Guid(DCTREE_START_DN));
        if (domainName == null) {
            if (debug.messageEnabled()) {
                debug.message("DCTree.setDomainAttrs: " + "No domain found for org : " + orgDN);
            }
            return;
        }
        DomainComponent dcNode = dcTree.getDomainComponent(domainName);
        if (attrSet != null) {
            if (debug.messageEnabled()) {
                debug.message("DCTree.setDomainAttrs: " + " setting attributes on domain " + domainName + ": " + attrSet.toString());
            }
            Attr ocAttr = attrSet.getAttribute("objectclass");
            if (ocAttr != null) {
                Attr oldOCAttr = dcNode.getAttribute("objectclass");
                if (oldOCAttr != null) {
                    ocAttr.addValues(oldOCAttr.getStringValues());
                }
                if (debug.messageEnabled()) {
                    debug.message("DCTree.setDomainAttrs-> " + "objectclasses to be set " + ocAttr.toString());
                }
                if (ocAttr.size() == 0)
                    dcNode.modify(ocAttr, ModificationType.DELETE);
                else
                    dcNode.modify(ocAttr, ModificationType.REPLACE);
                dcNode.save();
                attrSet.remove("objectclass");
            }
            int size = attrSet.size();
            for (int i = 0; i < size; i++) {
                Attr attr = attrSet.elementAt(i);
                if (attr.size() == 0) {
                    // remove attribute
                    dcNode.modify(attr, ModificationType.DELETE);
                } else {
                    // replace attribute
                    dcNode.modify(attr, ModificationType.REPLACE);
                }
            }
            dcNode.save();
        }
    } catch (UMSException umse) {
        debug.error("DCTree.setDomainAttributes: " + " error setting " + " attribute for domain " + domainName, umse);
    }
}
Also used : DomainComponent(com.iplanet.ums.dctree.DomainComponent) UMSException(com.iplanet.ums.UMSException) DomainComponentTree(com.iplanet.ums.dctree.DomainComponentTree) Guid(com.iplanet.ums.Guid) Attr(com.iplanet.services.ldap.Attr)

Example 2 with DomainComponent

use of com.iplanet.ums.dctree.DomainComponent 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 3 with DomainComponent

use of com.iplanet.ums.dctree.DomainComponent in project OpenAM by OpenRock.

the class DCTreeServicesImpl method getDomainAttributes.

protected AttrSet getDomainAttributes(SSOToken token, String orgDN, String[] attrNames) throws AMException, SSOException {
    String domainName = null;
    try {
        AttrSet domAttrSet;
        domainName = getCanonicalDomain(token, orgDN);
        if (domainName == null) {
            debug.error("DCTree.getDomainAttributes-> " + "Domain not found for:  " + orgDN);
            return null;
        }
        DomainComponentTree dcTree = new DomainComponentTree(token, new Guid(DCTREE_START_DN));
        DomainComponent dcNode = dcTree.getDomainComponent(domainName);
        if (attrNames != null) {
            domAttrSet = dcNode.getAttributes(attrNames);
        } else {
            domAttrSet = dcNode.getAttributes(dcNode.getAttributeNames());
        }
        AttrSet[] attrArray = splitAttrSet(null, domAttrSet);
        return attrArray[1];
    } catch (UMSException umse) {
        debug.error("DCTree.getDomainAttributes: " + " error getting attributes for domain " + domainName);
    }
    return null;
}
Also used : DomainComponent(com.iplanet.ums.dctree.DomainComponent) UMSException(com.iplanet.ums.UMSException) DomainComponentTree(com.iplanet.ums.dctree.DomainComponentTree) Guid(com.iplanet.ums.Guid) AttrSet(com.iplanet.services.ldap.AttrSet)

Aggregations

Guid (com.iplanet.ums.Guid)3 UMSException (com.iplanet.ums.UMSException)3 DomainComponent (com.iplanet.ums.dctree.DomainComponent)3 DomainComponentTree (com.iplanet.ums.dctree.DomainComponentTree)3 Attr (com.iplanet.services.ldap.Attr)2 AttrSet (com.iplanet.services.ldap.AttrSet)1 PersistentObject (com.iplanet.ums.PersistentObject)1 SearchControl (com.iplanet.ums.SearchControl)1 SearchResults (com.iplanet.ums.SearchResults)1