Search in sources :

Example 1 with Guid

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

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

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

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

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

the class DirectoryServicesImpl method getMembers.

/**
     * Get members for roles, dynamic group or static group
     * 
     * @param token
     *            SSOToken
     * @param entryDN
     *            DN of the role or group
     * @param objectType
     *            objectType of the target object, AMObject.ROLE or
     *            AMObject.GROUP
     * @return Set Member DNs
     */
public Set getMembers(SSOToken token, String entryDN, int objectType) throws AMException {
    try {
        SearchResults results;
        switch(objectType) {
            case AMObject.ROLE:
            case AMObject.MANAGED_ROLE:
                ManagedRole role = (ManagedRole) UMSObject.getObject(token, new Guid(entryDN));
                results = role.getMemberIDs();
                return searchResultsToSet(results);
            case AMObject.FILTERED_ROLE:
                FilteredRole filteredRole = (FilteredRole) UMSObject.getObject(token, new Guid(entryDN));
                results = filteredRole.getMemberIDs();
                return searchResultsToSet(results);
            case AMObject.GROUP:
            case AMObject.STATIC_GROUP:
                StaticGroup group = (StaticGroup) UMSObject.getObject(token, new Guid(entryDN));
                results = group.getMemberIDs();
                return searchResultsToSet(results);
            case AMObject.DYNAMIC_GROUP:
                DynamicGroup dynamicGroup = (DynamicGroup) UMSObject.getObject(token, new Guid(entryDN));
                results = dynamicGroup.getMemberIDs();
                return searchResultsToSet(results);
            case AMObject.ASSIGNABLE_DYNAMIC_GROUP:
                // TODO: See if it works after removing this workaround
                // fake object to get around UMS problem.
                // UMS AssignableDynamicGroup has a class resolver, it is
                // added to resolver list in static block. So I need to
                // construct a dummy AssignableDynamicGroup
                AssignableDynamicGroup adgroup = (AssignableDynamicGroup) UMSObject.getObject(token, new Guid(entryDN));
                results = adgroup.getMemberIDs();
                return searchResultsToSet(results);
            default:
                throw new AMException(token, "114");
        }
    } catch (EntryNotFoundException e) {
        debug.error("DirectoryServicesImpl.getMembers() entryDN " + entryDN + " objectType: " + objectType + " Unable to get members: ", e);
        String msgid = getEntryNotFoundMsgID(objectType);
        String entryName = getEntryName(e);
        Object[] args = { entryName };
        throw new AMException(AMSDKBundle.getString(msgid, args), msgid, args);
    } catch (UMSException e) {
        debug.error("DirectoryServicesImpl.getMembers() entryDN " + entryDN + " objectType: " + objectType + " Unable to get members: ", e);
        LdapException le = (LdapException) e.getRootCause();
        if (le != null) {
            ResultCode resultCode = le.getResult().getResultCode();
            if (ResultCode.SIZE_LIMIT_EXCEEDED.equals(resultCode) || ResultCode.ADMIN_LIMIT_EXCEEDED.equals(resultCode)) {
                throw new AMException(token, "505", e);
            }
        }
        throw new AMException(token, "454", e);
    }
}
Also used : DynamicGroup(com.iplanet.ums.DynamicGroup) AssignableDynamicGroup(com.iplanet.ums.AssignableDynamicGroup) UMSException(com.iplanet.ums.UMSException) AMException(com.iplanet.am.sdk.AMException) Guid(com.iplanet.ums.Guid) AMSearchResults(com.iplanet.am.sdk.AMSearchResults) SearchResults(com.iplanet.ums.SearchResults) StaticGroup(com.iplanet.ums.StaticGroup) ManagedRole(com.iplanet.ums.ManagedRole) FilteredRole(com.iplanet.ums.FilteredRole) EntryNotFoundException(com.iplanet.ums.EntryNotFoundException) LdapException(org.forgerock.opendj.ldap.LdapException) AssignableDynamicGroup(com.iplanet.ums.AssignableDynamicGroup) ResultCode(org.forgerock.opendj.ldap.ResultCode)

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