Search in sources :

Example 1 with RequestMessageLdap

use of org.gluu.oxauth.model.fido.u2f.RequestMessageLdap in project oxAuth by GluuFederation.

the class CleanerTimerTest method u2fRequest_whichIsExpiredAndDeletable_MustBeRemoved.

@Test
public void u2fRequest_whichIsExpiredAndDeletable_MustBeRemoved() throws StringEncrypter.EncryptionException {
    final Client client = createClient();
    clientService.persist(client);
    // 1. create token
    String userInum = "";
    String appId = "https://testapp.com";
    final RequestMessageLdap request = u2fRegistrationService.storeRegisterRequestMessage(u2fRegistrationService.builRegisterRequestMessage(appId, userInum), userInum, userInum);
    // 2. request exists
    assertNotNull(u2fRegistrationService.getRegisterRequestMessage(request.getId()));
    // 3. clean up
    cleanerTimer.processImpl();
    cacheService.clear();
    // 4. request exists
    assertNotNull(u2fRegistrationService.getRegisterRequestMessage(request.getId()));
    final Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.MINUTE, -10);
    request.setExpirationDate(calendar.getTime());
    u2fRegistrationService.merge(request);
    // 5. clean up
    cleanerTimer.processImpl();
    cacheService.clear();
    // 6. no request in persistence
    try {
        u2fRegistrationService.getRegisterRequestMessage(request.getId());
        throw new AssertionError("No exception, expected EntryPersistenceException on find request.");
    } catch (EntryPersistenceException e) {
    // ignore
    }
}
Also used : EntryPersistenceException(org.gluu.persist.exception.EntryPersistenceException) Client(org.gluu.oxauth.model.registration.Client) RequestMessageLdap(org.gluu.oxauth.model.fido.u2f.RequestMessageLdap) Test(org.testng.annotations.Test) BaseComponentTest(org.gluu.oxauth.BaseComponentTest)

Example 2 with RequestMessageLdap

use of org.gluu.oxauth.model.fido.u2f.RequestMessageLdap 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)

Aggregations

RequestMessageLdap (org.gluu.oxauth.model.fido.u2f.RequestMessageLdap)2 BaseComponentTest (org.gluu.oxauth.BaseComponentTest)1 Client (org.gluu.oxauth.model.registration.Client)1 EntryPersistenceException (org.gluu.persist.exception.EntryPersistenceException)1 Filter (org.gluu.search.filter.Filter)1 Test (org.testng.annotations.Test)1