Search in sources :

Example 6 with Attr

use of com.iplanet.services.ldap.Attr 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 7 with Attr

use of com.iplanet.services.ldap.Attr in project OpenAM by OpenRock.

the class DirectoryServicesImpl method combineOCs.

/**
     * When an object is being created and attribute sets are being passed UMS
     * does not overrid objectclasses in the attribute set, with the ones from
     * creation template. This method takes care of that.
     * 
     * @param ct
     * @param aSet
     */
private AttrSet combineOCs(CreationTemplate ct, AttrSet aSet) {
    // UMS creation template will not append default user
    // objectclasses if the "objectclass" attribute is present
    // so we need to append those default objectclass here
    Attr attr = aSet.getAttribute("objectclass");
    // if (attr != null) {
    // TO: To write a separate method for attrSet combine object class
    // values. Need to avoid conversion from string array to sets.
    // get default user objectclass from creation template
    Attr defAttr = ct.getAttribute("objectclass");
    Set addOCs = (attr != null) ? CommonUtils.stringArrayToSet(attr.getStringValues()) : new HashSet();
    Set ctOCs = CommonUtils.stringArrayToSet(defAttr.getStringValues());
    Set finalOCs = CommonUtils.combineOCs(addOCs, ctOCs);
    aSet.remove("objectclass");
    Attr finalOCAttr = new Attr("objectclass", (String[]) finalOCs.toArray(new String[finalOCs.size()]));
    aSet.add(finalOCAttr);
    // }
    return aSet;
}
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) Attr(com.iplanet.services.ldap.Attr) HashSet(java.util.HashSet)

Example 8 with Attr

use of com.iplanet.services.ldap.Attr in project OpenAM by OpenRock.

the class DirectoryServicesImpl method createFilteredRole.

private void createFilteredRole(SSOToken token, PersistentObject parentObj, Map attributes, String profileName) throws UMSException, AMException {
    // Invoke the Pre Processing plugin
    String orgDN = getOrganizationDN(internalToken, parentObj.getDN());
    String entryDN = getNamingAttribute(AMObject.FILTERED_ROLE) + "=" + profileName + "," + parentObj.getDN();
    attributes = callBackHelper.preProcess(token, entryDN, orgDN, null, attributes, CallBackHelper.CREATE, AMObject.FILTERED_ROLE, false);
    AttrSet attrSet = CommonUtils.mapToAttrSet(attributes);
    makeNamingFirst(attrSet, getNamingAttribute(AMObject.FILTERED_ROLE), profileName);
    TemplateManager tempMgr = TemplateManager.getTemplateManager();
    CreationTemplate creationTemp = tempMgr.getCreationTemplate("BasicFilteredRole", new Guid(orgDN), TemplateManager.SCOPE_ANCESTORS);
    attrSet = combineOCs(creationTemp, attrSet);
    if (!attrSet.contains(FilteredRole.FILTER_ATTR_NAME)) {
        Attr attr = new Attr(FilteredRole.FILTER_ATTR_NAME, SearchFilterManager.getSearchFilter(AMObject.USER, orgDN));
        attrSet.add(attr);
    }
    FilteredRole frole = new FilteredRole(creationTemp, attrSet);
    parentObj.addChild(frole);
    // Invoke Post processing impls
    callBackHelper.postProcess(token, frole.getDN(), orgDN, null, attributes, CallBackHelper.CREATE, AMObject.FILTERED_ROLE, false);
}
Also used : CreationTemplate(com.iplanet.ums.CreationTemplate) FilteredRole(com.iplanet.ums.FilteredRole) TemplateManager(com.iplanet.ums.TemplateManager) Guid(com.iplanet.ums.Guid) Attr(com.iplanet.services.ldap.Attr) AttrSet(com.iplanet.services.ldap.AttrSet)

Example 9 with Attr

use of com.iplanet.services.ldap.Attr in project OpenAM by OpenRock.

the class ComplianceServicesImpl method verifyAndDeleteObject.

/**
     * Method which checks if the entry corresponding to DN represents a user
     * entry. If so, it sets the inetuserstatus attribute of the user to
     * deleted. Otherwise, it simply deletes the entry corresponding to the DN
     * 
     * @param token
     *            a SSOToken object
     * @param profileDN
     *            a String representing a DN
     * 
     * @exception AMException
     *                if an error is encountered while setting the
     *                intetuserstatus attribute or if an error was encountered
     *                while performing a delete.
     */
public void verifyAndDeleteObject(SSOToken token, String profileDN) throws AMException {
    try {
        EmailNotificationHelper mailer = null;
        Map attributes = null;
        Guid guid = new Guid(profileDN);
        PersistentObject po = UMSObject.getObject(token, guid);
        if (po instanceof com.iplanet.ums.User) {
            Attr attr = new Attr(USER_STATUS_ATTRIBUTE, "deleted");
            if (debug.messageEnabled()) {
                debug.message("Compliance:verifyAndDeleteObject: " + "Soft-delete mode, setting inetuserstatus " + "to deleted. " + "profileDN=" + profileDN);
            }
            po.modify(attr, ModificationType.REPLACE);
            po.save();
            mailer = new EmailNotificationHelper(profileDN);
            if (mailer != null) {
                mailer.setUserDeleteNotificationList();
                attributes = DirectoryServicesFactory.getInstance().getAttributes(token, profileDN, AMObject.USER);
                if (mailer.isPresentUserDeleteNotificationList()) {
                    mailer.sendUserDeleteNotification(attributes);
                }
            }
            return;
        }
        if (po instanceof com.iplanet.ums.Resource) {
            Attr attr = new Attr(RESOURCE_STATUS_ATTRIBUTE, "deleted");
            if (debug.messageEnabled()) {
                debug.message("Compliance:verifyAndDeleteObject: " + "Soft-delete mode, setting icsstatus " + "to deleted");
            }
            po.modify(attr, ModificationType.REPLACE);
            po.save();
            return;
        }
        if (po instanceof com.iplanet.ums.StaticGroup || po instanceof com.iplanet.ums.AssignableDynamicGroup || po instanceof com.iplanet.ums.DynamicGroup) {
            Attr attr = new Attr(GROUP_STATUS_ATTRIBUTE, "deleted");
            if (debug.messageEnabled()) {
                debug.message("Compliance:verifyAndDeleteObject: " + "Soft-delete mode, setting inetgroupstatus " + "to deleted");
            }
            po.modify(attr, ModificationType.REPLACE);
            po.save();
            return;
        }
        if (po instanceof com.iplanet.ums.Organization) {
            if (debug.messageEnabled()) {
                debug.message("Compliance:verifyAndDeleteObject: " + "Soft-delete mode, setting inetdomainstatus " + "to deleted");
            }
            Attr attr = new Attr(ORG_STATUS_ATTRIBUTE, "deleted");
            po.modify(attr, ModificationType.REPLACE);
            po.save();
            DCTreeServicesImpl dcTreeImpl = (DCTreeServicesImpl) DirectoryServicesFactory.getInstance().getDCTreeServicesImpl();
            if (dcTreeImpl.isRequired()) {
                dcTreeImpl.updateDomainStatus(token, profileDN, "deleted");
            }
        } else {
            UMSObject.removeObject(token, guid);
        }
    } catch (UMSException ue) {
        debug.error("Compliance.deleteObject(): ", ue);
        throw new AMException(AMSDKBundle.getString("773"), "773");
    } catch (SSOException se) {
        debug.error("Compliance.deleteObject(): ", se);
        throw new AMException(AMSDKBundle.getString("773"), "773");
    }
}
Also used : UMSException(com.iplanet.ums.UMSException) PersistentObject(com.iplanet.ums.PersistentObject) AMException(com.iplanet.am.sdk.AMException) SSOException(com.iplanet.sso.SSOException) Guid(com.iplanet.ums.Guid) Attr(com.iplanet.services.ldap.Attr) HashMap(java.util.HashMap) Map(java.util.Map) AssignableDynamicGroup(com.iplanet.ums.AssignableDynamicGroup)

Example 10 with Attr

use of com.iplanet.services.ldap.Attr in project OpenAM by OpenRock.

the class ComplianceServicesImpl method checkIfDeletedOrg.

/**
     * Method which checks if the entry corresponding to orgDN represents a
     * deleted organization entry (entry with inetdomainstatus:deleted).
     * 
     * @param token
     *            a SSOToken object.
     * @param orgDN
     *            a String representing an organization DN.
     * 
     * @exception AMEntryExistsException
     *                if the orgDN corresponds to a deleted organization.
     */
protected void checkIfDeletedOrg(SSOToken token, String orgDN) throws AMEntryExistsException {
    Attr attr;
    try {
        PersistentObject po = UMSObject.getObject(token, new Guid(orgDN));
        attr = po.getAttribute(ORG_STATUS_ATTRIBUTE);
    } catch (UMSException ue) {
        if (debug.messageEnabled())
            debug.message("Compliance.checkIfDeletedOrg(): ", ue);
        return;
    }
    if (((attr != null) && (attr.size() != 0)) && attr.contains("deleted")) {
        // Org is deleted
        debug.warning("Compliance.checkIfDeletedOrg(): " + "deleted org entry: " + orgDN);
        throw new AMEntryExistsException(AMSDKBundle.getString("361"), "361");
    }
}
Also used : UMSException(com.iplanet.ums.UMSException) PersistentObject(com.iplanet.ums.PersistentObject) Guid(com.iplanet.ums.Guid) Attr(com.iplanet.services.ldap.Attr) AMEntryExistsException(com.iplanet.am.sdk.AMEntryExistsException)

Aggregations

Attr (com.iplanet.services.ldap.Attr)89 AttrSet (com.iplanet.services.ldap.AttrSet)34 Guid (com.iplanet.ums.Guid)16 Iterator (java.util.Iterator)15 UMSException (com.iplanet.ums.UMSException)14 PersistentObject (com.iplanet.ums.PersistentObject)12 HashSet (java.util.HashSet)12 Set (java.util.Set)12 HashMap (java.util.HashMap)10 ArrayList (java.util.ArrayList)9 Map (java.util.Map)9 ByteString (org.forgerock.opendj.ldap.ByteString)9 AMException (com.iplanet.am.sdk.AMException)7 SSOException (com.iplanet.sso.SSOException)5 AMHashMap (com.iplanet.am.sdk.AMHashMap)4 Enumeration (java.util.Enumeration)4 AMEntryExistsException (com.iplanet.am.sdk.AMEntryExistsException)3 AssignableDynamicGroup (com.iplanet.ums.AssignableDynamicGroup)3 CreationTemplate (com.iplanet.ums.CreationTemplate)3 EntryNotFoundException (com.iplanet.ums.EntryNotFoundException)3