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);
}
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);
}
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);
}
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;
}
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;
}
Aggregations