Search in sources :

Example 31 with Filter

use of org.gluu.search.filter.Filter in project oxAuth by GluuFederation.

the class ExpirationNotificatorTimer method fillSessions.

private void fillSessions(Date future) {
    final String baseDn = staticConfiguration.getBaseDn().getSessions();
    final Filter filter = Filter.createANDFilter(Filter.createEqualityFilter("del", true), Filter.createLessOrEqualFilter("exp", persistenceEntryManager.encodeTime(baseDn, future)));
    final List<SessionId> sessions = persistenceEntryManager.findEntries(baseDn, SessionId.class, filter);
    if (sessions == null || sessions.isEmpty()) {
        return;
    }
    long now = new Date().getTime();
    for (SessionId session : sessions) {
        final long duration = session.getExpirationDate().getTime() - now;
        if (duration <= 0) {
            remove(session);
            continue;
        }
        expiringMap.put(new ExpId(session.getId(), ExpType.SESSION), session, duration, TimeUnit.MILLISECONDS);
    }
}
Also used : Filter(org.gluu.search.filter.Filter) SessionId(org.gluu.oxauth.model.common.SessionId) Date(java.util.Date)

Example 32 with Filter

use of org.gluu.search.filter.Filter in project oxAuth by GluuFederation.

the class DeviceRegistrationService method getCountDeviceRegistrations.

public int getCountDeviceRegistrations(String appId) {
    String baseDn = userService.getDnForUser(null);
    Filter appIdFilter = Filter.createEqualityFilter("oxApplication", appId);
    Filter activeDeviceFilter = Filter.createEqualityFilter("oxStatus", DeviceRegistrationStatus.ACTIVE.getValue());
    Filter resultFilter = Filter.createANDFilter(appIdFilter, activeDeviceFilter);
    return ldapEntryManager.countEntries(baseDn, DeviceRegistration.class, resultFilter);
}
Also used : Filter(org.gluu.search.filter.Filter)

Example 33 with Filter

use of org.gluu.search.filter.Filter in project oxAuth by GluuFederation.

the class DeviceRegistrationService method getExpiredDeviceRegistrations.

public List<DeviceRegistration> getExpiredDeviceRegistrations(BatchOperation<DeviceRegistration> batchOperation, Date expirationDate, String[] returnAttributes, int sizeLimit, int chunkSize) {
    final String u2fBaseDn = getDnForOneStepU2fDevice(null);
    Filter expirationFilter = Filter.createLessOrEqualFilter("creationDate", ldapEntryManager.encodeTime(u2fBaseDn, expirationDate));
    List<DeviceRegistration> deviceRegistrations = ldapEntryManager.findEntries(u2fBaseDn, DeviceRegistration.class, expirationFilter, SearchScope.SUB, returnAttributes, batchOperation, 0, sizeLimit, chunkSize);
    return deviceRegistrations;
}
Also used : Filter(org.gluu.search.filter.Filter) DeviceRegistration(org.gluu.oxauth.model.fido.u2f.DeviceRegistration)

Example 34 with Filter

use of org.gluu.search.filter.Filter in project oxAuth by GluuFederation.

the class RequestService method getExpiredRequestMessages.

public List<RequestMessageLdap> getExpiredRequestMessages(BatchOperation<RequestMessageLdap> batchOperation, Date expirationDate, String[] returnAttributes, int sizeLimit, int chunkSize) {
    // ou=u2f,o=gluu
    final String u2fBaseDn = staticConfiguration.getBaseDn().getU2fBase();
    Filter expirationFilter = Filter.createLessOrEqualFilter("creationDate", ldapEntryManager.encodeTime(u2fBaseDn, expirationDate));
    List<RequestMessageLdap> requestMessageLdap = ldapEntryManager.findEntries(u2fBaseDn, RequestMessageLdap.class, expirationFilter, SearchScope.SUB, returnAttributes, batchOperation, 0, sizeLimit, chunkSize);
    return requestMessageLdap;
}
Also used : Filter(org.gluu.search.filter.Filter) RequestMessageLdap(org.gluu.oxauth.model.fido.u2f.RequestMessageLdap)

Example 35 with Filter

use of org.gluu.search.filter.Filter in project oxAuth by GluuFederation.

the class UserService method countFido2RegisteredDevices.

public long countFido2RegisteredDevices(String username) {
    String userInum = getUserInum(username);
    if (userInum == null) {
        return 0;
    }
    String baseDn = getBaseDnForFido2RegistrationEntries(userInum);
    if (persistenceEntryManager.hasBranchesSupport(baseDn)) {
        if (!persistenceEntryManager.contains(baseDn, SimpleBranch.class)) {
            return 0;
        }
    }
    Filter userInumFilter = Filter.createEqualityFilter("personInum", userInum);
    Filter registeredFilter = Filter.createEqualityFilter("oxStatus", "registered");
    Filter filter = Filter.createANDFilter(userInumFilter, registeredFilter);
    long countEntries = persistenceEntryManager.countEntries(baseDn, Fido2RegistrationEntry.class, filter);
    return countEntries;
}
Also used : SimpleBranch(org.gluu.persist.model.base.SimpleBranch) Filter(org.gluu.search.filter.Filter)

Aggregations

Filter (org.gluu.search.filter.Filter)122 ArrayList (java.util.ArrayList)34 GluuCustomPerson (org.gluu.oxtrust.model.GluuCustomPerson)9 EntryPersistenceException (org.gluu.persist.exception.mapping.EntryPersistenceException)7 MappingException (org.gluu.persist.exception.mapping.MappingException)7 EntryPersistenceException (org.gluu.persist.exception.EntryPersistenceException)6 SearchException (org.gluu.persist.exception.operation.SearchException)6 List (java.util.List)5 GluuAttribute (org.gluu.model.GluuAttribute)5 PropertyAnnotation (org.gluu.persist.model.PropertyAnnotation)5 SearchResult (com.unboundid.ldap.sdk.SearchResult)4 ParseException (java.text.ParseException)4 GluuGroup (org.gluu.oxtrust.model.GluuGroup)4 PersistenceEntryManager (org.gluu.persist.PersistenceEntryManager)4 AuthenticationException (org.gluu.persist.exception.operation.AuthenticationException)4 ConnectionException (org.gluu.persist.exception.operation.ConnectionException)4 SearchScopeException (org.gluu.persist.exception.operation.SearchScopeException)4 GluuAttribute (org.xdi.model.GluuAttribute)4 SearchResultEntry (com.unboundid.ldap.sdk.SearchResultEntry)3 Date (java.util.Date)3