Search in sources :

Example 16 with CrestQuery

use of org.forgerock.openam.utils.CrestQuery in project OpenAM by OpenRock.

the class IdServicesImpl method getSpecialIdentities.

public IdSearchResults getSpecialIdentities(SSOToken token, IdType type, String orgName) throws IdRepoException, SSOException {
    Set pluginClasses = new OrderedSet();
    if (ServiceManager.isConfigMigratedTo70() && ServiceManager.getBaseDN().equalsIgnoreCase(orgName)) {
        // Check the cache
        if (specialIdentities != null) {
            return (specialIdentities);
        }
        // get the "SpecialUser plugin
        Set repos = idrepoCache.getIdRepoPlugins(orgName);
        for (Iterator items = repos.iterator(); items.hasNext(); ) {
            IdRepo repo = (IdRepo) items.next();
            if (repo instanceof SpecialRepo) {
                pluginClasses.add(repo);
            }
        }
    }
    // If no plugins found, return empty results
    if (pluginClasses.isEmpty()) {
        return (emptyUserIdentities);
    } else {
        IdRepo specialRepo = (IdRepo) pluginClasses.iterator().next();
        CrestQuery crestQuery = new CrestQuery("*");
        RepoSearchResults res = specialRepo.search(token, type, crestQuery, 0, 0, Collections.EMPTY_SET, false, 0, Collections.EMPTY_MAP, false);
        Object[][] obj = new Object[1][2];
        obj[0][0] = res;
        obj[0][1] = Collections.EMPTY_MAP;
        specialIdentities = combineSearchResults(token, obj, 1, type, orgName, false, null);
    }
    return (specialIdentities);
}
Also used : OrderedSet(com.sun.identity.shared.datastruct.OrderedSet) CrestQuery(org.forgerock.openam.utils.CrestQuery) Set(java.util.Set) OrderedSet(com.sun.identity.shared.datastruct.OrderedSet) CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) HashSet(java.util.HashSet) SpecialRepo(com.sun.identity.idm.plugins.internal.SpecialRepo) IdRepo(com.sun.identity.idm.IdRepo) Iterator(java.util.Iterator) RepoSearchResults(com.sun.identity.idm.RepoSearchResults)

Example 17 with CrestQuery

use of org.forgerock.openam.utils.CrestQuery in project OpenAM by OpenRock.

the class IdServicesImpl method isSpecialIdentity.

protected boolean isSpecialIdentity(SSOToken token, String name, IdType type, String orgName) throws IdRepoException, SSOException {
    if (ServiceManager.isConfigMigratedTo70() && ServiceManager.getBaseDN().equalsIgnoreCase(orgName) && type.equals(IdType.USER)) {
        // Check the cache
        if (specialIdentityNames == null) {
            // get the "SpecialUser plugin
            Set spIds = new CaseInsensitiveHashSet();
            Set repos = idrepoCache.getIdRepoPlugins(orgName);
            for (Iterator items = repos.iterator(); items.hasNext(); ) {
                IdRepo repo = (IdRepo) items.next();
                if (repo instanceof SpecialRepo) {
                    CrestQuery crestQuery = new CrestQuery("*");
                    RepoSearchResults res = repo.search(token, type, crestQuery, 0, 0, Collections.EMPTY_SET, false, 0, Collections.EMPTY_MAP, false);
                    Set identities = res.getSearchResults();
                    for (Iterator ids = identities.iterator(); ids.hasNext(); ) {
                        spIds.add(ids.next());
                    }
                }
            }
            specialIdentityNames = spIds;
        }
        if ((specialIdentityNames != null) && !specialIdentityNames.isEmpty()) {
            return (specialIdentityNames.contains(name));
        }
    }
    return (false);
}
Also used : CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) CrestQuery(org.forgerock.openam.utils.CrestQuery) Set(java.util.Set) OrderedSet(com.sun.identity.shared.datastruct.OrderedSet) CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) HashSet(java.util.HashSet) SpecialRepo(com.sun.identity.idm.plugins.internal.SpecialRepo) IdRepo(com.sun.identity.idm.IdRepo) Iterator(java.util.Iterator) RepoSearchResults(com.sun.identity.idm.RepoSearchResults)

Example 18 with CrestQuery

use of org.forgerock.openam.utils.CrestQuery in project OpenAM by OpenRock.

the class IdRepoJAXRPCObjectImpl method search2_idrepo.

public Map search2_idrepo(String token, String type, String pattern, int maxTime, int maxResults, Set returnAttrs, boolean returnAllAttrs, int filterOp, Map avPairs, boolean recursive, String amOrgName) throws RemoteException, IdRepoException, SSOException {
    SSOToken ssoToken = getSSOToken(token);
    IdType idtype = IdUtils.getType(type);
    IdSearchControl ctrl = new IdSearchControl();
    ctrl.setAllReturnAttributes(returnAllAttrs);
    ctrl.setMaxResults(maxResults);
    ctrl.setReturnAttributes(returnAttrs);
    ctrl.setTimeOut(maxTime);
    IdSearchOpModifier modifier = (filterOp == IdRepo.OR_MOD) ? IdSearchOpModifier.OR : IdSearchOpModifier.AND;
    ctrl.setSearchModifiers(modifier, avPairs);
    CrestQuery crestQuery = new CrestQuery(pattern);
    return IdSearchResultsToMap(idServices.search(ssoToken, idtype, ctrl, amOrgName, crestQuery));
}
Also used : CrestQuery(org.forgerock.openam.utils.CrestQuery) SSOToken(com.iplanet.sso.SSOToken) IdSearchControl(com.sun.identity.idm.IdSearchControl) IdSearchOpModifier(com.sun.identity.idm.IdSearchOpModifier) IdType(com.sun.identity.idm.IdType)

Aggregations

CrestQuery (org.forgerock.openam.utils.CrestQuery)18 RepoSearchResults (com.sun.identity.idm.RepoSearchResults)11 HashSet (java.util.HashSet)7 Set (java.util.Set)7 Test (org.testng.annotations.Test)7 SSOToken (com.iplanet.sso.SSOToken)6 CaseInsensitiveHashSet (com.sun.identity.common.CaseInsensitiveHashSet)5 IdRepoException (com.sun.identity.idm.IdRepoException)5 SSOException (com.iplanet.sso.SSOException)4 BadRequestException (org.forgerock.json.resource.BadRequestException)4 ForbiddenException (org.forgerock.json.resource.ForbiddenException)4 InternalServerErrorException (org.forgerock.json.resource.InternalServerErrorException)4 NotFoundException (org.forgerock.json.resource.NotFoundException)4 PermanentException (org.forgerock.json.resource.PermanentException)4 ResourceException (org.forgerock.json.resource.ResourceException)4 CaseInsensitiveHashMap (com.sun.identity.common.CaseInsensitiveHashMap)3 IdentityDetails (com.sun.identity.idsvcs.IdentityDetails)3 SMSException (com.sun.identity.sm.SMSException)3 ServiceNotFoundException (com.sun.identity.sm.ServiceNotFoundException)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3