Package org.apache.zookeeper.server.auth
Class DigestAuthenticationProvider
- java.lang.Object
- 
- org.apache.zookeeper.server.auth.DigestAuthenticationProvider
 
- 
- All Implemented Interfaces:
- AuthenticationProvider
 
 public class DigestAuthenticationProvider extends Object implements AuthenticationProvider 
- 
- 
Field SummaryFields Modifier and Type Field Description static StringDIGEST_ALGORITHM_KEY
 - 
Constructor SummaryConstructors Constructor Description DigestAuthenticationProvider()
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static byte[]digest(String idPassword)static StringgenerateDigest(String idPassword)StringgetScheme()The String used to represent this provider.StringgetUserName(String id)id represents the authentication info which is set in server connection.KeeperException.CodehandleAuthentication(ServerCnxn cnxn, byte[] authData)This method is called when a client passes authentication data for this scheme.booleanisAuthenticated()This method is used to check if the authentication done by this provider should be used to identify the creator of a node.static booleanisEnabled()booleanisValid(String id)Validates the syntax of an id.static voidmain(String[] args)Call with a single argument of user:pass to generate authdata.booleanmatches(String id, String aclExpr)This method is called to see if the given id matches the given id expression in the ACL.
 
- 
- 
- 
Field Detail- 
DIGEST_ALGORITHM_KEYpublic static final String DIGEST_ALGORITHM_KEY - See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
isEnabledpublic static boolean isEnabled() 
 - 
getSchemepublic String getScheme() Description copied from interface:AuthenticationProviderThe String used to represent this provider. This will correspond to the scheme field of an Id.- Specified by:
- getSchemein interface- AuthenticationProvider
- Returns:
- the scheme of this provider.
 
 - 
generateDigestpublic static String generateDigest(String idPassword) throws NoSuchAlgorithmException - Throws:
- NoSuchAlgorithmException
 
 - 
digestpublic static byte[] digest(String idPassword) throws NoSuchAlgorithmException - Throws:
- NoSuchAlgorithmException
 
 - 
handleAuthenticationpublic KeeperException.Code handleAuthentication(ServerCnxn cnxn, byte[] authData) Description copied from interface:AuthenticationProviderThis 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:
- handleAuthenticationin interface- AuthenticationProvider
- Parameters:
- cnxn- the cnxn that received the authentication information.
- authData- the authentication data received.
- Returns:
- TODO
 
 - 
isAuthenticatedpublic boolean isAuthenticated() Description copied from interface:AuthenticationProviderThis 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:
- isAuthenticatedin interface- AuthenticationProvider
- Returns:
- true if this provider identifies creators.
 
 - 
isValidpublic boolean isValid(String id) Description copied from interface:AuthenticationProviderValidates the syntax of an id.- Specified by:
- isValidin interface- AuthenticationProvider
- Parameters:
- id- the id to validate.
- Returns:
- true if id is well formed.
 
 - 
matchespublic boolean matches(String id, String aclExpr) Description copied from interface:AuthenticationProviderThis 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:
- matchesin interface- AuthenticationProvider
- Parameters:
- id- the id to check.
- aclExpr- the expression to match ids against.
- Returns:
- true if the id can be matched by the expression.
 
 - 
getUserNamepublic String getUserName(String id) Description copied from interface:AuthenticationProviderid 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:
- getUserNamein interface- AuthenticationProvider
- Parameters:
- id- authentication info set by client.
- Returns:
- String user name
 
 - 
mainpublic static void main(String[] args) throws NoSuchAlgorithmException 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
 
 
- 
 
-