Package org.apache.zookeeper.server.auth
Class DigestAuthenticationProvider
java.lang.Object
org.apache.zookeeper.server.auth.DigestAuthenticationProvider
- All Implemented Interfaces:
AuthenticationProvider
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
static String
generateDigest
(String idPassword) The String used to represent this provider.getUserName
(String id) id represents the authentication info which is set in server connection.handleAuthentication
(javax.servlet.http.HttpServletRequest request, byte[] authData) This method is called when admin server command passes authentication data for this scheme.handleAuthentication
(ServerCnxn cnxn, byte[] authData) This method is called when a client passes authentication data for this scheme.boolean
This method is used to check if the authentication done by this provider should be used to identify the creator of a node.static boolean
boolean
Validates the syntax of an id.static void
Call with a single argument of user:pass to generate authdata.boolean
This method is called to see if the given id matches the given id expression in the ACL.
-
Field Details
-
DIGEST_ALGORITHM_KEY
- See Also:
-
-
Constructor Details
-
DigestAuthenticationProvider
public DigestAuthenticationProvider()
-
-
Method Details
-
isEnabled
public static boolean isEnabled() -
getScheme
Description copied from interface:AuthenticationProvider
The String used to represent this provider. This will correspond to the scheme field of an Id.- Specified by:
getScheme
in interfaceAuthenticationProvider
- Returns:
- the scheme of this provider.
-
generateDigest
- Throws:
NoSuchAlgorithmException
-
digest
- Throws:
NoSuchAlgorithmException
-
handleAuthentication
Description copied from interface:AuthenticationProvider
This method is called when a client passes authentication data for this scheme. The authData is directly from the authentication packet. The implementor may attach new ids to the authInfo field of cnxn or may use cnxn to send packets back to the client.- Specified by:
handleAuthentication
in interfaceAuthenticationProvider
- Parameters:
cnxn
- the cnxn that received the authentication information.authData
- the authentication data received.- Returns:
- TODO
-
handleAuthentication
public List<Id> handleAuthentication(javax.servlet.http.HttpServletRequest request, byte[] authData) Description copied from interface:AuthenticationProvider
This method is called when admin server command passes authentication data for this scheme.- Specified by:
handleAuthentication
in interfaceAuthenticationProvider
- Parameters:
request
- the request that contains the authentication information.authData
- the authentication data received.- Returns:
- Ids the list of Id. Empty list means not authenticated
-
isAuthenticated
public boolean isAuthenticated()Description copied from interface:AuthenticationProvider
This method is used to check if the authentication done by this provider should be used to identify the creator of a node. Some ids such as hosts and ip addresses are rather transient and in general don't really identify a client even though sometimes they do.- Specified by:
isAuthenticated
in interfaceAuthenticationProvider
- Returns:
- true if this provider identifies creators.
-
isValid
Description copied from interface:AuthenticationProvider
Validates the syntax of an id.- Specified by:
isValid
in interfaceAuthenticationProvider
- Parameters:
id
- the id to validate.- Returns:
- true if id is well formed.
-
matches
Description copied from interface:AuthenticationProvider
This method is called to see if the given id matches the given id expression in the ACL. This allows schemes to use application specific wild cards.- Specified by:
matches
in interfaceAuthenticationProvider
- Parameters:
id
- the id to check.aclExpr
- the expression to match ids against.- Returns:
- true if the id can be matched by the expression.
-
getUserName
Description copied from interface:AuthenticationProvider
id represents the authentication info which is set in server connection. id may contain both user name as well as password. This method should be implemented to extract the user name.- Specified by:
getUserName
in interfaceAuthenticationProvider
- Parameters:
id
- authentication info set by client.- Returns:
- String user name
-
main
Call with a single argument of user:pass to generate authdata. Authdata output can be used when setting superDigest for example.- Parameters:
args
- single argument of user:pass- Throws:
NoSuchAlgorithmException
-