Class DefaultDuoOIDCIntegration
- java.lang.Object
-
- net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
-
- net.shibboleth.idp.plugin.authn.duo.DefaultDuoOIDCIntegration
-
- All Implemented Interfaces:
PrincipalSupportingComponent,DuoOIDCIntegration,DynamicDuoOIDCIntegration,Component,DestructableComponent,InitializableComponent
@ThreadSafe public final class DefaultDuoOIDCIntegration extends AbstractInitializableComponent implements DynamicDuoOIDCIntegration
Data wrapper for use with Duo OIDC integrations. Holds shared-state.Despite most fields being 'effectively immutable' once published by Spring, the redirectURI is allowed to change, but in a guarded, shared-thread-safe manor.
-
-
Field Summary
Fields Modifier and Type Field Description private Set<String>allowedOriginsA set of 'allowed' origins that can be used as the scheme, host, and port portion of the redirectURI.private StringapiHostAPI host.private StringauthorizeEndpointThe URL path to the authorization endpoint.private StringclientIdIntegration key.private StringhealthEndpointThe URL path to the health endpoint.private org.slf4j.LoggerlogClass logger.private StringredirectURIThe used (by clients) redirect_uri to send the client after authorisation .private StringregisteredRedirectURIA statically set (pre-registered) redirectURI to send the client to after authorisation.private StringsecretKeySecret key.private SubjectsupportedPrincipalsContainer for supported principals.private StringtokenEndpointThe URL path to the token endpoint.
-
Constructor Summary
Constructors Constructor Description DefaultDuoOIDCIntegration()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddoInitialize()booleanequals(Object obj)Set<String>getAllowedOrigins()Get a list of URL origins that are allowed to appear in computed redirect URIs.StringgetAPIHost()Get the name of the API host to contact.StringgetAuthorizeEndpoint()Get the path of the authorization endpoint.StringgetClientId()Get the clientId key.StringgetHealthCheckEndpoint()Get the path of the health check endpoint.StringgetRedirectURI()Get the runtime redirectURI to direct the client to after authorisation.StringgetRegisteredRedirectURI()Get the static pre-registered redirect_uri.StringgetSecretKey()Get the secret key.<T extends Principal>
Set<T>getSupportedPrincipals(Class<T> c)StringgetTokenEndpoint()Get the path of the token endpoint.inthashCode()booleanisRedirectURIPreregistered()Has a redirectURI been pre-registered i.e.voidsetAllowedOrigins(Collection<String> hosts)Set the origins that are allowed to form the scheme, host, and port part of a computed redirect_uri.voidsetAPIHost(String host)Set the API host to use.voidsetAuthorizeEndpoint(String endpoint)Set the authorize endpoint URL path.voidsetClientId(String id)Set the client ID to use.voidsetHealthCheckEndpoint(String endpoint)Set the health check endpoint URL path.voidsetRedirectURIIfAbsent(String computedRedirectURI)Set the redirectURI from the one given in a thread-safe way.voidsetRegisteredRedirectURI(String uri)Set the redirect_uri to use.voidsetSecretKey(String key)Set the secret key to use.<T extends Principal>
voidsetSupportedPrincipals(Collection<T> principals)Set supported non-user-specific principals that the action will include in the subjects it generates, in place of any default principals from the flow.voidsetTokenEndpoint(String endpoint)Set the token endpoint URL path.StringtoString()-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
destroy, doDestroy, initialize, isDestroyed, isInitialized
-
-
-
-
Field Detail
-
log
@Nonnull private final org.slf4j.Logger log
Class logger.
-
apiHost
@NonnullAfterInit @NotEmpty private String apiHost
API host.
-
clientId
@NonnullAfterInit @NotEmpty private String clientId
Integration key.
-
secretKey
@NonnullAfterInit @NotEmpty private String secretKey
Secret key.
-
redirectURI
@Nullable private String redirectURI
The used (by clients) redirect_uri to send the client after authorisation .
-
registeredRedirectURI
@Nullable private String registeredRedirectURI
A statically set (pre-registered) redirectURI to send the client to after authorisation.
-
allowedOrigins
@Nonnull @NonnullElements @Unmodifiable private Set<String> allowedOrigins
A set of 'allowed' origins that can be used as the scheme, host, and port portion of the redirectURI.
-
healthEndpoint
@NonnullAfterInit @NotEmpty private String healthEndpoint
The URL path to the health endpoint.
-
authorizeEndpoint
@NonnullAfterInit @NotEmpty private String authorizeEndpoint
The URL path to the authorization endpoint.
-
tokenEndpoint
@NonnullAfterInit @NotEmpty private String tokenEndpoint
The URL path to the token endpoint.
-
supportedPrincipals
@Nonnull private final Subject supportedPrincipals
Container for supported principals.
-
-
Method Detail
-
setAllowedOrigins
public void setAllowedOrigins(@Nullable @NonnullElements Collection<String> hosts)
Set the origins that are allowed to form the scheme, host, and port part of a computed redirect_uri.- Parameters:
hosts- the hostnames to allow.
-
getAllowedOrigins
@Nonnull @NotLive @Unmodifiable public Set<String> getAllowedOrigins()
Description copied from interface:DynamicDuoOIDCIntegrationGet a list of URL origins that are allowed to appear in computed redirect URIs.- Specified by:
getAllowedOriginsin interfaceDynamicDuoOIDCIntegration- Returns:
- a set of unmodifiable allowed origins. Never null but could be empty.
-
getAPIHost
@NonnullAfterInit @NotEmpty public String getAPIHost()
Description copied from interface:DuoOIDCIntegrationGet the name of the API host to contact.- Specified by:
getAPIHostin interfaceDuoOIDCIntegration- Returns:
- name of API host
-
setAPIHost
public void setAPIHost(@Nonnull @NotEmpty String host)
Set the API host to use.- Parameters:
host- API host
-
getHealthCheckEndpoint
@NonnullAfterInit @NotEmpty public String getHealthCheckEndpoint()
Description copied from interface:DuoOIDCIntegrationGet the path of the health check endpoint.- Specified by:
getHealthCheckEndpointin interfaceDuoOIDCIntegration- Returns:
- the path of the health check endpoint
-
setHealthCheckEndpoint
public void setHealthCheckEndpoint(@Nonnull @NotEmpty String endpoint)
Set the health check endpoint URL path.- Parameters:
endpoint- the endpoint.
-
getAuthorizeEndpoint
@NonnullAfterInit @NotEmpty public String getAuthorizeEndpoint()
Description copied from interface:DuoOIDCIntegrationGet the path of the authorization endpoint.- Specified by:
getAuthorizeEndpointin interfaceDuoOIDCIntegration- Returns:
- the path of the authorization endpoint
-
setAuthorizeEndpoint
public void setAuthorizeEndpoint(@Nonnull @NotEmpty String endpoint)
Set the authorize endpoint URL path.- Parameters:
endpoint- the endpoint.
-
getTokenEndpoint
@NonnullAfterInit @NotEmpty public String getTokenEndpoint()
Description copied from interface:DuoOIDCIntegrationGet the path of the token endpoint.- Specified by:
getTokenEndpointin interfaceDuoOIDCIntegration- Returns:
- the path of the token endpoint;
-
setTokenEndpoint
public void setTokenEndpoint(@Nonnull @NotEmpty String endpoint)
Set the token endpoint URL path.- Parameters:
endpoint- the endpoint.
-
getRedirectURI
@Nullable public String getRedirectURI()
Description copied from interface:DuoOIDCIntegrationGet the runtime redirectURI to direct the client to after authorisation.- Specified by:
getRedirectURIin interfaceDuoOIDCIntegration- Returns:
- the redirectURI
-
setRegisteredRedirectURI
public void setRegisteredRedirectURI(@Nullable String uri)Set the redirect_uri to use.- Parameters:
uri- the redirect_uri
-
getRegisteredRedirectURI
@Nullable public String getRegisteredRedirectURI()
Description copied from interface:DynamicDuoOIDCIntegrationGet the static pre-registered redirect_uri.- Specified by:
getRegisteredRedirectURIin interfaceDynamicDuoOIDCIntegration- Returns:
- the pre-registered redirect_uri.
-
isRedirectURIPreregistered
public boolean isRedirectURIPreregistered()
Description copied from interface:DynamicDuoOIDCIntegrationHas a redirectURI been pre-registered i.e. set in the properties file.- Specified by:
isRedirectURIPreregisteredin interfaceDynamicDuoOIDCIntegration- Returns:
- true iff
DynamicDuoOIDCIntegration.getRegisteredRedirectURI()is not null, false otherwise.
-
setRedirectURIIfAbsent
@Nonnull @NotEmpty public void setRedirectURIIfAbsent(@Nonnull @NotEmpty String computedRedirectURI)
Description copied from interface:DynamicDuoOIDCIntegrationSet the redirectURI from the one given in a thread-safe way.
Once set,
DuoOIDCIntegration.getRedirectURI()should return the value of computedRedirectURI.This is a sate changing operation, and should be thread-safe in its operation, as the integration will be shared amongst threads e.g. synchronize the method call.
- Specified by:
setRedirectURIIfAbsentin interfaceDynamicDuoOIDCIntegration- Parameters:
computedRedirectURI- the runtime computed redirectURI.
-
setClientId
public void setClientId(@Nonnull @NotEmpty String id)
Set the client ID to use.- Parameters:
id- the client identifier.
-
getClientId
@NonnullAfterInit @NotEmpty public String getClientId()
Description copied from interface:DuoOIDCIntegrationGet the clientId key.- Specified by:
getClientIdin interfaceDuoOIDCIntegration- Returns:
- the integration key
-
setSecretKey
public void setSecretKey(@Nonnull @NotEmpty String key)
Set the secret key to use.- Parameters:
key- secret key
-
getSecretKey
@NonnullAfterInit @NotEmpty public String getSecretKey()
Description copied from interface:DuoOIDCIntegrationGet the secret key.- Specified by:
getSecretKeyin interfaceDuoOIDCIntegration- Returns:
- the secret key
-
getSupportedPrincipals
@Nonnull @NonnullElements @Unmodifiable public <T extends Principal> Set<T> getSupportedPrincipals(@Nonnull Class<T> c)
- Specified by:
getSupportedPrincipalsin interfacePrincipalSupportingComponent
-
setSupportedPrincipals
public <T extends Principal> void setSupportedPrincipals(@Nullable @NonnullElements Collection<T> principals)
Set supported non-user-specific principals that the action will include in the subjects it generates, in place of any default principals from the flow.Setting to a null or empty collection will maintain the default behavior of relying on the flow.
- Type Parameters:
T- a type of principal to add, if not generic- Parameters:
principals- supported principals to include
-
doInitialize
protected void doInitialize() throws ComponentInitializationException- Overrides:
doInitializein classAbstractInitializableComponent- Throws:
ComponentInitializationException
-
-