001: /*************************************************************************
002: * *
003: * EJBCA: The OpenSource Certificate Authority *
004: * *
005: * This software is free software; you can redistribute it and/or *
006: * modify it under the terms of the GNU Lesser General Public *
007: * License as published by the Free Software Foundation; either *
008: * version 2.1 of the License, or any later version. *
009: * *
010: * See terms of license at gnu.org. *
011: * *
012: *************************************************************************/package org.ejbca.core.model.log;
013:
014: import java.io.Serializable;
015: import java.security.cert.X509Certificate;
016: import java.util.Collection;
017: import java.util.Date;
018: import java.util.Properties;
019:
020: import org.ejbca.core.model.ca.caadmin.CADoesntExistsException;
021: import org.ejbca.core.model.ca.caadmin.extendedcaservices.ExtendedCAServiceNotActiveException;
022: import org.ejbca.core.model.ca.caadmin.extendedcaservices.ExtendedCAServiceRequestException;
023: import org.ejbca.core.model.ca.caadmin.extendedcaservices.IllegalExtendedCAServiceRequestException;
024: import org.ejbca.util.query.IllegalQueryException;
025: import org.ejbca.util.query.Query;
026:
027: /**
028: * Interface used by EJBCA external log devices such as Log4j.
029: * @version $Id: ILogDevice.java,v 1.4 2008/01/04 08:55:19 jeklund Exp $
030: */
031: public interface ILogDevice extends Serializable {
032:
033: public final String PROPERTY_DEVICENAME = "deviceName";
034:
035: /**
036: * Log information.
037: * @param admininfo contains information about the administrator performing the event.
038: * @param caid the id of the catch (connected to the event.
039: * @param module indicates the module using the bean.
040: * @param time the time the event occured.
041: * @param username the name of the user involved or null if no user is involved.
042: * @param certificate the certificate involved in the event or null if no certificate is involved.
043: * @param event id of the event, should be one of the org.ejbca.core.model.log.LogConstants.EVENT_ constants.
044: * @param comment comment of the event.
045: * @param exception the exception that has occurred (can be null)
046: */
047: public void log(Admin admininfo, int caid, int module, Date time,
048: String username, X509Certificate certificate, int event,
049: String comment, Exception exception);
050:
051: /**
052: * Method to export log records according to a customized query on the log db data. The parameter query should be a legal Query object.
053: *
054: * @param query a number of statments compiled by query class to a SQL 'WHERE'-clause statment.
055: * @param viewlogprivileges is a sql query string returned by a LogAuthorization object.
056: * @param logexporter is the obbject that converts the result set into the desired log format
057: * @return an exported byte array. Maximum number of exported entries is defined i LogConstants.MAXIMUM_QUERY_ROWCOUNT, returns null if there is nothing to export
058: * @throws IllegalQueryException when query parameters internal rules isn't fullfilled.
059: * @throws ExtendedCAServiceNotActiveException
060: * @throws IllegalExtendedCAServiceRequestException
061: * @throws ExtendedCAServiceRequestException
062: * @throws CADoesntExistsException
063: * @see org.ejbca.util.query.Query
064: */
065: public byte[] export(Admin admin, Query query,
066: String viewlogprivileges, String capriviledges,
067: ILogExporter logexporter) throws IllegalQueryException,
068: CADoesntExistsException, ExtendedCAServiceRequestException,
069: IllegalExtendedCAServiceRequestException,
070: ExtendedCAServiceNotActiveException;
071:
072: /**
073: * Method to execute a customized query on the log db data. The parameter query should be a legal Query object.
074: *
075: * @param query a number of statments compiled by query class to a SQL 'WHERE'-clause statment.
076: * @param viewlogprivileges is a sql query string returned by a LogAuthorization object.
077: * @return a collection of LogEntry. Maximum size of Collection is defined i LogConstants.MAXIMUM_QUERY_ROWCOUNT
078: * @throws IllegalQueryException when query parameters internal rules isn't fullfilled.
079: * @see org.ejbca.util.query.Query
080: */
081: public Collection query(Query query, String viewlogprivileges,
082: String capriviledges) throws IllegalQueryException;
083:
084: /**
085: * This is called for the log device, right before the LogSessionBean is removed. Since there can exist several LogSessionBeans, this
086: * should be able to handle multiple calls.
087: */
088: public void destructor();
089:
090: /**
091: * @return true if this device uses the internal log configuration framework
092: */
093: public boolean getAllowConfigurableEvents();
094:
095: /**
096: * @return the properties used by this LogDevice.
097: */
098: public Properties getProperties();
099:
100: /**
101: * @return the name the device
102: */
103: public String getDeviceName();
104:
105: /**
106: * Resets the status of the device. Used externally for testing.
107: */
108: public void resetDevice(Properties properties);
109:
110: }
|