Search in sources :

Example 1 with DomainComponentTree

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

the class DCTreeServicesImpl method createDomain.

/**
     * Method which creates a <Code>Domain Component Tree </Code> for the given
     * organization, if the <code>sunPreferredDomain</code> attribute is
     * present and has a fully qualified domain name as value.
     * 
     * @param token
     *            SSO Token
     * @param orgGuid
     *            identifiication of organization entry to be mapped from 
     *            <Code>dctree</Code> to organization DIT organization
     * @param attrSet
     *            the attributes to be set on creation of domain.
     * 
     * @exception AMException
     *                if unsuccessful in creating a dc tree for the organization
     *                or unsuccessful in setting the mapping between dc tree and
     *                the organization
     */
protected void createDomain(SSOToken token, Guid orgGuid, AttrSet attrSet) throws AMException, SSOException {
    if (DCTREE_START_DN == null) {
        throw new AMException(AMSDKBundle.getString("355"), "355");
    }
    // Create a DC tree is value is specified for
    // sunPreferredDomain attribute
    String domainName = attrSet.getValue(IPLANET_DOMAIN_NAME_ATTR);
    // remove the attribute from the attribute set.
    attrSet.remove(IPLANET_DOMAIN_NAME_ATTR);
    if ((domainName != null) && (!domainName.equals(""))) {
        try {
            DomainComponentTree dcTree = new DomainComponentTree(token, new Guid(DCTREE_START_DN));
            dcTree.addDomain(domainName);
            // Set the domain mapping
            dcTree.setDomainMapping(domainName, orgGuid);
            String status = attrSet.getValue(INET_DOMAIN_STATUS_ATTR);
            if (status != null) {
                dcTree.setDomainStatus(domainName, status);
            }
            AttrSet[] attrSetArray = splitAttrSet(orgGuid.getDn(), attrSet);
            if (attrSetArray[1] != null) {
                setDomainAttributes(token, orgGuid.getDn(), attrSetArray[1]);
            }
        } catch (InvalidDCRootException ie) {
            debug.error("DCTree.createDomain(): ", ie);
            throw new AMException(AMSDKBundle.getString("343"), "343");
        } catch (UMSException ue) {
            debug.error("DCTree.createDomain(): ", ue);
            throw new AMException(AMSDKBundle.getString("344"), "344");
        }
    }
}
Also used : UMSException(com.iplanet.ums.UMSException) AMException(com.iplanet.am.sdk.AMException) DomainComponentTree(com.iplanet.ums.dctree.DomainComponentTree) Guid(com.iplanet.ums.Guid) InvalidDCRootException(com.iplanet.ums.dctree.InvalidDCRootException) AttrSet(com.iplanet.services.ldap.AttrSet)

Example 2 with DomainComponentTree

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

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

the class DCTreeServicesImpl method getDCNodeDN.

protected String getDCNodeDN(SSOToken token, String orgDN) throws AMException {
    try {
        String domainName = getCanonicalDomain(token, orgDN);
        if (domainName != null) {
            DomainComponentTree dcTree = new DomainComponentTree(token, new Guid(DCTREE_START_DN));
            String dcNodeDN = dcTree.mapDomainToDN(domainName);
            return LDAPUtils.formatToRFC(dcNodeDN);
        } else {
            return null;
        }
    } catch (InvalidDCRootException e) {
        debug.error("DCTree.getDCNodeDN(): Invalid DC root ", e);
        throw new AMException(AMSDKBundle.getString("343"), "343");
    } catch (UMSException e) {
        debug.error("DCTree.getDCNodeDN(): Unable to get dc node dn " + "for: " + orgDN, e);
        throw new AMException(AMSDKBundle.getString("344"), "344");
    }
}
Also used : UMSException(com.iplanet.ums.UMSException) AMException(com.iplanet.am.sdk.AMException) DomainComponentTree(com.iplanet.ums.dctree.DomainComponentTree) Guid(com.iplanet.ums.Guid) InvalidDCRootException(com.iplanet.ums.dctree.InvalidDCRootException)

Example 4 with DomainComponentTree

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

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

Aggregations

Guid (com.iplanet.ums.Guid)9 UMSException (com.iplanet.ums.UMSException)9 DomainComponentTree (com.iplanet.ums.dctree.DomainComponentTree)9 AMException (com.iplanet.am.sdk.AMException)5 DomainComponent (com.iplanet.ums.dctree.DomainComponent)3 InvalidDCRootException (com.iplanet.ums.dctree.InvalidDCRootException)3 Attr (com.iplanet.services.ldap.Attr)2 AttrSet (com.iplanet.services.ldap.AttrSet)2 PersistentObject (com.iplanet.ums.PersistentObject)2 SearchControl (com.iplanet.ums.SearchControl)1 SearchResults (com.iplanet.ums.SearchResults)1 Hashtable (java.util.Hashtable)1