Search in sources :

Example 1 with DeviceRegistration

use of io.jans.as.server.model.fido.u2f.DeviceRegistration in project jans by JanssenProject.

the class UserService method countFidoRegisteredDevices.

public long countFidoRegisteredDevices(String username, String domain) {
    String userInum = getUserInum(username);
    if (userInum == null) {
        return 0;
    }
    String baseDn = getBaseDnForFidoDevices(userInum);
    if (persistenceEntryManager.hasBranchesSupport(baseDn)) {
        if (!persistenceEntryManager.contains(baseDn, SimpleBranch.class)) {
            return 0;
        }
    }
    Filter resultFilter = Filter.createEqualityFilter("jansStatus", DeviceRegistrationStatus.ACTIVE.getValue());
    List<DeviceRegistration> fidoRegistrations = persistenceEntryManager.findEntries(baseDn, DeviceRegistration.class, resultFilter);
    if (StringUtils.isEmpty(domain)) {
        return fidoRegistrations.size();
    }
    return fidoRegistrations.parallelStream().filter(f -> StringHelper.equals(domain, networkService.getHost(f.getApplication()))).count();
}
Also used : SimpleBranch(io.jans.orm.model.base.SimpleBranch) LdapEntryManagerFactory(io.jans.orm.ldap.impl.LdapEntryManagerFactory) StringUtils(org.apache.commons.lang.StringUtils) Filter(io.jans.orm.search.filter.Filter) Fido2RegistrationEntry(io.jans.fido2.model.entry.Fido2RegistrationEntry) AppConfiguration(io.jans.as.model.configuration.AppConfiguration) DeviceRegistrationStatus(io.jans.as.model.fido.u2f.DeviceRegistrationStatus) Inject(javax.inject.Inject) List(java.util.List) AttributeConstants(io.jans.as.common.util.AttributeConstants) StaticConfiguration(io.jans.as.model.config.StaticConfiguration) DeviceRegistration(io.jans.as.server.model.fido.u2f.DeviceRegistration) ApplicationScoped(javax.enterprise.context.ApplicationScoped) CustomEntry(io.jans.orm.model.base.CustomEntry) StringHelper(io.jans.util.StringHelper) NetworkService(io.jans.service.net.NetworkService) SimpleBranch(io.jans.orm.model.base.SimpleBranch) Filter(io.jans.orm.search.filter.Filter) DeviceRegistration(io.jans.as.server.model.fido.u2f.DeviceRegistration)

Aggregations

AttributeConstants (io.jans.as.common.util.AttributeConstants)1 StaticConfiguration (io.jans.as.model.config.StaticConfiguration)1 AppConfiguration (io.jans.as.model.configuration.AppConfiguration)1 DeviceRegistrationStatus (io.jans.as.model.fido.u2f.DeviceRegistrationStatus)1 DeviceRegistration (io.jans.as.server.model.fido.u2f.DeviceRegistration)1 Fido2RegistrationEntry (io.jans.fido2.model.entry.Fido2RegistrationEntry)1 LdapEntryManagerFactory (io.jans.orm.ldap.impl.LdapEntryManagerFactory)1 CustomEntry (io.jans.orm.model.base.CustomEntry)1 SimpleBranch (io.jans.orm.model.base.SimpleBranch)1 Filter (io.jans.orm.search.filter.Filter)1 NetworkService (io.jans.service.net.NetworkService)1 StringHelper (io.jans.util.StringHelper)1 List (java.util.List)1 ApplicationScoped (javax.enterprise.context.ApplicationScoped)1 Inject (javax.inject.Inject)1 StringUtils (org.apache.commons.lang.StringUtils)1