Class JSONRPC2LogUtility

java.lang.Object
com.nimbusds.common.jsonrpc2.JSONRPC2LogUtility

public class JSONRPC2LogUtility extends Object
Helper methods for Log4j message generation.
  • Method Summary

    Modifier and Type
    Method
    Description
    static com.thetransactioncompany.jsonrpc2.JSONRPC2Request
    hideParameter(com.thetransactioncompany.jsonrpc2.JSONRPC2Request request, String paramName)
    Hides the value of the specified parameter in a JSON-RPC 2.0 request.
    static com.thetransactioncompany.jsonrpc2.JSONRPC2Request
    hidePassword(com.thetransactioncompany.jsonrpc2.JSONRPC2Request request)
    Hides the "password" parameter value in a JSON-RPC 2.0 request.
    static void
    log(com.thetransactioncompany.jsonrpc2.JSONRPC2Request request, com.thetransactioncompany.jsonrpc2.JSONRPC2Response response)
    Logs (at INFO level) the name of the JSON-RPC 2.0 request and the resulting response (success or error code + message).
    static void
    log(com.thetransactioncompany.jsonrpc2.JSONRPC2Request request, com.thetransactioncompany.jsonrpc2.JSONRPC2Response response, String prefix)
    Logs (at INFO level) the name of the JSON-RPC 2.0 request and the resulting response (success or error code + message).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • log

      public static void log(com.thetransactioncompany.jsonrpc2.JSONRPC2Request request, com.thetransactioncompany.jsonrpc2.JSONRPC2Response response, String prefix)
      Logs (at INFO level) the name of the JSON-RPC 2.0 request and the resulting response (success or error code + message). The message may be optionally prefixed.

      Format:

       [prefix] request-method-name: Success | Error code: Message
       

      Example:

       [CID dff6fb77-7f96-4b82-a0f9-0ac25cfb1852] ldap.getEntry: Success
      
       [CID dff6fb77-7f96-4b82-a0f9-0ac25cfb1852] ldap.getEntry: Error -1000: Invalid/expired LDAP connection identifier (CID)
       
      Parameters:
      request - The JSON-RPC 2.0 request. Must not be null.
      response - The resulting JSON-RPC 2.0 response. Must not be null.
      prefix - The log message prefix. If null the log message will not be prefixed.
    • log

      public static void log(com.thetransactioncompany.jsonrpc2.JSONRPC2Request request, com.thetransactioncompany.jsonrpc2.JSONRPC2Response response)
      Logs (at INFO level) the name of the JSON-RPC 2.0 request and the resulting response (success or error code + message).

      Format:

       request-method-name: Success | Error code: Message
       

      Example:

       ldap.getEntry: Success
      
       ldap.getEntry: Error -1000 Invalid/expired LDAP connection identifier (CID)
       
      Parameters:
      request - The JSON-RPC 2.0 request. Must not be null.
      response - The resulting JSON-RPC 2.0 response. Must not be null.
    • hideParameter

      public static com.thetransactioncompany.jsonrpc2.JSONRPC2Request hideParameter(com.thetransactioncompany.jsonrpc2.JSONRPC2Request request, String paramName)
      Hides the value of the specified parameter in a JSON-RPC 2.0 request. The value is replaced by a string "[hidden]". If the specified parameter is not found request is returned unmodified.

      This method is intended for logging JSON-RPC 2.0 requests.

      Parameters:
      request - The JSON-RPC 2.0 request. May be null.
      paramName - The name of the parameter to hide. May be null.
      Returns:
      The processed JSON-RPC 2.0 request.
    • hidePassword

      public static com.thetransactioncompany.jsonrpc2.JSONRPC2Request hidePassword(com.thetransactioncompany.jsonrpc2.JSONRPC2Request request)
      Hides the "password" parameter value in a JSON-RPC 2.0 request. The value is replaced by a string "[hidden]". If no "password" parameter is contained the request is returned unmodified.

      This method is intended for logging JSON-RPC 2.0 requests.

      Parameters:
      request - The JSON-RPC 2.0 request. May be null.
      Returns:
      The JSON-RPC 2.0 request with any password value hidden.