Class PasswordlessCookieManager
java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.idp.plugin.authn.duo.PasswordlessCookieManager
- All Implemented Interfaces:
Component,DestructableComponent,InitializableComponent
Wrapper for managing the passwordless guard cookie, allowing read/write with less explicit code,
error handling, etc.
The component can be wired up without the necessary components, but then all operations do nothing. This is allowed for the case where deployers disable the shared key feature of the IdP, though very rare.
- Since:
- 2.1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanFlags whether the component is active or should no-op.private CookieManagerOptional cookie manager to use.private StringPasswordless cookie name.private DataSealerOptional data sealer to use.private final org.slf4j.LoggerClass logger.static final StringA negative signal to allow caching opt-out. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidUnset the cookie.protected voidbooleanisOptOut()Tests whether the cookie's value indicates a cached negative response.Read back existing cookie and return the username embedded in it, if any.booleanFor a non-negative cookie, this recreates the cookie using the current default key to ensure it can continue to be read.voidsetCookieManager(CookieManager manager) SetsCookieManagerto use.voidsetCookieName(String name) Set cookie name to use for "authorizing" passwordless use.voidsetDataSealer(DataSealer sealer) SetsDataSealerto use.booleanwriteCookie(String username) Creates a fresh cookie for a given username (or a placeholder if null to indicate the negative).Methods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent
checkComponentActive, checkSetterPreconditions, destroy, doDestroy, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException, initialize, isDestroyed, isInitialized
-
Field Details
-
NEGATIVE_VALUE
A negative signal to allow caching opt-out.- See Also:
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
cookieName
Passwordless cookie name. -
cookieManager
Optional cookie manager to use. -
dataSealer
Optional data sealer to use. -
active
private boolean activeFlags whether the component is active or should no-op.
-
-
Constructor Details
-
PasswordlessCookieManager
public PasswordlessCookieManager()
-
-
Method Details
-
setCookieName
Set cookie name to use for "authorizing" passwordless use.- Parameters:
name- cookie name
-
doInitialize
- Overrides:
doInitializein classAbstractInitializableComponent- Throws:
ComponentInitializationException
-
isOptOut
public boolean isOptOut()Tests whether the cookie's value indicates a cached negative response.- Returns:
- true iff the input value corresponds to the "opt-out" constant
-
readCookie
Read back existing cookie and return the username embedded in it, if any.A null is returned in the event of various decoding errors or if the cookie contains the "negative" magic value.
- Returns:
- username from sealed cookie, or null
-
writeCookie
Creates a fresh cookie for a given username (or a placeholder if null to indicate the negative).- Parameters:
username- username or null- Returns:
- true iff the operation succeeded
-
refreshCookie
public boolean refreshCookie()For a non-negative cookie, this recreates the cookie using the current default key to ensure it can continue to be read.- Returns:
- true iff the operation succeeded
-
clearCookie
public void clearCookie()Unset the cookie.
-