Search in sources :

Example 46 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 47 with Attr

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

the class ComplianceServicesImpl method isAncestorOrgDeleted.

/**
     * Method which checks all the parent organizations of this entry till the
     * base DN, and returns true if any one of them is deleted.
     * 
     * @param token Single Sign On token of user.
     * @param dn Distinguished name of the object.
     * @param profileType the profile type of the object whose ancestor is
     *        being checked.
     * @throws AMException if there are errors from data layer.
     */
public boolean isAncestorOrgDeleted(SSOToken token, String dn, int profileType) throws AMException {
    if (debug.messageEnabled()) {
        debug.message("Compliance.isAncestorOrgDeleted-> " + " checking from... " + dn);
    }
    String tdn = DN.valueOf(dn).toString().toLowerCase();
    if ((profileType == AMObject.ORGANIZATION) && deletedOrg.containsKey(tdn)) {
        if (((Boolean) deletedOrg.get(tdn)).booleanValue()) {
            return true;
        }
    // else continue
    }
    if (profileType != AMObject.ORGANIZATION) {
        tdn = DirectoryServicesFactory.getInstance().getOrganizationDN(internalToken, dn);
    }
    while (!tdn.equalsIgnoreCase(rootSuffix)) {
        // Check to see if ancestor is in the cache deleted cache.
        if (debug.messageEnabled()) {
            debug.message("Compliance.isAncestorOrgDeleted-> " + "Checking for deleted status of " + tdn);
        }
        if (deletedOrg.containsKey(tdn)) {
            return ((Boolean) deletedOrg.get(tdn)).booleanValue();
        }
        try {
            PersistentObject po = UMSObject.getObject(internalToken, new Guid(tdn));
            Attr attr = po.getAttribute(ORG_STATUS_ATTRIBUTE);
            if (debug.messageEnabled() && (attr != null)) {
                debug.message("Compliance.isAncestorOrgDeleted-> " + ORG_STATUS_ATTRIBUTE + "=" + attr.toString());
            }
            if (((attr != null) && (attr.size() != 0)) && attr.contains("deleted")) {
                // Org is deleted
                if (debug.messageEnabled()) {
                    debug.message("isAncestorOrgDeleted: caching org: " + tdn + " as deleted");
                }
                synchronized (deletedOrg) {
                    deletedOrg.put(tdn, Boolean.TRUE);
                }
                // who is deleted so return true.
                return true;
            } else {
                if (debug.messageEnabled()) {
                    debug.message("isAncestorOrgDeleted: caching org: " + tdn + " as active");
                }
                synchronized (deletedOrg) {
                    deletedOrg.put(tdn, Boolean.FALSE);
                }
            }
        } catch (UMSException umse) {
            debug.error("Compliance.isAncestorOrgDeleted-> " + "UMSException", umse);
            return false;
        }
        // continue till we reach the rootSuffix. any one of
        // the ancestors could still be marked deleted.
        tdn = DirectoryServicesFactory.getInstance().getOrganizationDN(token, dn);
    }
    // reached the rootsuffix. This will should never be marked deleted
    return false;
}
Also used : UMSException(com.iplanet.ums.UMSException) PersistentObject(com.iplanet.ums.PersistentObject) Guid(com.iplanet.ums.Guid) Attr(com.iplanet.services.ldap.Attr)

Example 48 with Attr

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

the class CommonUtils 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
     */
protected 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 49 with Attr

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

the class ComplianceServicesImpl method checkIfDeletedUser.

/**
     * Method which checks if the entry corresponding to userDN represents a
     * deleted user entry (entry with inetuserstatus:deleted)
     * 
     * @param token
     *            a SSOToken object
     * @param userDN
     *            a String representing a user DN
     * 
     * @exception AMEntryExistsException
     *                if the userDN corresponds to a deleted user
     */
protected void checkIfDeletedUser(SSOToken token, String userDN) throws AMEntryExistsException {
    String[] userAttribute = { USER_STATUS_ATTRIBUTE };
    Attr attr;
    try {
        PersistentObject po = UMSObject.getObject(token, new Guid(userDN), userAttribute);
        attr = po.getAttribute(USER_STATUS_ATTRIBUTE);
    } catch (UMSException ue) {
        if (debug.messageEnabled())
            debug.message("Compliance.checkIfDeletedUser(): ", ue);
        return;
    }
    if (attr != null) {
        String attrValue = attr.getValue();
        if (attrValue != null && attrValue.equalsIgnoreCase("deleted")) {
            debug.warning("Compliance.checkIfDeletedUser(): " + "deleted user entry: " + userDN);
            throw new AMEntryExistsException(AMSDKBundle.getString("329"), "329");
        }
    }
}
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)

Example 50 with Attr

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

the class CommonUtils 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
     */
protected 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