Package org.apache.zookeeper.server.auth
Class IPAuthenticationProvider
- java.lang.Object
-
- org.apache.zookeeper.server.auth.IPAuthenticationProvider
-
- All Implemented Interfaces:
AuthenticationProvider
public class IPAuthenticationProvider extends Object implements AuthenticationProvider
-
-
Field Summary
Fields Modifier and Type Field Description static String
USE_X_FORWARDED_FOR_KEY
static String
X_FORWARDED_FOR_HEADER_NAME
-
Constructor Summary
Constructors Constructor Description IPAuthenticationProvider()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static String
getClientIPAddress(javax.servlet.http.HttpServletRequest request)
Returns the HTTP(s) client IP addressString
getScheme()
The String used to represent this provider.List<Id>
handleAuthentication(javax.servlet.http.HttpServletRequest request, byte[] authData)
This method is called when admin server command passes authentication data for this scheme.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.boolean
isValid(String id)
Validates the syntax of an id.boolean
matches(String id, 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
-
Methods inherited from interface org.apache.zookeeper.server.auth.AuthenticationProvider
getUserName
-
-
-
-
Field Detail
-
X_FORWARDED_FOR_HEADER_NAME
public static final String X_FORWARDED_FOR_HEADER_NAME
- See Also:
- Constant Field Values
-
USE_X_FORWARDED_FOR_KEY
public static final String USE_X_FORWARDED_FOR_KEY
- See Also:
- Constant Field Values
-
-
Method Detail
-
getScheme
public 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 interfaceAuthenticationProvider
- Returns:
- the scheme of this provider.
-
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 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
-
matches
public boolean matches(String id, 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 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.
-
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
public boolean isValid(String id)
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.
-
getClientIPAddress
public static String getClientIPAddress(javax.servlet.http.HttpServletRequest request)
Returns the HTTP(s) client IP address- Parameters:
request
- HttpServletRequest- Returns:
- IP address
-
-