Search in sources :

Example 11 with AttrSet

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

the class ComplianceServicesImpl method createAdminGroups.

/**
     * Method which creates Admin Groups for an organization.
     * 
     * @param token
     *            a SSOToken object
     * @param org
     *            an organization object
     * @exception AMException
     *                if an error is encountered
     */
protected void createAdminGroups(SSOToken token, PersistentObject org) throws AMException, SSOException {
    String gcDN = NamingAttributeManager.getNamingAttribute(AMObject.GROUP_CONTAINER) + "=groups," + org.getDN();
    AttrSet attrSet = new AttrSet();
    Attr attr = new Attr("objectclass", INET_ADMIN_OBJECT_CLASS);
    attrSet.add(attr);
    attr = new Attr(ADMIN_ROLE_ATTR, DOMAIN_ADMINISTRATORS);
    attrSet.add(attr);
    Map attributes = CommonUtils.attrSetToMap(attrSet);
    DirectoryServicesFactory.getInstance().createEntry(token, DOMAIN_ADMINISTRATORS, AMObject.ASSIGNABLE_DYNAMIC_GROUP, gcDN, attributes);
    attrSet = new AttrSet();
    attr = new Attr("objectclass", INET_ADMIN_OBJECT_CLASS);
    attrSet.add(attr);
    attr = new Attr(ADMIN_ROLE_ATTR, DOMAIN_ADMINISTRATORS);
    attrSet.add(attr);
    attributes = CommonUtils.attrSetToMap(attrSet);
    DirectoryServicesFactory.getInstance().createEntry(token, DOMAIN_HELP_DESK_ADMINISTRATORS, AMObject.ASSIGNABLE_DYNAMIC_GROUP, gcDN, attributes);
}
Also used : HashMap(java.util.HashMap) Map(java.util.Map) Attr(com.iplanet.services.ldap.Attr) AttrSet(com.iplanet.services.ldap.AttrSet)

Example 12 with AttrSet

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

the class DirectoryServicesImpl method createPeopleContainer.

private void createPeopleContainer(PersistentObject parentObj, Map attributes, String profileName) throws UMSException, AMException {
    AttrSet attrSet = CommonUtils.mapToAttrSet(attributes);
    makeNamingFirst(attrSet, getNamingAttribute(AMObject.PEOPLE_CONTAINER), profileName);
    TemplateManager tempMgr = TemplateManager.getTemplateManager();
    String orgDN = getOrganizationDN(internalToken, parentObj.getDN());
    CreationTemplate creationTemp = tempMgr.getCreationTemplate("BasicPeopleContainer", new Guid(orgDN), TemplateManager.SCOPE_ANCESTORS);
    attrSet = combineOCs(creationTemp, attrSet);
    com.iplanet.ums.PeopleContainer pc = new PeopleContainer(creationTemp, attrSet);
    parentObj.addChild(pc);
}
Also used : CreationTemplate(com.iplanet.ums.CreationTemplate) PeopleContainer(com.iplanet.ums.PeopleContainer) TemplateManager(com.iplanet.ums.TemplateManager) PeopleContainer(com.iplanet.ums.PeopleContainer) Guid(com.iplanet.ums.Guid) AttrSet(com.iplanet.services.ldap.AttrSet)

Example 13 with AttrSet

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

the class DirectoryServicesImpl method getAttributesFromDS.

/**
     * Gets the specific attributes corresponding to the entryDN. This method
     * obtains the DC Tree node attributes and also performs compliance related
     * verification checks in compliance mode. Note: In compliance mode you can
     * skip the compliance checks by setting ignoreCompliance to "false".
     * 
     * @param token
     *            a valid SSOToken
     * @param entryDN
     *            the DN of the entry whose attributes need to retrieved
     * @param attrNames
     *            a Set of names of the attributes that need to be retrieved.
     *            The attrNames should not be null.
     * @param ignoreCompliance
     *            a boolean value specificying if compliance related entries
     *            need to ignored or not. Ignored if true.
     * @return a Map containing attribute names as keys and Set of values
     *         corresponding to each key.
     * @throws AMException
     *             if an error is encountered in fetching the attributes
     */
public Map getAttributesFromDS(SSOToken token, String entryDN, Set attrNames, boolean ignoreCompliance, boolean byteValues, int profileType) throws AMException, SSOException {
    if (attrNames == null) {
        return getAttributes(token, entryDN, ignoreCompliance, byteValues, profileType);
    }
    try {
        // Convert the attrNames to String[]
        String[] names = (String[]) attrNames.toArray(new String[attrNames.size()]);
        PersistentObject po = UMSObject.getObjectHandle(token, new Guid(entryDN));
        // Perform compliance related checks
        AttrSet attrSet;
        if (!ignoreCompliance && ComplianceServicesImpl.isComplianceUserDeletionEnabled()) {
            // check for deleted user by getting complaince attributes
            attrSet = complianceImpl.verifyAndGetAttributes(po, names);
        } else {
            attrSet = po.getAttributes(names);
        }
        AMHashMap attributes = (AMHashMap) CommonUtils.attrSetToMap(attrSet, byteValues);
        // Obtain DC tree attributes if applicable            
        Map dcAttributes = getDCTreeAttributes(token, entryDN, attrNames, byteValues, profileType);
        attributes.copy(dcAttributes);
        return attributes;
    } catch (UMSException e) {
        if (debug.warningEnabled()) {
            debug.warning("DirectoryServicesImpl.getAttributes(): " + "Unable to get attributes: ", e);
        }
        // Extract the ldap error code from Exception
        throw new AMException(token, "330", e);
    }
}
Also used : UMSException(com.iplanet.ums.UMSException) AMHashMap(com.iplanet.am.sdk.AMHashMap) PersistentObject(com.iplanet.ums.PersistentObject) AMException(com.iplanet.am.sdk.AMException) Guid(com.iplanet.ums.Guid) Map(java.util.Map) AMHashMap(com.iplanet.am.sdk.AMHashMap) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) AttrSet(com.iplanet.services.ldap.AttrSet)

Example 14 with AttrSet

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

the class CallBackHelper method preProcess.

// TODO: Remove this. Use the Maps interface only
public AttrSet preProcess(SSOToken token, String entryDN, String orgDN, AttrSet oldAttrSet, AttrSet newAttrSet, int operation, int objectType, boolean softDelete) throws AMException {
    Set implSet = getPrePostImpls(orgDN);
    if (implSet != null && !implSet.isEmpty()) {
        // Post processing impls present
        // Iterate through the Pre-Processing Impls and execute
        Iterator itr = implSet.iterator();
        Map newAttrMap = CommonUtils.attrSetToMap(newAttrSet);
        Map oldAttrMap = CommonUtils.attrSetToMap(oldAttrSet);
        while (itr.hasNext()) {
            String className = (String) itr.next();
            AMCallBack impl = getCallBackObject(className);
            if (impl == null) {
                continue;
            }
            try {
                Map map;
                switch(operation) {
                    case CREATE:
                        map = impl.preProcessCreate(token, entryDN, newAttrMap, objectType);
                        newAttrMap = ((map == null) ? newAttrMap : map);
                        break;
                    case MODIFY:
                        map = impl.preProcessModify(token, entryDN, oldAttrMap, newAttrMap, objectType);
                        newAttrMap = ((map == null) ? newAttrMap : map);
                        break;
                    case DELETE:
                        impl.preProcessDelete(token, entryDN, oldAttrMap, softDelete, objectType);
                        break;
                }
            } catch (AMException ae) {
                // Exception thrown by the external impl
                debug.error("CallBackHelper.preProcess(): Preprocessing" + "impl " + className + " exception thrown by impl:", ae);
                throw ae;
            }
        }
        return CommonUtils.mapToAttrSet(newAttrMap);
    }
    // not null as newAttrSet will be the latest one needed for updation
    return ((newAttrSet != null) ? newAttrSet : oldAttrSet);
}
Also used : AMCallBack(com.iplanet.am.sdk.AMCallBack) AttrSet(com.iplanet.services.ldap.AttrSet) Set(java.util.Set) Iterator(java.util.Iterator) AMException(com.iplanet.am.sdk.AMException) Map(java.util.Map) HashMap(java.util.HashMap)

Example 15 with AttrSet

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

the class MiscUtils method mapToAttrSet.

/**
     * Method to convert a Map to AttrSet.
     * 
     * @param map
     *            a map contaning attribute names as keys and a Set of attribute
     *            values corresponding to each map key.
     * @param byteValues
     *            if true then values are bytes otherwise strings
     * @return an AttrSet having the contents of the supplied map
     */
public static AttrSet mapToAttrSet(Map map, boolean byteValues) {
    AttrSet attrSet = new AttrSet();
    if (map == null) {
        return attrSet;
    }
    if (!byteValues) {
        Iterator itr = map.keySet().iterator();
        while (itr.hasNext()) {
            String attrName = (String) (itr.next());
            Set set = (Set) (map.get(attrName));
            String[] attrValues = (set == null ? null : (String[]) set.toArray(new String[set.size()]));
            attrSet.replace(new Attr(attrName, attrValues));
        }
    } else {
        Iterator itr = map.keySet().iterator();
        while (itr.hasNext()) {
            String attrName = (String) (itr.next());
            byte[][] attrValues = (byte[][]) (map.get(attrName));
            attrSet.replace(new Attr(attrName, attrValues));
        }
    }
    return attrSet;
}
Also used : AttrSet(com.iplanet.services.ldap.AttrSet) Set(java.util.Set) HashSet(java.util.HashSet) Iterator(java.util.Iterator) Attr(com.iplanet.services.ldap.Attr) AttrSet(com.iplanet.services.ldap.AttrSet)

Aggregations

AttrSet (com.iplanet.services.ldap.AttrSet)61 Attr (com.iplanet.services.ldap.Attr)33 Guid (com.iplanet.ums.Guid)19 Iterator (java.util.Iterator)16 Set (java.util.Set)14 UMSException (com.iplanet.ums.UMSException)13 AMException (com.iplanet.am.sdk.AMException)12 CreationTemplate (com.iplanet.ums.CreationTemplate)12 TemplateManager (com.iplanet.ums.TemplateManager)12 HashMap (java.util.HashMap)9 HashSet (java.util.HashSet)9 Map (java.util.Map)9 ArrayList (java.util.ArrayList)8 PersistentObject (com.iplanet.ums.PersistentObject)6 SSOException (com.iplanet.sso.SSOException)5 AMHashMap (com.iplanet.am.sdk.AMHashMap)4 AssignableDynamicGroup (com.iplanet.ums.AssignableDynamicGroup)4 AMEntryExistsException (com.iplanet.am.sdk.AMEntryExistsException)3 AccessRightsException (com.iplanet.ums.AccessRightsException)3 EntryAlreadyExistsException (com.iplanet.ums.EntryAlreadyExistsException)3