Class ServletLogUtility

java.lang.Object
com.nimbusds.common.servlet.ServletLogUtility

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

    Modifier and Type
    Method
    Description
    static String
    composeLogMessage(jakarta.servlet.http.HttpServletRequest httpRequest)
    Composes a log message with the method, the client IP address, CORS origin (if any and a CORS Filter is configured) and the security client certificate principal (if any) of an HTTP request.
    static void
    log(jakarta.servlet.http.HttpServletRequest httpRequest)
    Logs (at INFO level) the method, the client IP address, CORS origin (if any and a CORS Filter is configured) and the security client certificate principal (if any) of an HTTP request.
    static void
    log(org.apache.logging.log4j.Logger log, jakarta.servlet.http.HttpServletRequest httpRequest)
    Logs (at INFO level) the method, the client IP address, CORS origin (if any and a CORS Filter is configured) and the security client certificate principal (if any) of an HTTP request.

    Methods inherited from class java.lang.Object

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

    • composeLogMessage

      public static String composeLogMessage(jakarta.servlet.http.HttpServletRequest httpRequest)
      Composes a log message with the method, the client IP address, CORS origin (if any and a CORS Filter is configured) and the security client certificate principal (if any) of an HTTP request.

      Example:

       HTTP POST request: ip=127.0.0.1 path=/json2ldap
       HTTPS POST request: ip=192.168.0.1 path=/authservice
       HTTPS CORS GET request: ip=192.168.0.1 origin=192.168.10.20 path=/json2ldap
       
      Parameters:
      httpRequest - The HTTP request. Must not be null.
      Returns:
      The log message.
    • log

      public static void log(jakarta.servlet.http.HttpServletRequest httpRequest)
      Logs (at INFO level) the method, the client IP address, CORS origin (if any and a CORS Filter is configured) and the security client certificate principal (if any) of an HTTP request.

      Example:

       HTTP POST request: ip=127.0.0.1 path=/json2ldap
       HTTPS POST request: ip=192.168.0.1 path=/authservice
       HTTPS CORS GET request: ip=192.168.0.1 origin=192.168.10.20 path=/json2ldap
       
      Parameters:
      httpRequest - The HTTP request to log. If null the method will return immediately.
    • log

      public static void log(org.apache.logging.log4j.Logger log, jakarta.servlet.http.HttpServletRequest httpRequest)
      Logs (at INFO level) the method, the client IP address, CORS origin (if any and a CORS Filter is configured) and the security client certificate principal (if any) of an HTTP request.

      Example:

       HTTP POST request: ip=127.0.0.1 path=/json2ldap
       HTTPS POST request: ip=192.168.0.1 path=/authservice
       HTTPS CORS GET request: ip=192.168.0.1 origin=192.168.10.20 path=/json2ldap
       
      Parameters:
      log - The logger. If true the method will return immediately.
      httpRequest - The HTTP request to log. If null the method will return immediately.