Search in sources :

Example 6 with Guid

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

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

the class ComplianceServicesImpl method verifyAndUnLinkRoleToGroup.

/**
     * Verifies if the <code>roleDN</code> corresponds to an admin role. If
     * true the <code>memberOf</code> and <code>adminRole</code> attributes
     * of each member/user are set to null. Each of the members/users are also
     * removed to the corresponding admin group.
     * 
     * @param token
     *            single sign on token.
     * @param members
     *            Set of member distinguished name to be operated.
     * @param roleDN
     *            distinguished name of the role.
     * @exception AMException
     *                if unsuccessful in removing the members from the
     *                corresponding administrative groups and updating the
     *                <code>memberOf</code> and <code>adminRole</code>
     *                attribute values to null.
     */
protected void verifyAndUnLinkRoleToGroup(SSOToken token, Set members, String roleDN) throws AMException {
    // Obtain the group corresponding to roleDN
    DN dn = DN.valueOf(roleDN);
    String groupName = getGroupFromRoleDN(dn);
    if (groupName != null) {
        String orgDN = dn.parent().toString();
        String groupDN = NamingAttributeManager.getNamingAttribute(AMObject.GROUP) + "=" + groupName + ",ou=Groups," + orgDN;
        String groupRDN = NamingAttributeManager.getNamingAttribute(AMObject.GROUP) + "=" + groupName;
        // Delete the attributes memberOf & adminRole attribute values'
        // corresponding to this groupDN.
        Attr[] attrs = new Attr[1];
        attrs[0] = new Attr("adminrole", groupRDN);
        AttrSet attrSet = new AttrSet(attrs);
        Iterator itr = members.iterator();
        try {
            AssignableDynamicGroup group = (AssignableDynamicGroup) UMSObject.getObject(token, new Guid(groupDN));
            while (itr.hasNext()) {
                String memberDN = (String) itr.next();
                removeAttributesFromEntry(token, memberDN, attrSet);
                group.removeMember(new Guid(memberDN));
            }
        } catch (EntryNotFoundException ex) {
            debug.error("Compliance.verifyAndUnLinkRoleToGroup: " + "Admin groups are missing");
        } catch (UMSException ue) {
            debug.error("Compliance." + "verifyAndUnLinkRoleToGroup(): ", ue);
            throw new AMException(AMSDKBundle.getString("772"), "772");
        }
    }
}
Also used : UMSException(com.iplanet.ums.UMSException) Iterator(java.util.Iterator) EntryNotFoundException(com.iplanet.ums.EntryNotFoundException) AMException(com.iplanet.am.sdk.AMException) DN(org.forgerock.opendj.ldap.DN) Guid(com.iplanet.ums.Guid) Attr(com.iplanet.services.ldap.Attr) AssignableDynamicGroup(com.iplanet.ums.AssignableDynamicGroup) AttrSet(com.iplanet.services.ldap.AttrSet)

Example 8 with Guid

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

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

the class DCTreeServicesImpl method getOrganizationDN.

/**
     * Returns the organization DN matching the domain name
     * 
     * @param token
     *            SSOToken
     * @param domainName
     *            String representing domin name
     * @return
     *            the organization dn
     * @throws AMException
     */
public String getOrganizationDN(SSOToken token, String domainName) throws AMException {
    try {
        DomainComponentTree dcTree = new DomainComponentTree(token, new Guid(DCTREE_START_DN));
        Hashtable domainToOrgTable = dcTree.getChildDomainIDs();
        if (debug.messageEnabled()) {
            debug.message("DCTree:getOrgDN-> domain=" + domainName);
        }
        return ((String) domainToOrgTable.get(domainName));
    } catch (UMSException umse) {
        // Deepa: Is there a localized property for 1000?
        debug.error("DCTree:getOrganizationDN: " + "UMS Exception: ", umse);
        throw new AMException(AMSDKBundle.getString("1000"), "1000");
    }
}
Also used : UMSException(com.iplanet.ums.UMSException) Hashtable(java.util.Hashtable) AMException(com.iplanet.am.sdk.AMException) DomainComponentTree(com.iplanet.ums.dctree.DomainComponentTree) Guid(com.iplanet.ums.Guid)

Example 10 with Guid

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

the class DCTreeServicesImpl method createDomain.

/**
     * Method which creates a DC Tree for the given org, if the
     * <code>sunPreferredDomain</code> attribute is present and has a fully
     * qualified domain name as value.
     * 
     * @param token
     *            SSOToken
     * @param orgGuid
     *            identifiication of Organization entry to be mapped from dctree
     *            to organization DIT organization
     * @param domainName
     *            set the domain this organization belongs to.
     * @param attrSet
     *            the AttrSet of the organization
     * 
     * @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, String domainName, AttrSet attrSet) throws AMException {
    if (DCTREE_START_DN == null) {
        throw new AMException(AMSDKBundle.getString("355"), "355");
    }
    // Create a DC tree for specified domain.
    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);
            }
        } 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)

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