Commit f3118dc9 authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

Added event count retrieval to security auditor for future use.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@9953 b35dd754-fafc-0310-a699-88a17e54d16e
parent 9ec84064
......@@ -94,6 +94,16 @@ public class ClearspaceSecurityAuditProvider implements SecurityAuditProvider {
return null;
}
/**
* The ClearspaceSecurityAuditProvider does not retrieve audit entries from Clearspace. Instead
* it refers the admin to a URL where they can read the logs.
* @see org.jivesoftware.openfire.security.SecurityAuditProvider#getEventCount()
*/
public Integer getEventCount() {
// This is not used.
return null;
}
/**
* The ClearspaceSecurityAuditProvider does not retrieve audit entries from Clearspace. Instead
* it refers the admin to a URL where they can read the logs.
......
......@@ -33,6 +33,8 @@ public class DefaultSecurityAuditProvider implements SecurityAuditProvider {
"SELECT msgID,username,entryStamp,summary,node,details FROM jiveSecurityAuditLog";
private static final String GET_EVENT =
"SELECT msgID,username,entryStamp,summary,node,details FROM jiveSecurityAuditLog WHERE msgID=?";
private static final String GET_EVENT_COUNT =
"SELECT COUNT(msgID) FROM jiveSecurityAuditLog";
/**
* Constructs a new DefaultSecurityAuditProvider
......@@ -182,6 +184,32 @@ public class DefaultSecurityAuditProvider implements SecurityAuditProvider {
return event;
}
/**
* The default provider counts the number of entries in the jiveSecurityAuditLog table.
* @see org.jivesoftware.openfire.security.SecurityAuditProvider#getEventCount()
*/
public Integer getEventCount() {
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
Integer cnt = 0;
try {
con = DbConnectionManager.getConnection();
pstmt = con.prepareStatement(GET_EVENT_COUNT);
rs = pstmt.executeQuery();
cnt = rs.getInt(1);
}
catch (Exception e) {
// Hrm. That should not occur.
Log.error("Error while looking up number of security audit events: ", e);
}
finally {
DbConnectionManager.closeConnection(rs, pstmt, con);
}
return cnt;
}
/**
* The default provider writes logs into a local Openfire database.
* @see org.jivesoftware.openfire.security.SecurityAuditProvider#isWriteOnly()
......
......@@ -57,6 +57,13 @@ public interface SecurityAuditProvider {
*/
public SecurityAuditEvent getEvent(Integer msgID) throws EventNotFoundException;
/**
* Retrieves number of events recorded.
*
* @return Number of events that have been recorded.
*/
public Integer getEventCount();
/**
* Returns true if the provider logs can be read by Openfire for display from Openfire's
* own admin interface. If false, the administrative interface will place a stub in place
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment