java.lang.Object
net.i2p.i2pcontrol.servlets.jsonrpc2handlers.JSONRPC2Helper
Helper utility class for I2PControl JSON-RPC2 handlers. Provides common functionality for parameter validation and authentication token verification.
Field Summary
Modifier and TypeFieldDescriptionprivate final SecurityManagerThe manager consulted to validate the token a request carries.static final BooleanToken value marking a handler call as needing authentication.static final BooleanToken value marking a handler call as needing no authentication.Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionvalidateParams(String[] requiredArgs, JSONRPC2Request req) Check incoming request for required arguments, to make sure they are valid.validateParams(String[] requiredArgs, JSONRPC2Request req, Boolean useAuth) Check incoming request for required arguments, to make sure they are valid.private JSONRPC2ErrorvalidateToken(Map<String, Object> params) Will check incoming parameters to make sure they contain a valid token.
Field Details
USE_NO_AUTH
Token value marking a handler call as needing no authentication.USE_AUTH
Token value marking a handler call as needing authentication._secMan
The manager consulted to validate the token a request carries.
Constructor Details
JSONRPC2Helper
JSONRPC2Helper.- Parameters:
secMan- SecurityManager consulted when a request carries an authentication token
Method Details
validateParams
Check incoming request for required arguments, to make sure they are valid.- Parameters:
requiredArgs- - Array of names of required arguments. If null don't check for any parameters.req- - Incoming JSONRPC2 requestuseAuth- - If true, will validate authentication token.- Returns:
- - null if no errors were found. Corresponding JSONRPC2Error if error is found.
validateParams
Check incoming request for required arguments, to make sure they are valid. Will authenticate req.- Parameters:
requiredArgs- - Array of names of required arguments. If null don't check for any parameters.req- - Incoming JSONRPC2 request- Returns:
- - null if no errors were found. Corresponding JSONRPC2Error if error is found.
validateToken
Will check incoming parameters to make sure they contain a valid token.- Parameters:
params- - Parameters of incoming request- Returns:
- null if everything is fine, JSONRPC2Error for any corresponding error.