Search in sources :

Example 11 with Attr

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

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

the class ComplianceServicesImpl method removeAttributesFromEntry.

/**
     * Method to remove attributes from an entry
     */
private void removeAttributesFromEntry(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.DELETE);
    }
    po.save();
}
Also used : PersistentObject(com.iplanet.ums.PersistentObject) Guid(com.iplanet.ums.Guid) Attr(com.iplanet.services.ldap.Attr)

Example 13 with Attr

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

Example 14 with Attr

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

the class MiscUtils method combineAttrSets.

/**
     * Combines 2 AttrSets and returns the result set. The original sets are not
     * modified.
     * 
     * @param attrSet1
     *            the first AttrSet
     * @param attrSet2
     *            the second AttrSet
     * @return an AttrSet which has combined values of attrSet1 & attrSet2
     */
public static AttrSet combineAttrSets(AttrSet attrSet1, AttrSet attrSet2) {
    AttrSet retAttrSet = new AttrSet();
    if (attrSet1 != null) {
        int count = attrSet1.size();
        for (int i = 0; i < count; i++) {
            Attr attr = attrSet1.elementAt(i);
            retAttrSet.add(attr);
        }
    }
    if (attrSet2 != null) {
        int count = attrSet2.size();
        for (int i = 0; i < count; i++) {
            Attr attr = attrSet2.elementAt(i);
            retAttrSet.add(attr);
        }
    }
    return retAttrSet;
}
Also used : Attr(com.iplanet.services.ldap.Attr) AttrSet(com.iplanet.services.ldap.AttrSet)

Example 15 with Attr

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

the class MiscUtils method attrSetToMap.

/**
     * Method to convert a AttrSet object to Map.
     * 
     * @param attrSet
     *            the AttrSet to be converted to a Map
     * @param fetchByteValues
     *            if false stringValues are added, if true byteValues are added.
     * @return a Map containing attribute names as key's and a Set of attribute
     *         values or byte Values
     */
public static Map attrSetToMap(AttrSet attrSet, boolean fetchByteValues) {
    Map attributesMap = new AMHashMap(fetchByteValues);
    if (attrSet == null) {
        return attributesMap;
    }
    int attrSetSize = attrSet.size();
    if (!fetchByteValues) {
        for (int i = 0; i < attrSetSize; i++) {
            Attr attr = attrSet.elementAt(i);
            String[] values = attr.getStringValues();
            attributesMap.put(attr.getName(), stringArrayToSet(values));
        }
    } else {
        for (int i = 0; i < attrSetSize; i++) {
            Attr attr = attrSet.elementAt(i);
            attributesMap.put(attr.getName(), attr.getByteValues());
        }
    }
    return attributesMap;
}
Also used : AMHashMap(com.iplanet.am.sdk.AMHashMap) AMHashMap(com.iplanet.am.sdk.AMHashMap) HashMap(java.util.HashMap) Map(java.util.Map) Attr(com.iplanet.services.ldap.Attr)

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