no.ntnu.vegare.visualizer.server.db
Class LogDatabase

java.lang.Object
  extended by no.ntnu.vegare.visualizer.server.db.LogDatabase

public class LogDatabase
extends java.lang.Object

A simplified implementation of a SQLite database interface.

Uses SqliteJDBC ( http://www.zentus.com/sqlitejdbc/) to create an in-memory database, and provides an interface to insert or load entries.

The database is cleared when the process dies.

Author:
vegare

Constructor Summary
LogDatabase()
          Create an in-memory database and a table for log records.
 
Method Summary
 void addEntry(int severity, java.lang.String facility, java.lang.String ip, java.lang.String msg)
          Add a new security incident to the database.
 java.lang.String getEntries(int startTime, int stopTime, int minSev)
          Load all incidents occurring in a time interval, specified by two UNIX timestamps.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LogDatabase

public LogDatabase()
Create an in-memory database and a table for log records.

Method Detail

addEntry

public void addEntry(int severity,
                     java.lang.String facility,
                     java.lang.String ip,
                     java.lang.String msg)

Add a new security incident to the database.

Severity is given as one of the following:

Parameters:
severity - Integer value from 0-7
facility - Textual name of target system
ip - IP addres as a dot-decimal string
msg - Textual message

getEntries

public java.lang.String getEntries(int startTime,
                                   int stopTime,
                                   int minSev)

Load all incidents occurring in a time interval, specified by two UNIX timestamps. In addition, filtering can be performed on severity, avoiding routine messages.

Parameters:
startTime - Earliest time, as UNIX timestamp
stopTime - Latest time, as UNIX timestamp
minSev - Minimum severity to load
Returns:
JSON formatted string of incidents