Class AuthenticationClientManager
- All Implemented Interfaces:
- AuthenticationClient,- PublicKeyAuthenticationClient,- TokenAuthenticationClient,- TokenFactoryFactory,- TokenVerificationClient,- AutoCloseable
- Direct Known Subclasses:
- AuthenticationClientManager.Null,- GrpcAuthenticationClientManager
Class for managing and authenticating to possibly multiple remote authentication servers.
In our gRPC re-implementation there is only a single remote (behind a gRPC channel that may be load balanced to multiple actual servers). The API (supporting multiple servers) was kept. See AuthenticationClientManagerBase} for details.
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic interfaceThis interface is used for underlying transport status changes for authentication clients.static classNull object for testing.Nested classes/interfaces inherited from class io.deephaven.enterprise.auth.AuthenticationClientManagerBaseAuthenticationClientManagerBase.SingleClientTokenFactory, AuthenticationClientManagerBase.TokenFactoryBaseNested classes/interfaces inherited from interface io.deephaven.enterprise.auth.TokenFactoryFactoryTokenFactoryFactory.TokenFactory
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final List<ClientAuthMethod>protected final com.fishlib.base.WeakReferenceManager<AuthenticationClientManager.ClientTransportStatusChangeListener>protected static final com.fishlib.io.logger.Logger
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionfinal voidAllows tracking of connection to server state; note that a gRPC transport will transparently try to reconnect; still, users of this class can register listeners via this method to get notified about channel state changes.abstract booleanchallengeResponse(String privateKeyFile) Authenticate with the user denoted in the specified private key fileprotected voidIf any plugins have been enabled, check whether they match the required signature.abstract voidclose()Disconnect from the originCreate a set of tokens for delegating authentication for each Auth server.createDelegateTokensForUser(String operateAs) Create a set of tokens for delegating authentication for each Auth server, as a specific user.abstract AuthTokencreateToken(String service) Create a new authentication token for the requested service.abstract AuthTokencreateTokenForUser(String service, String operateAs) Create a new authentication token for the requested service operating as the specified userabstract booleanPerform default authentication.abstract booleanIf no previous authentication attempt has been made, try default authentication.abstract StringexternalLogin(String key) Attempt to perform key-based external-authentication against all connected/nonauthenticated serversstatic AuthenticationClientManagergetTokenFactory(String service) Create a token factory for the provided servicegetTokenFactory(String service, String user) Create a token factory for the provided service and userprotected abstract TokenFactoryFactory.TokenFactorygetTokenFactoryInternal(String service, String user) abstract booleanReturn true if this client is authenticated.static AuthenticationClientManagerFactory method to create a new AuthenticationClientManager.abstract booleanpasswordAuthentication(String checkUser, String password, String operateAs) Authenticate to all connected/nonauthenticated servers with username/passwordprotected abstract booleanAttempt authentication with any plugins that have been set up on the system.abstract booleanpresentDelegateToken(AuthToken delegatedToken) Validate the delegated tokens created bycreateDelegateTokens()orcreateDelegateTokensForUser(String)presentDelegateTokenAsync(AuthToken delegatedToken) Validate the delegated tokens created bycreateDelegateTokens()orcreateDelegateTokensForUser(String)final voidremoveConnectionStatusHandler(AuthenticationClientManager.ClientTransportStatusChangeListener handler) Remove a lister to channel state changes.final booleanverifyToken(DhService service, AuthToken token) abstract booleanverifyToken(String service, AuthToken token) Verify the specified service token with the server.abstract voidwaitForSuccessfulServerRoundtrip(long timeoutMillis) Attempt to do a roundtrip to a (any) server, for up to the timeout milliseconds.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.deephaven.enterprise.auth.AuthenticationClientpasswordAuthenticationMethods inherited from interface io.deephaven.enterprise.auth.TokenAuthenticationClientcreateToken, createTokenForUserMethods inherited from interface io.deephaven.enterprise.auth.TokenFactoryFactorygetTokenFactory, getTokenFactory
- 
Field Details- 
connectionStatusHandlersprotected final com.fishlib.base.WeakReferenceManager<AuthenticationClientManager.ClientTransportStatusChangeListener> connectionStatusHandlers
- 
logprotected static final com.fishlib.io.logger.Logger log
- 
authMethods
- 
AlwaysFalseBooleanFuture
 
- 
- 
Constructor Details- 
AuthenticationClientManagerpublic AuthenticationClientManager()
 
- 
- 
Method Details- 
getDefault
- 
makeFactory method to create a new AuthenticationClientManager.- Parameters:
- name- a meaningful name to display for this client in logs, to help identify it. It should not contain a hostname component as that will be added to it.
- Returns:
- a new AuthenticationClientManager.
 
- 
checkForPluginsprotected void checkForPlugins()If any plugins have been enabled, check whether they match the required signature.
- 
addConnectionStatusHandlerpublic final void addConnectionStatusHandler(AuthenticationClientManager.ClientTransportStatusChangeListener handler) Allows tracking of connection to server state; note that a gRPC transport will transparently try to reconnect; still, users of this class can register listeners via this method to get notified about channel state changes.- Parameters:
- handler- the listener where to get notifications of state changes.
 
- 
removeConnectionStatusHandlerpublic final void removeConnectionStatusHandler(AuthenticationClientManager.ClientTransportStatusChangeListener handler) Remove a lister to channel state changes.- Parameters:
- handler- the listener to remove.
 
- 
createTokenCreate a new authentication token for the requested service. SeeTokenAuthenticationClient.createToken(String)for exception details Users are encouraged to usegetTokenFactory(String)andTokenFactoryFactory.TokenFactory.tryActionWithToken(Consumer)orTokenFactoryFactory.TokenFactory.tryGetWithToken(Function)instead as they provide a means to handle the loss of an origin.- Specified by:
- createTokenin interface- TokenAuthenticationClient
- Returns:
- a new AuthTokenfor service
 
- 
createTokenForUserCreate a new authentication token for the requested service operating as the specified user SeeTokenAuthenticationClient.createTokenForUser(String, String)for exception details Users are encouraged to usegetTokenFactory(String, String)andTokenFactoryFactory.TokenFactory.tryActionWithToken(Consumer)orTokenFactoryFactory.TokenFactory.tryGetWithToken(Function)instead as they provide a means to handle the loss of an origin.- Specified by:
- createTokenForUserin interface- TokenAuthenticationClient
- Returns:
- a new AuthTokenfor service operating as operateAs
 
- 
createDelegateTokensCreate a set of tokens for delegating authentication for each Auth server. SeeTokenAuthenticationClient.createToken(String)for exception details- Returns:
- a list of AuthTokens delegating authentication for each available server
 
- 
createDelegateTokensForUserCreate a set of tokens for delegating authentication for each Auth server, as a specific user. SeeTokenAuthenticationClient.createTokenForUser(String, String)for exception details- Returns:
- a list of AuthTokens delegating authentication for each available server
 
- 
verifyTokenVerify the specified service token with the server. SeeTokenVerificationClient.verifyToken(String, AuthToken)for additional exception details- Specified by:
- verifyTokenin interface- TokenVerificationClient
- Returns:
- true if the token was validated, false otherwise
 
- 
verifyToken
- 
defaultAuthenticationpublic abstract boolean defaultAuthentication()Perform default authentication. Default authentication implies authenticating with the private key file, or with plugins if there is no private key file. SeechallengeResponse(String)for exception details- Returns:
- false if already authenticated or if an authentication attempt was done and failed, true otherwise.
 
- 
ensureAuthenticationpublic abstract boolean ensureAuthentication()If no previous authentication attempt has been made, try default authentication. Default authentication implies attempt to authenticate with the private key file, or with plugins if there is no private key file. If a previous authentication attempt succeeded in the past, and that authentication method can be retried, and the client is current unauthenticated, then attempt again the same method that succeeded before. SeechallengeResponse(String)for exception details- Returns:
- true if authenticated by the time this call returns (either because we were already authenticated, or because we were not authenticated and an authentication attempt was done and was successful), false otherwise. When false is returned it implies not authenticated.
 
- 
passwordAuthenticationAuthenticate to all connected/nonauthenticated servers with username/password SeeAuthenticationClient.passwordAuthentication(String, String, String)for exception details- Specified by:
- passwordAuthenticationin interface- AuthenticationClient
- Parameters:
- checkUser- The user to authenticate
- password- The password
- operateAs- The effective user to operate as
- Returns:
- true on success, false on failure
 
- 
externalLoginAttempt to perform key-based external-authentication against all connected/nonauthenticated servers SeeAuthenticationClient.externalLogin(String)for details- Specified by:
- externalLoginin interface- AuthenticationClient
- Parameters:
- key- a nonce which an appropriate auth-module may be able to confirm as authenticated
- Returns:
- the authenticated user-name if this key is approved by an auth-module, else null
 
- 
presentDelegateTokenValidate the delegated tokens created by SeecreateDelegateTokens()orcreateDelegateTokensForUser(String)AuthenticationClient.presentDelegateToken(AuthToken)for additional exception detail- Specified by:
- presentDelegateTokenin interface- AuthenticationClient
- Parameters:
- delegatedToken- The delegate token created by AuthenticationClientManager.createDelegateTokens()
- Returns:
- true if the token was validated, false otherwise
 
- 
presentDelegateTokenAsyncValidate the delegated tokens created by SeecreateDelegateTokens()orcreateDelegateTokensForUser(String)AuthenticationClient.presentDelegateToken(AuthToken)for additional exception detail- Returns:
- a Future<Boolean>that will be true if the token was validated, false otherwise
 
- 
challengeResponseAuthenticate with the user denoted in the specified private key file- Specified by:
- challengeResponsein interface- PublicKeyAuthenticationClient
- Parameters:
- privateKeyFile- the file containing the elements required for authentication; user, operateas, public and private keys.
- Returns:
- False if already authenticated. If not already authenticated at the time of the call, the status of the authentication-attempt; true if successfully authenticated, else false
- Throws:
- UncheckedIOException- if the server was unreachable
- PubPrivKeyException- if there was a problem with public/private key operations
- AuthException- if any other problem occurred
 
- 
getTokenFactoryCreate a token factory for the provided service- Specified by:
- getTokenFactoryin interface- TokenFactoryFactory
- Parameters:
- service- the service
- Returns:
- the created TokenFactory
 
- 
getTokenFactoryCreate a token factory for the provided service and user- Specified by:
- getTokenFactoryin interface- TokenFactoryFactory
- Parameters:
- service- the service
- user- the user
- Returns:
- the created TokenFactory
 
- 
getTokenFactoryInternalprotected abstract TokenFactoryFactory.TokenFactory getTokenFactoryInternal(String service, String user) 
- 
isAuthenticatedpublic abstract boolean isAuthenticated()Return true if this client is authenticated. This method may wait to return if there is a concurrent authentication attempt in flight. Unlike most other methods in this class,isAuthenticatedwill never throw anAuthException.- Returns:
- true if authenticated, false otherwise.
 
- 
waitForSuccessfulServerRoundtrippublic abstract void waitForSuccessfulServerRoundtrip(long timeoutMillis) Attempt to do a roundtrip to a (any) server, for up to the timeout milliseconds. An AuthException is thrown if the roundtrip doesn't succeed before the deadline. When this method returns normally, a client can be certain that there was an authentication server ready to service requests at some point during the call.- Throws:
- AuthException- if it was not possible to get a server (any server) response.
 
- 
closepublic abstract void close()Description copied from interface:AuthenticationClientDisconnect from the origin- Specified by:
- closein interface- AuthenticationClient
- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- TokenFactoryFactory
 
- 
pluginAuthenticationprotected abstract boolean pluginAuthentication()Attempt authentication with any plugins that have been set up on the system.- Returns:
- True if at least one plugin was able to authenticate with at least one client; false otherwise.
 
 
-