Search in sources :

Example 1 with DynamicGroup

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

the class DirectoryServicesImpl method getGroupFilterAndScope.

// ##########Group and role related APIs
/**
     * Returns an array containing the dynamic group's scope, base dn, and
     * filter.
     */
public String[] getGroupFilterAndScope(SSOToken token, String entryDN, int profileType) throws SSOException, AMException {
    String[] result = new String[3];
    int scope;
    String base;
    String gfilter;
    try {
        DynamicGroup dg = (DynamicGroup) UMSObject.getObject(token, new Guid(entryDN));
        scope = dg.getSearchScope();
        base = dg.getSearchBase().getDn();
        gfilter = dg.getSearchFilter();
        result[0] = Integer.toString(scope);
        result[1] = base;
        result[2] = gfilter;
    } catch (EntryNotFoundException e) {
        debug.error("AMGroupImpl.searchUsers", e);
        String msgid = getEntryNotFoundMsgID(profileType);
        String expectionEntryName = getEntryName(e);
        Object[] args = { expectionEntryName };
        throw new AMException(AMSDKBundle.getString(msgid, args), msgid, args);
    } catch (UMSException e) {
        debug.message("AMGroupImpl.searchUsers", e);
        throw new AMException(AMSDKBundle.getString("341"), "341", e);
    }
    return result;
}
Also used : DynamicGroup(com.iplanet.ums.DynamicGroup) AssignableDynamicGroup(com.iplanet.ums.AssignableDynamicGroup) UMSException(com.iplanet.ums.UMSException) EntryNotFoundException(com.iplanet.ums.EntryNotFoundException) AMException(com.iplanet.am.sdk.AMException) Guid(com.iplanet.ums.Guid)

Example 2 with DynamicGroup

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

the class DirectoryServicesImpl method getMembers.

/**
     * Get members for roles, dynamic group or static group
     * 
     * @param token
     *            SSOToken
     * @param entryDN
     *            DN of the role or group
     * @param objectType
     *            objectType of the target object, AMObject.ROLE or
     *            AMObject.GROUP
     * @return Set Member DNs
     */
public Set getMembers(SSOToken token, String entryDN, int objectType) throws AMException {
    try {
        SearchResults results;
        switch(objectType) {
            case AMObject.ROLE:
            case AMObject.MANAGED_ROLE:
                ManagedRole role = (ManagedRole) UMSObject.getObject(token, new Guid(entryDN));
                results = role.getMemberIDs();
                return searchResultsToSet(results);
            case AMObject.FILTERED_ROLE:
                FilteredRole filteredRole = (FilteredRole) UMSObject.getObject(token, new Guid(entryDN));
                results = filteredRole.getMemberIDs();
                return searchResultsToSet(results);
            case AMObject.GROUP:
            case AMObject.STATIC_GROUP:
                StaticGroup group = (StaticGroup) UMSObject.getObject(token, new Guid(entryDN));
                results = group.getMemberIDs();
                return searchResultsToSet(results);
            case AMObject.DYNAMIC_GROUP:
                DynamicGroup dynamicGroup = (DynamicGroup) UMSObject.getObject(token, new Guid(entryDN));
                results = dynamicGroup.getMemberIDs();
                return searchResultsToSet(results);
            case AMObject.ASSIGNABLE_DYNAMIC_GROUP:
                // TODO: See if it works after removing this workaround
                // fake object to get around UMS problem.
                // UMS AssignableDynamicGroup has a class resolver, it is
                // added to resolver list in static block. So I need to
                // construct a dummy AssignableDynamicGroup
                AssignableDynamicGroup adgroup = (AssignableDynamicGroup) UMSObject.getObject(token, new Guid(entryDN));
                results = adgroup.getMemberIDs();
                return searchResultsToSet(results);
            default:
                throw new AMException(token, "114");
        }
    } catch (EntryNotFoundException e) {
        debug.error("DirectoryServicesImpl.getMembers() entryDN " + entryDN + " objectType: " + objectType + " Unable to get members: ", e);
        String msgid = getEntryNotFoundMsgID(objectType);
        String entryName = getEntryName(e);
        Object[] args = { entryName };
        throw new AMException(AMSDKBundle.getString(msgid, args), msgid, args);
    } catch (UMSException e) {
        debug.error("DirectoryServicesImpl.getMembers() entryDN " + entryDN + " objectType: " + objectType + " Unable to get members: ", e);
        LdapException le = (LdapException) e.getRootCause();
        if (le != null) {
            ResultCode resultCode = le.getResult().getResultCode();
            if (ResultCode.SIZE_LIMIT_EXCEEDED.equals(resultCode) || ResultCode.ADMIN_LIMIT_EXCEEDED.equals(resultCode)) {
                throw new AMException(token, "505", e);
            }
        }
        throw new AMException(token, "454", e);
    }
}
Also used : DynamicGroup(com.iplanet.ums.DynamicGroup) AssignableDynamicGroup(com.iplanet.ums.AssignableDynamicGroup) UMSException(com.iplanet.ums.UMSException) AMException(com.iplanet.am.sdk.AMException) Guid(com.iplanet.ums.Guid) AMSearchResults(com.iplanet.am.sdk.AMSearchResults) SearchResults(com.iplanet.ums.SearchResults) StaticGroup(com.iplanet.ums.StaticGroup) ManagedRole(com.iplanet.ums.ManagedRole) FilteredRole(com.iplanet.ums.FilteredRole) EntryNotFoundException(com.iplanet.ums.EntryNotFoundException) LdapException(org.forgerock.opendj.ldap.LdapException) AssignableDynamicGroup(com.iplanet.ums.AssignableDynamicGroup) ResultCode(org.forgerock.opendj.ldap.ResultCode)

Example 3 with DynamicGroup

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

the class DirectoryServicesImpl method setGroupFilter.

/**
     * Sets the filter for a dynamic group in the datastore.
     * 
     * @param token
     * @param entryDN
     * @param filter
     * @throws AMException
     * @throws SSOException
     */
public void setGroupFilter(SSOToken token, String entryDN, String filter) throws AMException, SSOException {
    try {
        DynamicGroup dynamicGroup = (DynamicGroup) UMSObject.getObject(token, new Guid(entryDN));
        dynamicGroup.setSearchFilter(filter);
        dynamicGroup.save();
    } catch (UMSException ume) {
        debug.message("AMDynamicGroup.setSearchFilter() - Unable to " + "setFilter()", ume);
        throw new AMException(token, "352", ume);
    }
}
Also used : DynamicGroup(com.iplanet.ums.DynamicGroup) AssignableDynamicGroup(com.iplanet.ums.AssignableDynamicGroup) UMSException(com.iplanet.ums.UMSException) AMException(com.iplanet.am.sdk.AMException) Guid(com.iplanet.ums.Guid)

Aggregations

AMException (com.iplanet.am.sdk.AMException)3 AssignableDynamicGroup (com.iplanet.ums.AssignableDynamicGroup)3 DynamicGroup (com.iplanet.ums.DynamicGroup)3 Guid (com.iplanet.ums.Guid)3 UMSException (com.iplanet.ums.UMSException)3 EntryNotFoundException (com.iplanet.ums.EntryNotFoundException)2 AMSearchResults (com.iplanet.am.sdk.AMSearchResults)1 FilteredRole (com.iplanet.ums.FilteredRole)1 ManagedRole (com.iplanet.ums.ManagedRole)1 SearchResults (com.iplanet.ums.SearchResults)1 StaticGroup (com.iplanet.ums.StaticGroup)1 LdapException (org.forgerock.opendj.ldap.LdapException)1 ResultCode (org.forgerock.opendj.ldap.ResultCode)1