Search in sources :

Example 66 with Filter

use of io.jans.orm.search.filter.Filter in project jans by JanssenProject.

the class ManualSqlEntryManagerTest method searchSessionIdWithRanges.

@Test(dependsOnMethods = "deleteSessionId", enabled = false)
public void searchSessionIdWithRanges() throws IOException {
    String outsideSid = UUID.randomUUID().toString();
    for (int i = 0; i < 20; i++) {
        SessionId sessionId = buildSessionId();
        sessionId.setOutsideSid(outsideSid);
        manager.persist(sessionId);
    }
    Filter filter = Filter.createEqualityFilter("sid", outsideSid);
    List<SessionId> sessionIdList = manager.findEntries("o=jans", SessionId.class, filter);
    assertNotNull(sessionIdList);
    assertEquals(sessionIdList.size(), 20);
    List<SessionId> sessionIdList2 = manager.findEntries("o=jans", SessionId.class, filter, 5);
    assertNotNull(sessionIdList2);
    assertEquals(sessionIdList2.size(), 5);
    List<SessionId> sessionIdList3 = manager.findEntries("o=jans", SessionId.class, filter, 25);
    assertNotNull(sessionIdList3);
    assertEquals(sessionIdList3.size(), 20);
    List<SessionId> sessionIdList4 = manager.findEntries("o=jans", SessionId.class, filter, null, null, 14, 7, 3);
    assertNotNull(sessionIdList4);
    assertEquals(sessionIdList4.size(), 6);
    List<SessionId> sessionIdList5 = manager.findEntries("o=jans", SessionId.class, filter, null, null, 20, 10, 5);
    assertNotNull(sessionIdList5);
    assertEquals(sessionIdList5.size(), 0);
    List<SessionId> sessionIdList6 = manager.findEntries("o=jans", SessionId.class, filter, null, null, 19, -1, 5);
    assertNotNull(sessionIdList6);
    assertEquals(sessionIdList6.size(), 1);
}
Also used : Filter(io.jans.orm.search.filter.Filter) Test(org.testng.annotations.Test)

Example 67 with Filter

use of io.jans.orm.search.filter.Filter in project jans by JanssenProject.

the class ManualSqlEntryManagerTest method searchPagedSessionIdWithRanges.

@Test(dependsOnMethods = "deleteSessionId", enabled = false)
public void searchPagedSessionIdWithRanges() throws IOException {
    String outsideSid = UUID.randomUUID().toString();
    for (int i = 0; i < 20; i++) {
        SessionId sessionId = buildSessionId();
        sessionId.setOutsideSid(outsideSid);
        manager.persist(sessionId);
    }
    Filter filter = Filter.createEqualityFilter("sid", outsideSid);
    PagedResult<SessionId> sessionIdList = manager.findPagedEntries("o=jans", SessionId.class, filter, null, "sid", SortOrder.DESCENDING, 0, -1, -1);
    assertNotNull(sessionIdList);
    assertEquals(sessionIdList.getTotalEntriesCount(), 20);
    PagedResult<SessionId> sessionIdList2 = manager.findPagedEntries("o=jans", SessionId.class, filter, null, "sid", SortOrder.DESCENDING, 0, 5, -1);
    assertNotNull(sessionIdList2);
    assertEquals(sessionIdList2.getStart(), 0);
    assertEquals(sessionIdList2.getEntriesCount(), 5);
    assertEquals(sessionIdList2.getTotalEntriesCount(), 20);
    PagedResult<SessionId> sessionIdList4 = manager.findPagedEntries("o=jans", SessionId.class, filter, null, "sid", SortOrder.DESCENDING, 14, 7, 3);
    assertNotNull(sessionIdList4);
    assertEquals(sessionIdList4.getStart(), 14);
    assertEquals(sessionIdList4.getEntriesCount(), 6);
    assertEquals(sessionIdList4.getTotalEntriesCount(), 20);
    PagedResult<SessionId> sessionIdList5 = manager.findPagedEntries("o=jans", SessionId.class, filter, null, "sid", SortOrder.DESCENDING, 20, 10, 5);
    assertNotNull(sessionIdList5);
    assertEquals(sessionIdList5.getStart(), 20);
    assertEquals(sessionIdList5.getEntriesCount(), 0);
    assertEquals(sessionIdList5.getTotalEntriesCount(), 20);
    PagedResult<SessionId> sessionIdList6 = manager.findPagedEntries("o=jans", SessionId.class, filter, null, "sid", SortOrder.DESCENDING, 19, -1, 5);
    assertNotNull(sessionIdList6);
    assertEquals(sessionIdList6.getStart(), 19);
    assertEquals(sessionIdList6.getEntriesCount(), 1);
    assertEquals(sessionIdList6.getTotalEntriesCount(), 20);
}
Also used : Filter(io.jans.orm.search.filter.Filter) Test(org.testng.annotations.Test)

Example 68 with Filter

use of io.jans.orm.search.filter.Filter in project jans by JanssenProject.

the class ManualSqlEntryManagerTest method countSessionIdByFilter.

@Test(dependsOnMethods = "deleteSessionId", enabled = false)
public void countSessionIdByFilter() throws IOException {
    String outsideSid = UUID.randomUUID().toString();
    for (int i = 0; i < 33; i++) {
        SessionId sessionId = buildSessionId();
        sessionId.setOutsideSid(outsideSid);
        manager.persist(sessionId);
    }
    Filter filter = Filter.createEqualityFilter("sid", outsideSid);
    int countEntries = manager.countEntries("ou=sessions,o=jans", SessionId.class, filter, null);
    assertEquals(countEntries, 33);
}
Also used : Filter(io.jans.orm.search.filter.Filter) Test(org.testng.annotations.Test)

Example 69 with Filter

use of io.jans.orm.search.filter.Filter in project jans by JanssenProject.

the class RegistrationPersistenceService method findAllByUsername.

public List<Fido2RegistrationEntry> findAllByUsername(String username) {
    String userInum = userService.getUserInum(username);
    if (userInum == null) {
        return Collections.emptyList();
    }
    String baseDn = getBaseDnForFido2RegistrationEntries(userInum);
    if (persistenceEntryManager.hasBranchesSupport(baseDn)) {
        if (!containsBranch(baseDn)) {
            return Collections.emptyList();
        }
    }
    Filter userFilter = Filter.createEqualityFilter("personInum", userInum);
    List<Fido2RegistrationEntry> fido2RegistrationnEntries = persistenceEntryManager.findEntries(baseDn, Fido2RegistrationEntry.class, userFilter);
    return fido2RegistrationnEntries;
}
Also used : Fido2RegistrationEntry(io.jans.fido2.model.entry.Fido2RegistrationEntry) Filter(io.jans.orm.search.filter.Filter)

Example 70 with Filter

use of io.jans.orm.search.filter.Filter in project jans by JanssenProject.

the class RegistrationPersistenceService method findByChallenge.

public List<Fido2RegistrationEntry> findByChallenge(String challenge) {
    String baseDn = getBaseDnForFido2RegistrationEntries(null);
    Filter codeChallengFilter = Filter.createEqualityFilter("jansCodeChallenge", challenge);
    Filter codeChallengHashCodeFilter = Filter.createEqualityFilter("jansCodeChallengeHash", String.valueOf(getChallengeHashCode(challenge)));
    Filter filter = Filter.createANDFilter(codeChallengFilter, codeChallengHashCodeFilter);
    List<Fido2RegistrationEntry> fido2RegistrationnEntries = persistenceEntryManager.findEntries(baseDn, Fido2RegistrationEntry.class, filter);
    return fido2RegistrationnEntries;
}
Also used : Fido2RegistrationEntry(io.jans.fido2.model.entry.Fido2RegistrationEntry) Filter(io.jans.orm.search.filter.Filter)

Aggregations

Filter (io.jans.orm.search.filter.Filter)188 Test (org.testng.annotations.Test)50 EntryPersistenceException (io.jans.orm.exception.EntryPersistenceException)32 ConvertedExpression (io.jans.orm.couchbase.model.ConvertedExpression)28 SearchException (io.jans.orm.exception.operation.SearchException)25 ConvertedExpression (io.jans.orm.sql.model.ConvertedExpression)24 MappingException (io.jans.orm.exception.MappingException)22 ArrayList (java.util.ArrayList)21 AuthenticationException (io.jans.orm.exception.AuthenticationException)20 PropertyAnnotation (io.jans.orm.reflect.property.PropertyAnnotation)19 EntryDeleteException (io.jans.orm.exception.EntryDeleteException)18 Date (java.util.Date)14 List (java.util.List)14 SqlEntryManager (io.jans.orm.sql.impl.SqlEntryManager)11 SqlEntryManagerSample (io.jans.orm.sql.persistence.SqlEntryManagerSample)11 CustomAttribute (io.jans.orm.model.base.CustomAttribute)9 CustomObjectAttribute (io.jans.orm.model.base.CustomObjectAttribute)9 DateTimeParseException (java.time.format.DateTimeParseException)9 SpannerEntryManager (io.jans.orm.cloud.spanner.impl.SpannerEntryManager)8 SpannerEntryManagerSample (io.jans.orm.cloud.spanner.persistence.SpannerEntryManagerSample)8