Class DigestAuthenticationProvider

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String DIGEST_ALGORITHM_KEY  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] digest​(java.lang.String idPassword)  
      static java.lang.String generateDigest​(java.lang.String idPassword)  
      java.lang.String getScheme()
      The String used to represent this provider.
      java.lang.String getUserName​(java.lang.String id)
      id represents the authentication info which is set in server connection.
      KeeperException.Code handleAuthentication​(ServerCnxn cnxn, byte[] authData)
      This method is called when a client passes authentication data for this scheme.
      boolean isAuthenticated()
      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 isEnabled()  
      boolean isValid​(java.lang.String id)
      Validates the syntax of an id.
      static void main​(java.lang.String[] args)
      Call with a single argument of user:pass to generate authdata.
      boolean matches​(java.lang.String id, java.lang.String aclExpr)
      This method is called to see if the given id matches the given id expression in the ACL.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DIGEST_ALGORITHM_KEY

        public static final java.lang.String DIGEST_ALGORITHM_KEY
        See Also:
        Constant Field Values
    • Constructor Detail

      • DigestAuthenticationProvider

        public DigestAuthenticationProvider()
    • Method Detail

      • isEnabled

        public static boolean isEnabled()
      • getScheme

        public java.lang.String 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 interface AuthenticationProvider
        Returns:
        the scheme of this provider.
      • generateDigest

        public static java.lang.String generateDigest​(java.lang.String idPassword)
                                               throws java.security.NoSuchAlgorithmException
        Throws:
        java.security.NoSuchAlgorithmException
      • digest

        public static byte[] digest​(java.lang.String idPassword)
                             throws java.security.NoSuchAlgorithmException
        Throws:
        java.security.NoSuchAlgorithmException
      • handleAuthentication

        public KeeperException.Code handleAuthentication​(ServerCnxn cnxn,
                                                         byte[] authData)
        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 interface AuthenticationProvider
        Parameters:
        cnxn - the cnxn that received the authentication information.
        authData - the authentication data received.
        Returns:
        TODO
      • 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 interface AuthenticationProvider
        Returns:
        true if this provider identifies creators.
      • isValid

        public boolean isValid​(java.lang.String id)
        Description copied from interface: AuthenticationProvider
        Validates the syntax of an id.
        Specified by:
        isValid in interface AuthenticationProvider
        Parameters:
        id - the id to validate.
        Returns:
        true if id is well formed.
      • matches

        public boolean matches​(java.lang.String id,
                               java.lang.String aclExpr)
        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 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.
      • getUserName

        public java.lang.String getUserName​(java.lang.String id)
        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 interface AuthenticationProvider
        Parameters:
        id - authentication info set by client.
        Returns:
        String user name
      • main

        public static void main​(java.lang.String[] args)
                         throws java.security.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:
        java.security.NoSuchAlgorithmException