Class JsonLoggerSqlFirewallTrigger

java.lang.Object
org.kawanfw.sql.api.server.firewall.trigger.JsonLoggerSqlFirewallTrigger
All Implemented Interfaces:
SqlFirewallTrigger

public class JsonLoggerSqlFirewallTrigger
extends Object
implements SqlFirewallTrigger
A trigger that will log using JSON format the SqlEvent info and the sqlFirewallManager class name.
Since:
11.0
Author:
Nicolas de Pomereu
  • Constructor Summary

    Constructors
    Constructor Description
    JsonLoggerSqlFirewallTrigger()  
  • Method Summary

    Modifier and Type Method Description
    static Map<String,​String> getLoggerElements()
    Returns the Logger elements (for debug purpose)
    void runIfStatementRefused​(SqlEvent sqlEvent, SqlFirewallManager sqlFirewallManager, Connection connection)
    Logs using JSON format the SqlEvent and the SqlFirewallManager class name into a Logger with parameters: Name: sonLoggerSqlFirewallTrigger File name pattern: user.home/.kawansoft/log/JsonLoggerSqlFirewallTrigger_%d.log.%i (example of file created: JsonLoggerSqlFirewallTrigger_2022-07-01.log.1.). Pattern of each line of log: "%msg%n" Maximum File Size: 300Mb Total Size Cap: 30Gb These default values may be superseded by creating a JsonLoggerSqlFirewallTrigger.properties file in user.home/.kawansoft/conf.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JsonLoggerSqlFirewallTrigger

      public JsonLoggerSqlFirewallTrigger()
  • Method Details

    • runIfStatementRefused

      public void runIfStatementRefused​(SqlEvent sqlEvent, SqlFirewallManager sqlFirewallManager, Connection connection) throws IOException, SQLException
      Logs using JSON format the SqlEvent and the SqlFirewallManager class name into a Logger with parameters:
      • Name: sonLoggerSqlFirewallTrigger
      • File name pattern: user.home/.kawansoft/log/JsonLoggerSqlFirewallTrigger_%d.log.%i (example of file created: JsonLoggerSqlFirewallTrigger_2022-07-01.log.1.).
      • Pattern of each line of log: "%msg%n"
      • Maximum File Size: 300Mb
      • Total Size Cap: 30Gb
      These default values may be superseded by creating a JsonLoggerSqlFirewallTrigger.properties file in user.home/.kawansoft/conf.

      See the JsonLoggerSqlFirewallTrigger.properties format.


      Specified by:
      runIfStatementRefused in interface SqlFirewallTrigger
      Parameters:
      sqlEvent - the SQL event asked by the client side. Contains all info about the SQL call (client username, database name, IP Address of the client, and SQL statement details).
      sqlFirewallManager - the instance that triggers this call.
      connection - The current SQL/JDBC Connection
      Throws:
      IOException - if an IOException occurs
      SQLException - if a SQLException occurs
    • getLoggerElements

      public static Map<String,​String> getLoggerElements()
      Returns the Logger elements (for debug purpose)
      Returns:
      the lOGGER_ELEMENTS