Search in sources :

Example 1 with RequestMessageLdap

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

the class RegistrationService method storeRegisterRequestMessage.

public void storeRegisterRequestMessage(RegisterRequestMessage requestMessage, String userInum, String sessionState) {
    Date now = new GregorianCalendar(TimeZone.getTimeZone("UTC")).getTime();
    final String registerRequestMessageId = UUID.randomUUID().toString();
    RequestMessageLdap registerRequestMessageLdap = new RegisterRequestMessageLdap(getDnForRegisterRequestMessage(registerRequestMessageId), registerRequestMessageId, now, sessionState, userInum, requestMessage);
    ldapEntryManager.persist(registerRequestMessageLdap);
}
Also used : GregorianCalendar(java.util.GregorianCalendar) RegisterRequestMessageLdap(org.xdi.oxauth.model.fido.u2f.RegisterRequestMessageLdap) Date(java.util.Date) RegisterRequestMessageLdap(org.xdi.oxauth.model.fido.u2f.RegisterRequestMessageLdap) RequestMessageLdap(org.xdi.oxauth.model.fido.u2f.RequestMessageLdap)

Example 2 with RequestMessageLdap

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

the class RequestService method getExpiredRequestMessages.

public List<RequestMessageLdap> getExpiredRequestMessages(BatchOperation<RequestMessageLdap> batchOperation, Date expirationDate) {
    // ou=u2f,o=@!1111,o=gluu
    final String u2fBaseDn = staticConfiguration.getBaseDn().getU2fBase();
    Filter expirationFilter = Filter.createLessOrEqualFilter("creationDate", ldapEntryManager.encodeGeneralizedTime(expirationDate));
    List<RequestMessageLdap> requestMessageLdap = ldapEntryManager.findEntries(u2fBaseDn, RequestMessageLdap.class, expirationFilter, SearchScope.SUB, null, batchOperation, 0, CleanerTimer.BATCH_SIZE, CleanerTimer.BATCH_SIZE);
    return requestMessageLdap;
}
Also used : Filter(com.unboundid.ldap.sdk.Filter) RequestMessageLdap(org.xdi.oxauth.model.fido.u2f.RequestMessageLdap)

Example 3 with RequestMessageLdap

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

the class CleanerTimer method processU2fRequests.

private void processU2fRequests() {
    log.debug("Start U2F request clean up");
    Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
    calendar.add(Calendar.SECOND, -90);
    final Date expirationDate = calendar.getTime();
    BatchOperation<RequestMessageLdap> requestMessageLdapBatchService = new BatchOperation<RequestMessageLdap>(ldapEntryManager) {

        @Override
        protected List<RequestMessageLdap> getChunkOrNull(int chunkSize) {
            return u2fRequestService.getExpiredRequestMessages(this, expirationDate);
        }

        @Override
        protected void performAction(List<RequestMessageLdap> entries) {
            for (RequestMessageLdap requestMessageLdap : entries) {
                try {
                    log.debug("Removing RequestMessageLdap: {}, Creation date: {}", requestMessageLdap.getRequestId(), requestMessageLdap.getCreationDate());
                    u2fRequestService.removeRequestMessage(requestMessageLdap);
                } catch (Exception e) {
                    log.error("Failed to remove entry", e);
                }
            }
        }
    };
    requestMessageLdapBatchService.iterateAllByChunks(BATCH_SIZE);
    log.debug("End U2F request clean up");
}
Also used : AuthorizationGrantList(org.xdi.oxauth.model.common.AuthorizationGrantList) BatchOperation(org.gluu.site.ldap.persistence.BatchOperation) RequestMessageLdap(org.xdi.oxauth.model.fido.u2f.RequestMessageLdap)

Aggregations

RequestMessageLdap (org.xdi.oxauth.model.fido.u2f.RequestMessageLdap)3 Filter (com.unboundid.ldap.sdk.Filter)1 Date (java.util.Date)1 GregorianCalendar (java.util.GregorianCalendar)1 BatchOperation (org.gluu.site.ldap.persistence.BatchOperation)1 AuthorizationGrantList (org.xdi.oxauth.model.common.AuthorizationGrantList)1 RegisterRequestMessageLdap (org.xdi.oxauth.model.fido.u2f.RegisterRequestMessageLdap)1