Search in sources :

Example 16 with RepoSearchResults

use of com.sun.identity.idm.RepoSearchResults in project OpenAM by OpenRock.

the class FilesRepo method getFullyQualifiedName.

public String getFullyQualifiedName(SSOToken token, IdType type, String name) throws IdRepoException, SSOException {
    if (initializationException != null) {
        debug.error("FilesRepo: throwing initialization exception");
        throw (initializationException);
    }
    RepoSearchResults results = search(token, type, name, null, true, 0, 0, null);
    Set dns = results.getSearchResults();
    if (dns != null || dns.size() != 1) {
        String[] args = { NAME, name };
        throw (new IdRepoException(IdRepoBundle.BUNDLE_NAME, IdRepoErrorCode.UNABLE_FIND_ENTRY, args));
    }
    return ("files://FilesRepo/" + type.getName() + "/" + dns.iterator().next().toString());
}
Also used : CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) HashSet(java.util.HashSet) Set(java.util.Set) IdRepoException(com.sun.identity.idm.IdRepoException) RepoSearchResults(com.sun.identity.idm.RepoSearchResults)

Example 17 with RepoSearchResults

use of com.sun.identity.idm.RepoSearchResults in project OpenAM by OpenRock.

the class GenericRepoTest method searchReturnsEarlyIfMaxResultsReached.

@Test(enabled = false)
public void searchReturnsEarlyIfMaxResultsReached() throws Exception {
    CrestQuery crestQuery = new CrestQuery("*");
    RepoSearchResults results = idrepo.search(null, IdType.USER, crestQuery, 0, 2, null, true, IdRepo.AND_MOD, null, true);
    assertThat(results.getErrorCode()).isEqualTo(RepoSearchResults.SIZE_LIMIT_EXCEEDED);
    assertThat(results.getSearchResults()).hasSize(2);
}
Also used : CrestQuery(org.forgerock.openam.utils.CrestQuery) RepoSearchResults(com.sun.identity.idm.RepoSearchResults) Test(org.testng.annotations.Test)

Example 18 with RepoSearchResults

use of com.sun.identity.idm.RepoSearchResults in project OpenAM by OpenRock.

the class GenericRepoTest method searchReturnsRequestedAttributes.

@Test
public void searchReturnsRequestedAttributes() throws Exception {
    CrestQuery crestQuery = new CrestQuery("searchTester1");
    RepoSearchResults results = idrepo.search(null, IdType.USER, crestQuery, 0, 0, asSet("sn"), false, IdRepo.AND_MOD, null, true);
    assertThat(results.getErrorCode()).isEqualTo(ResultCode.SUCCESS.intValue());
    assertThat(results.getType()).isEqualTo(IdType.USER);
    assertThat(results.getSearchResults()).hasSize(1).containsOnly("searchTester1");
    Map<String, Map<String, Set<String>>> resultAttrs = results.getResultAttributes();
    assertThat(resultAttrs).hasSize(1);
    assertThat(resultAttrs.get("searchTester1")).hasSize(2);
    assertThat(resultAttrs.get("searchTester1").get("sn")).containsOnly("hello");
    assertThat(resultAttrs.get("searchTester1").get("uid")).containsOnly("searchTester1");
}
Also used : CrestQuery(org.forgerock.openam.utils.CrestQuery) RepoSearchResults(com.sun.identity.idm.RepoSearchResults) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) Map(java.util.Map) Test(org.testng.annotations.Test)

Example 19 with RepoSearchResults

use of com.sun.identity.idm.RepoSearchResults in project OpenAM by OpenRock.

the class GenericRepoTest method searchReturnsMatchesForSearchAttribute.

@Test
public void searchReturnsMatchesForSearchAttribute() throws Exception {
    CrestQuery crestQuery = new CrestQuery("searchTester*");
    RepoSearchResults results = idrepo.search(null, IdType.USER, crestQuery, 0, 0, null, true, IdRepo.AND_MOD, null, true);
    assertThat(results.getErrorCode()).isEqualTo(ResultCode.SUCCESS.intValue());
    assertThat(results.getType()).isEqualTo(IdType.USER);
    assertThat(results.getSearchResults()).hasSize(4).containsOnly("searchTester1", "searchTester2", "searchTester3", "searchTester4");
}
Also used : CrestQuery(org.forgerock.openam.utils.CrestQuery) RepoSearchResults(com.sun.identity.idm.RepoSearchResults) Test(org.testng.annotations.Test)

Example 20 with RepoSearchResults

use of com.sun.identity.idm.RepoSearchResults in project OpenAM by OpenRock.

the class GenericRepoTest method searchReturnsMatchesForComplexFilters.

//need to depend on deleteSuccessful, otherwise testuser1 would ruin the day :)
@Test(dependsOnMethods = "deleteSuccessful")
public void searchReturnsMatchesForComplexFilters() throws Exception {
    Map<String, Set<String>> avPairs = new HashMap<String, Set<String>>();
    avPairs.put("objectclass", asSet("inetorgperson"));
    avPairs.put("sn", asSet("hellNo"));
    CrestQuery crestQuery = new CrestQuery("*");
    RepoSearchResults results = idrepo.search(null, IdType.USER, crestQuery, 0, 0, null, true, IdRepo.AND_MOD, avPairs, true);
    assertThat(results.getErrorCode()).isEqualTo(ResultCode.SUCCESS.intValue());
    assertThat(results.getType()).isEqualTo(IdType.USER);
    assertThat(results.getSearchResults()).containsOnly("searchTester3");
    results = idrepo.search(null, IdType.USER, crestQuery, 0, 0, null, true, IdRepo.OR_MOD, avPairs, true);
    assertThat(results.getErrorCode()).isEqualTo(ResultCode.SUCCESS.intValue());
    assertThat(results.getType()).isEqualTo(IdType.USER);
    assertThat(results.getSearchResults()).containsOnly(DEMO, "searchTester1", "searchTester2", "searchTester3", "searchTester4");
}
Also used : CrestQuery(org.forgerock.openam.utils.CrestQuery) CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) HashSet(java.util.HashSet) CollectionUtils.asOrderedSet(org.forgerock.openam.utils.CollectionUtils.asOrderedSet) Set(java.util.Set) CollectionUtils.asSet(org.forgerock.openam.utils.CollectionUtils.asSet) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) RepoSearchResults(com.sun.identity.idm.RepoSearchResults) Test(org.testng.annotations.Test)

Aggregations

RepoSearchResults (com.sun.identity.idm.RepoSearchResults)25 HashSet (java.util.HashSet)19 Set (java.util.Set)18 CaseInsensitiveHashSet (com.sun.identity.common.CaseInsensitiveHashSet)14 CaseInsensitiveHashMap (com.sun.identity.common.CaseInsensitiveHashMap)13 HashMap (java.util.HashMap)13 Map (java.util.Map)12 IdRepoException (com.sun.identity.idm.IdRepoException)11 Iterator (java.util.Iterator)11 CrestQuery (org.forgerock.openam.utils.CrestQuery)11 Test (org.testng.annotations.Test)7 OrderedSet (com.sun.identity.shared.datastruct.OrderedSet)4 NotificationSet (com.iplanet.services.comm.share.NotificationSet)3 SSOException (com.iplanet.sso.SSOException)3 IdRepo (com.sun.identity.idm.IdRepo)3 IdRepoUnsupportedOpException (com.sun.identity.idm.IdRepoUnsupportedOpException)3 AMHashMap (com.iplanet.am.sdk.AMHashMap)2 SSOToken (com.iplanet.sso.SSOToken)2 AMIdentity (com.sun.identity.idm.AMIdentity)2 IdSearchResults (com.sun.identity.idm.IdSearchResults)2