Search in sources :

Example 1 with SpecialRepo

use of com.sun.identity.idm.plugins.internal.SpecialRepo 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 2 with SpecialRepo

use of com.sun.identity.idm.plugins.internal.SpecialRepo in project OpenAM by OpenRock.

the class IdServicesImpl method getSupportedOperations.

public Set getSupportedOperations(SSOToken token, IdType type, String amOrgName) throws IdRepoException, SSOException {
    // First get the list of plugins that support the create operation.
    Set unionSupportedOps = new HashSet();
    Set configuredPluginClasses = idrepoCache.getIdRepoPlugins(amOrgName);
    if (configuredPluginClasses == null || configuredPluginClasses.isEmpty()) {
        throw new IdRepoException(IdRepoBundle.BUNDLE_NAME, IdRepoErrorCode.NO_PLUGINS_CONFIGURED, null);
    }
    Iterator it = configuredPluginClasses.iterator();
    while (it.hasNext()) {
        IdRepo repo = (IdRepo) it.next();
        if (repo instanceof SpecialRepo) {
            continue;
        }
        Set supportedOps = repo.getSupportedOperations(type);
        if (supportedOps != null && !supportedOps.isEmpty()) {
            unionSupportedOps.addAll(supportedOps);
        }
    }
    return unionSupportedOps;
}
Also used : 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) IdRepoException(com.sun.identity.idm.IdRepoException) Iterator(java.util.Iterator) CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) HashSet(java.util.HashSet)

Example 3 with SpecialRepo

use of com.sun.identity.idm.plugins.internal.SpecialRepo 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)

Aggregations

CaseInsensitiveHashSet (com.sun.identity.common.CaseInsensitiveHashSet)3 IdRepo (com.sun.identity.idm.IdRepo)3 SpecialRepo (com.sun.identity.idm.plugins.internal.SpecialRepo)3 OrderedSet (com.sun.identity.shared.datastruct.OrderedSet)3 HashSet (java.util.HashSet)3 Iterator (java.util.Iterator)3 Set (java.util.Set)3 RepoSearchResults (com.sun.identity.idm.RepoSearchResults)2 CrestQuery (org.forgerock.openam.utils.CrestQuery)2 IdRepoException (com.sun.identity.idm.IdRepoException)1