net.i2p.i2pcontrol.servlets.jsonrpc2handlers

## Class JSONRPC2Helper

- java.lang.Object
- - net.i2p.i2pcontrol.servlets.jsonrpc2handlers.JSONRPC2Helper

-     public class JSONRPC2Helper
      extends Object

  Helper utility class for I2PControl JSON-RPC2 handlers. Provides common functionality for parameter validation and authentication token verification.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static Boolean` | `USE_AUTH`
    `static Boolean` | `USE_NO_AUTH`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JSONRPC2Helper(SecurityManager secMan)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `JSONRPC2Error` | `validateParams(String[] requiredArgs, JSONRPC2Request req)` Check incoming request for required arguments, to make sure they are valid.
    `JSONRPC2Error` | `validateParams(String[] requiredArgs, JSONRPC2Request req, Boolean useAuth)` Check incoming request for required arguments, to make sure they are valid.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### USE_AUTH

          public static final Boolean USE_AUTH

    - #### USE_NO_AUTH

          public static final Boolean USE_NO_AUTH

  - ### Constructor Detail

    - #### JSONRPC2Helper

          public JSONRPC2Helper(SecurityManager secMan)

  - ### Method Detail

    - #### validateParams

          public JSONRPC2Error validateParams(String[] requiredArgs,
                                              JSONRPC2Request req)

      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.

    - #### validateParams

          public JSONRPC2Error validateParams(String[] requiredArgs,
                                              JSONRPC2Request req,
                                              Boolean useAuth)

      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 request
        `useAuth` - - If true, will validate authentication token.
      Returns:
        - null if no errors were found. Corresponding JSONRPC2Error if error is found.