diff --git a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/audit-common-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/audit-common-SqlMap.xml
index 2e19fbd0ee..508d5212eb 100644
--- a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/audit-common-SqlMap.xml
+++ b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/audit-common-SqlMap.xml
@@ -145,6 +145,45 @@
+
+
+
+ app.app_name_id = #auditAppNameId#
+
+
+ entry.audit_user_id = #auditUserId#
+
+
+ = #auditFromId#]]>
+
+
+
+
+
+ = #auditFromTime#]]>
+
+
+
+
+
+ sp_kpl.key_prop_id = #searchKeyId#
+
+
+ sp_mpl.value_prop_id = #searchValueId#
+
+
+
+
+
+ order by
+ entry.id asc
+
+
+ order by
+ entry.id desc
+
+
+
@@ -236,40 +243,8 @@
join alf_prop_link sp_mpl on (sp_mpl.root_prop_id = entry.audit_values_id)
-
-
- app.app_name_id = #auditAppNameId#
-
-
- entry.audit_user_id = #auditUserId#
-
-
- = #auditFromId#]]>
-
-
-
-
-
- = #auditFromTime#]]>
-
-
-
-
-
- sp_kpl.key_prop_id = #searchKeyId#
-
-
- sp_mpl.value_prop_id = #searchValueId#
-
-
-
- order by
- entry.id asc
-
-
- order by
- entry.id desc
-
+
+
\ No newline at end of file
diff --git a/config/alfresco/public-services-security-context.xml b/config/alfresco/public-services-security-context.xml
index 679aa59cb9..245e3b50ce 100644
--- a/config/alfresco/public-services-security-context.xml
+++ b/config/alfresco/public-services-security-context.xml
@@ -857,7 +857,16 @@
-
+
+
+
+
+
+
+ org.alfresco.service.cmr.audit.AuditService.*=ACL_METHOD.ROLE_ADMINISTRATOR
+
+
+
diff --git a/source/java/org/alfresco/repo/audit/AuditComponentTest.java b/source/java/org/alfresco/repo/audit/AuditComponentTest.java
index ab0f6af684..520c350c0a 100644
--- a/source/java/org/alfresco/repo/audit/AuditComponentTest.java
+++ b/source/java/org/alfresco/repo/audit/AuditComponentTest.java
@@ -512,10 +512,10 @@ public class AuditComponentTest extends TestCase
}
};
- auditService.clearAudit(APPLICATION_API_TEST);
+ clearAuditLog(APPLICATION_API_TEST);
results.clear();
sb.delete(0, sb.length());
- auditService.auditQuery(auditQueryCallback, params, -1);
+ queryAuditLog(auditQueryCallback, params, -1);
logger.debug(sb.toString());
assertTrue("There should be no audit entries for the API test after a clear", results.isEmpty());
@@ -535,7 +535,7 @@ public class AuditComponentTest extends TestCase
AuthenticationUtil.runAs(createAuthenticationWork, AuthenticationUtil.getSystemUserName());
// Clear everything out and do a successful authentication
- auditService.clearAudit(APPLICATION_API_TEST);
+ clearAuditLog(APPLICATION_API_TEST);
try
{
AuthenticationUtil.pushAuthentication();
@@ -549,12 +549,12 @@ public class AuditComponentTest extends TestCase
// Check that the call was audited
results.clear();
sb.delete(0, sb.length());
- auditService.auditQuery(auditQueryCallback, params, -1);
+ queryAuditLog(auditQueryCallback, params, -1);
logger.debug(sb.toString());
assertFalse("Did not get any audit results after successful login", results.isEmpty());
// Clear everything and check that unsuccessful authentication was audited
- auditService.clearAudit(APPLICATION_API_TEST);
+ clearAuditLog(APPLICATION_API_TEST);
try
{
authenticationService.authenticate("banana", "****".toCharArray());
@@ -566,7 +566,7 @@ public class AuditComponentTest extends TestCase
}
results.clear();
sb.delete(0, sb.length());
- auditService.auditQuery(auditQueryCallback, params, -1);
+ queryAuditLog(auditQueryCallback, params, -1);
logger.debug(sb.toString());
assertFalse("Did not get any audit results after failed login", results.isEmpty());
}
@@ -606,7 +606,40 @@ public class AuditComponentTest extends TestCase
params.setApplicationName(APPLICATION_API_TEST);
params.setForward(false);
params.setToId(Long.MAX_VALUE);
- auditService.auditQuery(auditQueryCallback, params, 1);
+ queryAuditLog(auditQueryCallback, params, 1);
}
+ /**
+ * Clearn the audit log as 'admin'
+ */
+ private void clearAuditLog(final String applicationName)
+ {
+ RunAsWork work = new RunAsWork()
+ {
+ @Override
+ public Void doWork() throws Exception
+ {
+ auditService.clearAudit(applicationName);
+ return null;
+ }
+ };
+ AuthenticationUtil.runAs(work, AuthenticationUtil.getAdminRoleName());
+ }
+
+ /**
+ * Clearn the audit log as 'admin'
+ */
+ private void queryAuditLog(final AuditQueryCallback callback, final AuditQueryParameters parameters, final int maxResults)
+ {
+ RunAsWork work = new RunAsWork()
+ {
+ @Override
+ public Void doWork() throws Exception
+ {
+ auditService.auditQuery(callback, parameters, maxResults);
+ return null;
+ }
+ };
+ AuthenticationUtil.runAs(work, AuthenticationUtil.getAdminRoleName());
+ }
}
diff --git a/source/java/org/alfresco/repo/audit/AuditServiceImpl.java b/source/java/org/alfresco/repo/audit/AuditServiceImpl.java
index 1f937be40d..7e0b89acaa 100644
--- a/source/java/org/alfresco/repo/audit/AuditServiceImpl.java
+++ b/source/java/org/alfresco/repo/audit/AuditServiceImpl.java
@@ -18,16 +18,14 @@
*/
package org.alfresco.repo.audit;
-import java.io.Serializable;
-
import org.alfresco.service.cmr.audit.AuditQueryParameters;
import org.alfresco.service.cmr.audit.AuditService;
-import org.springframework.extensions.surf.util.ParameterCheck;
/**
* The implementation of the AuditService for application auditing.
*
- * @author Andy Hind
+ * @author Derek Hulley
+ * @since 3.2
*/
public class AuditServiceImpl implements AuditService
{
@@ -43,6 +41,15 @@ public class AuditServiceImpl implements AuditService
this.auditComponent = auditComponent;
}
+ /**
+ * {@inheritDoc}
+ * @since 3.4
+ */
+ public boolean isAuditEnabled()
+ {
+ return auditComponent.isAuditEnabled();
+ }
+
/**
* {@inheritDoc}
* @since 3.2
@@ -89,55 +96,4 @@ public class AuditServiceImpl implements AuditService
{
auditComponent.auditQuery(callback, parameters, maxResults);
}
-
- /**
- * {@inheritDoc}
- * @since 3.2
- */
- public void auditQuery(
- AuditQueryCallback callback,
- boolean forward,
- String applicationName, String user, Long from, Long to,
- int maxResults)
-
- {
- ParameterCheck.mandatory("callback", callback);
-
- AuditQueryParameters params = new AuditQueryParameters();
- params.setForward(true);
- params.setApplicationName(applicationName);
- params.setUser(user);
- params.setFromTime(from);
- params.setToTime(to);
-
- auditComponent.auditQuery(callback, params, maxResults);
- }
-
- /**
- * {@inheritDoc}
- * @since 3.2
- */
- public void auditQuery(
- AuditQueryCallback callback,
- boolean forward,
- String applicationName, String user, Long from, Long to,
- String searchKey, Serializable searchValue,
- int maxResults)
-
- {
- ParameterCheck.mandatory("callback", callback);
-
- AuditQueryParameters params = new AuditQueryParameters();
- params.setForward(true);
- params.setApplicationName(applicationName);
- params.setUser(user);
- params.setFromTime(from);
- params.setToTime(to);
- if (searchKey != null || searchValue != null)
- {
- params.addSearchKey(searchKey, searchValue);
- }
-
- auditComponent.auditQuery(callback, params, maxResults);
- }
}
\ No newline at end of file
diff --git a/source/java/org/alfresco/service/cmr/audit/AuditService.java b/source/java/org/alfresco/service/cmr/audit/AuditService.java
index 7bf51c7810..8c4b6165f4 100644
--- a/source/java/org/alfresco/service/cmr/audit/AuditService.java
+++ b/source/java/org/alfresco/service/cmr/audit/AuditService.java
@@ -31,6 +31,13 @@ import org.alfresco.service.PublicService;
@PublicService
public interface AuditService
{
+ /**
+ * @return Returns true if auditing is globally enabled
+ *
+ * @since 3.4
+ */
+ boolean isAuditEnabled();
+
/**
* @param applicationName the name of the application to check
* @param path the path to check
@@ -122,49 +129,4 @@ public interface AuditService
* @since 3.3
*/
void auditQuery(AuditQueryCallback callback, AuditQueryParameters parameters, int maxResults);
-
- /**
- * Get the audit entries that match the given criteria.
- *
- * @param callback the callback that will handle results
- * @param forward true for results to ordered from first to last,
- * or false to order from last to first
- * @param applicationName if not null, find entries logged against this application
- * @param user if not null, find entries logged against this user
- * @param from the start search time (null to start at the beginning)
- * @param to the end search time (null for no limit)
- * @param maxResults the maximum number of results to retrieve (zero or negative to ignore)
- *
- * @since 3.2
- * @deprecated Use {@link #auditQuery(AuditQueryCallback, AuditQueryParameters)}
- */
- void auditQuery(
- AuditQueryCallback callback,
- boolean forward,
- String applicationName, String user, Long from, Long to,
- int maxResults);
-
- /**
- * Get the audit entries that match the given criteria.
- *
- * @param callback the callback that will handle results
- * @param forward true for results to ordered from first to last,
- * or false to order from last to first
- * @param applicationName if not null, find entries logged against this application
- * @param user if not null, find entries logged against this user
- * @param from the start search time (null to start at the beginning)
- * @param to the end search time (null for no limit)
- * @param searchKey the audit key path that must exist (null to ignore)
- * @param searchValue an audit value that must exist (null to ignore)
- * @param maxResults the maximum number of results to retrieve (zero or negative to ignore)
- *
- * @since 3.2
- * @deprecated Use {@link #auditQuery(AuditQueryCallback, AuditQueryParameters)}
- */
- void auditQuery(
- AuditQueryCallback callback,
- boolean forward,
- String applicationName, String user, Long from, Long to,
- String searchKey, Serializable searchValue,
- int maxResults);
}