java.lang.Object
net.i2p.i2pcontrol.servlets.jsonrpc2handlers.AuthenticateHandler
All Implemented Interfaces:
RequestHandler

public class AuthenticateHandlerextends Object implements RequestHandler
JSON-RPC handler for authentication requests. Processes authentication and token generation for I2PControl API access.
  • Field Details

    • _log

      private static final Log _log
      Logger for this class.
    • requiredArgs

      private static final String[] requiredArgs
      Arguments the request must carry.
    • _helper

      private final JSONRPC2Helper _helper
      Reads the request's arguments.
    • _secMan

      private final SecurityManager _secMan
      Issues the token on success.
  • Constructor Details

    • AuthenticateHandler

      public AuthenticateHandler(JSONRPC2Helper helper, SecurityManager secMan)
      Binds the reply helper and the token-issuing security manager.
      Parameters:
      helper - resolves the localized strings and version data used in the reply
      secMan - issues and tracks the authentication tokens
  • Method Details

    • handledRequests

      public String[] handledRequests()
      Method names this handler services.
      Specified by:
      handledRequests in interface RequestHandler
      Returns:
      method names handled by this handler
    • process

      public JSONRPC2Response process(JSONRPC2Request req, MessageContext ctx)
      Process an Authenticate request
      Specified by:
      process in interface RequestHandler
      Parameters:
      req - A valid JSON-RPC 2.0 request instance. Must not be null.
      ctx - Context information about the request message, may be null if undefined.
      Returns:
      The resulting JSON-RPC 2.0 response. It indicates success or an error, such as METHOD_NOT_FOUND.
    • validateAPIVersion

      private static JSONRPC2Error validateAPIVersion(Object api)
      Validate the provided I2PControl API version against the ones supported by I2PControl.
      Parameters:
      api - the API version value from the request
      Returns:
      null if the version is supported, an error otherwise