Search in sources :

Example 11 with CrestQuery

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

the class IdentityServicesImpl method fetchAMIdentity.

private AMIdentity fetchAMIdentity(AMIdentityRepository repo, IdType type, String identity, boolean fetchAllAttrs) throws IdRepoException, ObjectNotFound, SSOException {
    AMIdentity rv = null;
    List<AMIdentity> identities = fetchAMIdentities(type, new CrestQuery(identity), fetchAllAttrs, repo, null);
    if (identities != null && !identities.isEmpty()) {
        rv = identities.get(0);
    }
    return rv;
}
Also used : CrestQuery(org.forgerock.openam.utils.CrestQuery) AMIdentity(com.sun.identity.idm.AMIdentity)

Example 12 with CrestQuery

use of org.forgerock.openam.utils.CrestQuery 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 13 with CrestQuery

use of org.forgerock.openam.utils.CrestQuery 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 14 with CrestQuery

use of org.forgerock.openam.utils.CrestQuery 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 15 with CrestQuery

use of org.forgerock.openam.utils.CrestQuery 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

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