Class DefaultDuoOIDCClientRegistry
- java.lang.Object
-
- net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
-
- net.shibboleth.utilities.java.support.component.AbstractIdentifiedInitializableComponent
-
- net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent
-
- net.shibboleth.idp.plugin.authn.duo.impl.DefaultDuoOIDCClientRegistry
-
- All Implemented Interfaces:
DuoOIDCClientRegistry,Component,DestructableComponent,IdentifiableComponent,IdentifiedComponent,InitializableComponent
@ThreadSafe public class DefaultDuoOIDCClientRegistry extends AbstractIdentifiableInitializableComponent implements DuoOIDCClientRegistry
The default Duo Client registry for mapping a
DuoOIDCIntegrationto either a new or existingDuoOIDCClient(assumed thread-safe) singleton instance.Clients are created and registered one-to-one against a
DuoOIDCIntegration. Once created, the same client instance is reused for the same given Duo integration for the lifetime of the IdP.The
DuoOIDCIntegrationis the 'key' to the map holding the clients. It therefore should decide its own 'business key' using theObject.equals(Object)andObject.hashCode()method appropriately. For example, theDefaultDuoOIDCIntegrationuses the clientID as its key. The key should be immutable.Supports thread-safe lazy initialization of clients when they are first requested. A single, configurable, client factory is called to initialize new clients.
Initialization and fetching is thread safe thanks to the use of a
ConcurrentMapand itsConcurrentMap.computeIfAbsent(Object, Function)operation. This guarantees that two clients should never be created for the same integration. The client is safely published by the map.The registry itself is effectively immutable once published by spring.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classDefaultDuoOIDCClientRegistry.CreateNewClientMappingFunctionA function for creating a new Duo client from the configured client factory for the given Duo integration.
-
Field Summary
Fields Modifier and Type Field Description private DuoOIDCClientFactoryclientFactoryFactory to produce Duo clients.private ConcurrentMap<DuoOIDCIntegration,DuoOIDCClient>clientRegistryRegistry of Duo client to Duo integration.private Function<DuoOIDCIntegration,DuoOIDCClient>clientRegistryMappingFunctionFunction for creating a DuoClient from a DuoIntegration.private org.slf4j.LoggerlogClass logger.
-
Constructor Summary
Constructors Constructor Description DefaultDuoOIDCClientRegistry()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddoInitialize()private DuoOIDCClientFactorygetClientFactory()Internally synchronized method for obtaining the 'current' client factory.DuoOIDCClientgetClientOrCreate(DuoOIDCIntegration integration)voidsetClientFactory(DuoOIDCClientFactory factory)Set the client factory to use.-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent
setId
-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractIdentifiedInitializableComponent
getId
-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
destroy, doDestroy, initialize, isDestroyed, isInitialized
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.shibboleth.utilities.java.support.component.IdentifiedComponent
getId
-
-
-
-
Field Detail
-
log
@Nonnull private final org.slf4j.Logger log
Class logger.
-
clientFactory
@Nullable @NonnullAfterInit private DuoOIDCClientFactory clientFactory
Factory to produce Duo clients.
-
clientRegistry
@Nonnull @NonnullElements private final ConcurrentMap<DuoOIDCIntegration,DuoOIDCClient> clientRegistry
Registry of Duo client to Duo integration.
-
clientRegistryMappingFunction
@Nonnull private final Function<DuoOIDCIntegration,DuoOIDCClient> clientRegistryMappingFunction
Function for creating a DuoClient from a DuoIntegration.
-
-
Method Detail
-
setClientFactory
public void setClientFactory(@Nonnull DuoOIDCClientFactory factory)Set the client factory to use.- Parameters:
factory- the factory.
-
getClientFactory
@Nullable private DuoOIDCClientFactory getClientFactory()
Internally synchronized method for obtaining the 'current' client factory.- Returns:
- the client factory.
-
getClientOrCreate
@Nonnull public DuoOIDCClient getClientOrCreate(@Nonnull DuoOIDCIntegration integration) throws DuoRegistryException
- Specified by:
getClientOrCreatein interfaceDuoOIDCClientRegistry- Throws:
DuoRegistryException
-
doInitialize
protected void doInitialize() throws ComponentInitializationException- Overrides:
doInitializein classAbstractIdentifiedInitializableComponent- Throws:
ComponentInitializationException
-
-