mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
SAIL-240 (SAIL-294): DAO refactor for Audit.hbm.xml
- Removed audit.hbm.xml and related audit classes - Audit tests grouped into suite git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@20870 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.audit;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* The audit model used for application level auditing.
|
||||
*
|
||||
* @author andyh
|
||||
*/
|
||||
public interface ApplicationAuditModel
|
||||
{
|
||||
/**
|
||||
* Report if audit behaviour can be determined before the method call
|
||||
*
|
||||
* @param auditMode
|
||||
* @param application
|
||||
* @param description
|
||||
* @param key
|
||||
* @param args
|
||||
* @return - the audit mode
|
||||
*/
|
||||
public AuditMode beforeExecution(AuditMode auditMode, String application, String description, NodeRef key,
|
||||
Object... args);
|
||||
|
||||
/**
|
||||
* Report if audit behaviour can be determined after the method call
|
||||
*
|
||||
* @param auditMode
|
||||
* @param application
|
||||
* @param description
|
||||
* @param key
|
||||
* @param args
|
||||
* @return - the audit mode
|
||||
*/
|
||||
public AuditMode afterExecution(AuditMode auditMode, String application, String description, NodeRef key,
|
||||
Object... args);
|
||||
|
||||
/**
|
||||
* Report if audit behaviour should be invoked on error. It could be we look at the error and filter - this is not
|
||||
* supported at the moment.
|
||||
*
|
||||
* @param auditMode
|
||||
* @param application
|
||||
* @param description
|
||||
* @param key
|
||||
* @param args
|
||||
* @return - the audit mode
|
||||
*/
|
||||
public AuditMode onError(AuditMode auditMode, String application, String description, NodeRef key, Object... args);
|
||||
|
||||
/**
|
||||
* Get the optional parameters that are to be recorded
|
||||
*
|
||||
* @param application
|
||||
* @return - the audit mode
|
||||
*/
|
||||
public RecordOptions getAuditRecordOptions(String application);
|
||||
}
|
@@ -19,17 +19,13 @@
|
||||
package org.alfresco.repo.audit;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.repo.audit.model.AuditApplication;
|
||||
import org.alfresco.repo.audit.model.AuditModelRegistry;
|
||||
import org.alfresco.repo.audit.model._3.AuditPath;
|
||||
import org.alfresco.service.cmr.audit.AuditInfo;
|
||||
import org.alfresco.service.cmr.audit.AuditQueryParameters;
|
||||
import org.alfresco.service.cmr.audit.AuditService.AuditQueryCallback;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
|
||||
/**
|
||||
* The audit component. Used by the AuditService and AuditMethodInterceptor to insert audit entries.
|
||||
@@ -42,52 +38,6 @@ import org.aopalliance.intercept.MethodInvocation;
|
||||
*/
|
||||
public interface AuditComponent
|
||||
{
|
||||
/**
|
||||
* Audit entry point for method interceptors.
|
||||
*
|
||||
* @return - the return onbject from the normal invocation of the audited method.
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public Object audit(MethodInvocation methodInvocation) throws Throwable;
|
||||
|
||||
/**
|
||||
* @param source -
|
||||
* a string that represents the application
|
||||
* @param description -
|
||||
* the audit entry *
|
||||
* @param key -
|
||||
* a node ref to use as the key for filtering etc
|
||||
* @param args -
|
||||
* an arbitrary list of parameters
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public void audit(String source, String description, NodeRef key, Object... args);
|
||||
|
||||
/**
|
||||
* Add an audit entry - without invoking the method invocation.
|
||||
* Only the method arguments can be audited.
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
void beforeMethodCallManualAudit(Class<?> clazz, Object target, String method, Object ... args);
|
||||
|
||||
/**
|
||||
* Get the audit trail for a node.
|
||||
*
|
||||
* @param nodeRef -
|
||||
* the node ref for which we want the audit trail
|
||||
* @return - a list of AuditInfo objects that represent the audit trail for the given node reference.
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public List<AuditInfo> getAuditTrail(NodeRef nodeRef);
|
||||
|
||||
/*
|
||||
* V3.2 from here on. Put all fixes to the older audit code before this point, please.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Determines whether audit is globally enabled or disabled.
|
||||
*
|
||||
|
@@ -19,15 +19,10 @@
|
||||
package org.alfresco.repo.audit;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -35,9 +30,7 @@ import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.repo.audit.extractor.DataExtractor;
|
||||
import org.alfresco.repo.audit.generator.DataGenerator;
|
||||
import org.alfresco.repo.audit.model.AuditApplication;
|
||||
import org.alfresco.repo.audit.model.AuditEntry;
|
||||
import org.alfresco.repo.audit.model.AuditModelRegistry;
|
||||
import org.alfresco.repo.audit.model.TrueFalseUnset;
|
||||
import org.alfresco.repo.domain.audit.AuditDAO;
|
||||
import org.alfresco.repo.domain.propval.PropertyValueDAO;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
@@ -45,25 +38,12 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.service.Auditable;
|
||||
import org.alfresco.service.NotAuditable;
|
||||
import org.alfresco.service.PublicService;
|
||||
import org.alfresco.service.cmr.audit.AuditInfo;
|
||||
import org.alfresco.service.cmr.audit.AuditQueryParameters;
|
||||
import org.alfresco.service.cmr.audit.AuditService.AuditQueryCallback;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.Path;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.search.SearchParameters;
|
||||
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.util.PathMapper;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.aop.framework.ReflectiveMethodInvocation;
|
||||
import org.springframework.extensions.surf.util.ParameterCheck;
|
||||
|
||||
/**
|
||||
@@ -78,809 +58,20 @@ import org.springframework.extensions.surf.util.ParameterCheck;
|
||||
*/
|
||||
public class AuditComponentImpl implements AuditComponent
|
||||
{
|
||||
/**
|
||||
* The application name to use for audit entries generated by method interception around public services.
|
||||
*/
|
||||
private static final String SYSTEM_APPLICATION = "SystemMethodInterceptor";
|
||||
|
||||
/**
|
||||
* Logging
|
||||
*/
|
||||
private static Log logger = LogFactory.getLog(AuditComponentImpl.class);
|
||||
|
||||
/**
|
||||
* Suspend resume auditing
|
||||
*/
|
||||
private static ThreadLocal<Boolean> auditFlag = new ThreadLocal<Boolean>();
|
||||
|
||||
/**
|
||||
* IOC
|
||||
*/
|
||||
private PublicServiceIdentifier publicServiceIdentifier;
|
||||
|
||||
private AuditConfiguration auditConfiguration;
|
||||
|
||||
private AuditModelRegistry auditModelRegistry;
|
||||
private PropertyValueDAO propertyValueDAO;
|
||||
private AuditDAO auditDAO;
|
||||
|
||||
private TransactionService transactionService;
|
||||
|
||||
private NodeService nodeService;
|
||||
|
||||
private NamespacePrefixResolver namespacePrefixResolver;
|
||||
|
||||
private AuditModel auditModel;
|
||||
|
||||
/**
|
||||
* Keep hold of the host where the audit occurs. TODO: Check that we get the correct address ...
|
||||
*/
|
||||
|
||||
private InetAddress auditHost;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
public AuditComponentImpl()
|
||||
{
|
||||
super();
|
||||
// Initialise the host address
|
||||
try
|
||||
{
|
||||
auditHost = InetAddress.getLocalHost();
|
||||
}
|
||||
catch (UnknownHostException e)
|
||||
{
|
||||
logger.error("Failed to get local host address", e);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* IOC property setters
|
||||
*/
|
||||
|
||||
/**
|
||||
* Set the DAO for recording auditable information when no exception occurs.
|
||||
*/
|
||||
public void setAuditDAO(AuditDAO auditDAO)
|
||||
{
|
||||
this.auditDAO = auditDAO;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the DAO for recording failed actions - this is done in another transaction.
|
||||
*/
|
||||
public void setTransactionService(TransactionService transactionService)
|
||||
{
|
||||
this.transactionService = transactionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the NodeService for path extracting.
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the audit configuration.
|
||||
*/
|
||||
public void setAuditConfiguration(AuditConfiguration auditConfiguration)
|
||||
{
|
||||
this.auditConfiguration = auditConfiguration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the helper used to identify public services
|
||||
*/
|
||||
public void setPublicServiceIdentifier(PublicServiceIdentifier publicServiceIdentifier)
|
||||
{
|
||||
this.publicServiceIdentifier = publicServiceIdentifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the audit model.
|
||||
*/
|
||||
public void setAuditModel(AuditModel auditModel)
|
||||
{
|
||||
this.auditModel = auditModel;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the namespacePrefixResolver.
|
||||
*/
|
||||
public void setNamespacePrefixResolver(NamespacePrefixResolver namespacePrefixResolver)
|
||||
{
|
||||
this.namespacePrefixResolver = namespacePrefixResolver;
|
||||
}
|
||||
|
||||
public Object audit(MethodInvocation mi) throws Throwable
|
||||
{
|
||||
if ((auditFlag.get() == null) || (!auditFlag.get().booleanValue()))
|
||||
{
|
||||
if (auditModel instanceof AuditEntry && ((AuditEntry) auditModel).getEnabled() == TrueFalseUnset.TRUE)
|
||||
{
|
||||
boolean auditInternal = (auditModel.getAuditInternalServiceMethods(mi) == TrueFalseUnset.TRUE);
|
||||
try
|
||||
{
|
||||
Method method = mi.getMethod();
|
||||
String methodName = method.getName();
|
||||
String serviceName = publicServiceIdentifier.getPublicServiceName(mi);
|
||||
|
||||
if (!auditInternal)
|
||||
{
|
||||
auditFlag.set(Boolean.TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Auditing internal service use for - " + serviceName + "." + methodName);
|
||||
}
|
||||
}
|
||||
|
||||
if (method.isAnnotationPresent(Auditable.class))
|
||||
{
|
||||
|
||||
if (serviceName != null)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Auditing - " + serviceName + "." + methodName);
|
||||
}
|
||||
return auditImpl(mi, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("UnknownService." + methodName);
|
||||
}
|
||||
return auditImpl(mi, true);
|
||||
}
|
||||
|
||||
}
|
||||
else if (method.isAnnotationPresent(NotAuditable.class))
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Not Audited. " + serviceName + "." + methodName);
|
||||
}
|
||||
return mi.proceed();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Unannotated service method " + serviceName + "." + methodName);
|
||||
}
|
||||
if (method.getDeclaringClass().isInterface() && method.getDeclaringClass().isAnnotationPresent(PublicService.class))
|
||||
{
|
||||
throw new RuntimeException("Unannotated service method " + serviceName + "." + methodName);
|
||||
}
|
||||
else
|
||||
{
|
||||
return mi.proceed();
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!auditInternal)
|
||||
{
|
||||
auditFlag.set(Boolean.FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return mi.proceed();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return mi.proceed();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal audit of a method invocation
|
||||
*
|
||||
* @param mi -
|
||||
* the method to audit
|
||||
* @return - the return object from the audited method
|
||||
* @throws Throwable -
|
||||
* any Throwable that can be thrown by th audtied method.
|
||||
*/
|
||||
public Object auditImpl(MethodInvocation mi, boolean execute) throws Throwable
|
||||
{
|
||||
final AuditState auditInfo = new AuditState(auditConfiguration);
|
||||
// RecordOptions recordOptions = auditModel.getAuditRecordOptions(mi);
|
||||
AuditMode auditMode = AuditMode.UNSET;
|
||||
try
|
||||
{
|
||||
Object o = null;
|
||||
auditMode = beforeInvocation(auditMode, auditInfo, mi);
|
||||
if (execute)
|
||||
{
|
||||
o = mi.proceed();
|
||||
auditMode = postInvocation(auditMode, auditInfo, mi, o);
|
||||
}
|
||||
if ((auditMode == AuditMode.ALL) || (auditMode == AuditMode.SUCCESS))
|
||||
{
|
||||
RetryingTransactionCallback<Object> cb = new RetryingTransactionCallback<Object>()
|
||||
{
|
||||
public Object execute() throws Throwable
|
||||
{
|
||||
auditDAO.audit(auditInfo);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
boolean requiresNew = (AlfrescoTransactionSupport.getTransactionReadState() != TxnReadState.TXN_READ_WRITE);
|
||||
transactionService.getRetryingTransactionHelper().doInTransaction(cb, false, requiresNew);
|
||||
}
|
||||
return o;
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
auditMode = onError(auditMode, auditInfo, mi, t);
|
||||
if ((auditMode == AuditMode.ALL) || (auditMode == AuditMode.FAIL))
|
||||
{
|
||||
try
|
||||
{
|
||||
RetryingTransactionCallback<Object> cb = new RetryingTransactionCallback<Object>()
|
||||
{
|
||||
public Object execute() throws Throwable
|
||||
{
|
||||
auditDAO.audit(auditInfo);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
transactionService.getRetryingTransactionHelper().doInTransaction(cb, false, true);
|
||||
}
|
||||
catch (Throwable tt)
|
||||
{
|
||||
throw new AuditException("Failed to audit exception", new Object[] { tt }, t);
|
||||
}
|
||||
}
|
||||
throw t;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to set auditable properties and to determine if auditing is required when an exception is caught in
|
||||
* the audited method.
|
||||
*
|
||||
* @param auditMode
|
||||
* @param auditInfo
|
||||
* @param mi
|
||||
* @param t
|
||||
* @return - the audit mode
|
||||
*/
|
||||
private AuditMode onError(AuditMode auditMode, AuditState auditInfo, MethodInvocation mi, Throwable t)
|
||||
{
|
||||
if ((auditMode == AuditMode.ALL) || (auditMode == AuditMode.FAIL))
|
||||
{
|
||||
auditInfo.setFail(true);
|
||||
auditInfo.setThrowable(t);
|
||||
}
|
||||
|
||||
return auditMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to set audited information after method invocation and to determine if auditing should take place
|
||||
* based on the method return value.
|
||||
*
|
||||
* @param auditMode
|
||||
* @param auditInfo
|
||||
* @param mi
|
||||
* @param returnObject
|
||||
* @return - the audit mode.
|
||||
*/
|
||||
private AuditMode postInvocation(AuditMode auditMode, AuditState auditInfo, MethodInvocation mi, Object returnObject)
|
||||
{
|
||||
if (returnObject == null)
|
||||
{
|
||||
auditInfo.setReturnObject(null);
|
||||
}
|
||||
else if (returnObject instanceof Serializable)
|
||||
{
|
||||
auditInfo.setReturnObject((Serializable) returnObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
auditInfo.setReturnObject(returnObject.toString());
|
||||
}
|
||||
|
||||
Auditable auditable = mi.getMethod().getAnnotation(Auditable.class);
|
||||
if (auditable.key() == Auditable.Key.RETURN)
|
||||
{
|
||||
if (returnObject != null)
|
||||
{
|
||||
if (returnObject instanceof NodeRef)
|
||||
{
|
||||
NodeRef key = (NodeRef) returnObject;
|
||||
auditInfo.setKeyStore(key.getStoreRef());
|
||||
auditInfo.setKeyGUID(key.getId());
|
||||
RecordOptions recordOptions = auditModel.getAuditRecordOptions(mi);
|
||||
if (recordOptions != null && recordOptions.getRecordPath() == TrueFalseUnset.TRUE)
|
||||
{
|
||||
auditInfo.setPath(getNodePath(key));
|
||||
}
|
||||
}
|
||||
else if (returnObject instanceof StoreRef)
|
||||
{
|
||||
auditInfo.setKeyStore((StoreRef) returnObject);
|
||||
}
|
||||
else if (returnObject instanceof ChildAssociationRef)
|
||||
{
|
||||
ChildAssociationRef car = (ChildAssociationRef) returnObject;
|
||||
auditInfo.setKeyStore(car.getChildRef().getStoreRef());
|
||||
auditInfo.setKeyGUID(car.getChildRef().getId());
|
||||
RecordOptions recordOptions = auditModel.getAuditRecordOptions(mi);
|
||||
if (recordOptions != null && recordOptions.getRecordPath() == TrueFalseUnset.TRUE)
|
||||
{
|
||||
auditInfo.setPath(nodeService.getPath(car.getChildRef()).toString());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.warn("Key argument is not a node, store or child assoc ref for return object on "
|
||||
+ publicServiceIdentifier.getPublicServiceName(mi) + "." + mi.getMethod().getName() + " it is " + returnObject.getClass().getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If the user name is not set, try and set it after the method call.
|
||||
// This covers authentication when the user is only known after the call.
|
||||
|
||||
if (auditInfo.getUserIdentifier() == null)
|
||||
{
|
||||
auditInfo.setUserIdentifier(AuthenticationUtil.getFullyAuthenticatedUser());
|
||||
}
|
||||
|
||||
return auditMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set auditable information and determine if auditing is required before method invocation. This would normally be
|
||||
* based on the method arguments.
|
||||
*
|
||||
* @param auditMode
|
||||
* @param auditInfo
|
||||
* @param mi
|
||||
* @return - the audit mode.
|
||||
*/
|
||||
private AuditMode beforeInvocation(AuditMode auditMode, AuditState auditInfo, MethodInvocation mi)
|
||||
{
|
||||
AuditMode effectiveAuditMode = auditModel.beforeExecution(auditMode, mi);
|
||||
|
||||
if (auditMode != AuditMode.NONE)
|
||||
{
|
||||
String methodName = mi.getMethod().getName();
|
||||
String serviceName = publicServiceIdentifier.getPublicServiceName(mi);
|
||||
auditInfo.setAuditApplication(SYSTEM_APPLICATION);
|
||||
auditInfo.setAuditConfiguration(auditConfiguration);
|
||||
auditInfo.setAuditMethod(methodName);
|
||||
auditInfo.setAuditService(serviceName);
|
||||
auditInfo.setClientAddress(null);
|
||||
auditInfo.setDate(new Date());
|
||||
auditInfo.setFail(false);
|
||||
auditInfo.setFiltered(false);
|
||||
auditInfo.setHostAddress(auditHost);
|
||||
|
||||
auditInfo.setPath(null);
|
||||
|
||||
Auditable auditable = mi.getMethod().getAnnotation(Auditable.class);
|
||||
Object key = null;
|
||||
switch (auditable.key())
|
||||
{
|
||||
case ARG_0:
|
||||
checkArgLength(mi, methodName, serviceName, 0);
|
||||
key = mi.getArguments()[0];
|
||||
break;
|
||||
case ARG_1:
|
||||
checkArgLength(mi, methodName, serviceName, 1);
|
||||
key = mi.getArguments()[1];
|
||||
break;
|
||||
case ARG_2:
|
||||
checkArgLength(mi, methodName, serviceName, 2);
|
||||
key = mi.getArguments()[2];
|
||||
break;
|
||||
case ARG_3:
|
||||
checkArgLength(mi, methodName, serviceName, 3);
|
||||
key = mi.getArguments()[3];
|
||||
break;
|
||||
case ARG_4:
|
||||
checkArgLength(mi, methodName, serviceName, 4);
|
||||
key = mi.getArguments()[4];
|
||||
break;
|
||||
case ARG_5:
|
||||
checkArgLength(mi, methodName, serviceName, 5);
|
||||
key = mi.getArguments()[5];
|
||||
break;
|
||||
case ARG_6:
|
||||
checkArgLength(mi, methodName, serviceName, 6);
|
||||
key = mi.getArguments()[6];
|
||||
break;
|
||||
case ARG_7:
|
||||
checkArgLength(mi, methodName, serviceName, 7);
|
||||
key = mi.getArguments()[7];
|
||||
break;
|
||||
case ARG_8:
|
||||
checkArgLength(mi, methodName, serviceName, 8);
|
||||
key = mi.getArguments()[8];
|
||||
break;
|
||||
case ARG_9:
|
||||
checkArgLength(mi, methodName, serviceName, 9);
|
||||
key = mi.getArguments()[9];
|
||||
break;
|
||||
case NO_KEY:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (key != null)
|
||||
{
|
||||
RecordOptions recordOptions = auditModel.getAuditRecordOptions(mi);
|
||||
if (key instanceof NodeRef)
|
||||
{
|
||||
auditInfo.setKeyStore(((NodeRef) key).getStoreRef());
|
||||
auditInfo.setKeyGUID(((NodeRef) key).getId());
|
||||
if (recordOptions != null && recordOptions.getRecordPath() == TrueFalseUnset.TRUE)
|
||||
{
|
||||
auditInfo.setPath(getNodePath((NodeRef) key));
|
||||
}
|
||||
}
|
||||
else if (key instanceof StoreRef)
|
||||
{
|
||||
auditInfo.setKeyStore((StoreRef) key);
|
||||
}
|
||||
else if (key instanceof ChildAssociationRef)
|
||||
{
|
||||
ChildAssociationRef car = (ChildAssociationRef) key;
|
||||
auditInfo.setKeyStore(car.getParentRef().getStoreRef());
|
||||
auditInfo.setKeyGUID(car.getParentRef().getId());
|
||||
if (recordOptions != null && recordOptions.getRecordPath() == TrueFalseUnset.TRUE)
|
||||
{
|
||||
auditInfo.setPath(getNodePath(car.getParentRef()));
|
||||
}
|
||||
}
|
||||
else if (key instanceof SearchParameters)
|
||||
{
|
||||
SearchParameters sp = (SearchParameters) key;
|
||||
if (sp.getStores().size() > 0)
|
||||
{
|
||||
auditInfo.setKeyStore(sp.getStores().get(0));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.warn("Key argument is not a node, store or child assoc reference or search parameters on "
|
||||
+ serviceName + "." + methodName + " it is " + key.getClass().getName());
|
||||
}
|
||||
}
|
||||
auditInfo.setKeyPropertiesAfter(null);
|
||||
auditInfo.setKeyPropertiesBefore(null);
|
||||
auditInfo.setMessage(null);
|
||||
if (mi.getArguments() != null)
|
||||
{
|
||||
Serializable[] serArgs = new Serializable[mi.getArguments().length];
|
||||
for (int i = 0; i < mi.getArguments().length; i++)
|
||||
{
|
||||
if ((auditable.recordable() == null) || (auditable.recordable().length <= i) || auditable.recordable()[i])
|
||||
{
|
||||
if (mi.getArguments()[i] == null)
|
||||
{
|
||||
serArgs[i] = null;
|
||||
}
|
||||
else if (mi.getArguments()[i] instanceof Serializable)
|
||||
{
|
||||
serArgs[i] = (Serializable) mi.getArguments()[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
serArgs[i] = mi.getArguments()[i].toString();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
serArgs[i] = "********";
|
||||
}
|
||||
}
|
||||
auditInfo.setMethodArguments(serArgs);
|
||||
}
|
||||
auditInfo.setReturnObject(null);
|
||||
auditInfo.setSessionId(null);
|
||||
auditInfo.setThrowable(null);
|
||||
auditInfo.setTxId(AlfrescoTransactionSupport.getTransactionId());
|
||||
auditInfo.setUserIdentifier(AuthenticationUtil.getFullyAuthenticatedUser());
|
||||
}
|
||||
|
||||
return effectiveAuditMode;
|
||||
}
|
||||
|
||||
private void checkArgLength(MethodInvocation mi, String methodName, String serviceName, int position)
|
||||
{
|
||||
if (mi.getArguments().length <= position)
|
||||
{
|
||||
logger.warn("Auditable annotation on " + serviceName + "." + methodName + " references non existant argument");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.AuditComponent#beforeMethodCallManualAudit(org.aopalliance.intercept.MethodInvocation)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void beforeMethodCallManualAudit(Class clazz, Object target, String methodName, Object ... args)
|
||||
{
|
||||
Class[] argTypes = new Class[args.length];
|
||||
for(int i = 0; i < args.length; i++)
|
||||
{
|
||||
argTypes[i] = args[i].getClass();
|
||||
}
|
||||
Method method;
|
||||
try
|
||||
{
|
||||
method = clazz.getMethod(methodName, argTypes);
|
||||
}
|
||||
catch (SecurityException e1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
catch (NoSuchMethodException e1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
MethodInvocation methodInvocation = new ReflectiveMethodInvocation(null, target, method, args, null, null) {};
|
||||
if ((auditFlag.get() == null) || (!auditFlag.get().booleanValue()))
|
||||
{
|
||||
if (auditModel instanceof AuditEntry && ((AuditEntry) auditModel).getEnabled() == TrueFalseUnset.TRUE)
|
||||
{
|
||||
boolean auditInternal = (auditModel.getAuditInternalServiceMethods(methodInvocation) == TrueFalseUnset.TRUE);
|
||||
try
|
||||
{
|
||||
String serviceName = publicServiceIdentifier.getPublicServiceName(methodInvocation);
|
||||
|
||||
if (!auditInternal)
|
||||
{
|
||||
auditFlag.set(Boolean.TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Auditing internal service use for - " + serviceName + "." + methodName);
|
||||
}
|
||||
}
|
||||
|
||||
if (method.isAnnotationPresent(Auditable.class))
|
||||
{
|
||||
|
||||
if (serviceName != null)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Auditing - " + serviceName + "." + methodName);
|
||||
}
|
||||
try
|
||||
{
|
||||
auditImpl(methodInvocation, false);
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("UnknownService." + methodName);
|
||||
}
|
||||
try
|
||||
{
|
||||
auditImpl(methodInvocation, false);
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if (method.isAnnotationPresent(NotAuditable.class))
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Not Audited. " + serviceName + "." + methodName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Unannotated service method " + serviceName + "." + methodName);
|
||||
}
|
||||
if (method.getDeclaringClass().isInterface() && method.getDeclaringClass().isAnnotationPresent(PublicService.class))
|
||||
{
|
||||
throw new RuntimeException("Unannotated service method " + serviceName + "." + methodName);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!auditInternal)
|
||||
{
|
||||
auditFlag.set(Boolean.FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A simple audit entry Currently we ignore filtering here.
|
||||
*/
|
||||
public void audit(String source, String description, NodeRef key, Object... args)
|
||||
{
|
||||
final AuditState auditInfo = new AuditState(auditConfiguration);
|
||||
AuditMode auditMode = AuditMode.UNSET;
|
||||
try
|
||||
{
|
||||
auditMode = onApplicationAudit(auditMode, auditInfo, source, description, key, args);
|
||||
if ((auditMode == AuditMode.ALL) || (auditMode == AuditMode.SUCCESS))
|
||||
{
|
||||
RetryingTransactionCallback<Object> cb = new RetryingTransactionCallback<Object>()
|
||||
{
|
||||
public Object execute() throws Throwable
|
||||
{
|
||||
auditDAO.audit(auditInfo);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
transactionService.getRetryingTransactionHelper().doInTransaction(cb, false, false);
|
||||
}
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
auditMode = onError(auditMode, auditInfo, t, source, description, key, args);
|
||||
if ((auditMode == AuditMode.ALL) || (auditMode == AuditMode.FAIL))
|
||||
{
|
||||
try
|
||||
{
|
||||
RetryingTransactionCallback<Object> cb = new RetryingTransactionCallback<Object>()
|
||||
{
|
||||
public Object execute() throws Throwable
|
||||
{
|
||||
auditDAO.audit(auditInfo);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
transactionService.getRetryingTransactionHelper().doInTransaction(cb, false, true);
|
||||
}
|
||||
catch (Throwable tt)
|
||||
{
|
||||
throw new AuditException("Failed to audit exception", new Object[] { tt }, t);
|
||||
}
|
||||
}
|
||||
throw new AuditException("Application audit failed", t);
|
||||
}
|
||||
}
|
||||
|
||||
public List<AuditInfo> getAuditTrail(NodeRef nodeRef)
|
||||
{
|
||||
return auditDAO.getAuditTrail(nodeRef);
|
||||
}
|
||||
|
||||
private AuditMode onApplicationAudit(AuditMode auditMode, AuditState auditInfo, String source, String description, NodeRef key, Object... args)
|
||||
{
|
||||
AuditMode effectiveAuditMode = auditModel.beforeExecution(auditMode, source, description, key, args);
|
||||
auditModel.getAuditRecordOptions(source);
|
||||
if (auditMode != AuditMode.NONE)
|
||||
{
|
||||
if (source.equals(SYSTEM_APPLICATION))
|
||||
{
|
||||
throw new AuditException("Application audit can not use the reserved identifier " + SYSTEM_APPLICATION);
|
||||
}
|
||||
|
||||
auditInfo.setAuditApplication(source);
|
||||
auditInfo.setAuditConfiguration(auditConfiguration);
|
||||
auditInfo.setAuditMethod(null);
|
||||
auditInfo.setAuditService(null);
|
||||
auditInfo.setClientAddress(null);
|
||||
auditInfo.setDate(new Date());
|
||||
auditInfo.setFail(false);
|
||||
auditInfo.setFiltered(false);
|
||||
auditInfo.setHostAddress(auditHost);
|
||||
auditInfo.setPath(null);
|
||||
if (key != null)
|
||||
{
|
||||
auditInfo.setKeyStore(key.getStoreRef());
|
||||
auditInfo.setKeyGUID(key.getId());
|
||||
RecordOptions recordOptions = auditModel.getAuditRecordOptions(source);
|
||||
if (recordOptions != null && recordOptions.getRecordPath() == TrueFalseUnset.TRUE)
|
||||
{
|
||||
auditInfo.setPath(getNodePath(key));
|
||||
}
|
||||
}
|
||||
auditInfo.setKeyPropertiesAfter(null);
|
||||
auditInfo.setKeyPropertiesBefore(null);
|
||||
auditInfo.setMessage(description);
|
||||
if (args != null)
|
||||
{
|
||||
Serializable[] serArgs = new Serializable[args.length];
|
||||
for (int i = 0; i < args.length; i++)
|
||||
{
|
||||
if (args[i] == null)
|
||||
{
|
||||
serArgs[i] = null;
|
||||
}
|
||||
else if (args[i] instanceof Serializable)
|
||||
{
|
||||
serArgs[i] = (Serializable) args[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
serArgs[i] = args[i].toString();
|
||||
}
|
||||
}
|
||||
auditInfo.setMethodArguments(serArgs);
|
||||
}
|
||||
auditInfo.setReturnObject(null);
|
||||
auditInfo.setSessionId(null);
|
||||
auditInfo.setThrowable(null);
|
||||
auditInfo.setTxId(AlfrescoTransactionSupport.getTransactionId());
|
||||
auditInfo.setUserIdentifier(AuthenticationUtil.getFullyAuthenticatedUser());
|
||||
}
|
||||
|
||||
return effectiveAuditMode;
|
||||
}
|
||||
|
||||
private AuditMode onError(AuditMode auditMode, AuditState auditInfo, Throwable t, String source, String description, NodeRef key, Object... args)
|
||||
{
|
||||
if ((auditMode == AuditMode.ALL) || (auditMode == AuditMode.FAIL))
|
||||
{
|
||||
auditInfo.setFail(true);
|
||||
auditInfo.setThrowable(t);
|
||||
}
|
||||
|
||||
return auditMode;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns human readable path for node.
|
||||
* To improve performance may return simple toString() method of the path.
|
||||
*
|
||||
* @param nodeRef
|
||||
* @return Human readable path for node
|
||||
*/
|
||||
private String getNodePath(NodeRef nodeRef)
|
||||
{
|
||||
String result = null;
|
||||
if (nodeService.exists(nodeRef))
|
||||
{
|
||||
Path path = nodeService.getPath(nodeRef);
|
||||
return path.toPrefixString(namespacePrefixResolver);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* V3.2 from here on. Put all fixes to the older audit code before this point, please.
|
||||
*/
|
||||
|
||||
private AuditModelRegistry auditModelRegistry;
|
||||
private PropertyValueDAO propertyValueDAO;
|
||||
|
||||
/**
|
||||
* Set the registry holding the audit models
|
||||
* @since 3.2
|
||||
@@ -899,6 +90,23 @@ public class AuditComponentImpl implements AuditComponent
|
||||
this.propertyValueDAO = propertyValueDAO;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the DAO for accessing audit data
|
||||
* @since 3.2
|
||||
*/
|
||||
public void setAuditDAO(AuditDAO auditDAO)
|
||||
{
|
||||
this.auditDAO = auditDAO;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the service used to start new transactions
|
||||
*/
|
||||
public void setTransactionService(TransactionService transactionService)
|
||||
{
|
||||
this.transactionService = transactionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @since 3.2
|
||||
|
@@ -1,105 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.audit;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.context.ResourceLoaderAware;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
|
||||
/**
|
||||
* A class to read the audit configuration from the class path
|
||||
*
|
||||
* @author Andy Hind
|
||||
*/
|
||||
public class AuditConfigurationImpl implements AuditConfiguration, ResourceLoaderAware
|
||||
{
|
||||
private static Log logger = LogFactory.getLog(AuditConfigurationImpl.class);
|
||||
private static long STARTUP_TIME = System.currentTimeMillis();
|
||||
|
||||
private String config;
|
||||
|
||||
private ResourceLoader resourceLoader;
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*
|
||||
*/
|
||||
public AuditConfigurationImpl()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the audit config
|
||||
*
|
||||
* @param config
|
||||
*/
|
||||
public void setConfig(String config)
|
||||
{
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
private Resource getResource()
|
||||
{
|
||||
return this.resourceLoader.getResource(config);
|
||||
}
|
||||
|
||||
public InputStream getInputStream()
|
||||
{
|
||||
try
|
||||
{
|
||||
return getResource().getInputStream();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
logger.warn("Unable to resolve " + config + " as input stream", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see
|
||||
* org.springframework.context.ResourceLoaderAware#setResourceLoader(org.springframework.core.io.ResourceLoader)
|
||||
*/
|
||||
public void setResourceLoader(ResourceLoader resourceLoader)
|
||||
{
|
||||
this.resourceLoader = resourceLoader;
|
||||
}
|
||||
|
||||
public long getLastModified()
|
||||
{
|
||||
try
|
||||
{
|
||||
return getResource().getFile().lastModified();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Not all resources can be resolved to files on the filesystem. If this is the case, just return the time
|
||||
// the server was last started
|
||||
return STARTUP_TIME;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,503 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.audit;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* A class to encapsulate audit information supplied to the DAO layer.
|
||||
*
|
||||
* Null entries should be stored.
|
||||
*
|
||||
* @author Andy Hind
|
||||
*/
|
||||
public class AuditInfo
|
||||
{
|
||||
private static Log s_logger = LogFactory.getLog(AuditInfo.class);
|
||||
|
||||
/**
|
||||
* The user identifier for the person who caused this audit entry
|
||||
*/
|
||||
private String userIdentifier;
|
||||
|
||||
/**
|
||||
* The date for this audit entry
|
||||
*/
|
||||
private Date date;
|
||||
|
||||
/**
|
||||
* The transaction id in which this entry was made
|
||||
*/
|
||||
private String txId;
|
||||
|
||||
/**
|
||||
* The session is for this action
|
||||
*/
|
||||
private String sessionId;
|
||||
|
||||
/**
|
||||
* The store in which the action occured.
|
||||
*/
|
||||
private StoreRef keyStore;
|
||||
|
||||
/**
|
||||
* For a node ref, the node for the action.
|
||||
*/
|
||||
private String keyGUID;
|
||||
|
||||
/**
|
||||
* The path of the key
|
||||
*/
|
||||
private String keyPath;
|
||||
|
||||
/**
|
||||
* The audit application
|
||||
* Internal uses the "System" key and will only audit method information.
|
||||
*/
|
||||
private String auditApplication;
|
||||
|
||||
/**
|
||||
* The service holding the audited method.
|
||||
*/
|
||||
private String auditService;
|
||||
|
||||
/**
|
||||
* The name of the audited method.
|
||||
*/
|
||||
private String auditMethod;
|
||||
|
||||
/**
|
||||
* Did this entry passa filter?
|
||||
* If false - all entries were being recorded.
|
||||
*/
|
||||
private boolean filtered;
|
||||
|
||||
/**
|
||||
* The audit configuration in use at the time.
|
||||
*/
|
||||
private AuditConfiguration auditConfiguration;
|
||||
|
||||
/**
|
||||
* The object returned by the audited method.
|
||||
*/
|
||||
private Serializable returnObject;
|
||||
|
||||
/**
|
||||
* The arguments to the audited method.
|
||||
*/
|
||||
private Serializable[] methodArguments;
|
||||
|
||||
/**
|
||||
* Any Exception thrown by the audited method.
|
||||
*/
|
||||
private Throwable throwable;
|
||||
|
||||
/**
|
||||
* Did the audited method throw an exception?
|
||||
*/
|
||||
private boolean fail;
|
||||
|
||||
/**
|
||||
* The host address for where the audit was generated.
|
||||
*/
|
||||
private InetAddress hostAddress;
|
||||
|
||||
private static InetAddress s_hostAddress;
|
||||
|
||||
/**
|
||||
* The client address causing the audit
|
||||
*/
|
||||
private InetAddress clientAddress;
|
||||
|
||||
/**
|
||||
* The properties of the key node before the method execution.
|
||||
*/
|
||||
private Map<QName, Serializable> keyPropertiesBefore;
|
||||
|
||||
/**
|
||||
* The properties of the key node after the method execution.
|
||||
*/
|
||||
private Map<QName, Serializable> keyPropertiesAfter;
|
||||
|
||||
/**
|
||||
* For general auditing - the audit message.
|
||||
*/
|
||||
private String message;
|
||||
|
||||
static
|
||||
{
|
||||
try
|
||||
{
|
||||
s_hostAddress = InetAddress.getLocalHost();
|
||||
}
|
||||
catch (UnknownHostException e)
|
||||
{
|
||||
s_logger.error(e);
|
||||
s_hostAddress = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the default audit info from the audit configuration.
|
||||
*
|
||||
* @param auditConfiguration
|
||||
*/
|
||||
public AuditInfo(AuditConfiguration auditConfiguration)
|
||||
{
|
||||
super();
|
||||
// Add default information
|
||||
userIdentifier = AuthenticationUtil.getFullyAuthenticatedUser();
|
||||
date = new Date();
|
||||
txId = AlfrescoTransactionSupport.getTransactionId();
|
||||
sessionId = "Unavailable";
|
||||
hostAddress = s_hostAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the audited application.
|
||||
*
|
||||
* @return - the name of the audited application.
|
||||
*/
|
||||
public String getAuditApplication()
|
||||
{
|
||||
return auditApplication;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name of the audited application.
|
||||
*
|
||||
* @param auditApplication
|
||||
*/
|
||||
public void setAuditApplication(String auditApplication)
|
||||
{
|
||||
this.auditApplication = auditApplication;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the audit configuration.
|
||||
*
|
||||
* @return - the audit configuration.
|
||||
*/
|
||||
public AuditConfiguration getAuditConfiguration()
|
||||
{
|
||||
return auditConfiguration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the audit configuration.
|
||||
*
|
||||
* @param auditConfiguration
|
||||
*/
|
||||
public void setAuditConfiguration(AuditConfiguration auditConfiguration)
|
||||
{
|
||||
this.auditConfiguration = auditConfiguration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the audited method - if it makes sense in the uadited context.
|
||||
*
|
||||
* @return - the name of the audited method or null
|
||||
*/
|
||||
public String getAuditMethod()
|
||||
{
|
||||
return auditMethod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name of the audited method.
|
||||
*
|
||||
* @param auditMethod
|
||||
*/
|
||||
public void setAuditMethod(String auditMethod)
|
||||
{
|
||||
this.auditMethod = auditMethod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the audit service.
|
||||
*
|
||||
* @return - the audit service.
|
||||
*/
|
||||
public String getAuditService()
|
||||
{
|
||||
return auditService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the audit service (IOC)
|
||||
*
|
||||
* @param auditService
|
||||
*/
|
||||
public void setAuditService(String auditService)
|
||||
{
|
||||
this.auditService = auditService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the address o which the client application is running if available
|
||||
* @return - the address or null.
|
||||
*/
|
||||
public InetAddress getClientAddress()
|
||||
{
|
||||
return clientAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the client address that casued the audit.
|
||||
* @param clientAddress
|
||||
*/
|
||||
public void setClientAddress(InetAddress clientAddress)
|
||||
{
|
||||
this.clientAddress = clientAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the date for the audit entry/
|
||||
*
|
||||
* @return - the date for the audit entry.
|
||||
*/
|
||||
public Date getDate()
|
||||
{
|
||||
return date;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the date for the audit entry
|
||||
* @param date
|
||||
*/
|
||||
public void setDate(Date date)
|
||||
{
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this an audit of a failed method invocation?
|
||||
* @return - true if the audited methoed threw any kind of exception.
|
||||
*/
|
||||
public boolean isFail()
|
||||
{
|
||||
return fail;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set that this is an audit of a failed method invoation.
|
||||
*
|
||||
* @param fail
|
||||
*/
|
||||
public void setFail(boolean fail)
|
||||
{
|
||||
this.fail = fail;
|
||||
}
|
||||
|
||||
/**
|
||||
* Could some audit information have been filtered?
|
||||
* If true there may have been some unaudited operations of the same type.
|
||||
*
|
||||
* @return - true if there were any filter definitions in the audit model; false otherwise.
|
||||
*/
|
||||
public boolean isFiltered()
|
||||
{
|
||||
return filtered;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set if a filter was present for this audit entry
|
||||
*
|
||||
* @param filtered
|
||||
*/
|
||||
public void setFiltered(boolean filtered)
|
||||
{
|
||||
this.filtered = filtered;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the host address where the repository is running.
|
||||
* @return - the host address.
|
||||
*/
|
||||
public InetAddress getHostAddress()
|
||||
{
|
||||
return hostAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the host address where the repository is running.
|
||||
* @param hostAddress
|
||||
*/
|
||||
public void setHostAddress(InetAddress hostAddress)
|
||||
{
|
||||
this.hostAddress = hostAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the GUID for the key node ref
|
||||
* @return - the guid part of the node ref
|
||||
*/
|
||||
public String getKeyGUID()
|
||||
{
|
||||
return keyGUID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the GUID for the key node ref in the audited method invoation.
|
||||
* @param keyGUID
|
||||
*/
|
||||
public void setKeyGUID(String keyGUID)
|
||||
{
|
||||
this.keyGUID = keyGUID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the properies of the key node after the method invoation.
|
||||
* @return - the properties to be stored in the audit trail
|
||||
*/
|
||||
public Map<QName, Serializable> getKeyPropertiesAfter()
|
||||
{
|
||||
return keyPropertiesAfter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the preperties to be stored in the audit trail for the key node ref after the audited method has been invoked.
|
||||
* @param keyPropertiesAfter
|
||||
*/
|
||||
public void setKeyPropertiesAfter(Map<QName, Serializable> keyPropertiesAfter)
|
||||
{
|
||||
this.keyPropertiesAfter = keyPropertiesAfter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the properies of the key node before the method invoation.
|
||||
* @return - the properties to be stored in the audit trail
|
||||
*/
|
||||
public Map<QName, Serializable> getKeyPropertiesBefore()
|
||||
{
|
||||
return keyPropertiesBefore;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the preperties to be stored in the audit trail for the key node ref before the audited method has been invoked.
|
||||
* @param keyPropertiesAfter
|
||||
*/
|
||||
public void setKeyPropertiesBefore(Map<QName, Serializable> keyPropertiesBefore)
|
||||
{
|
||||
this.keyPropertiesBefore = keyPropertiesBefore;
|
||||
}
|
||||
|
||||
public StoreRef getKeyStore()
|
||||
{
|
||||
return keyStore;
|
||||
}
|
||||
|
||||
public void setKeyStore(StoreRef keyStore)
|
||||
{
|
||||
this.keyStore = keyStore;
|
||||
}
|
||||
|
||||
public String getMessage()
|
||||
{
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message)
|
||||
{
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Serializable[] getMethodArguments()
|
||||
{
|
||||
return methodArguments;
|
||||
}
|
||||
|
||||
public void setMethodArguments(Serializable[] methodArguments)
|
||||
{
|
||||
this.methodArguments = methodArguments;
|
||||
}
|
||||
|
||||
public String getPath()
|
||||
{
|
||||
return keyPath;
|
||||
}
|
||||
|
||||
public void setPath(String keyPath)
|
||||
{
|
||||
this.keyPath = keyPath;
|
||||
}
|
||||
|
||||
public Serializable getReturnObject()
|
||||
{
|
||||
return returnObject;
|
||||
}
|
||||
|
||||
public void setReturnObject(Serializable returnObject)
|
||||
{
|
||||
this.returnObject = returnObject;
|
||||
}
|
||||
|
||||
public String getSessionId()
|
||||
{
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
public void setSessionId(String sessionId)
|
||||
{
|
||||
this.sessionId = sessionId;
|
||||
}
|
||||
|
||||
public Throwable getThrowable()
|
||||
{
|
||||
return throwable;
|
||||
}
|
||||
|
||||
public void setThrowable(Throwable throwable)
|
||||
{
|
||||
this.throwable = throwable;
|
||||
}
|
||||
|
||||
public String getTxId()
|
||||
{
|
||||
return txId;
|
||||
}
|
||||
|
||||
public void setTxId(String txId)
|
||||
{
|
||||
this.txId = txId;
|
||||
}
|
||||
|
||||
public String getUserIdentifier()
|
||||
{
|
||||
return userIdentifier;
|
||||
}
|
||||
|
||||
public void setUserIdentifier(String userIdentifier)
|
||||
{
|
||||
this.userIdentifier = userIdentifier;
|
||||
}
|
||||
|
||||
}
|
@@ -92,9 +92,6 @@ public class AuditMethodInterceptor implements MethodInterceptor
|
||||
private AuditComponent auditComponent;
|
||||
private TransactionService transactionService;
|
||||
|
||||
// SysAdmin cache - used to cluster certain configuration parameters
|
||||
private boolean useNewConfig = false;
|
||||
|
||||
private final ThreadLocal<Boolean> inAudit = new ThreadLocal<Boolean>();
|
||||
|
||||
public AuditMethodInterceptor()
|
||||
@@ -109,7 +106,7 @@ public class AuditMethodInterceptor implements MethodInterceptor
|
||||
*/
|
||||
public void setUseNewConfig(boolean useNewConfig)
|
||||
{
|
||||
this.useNewConfig = useNewConfig;
|
||||
logger.warn("Property 'useNewConfig' is no longer used.");
|
||||
}
|
||||
|
||||
public void setPublicServiceIdentifier(PublicServiceIdentifier serviceIdentifier)
|
||||
@@ -160,7 +157,7 @@ public class AuditMethodInterceptor implements MethodInterceptor
|
||||
// If we are already in a nested audit call, there is nothing to do
|
||||
if (wasInAudit != null)
|
||||
{
|
||||
return useNewConfig ? mi.proceed() : auditComponent.audit(mi);
|
||||
return mi.proceed();
|
||||
}
|
||||
|
||||
// If there are no mapped paths, there is nothing to do
|
||||
@@ -168,14 +165,14 @@ public class AuditMethodInterceptor implements MethodInterceptor
|
||||
{
|
||||
// We can ignore the rest of the stack too
|
||||
inAudit.set(Boolean.TRUE);
|
||||
return useNewConfig ? mi.proceed() : auditComponent.audit(mi);
|
||||
return mi.proceed();
|
||||
}
|
||||
|
||||
Auditable auditableDef = mi.getMethod().getAnnotation(Auditable.class);
|
||||
if (auditableDef == null)
|
||||
{
|
||||
// No annotation, so just continue as normal
|
||||
return useNewConfig ? mi.proceed() : auditComponent.audit(mi);
|
||||
return mi.proceed();
|
||||
}
|
||||
|
||||
// First get the argument map, if present
|
||||
@@ -186,7 +183,7 @@ public class AuditMethodInterceptor implements MethodInterceptor
|
||||
if (serviceName == null)
|
||||
{
|
||||
// Not a public service
|
||||
return useNewConfig ? mi.proceed() : auditComponent.audit(mi);
|
||||
return mi.proceed();
|
||||
}
|
||||
String methodName = mi.getMethod().getName();
|
||||
|
||||
@@ -225,7 +222,7 @@ public class AuditMethodInterceptor implements MethodInterceptor
|
||||
Throwable thrown = null;
|
||||
try
|
||||
{
|
||||
ret = useNewConfig ? mi.proceed() : auditComponent.audit(mi);
|
||||
ret = mi.proceed();
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
|
@@ -1,98 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.audit;
|
||||
|
||||
import org.alfresco.repo.audit.model.AuditModelException;
|
||||
|
||||
/**
|
||||
* An enum to specify the audit mode:
|
||||
*
|
||||
* <ol>
|
||||
* <li> ALL - all calls are audited
|
||||
* <li> SUCCESS - only successful calls are audited (audited in the same TX)
|
||||
* <li> FAIL - only fail calls are audited (in a new transaction)
|
||||
* <li> NONE - noting is audited
|
||||
* <li> UNSET
|
||||
* </ol>
|
||||
*
|
||||
* The mode is inherited from containers if nothing is specified
|
||||
*
|
||||
* @author Andy Hind
|
||||
*/
|
||||
public enum AuditMode
|
||||
{
|
||||
/**
|
||||
* All
|
||||
*/
|
||||
ALL,
|
||||
|
||||
/**
|
||||
* Only success
|
||||
*/
|
||||
SUCCESS,
|
||||
|
||||
/**
|
||||
* Only exceptions/failures
|
||||
*/
|
||||
FAIL,
|
||||
|
||||
/**
|
||||
* Nothing
|
||||
*/
|
||||
NONE,
|
||||
|
||||
/**
|
||||
* Don't know
|
||||
*/
|
||||
UNSET;
|
||||
|
||||
/**
|
||||
* Parse the audit mode from a string
|
||||
*
|
||||
* @param value
|
||||
* @return - the audit mode.
|
||||
*/
|
||||
public static AuditMode getAuditMode(String value)
|
||||
{
|
||||
if(value.equalsIgnoreCase("all"))
|
||||
{
|
||||
return AuditMode.ALL;
|
||||
}
|
||||
else if(value.equalsIgnoreCase("success"))
|
||||
{
|
||||
return AuditMode.SUCCESS;
|
||||
}
|
||||
else if(value.equalsIgnoreCase("fail"))
|
||||
{
|
||||
return AuditMode.FAIL;
|
||||
}
|
||||
else if(value.equalsIgnoreCase("none"))
|
||||
{
|
||||
return AuditMode.NONE;
|
||||
}
|
||||
else if(value.equalsIgnoreCase("unset"))
|
||||
{
|
||||
return AuditMode.UNSET;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new AuditModelException("Invalid audit mode: "+value);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.audit;
|
||||
|
||||
|
||||
/**
|
||||
* API for querying the audit model
|
||||
*
|
||||
* @author Andy Hind
|
||||
*/
|
||||
public interface AuditModel extends ApplicationAuditModel, MethodAuditModel
|
||||
{
|
||||
/**
|
||||
* Constants for reading the xml model definition.
|
||||
*/
|
||||
|
||||
/* package */final static String NAME_SPACE = "http://www.alfresco.org/model/audit/1.0";
|
||||
|
||||
/* package */final static String EL_AUDIT = "Audit";
|
||||
|
||||
/* package */final static String EL_RECORD_OPTIONS = "RecordOptions";
|
||||
|
||||
/* package */final static String EL_RECORD_PATH = "recordPath";
|
||||
|
||||
/* package */final static String EL_RECORD_FILTERS = "recordFilters";
|
||||
|
||||
/* package */final static String EL_RECORD_SER_RETURN_VAL = "recordSerializedReturnValue";
|
||||
|
||||
/* package */final static String EL_RECORD_SER_EX = "recordSerializedExceptions";
|
||||
|
||||
/* package */final static String EL_RECORD_SER_ARGS = "recordSerializedMethodArguments";
|
||||
|
||||
/* package */final static String EL_RECORD_SER_PROP_BEFORE = "recordSerializedKeyPropertiesBeforeInvocation";
|
||||
|
||||
/* package */final static String EL_RECORD_SER_PROP_AFTER = "recordSerializedKeyPropertiesAferInvocation";
|
||||
|
||||
/* package */final static String EL_FILTER = "Filter";
|
||||
|
||||
/* package */final static String EL_METHOD = "Method";
|
||||
|
||||
/* package */final static String EL_SERVICE = "Service";
|
||||
|
||||
/* package */final static String EL_APPLICATION = "Application";
|
||||
|
||||
/* package */final static String EL_EXPRESSION = "Expression";
|
||||
|
||||
/* package */final static String EL_PARAMETER_NAME = "ParameterName";
|
||||
|
||||
/* package */final static String AT_MODE = "mode";
|
||||
|
||||
/* package */final static String AT_ENABLED = "enabled";
|
||||
|
||||
/* package */final static String AT_AUDIT_INTERNAL = "auditInternal";
|
||||
|
||||
/* package */final static String AT_NAME = "name";
|
||||
|
||||
/* package */final static String AT_INVERT = "invert";
|
||||
|
||||
/* package */final static String AT_TYPE = "type";
|
||||
}
|
@@ -19,20 +19,10 @@
|
||||
package org.alfresco.repo.audit;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import javax.transaction.UserTransaction;
|
||||
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.service.cmr.audit.AuditInfo;
|
||||
import org.alfresco.service.cmr.audit.AuditQueryParameters;
|
||||
import org.alfresco.service.cmr.audit.AuditService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.util.ApplicationContextHelper;
|
||||
import org.springframework.extensions.surf.util.ParameterCheck;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
||||
/**
|
||||
* The implementation of the AuditService for application auditing.
|
||||
@@ -53,77 +43,6 @@ public class AuditServiceImpl implements AuditService
|
||||
this.auditComponent = auditComponent;
|
||||
}
|
||||
|
||||
public void audit(String source, String description)
|
||||
{
|
||||
auditComponent.audit(source, description, null, (Object[]) null);
|
||||
}
|
||||
|
||||
public void audit(String source, String description, NodeRef key)
|
||||
{
|
||||
auditComponent.audit(source, description, key, (Object[]) null);
|
||||
}
|
||||
|
||||
public void audit(String source, String description, Object... args)
|
||||
{
|
||||
auditComponent.audit(source, description, null, args);
|
||||
}
|
||||
|
||||
public void audit(String source, String description, NodeRef key, Object... args)
|
||||
{
|
||||
auditComponent.audit(source, description, key, args);
|
||||
}
|
||||
|
||||
public List<AuditInfo> getAuditTrail(NodeRef nodeRef)
|
||||
{
|
||||
return auditComponent.getAuditTrail(nodeRef);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception
|
||||
{
|
||||
|
||||
ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
|
||||
AuditService as = (AuditService) ctx.getBean("AuditService");
|
||||
|
||||
TransactionService txs = (TransactionService) ctx.getBean("transactionComponent");
|
||||
UserTransaction tx = txs.getUserTransaction();
|
||||
tx.begin();
|
||||
|
||||
AuthenticationUtil.setRunAsUserSystem();
|
||||
try
|
||||
{
|
||||
|
||||
NodeRef nodeRef = new NodeRef(new StoreRef("test", "audit"), "id");
|
||||
as.audit("AuditedApp", "First");
|
||||
System.out.println("Audit entries for node "+as.getAuditTrail(nodeRef).size());
|
||||
as.audit("AuditedApp", "Second", nodeRef);
|
||||
System.out.println("Audit entries for node "+as.getAuditTrail(nodeRef).size());
|
||||
as.audit("AuditedApp", "Third", new Object[] { "one", "two", "three" });
|
||||
System.out.println("Audit entries for node "+as.getAuditTrail(nodeRef).size());
|
||||
as.audit("AuditedApp", "Fourth",nodeRef, new Object[] { "one",
|
||||
"two", "three" });
|
||||
System.out.println("Audit entries for node "+as.getAuditTrail(nodeRef).size());
|
||||
as.audit("UnAuditedApp", "First");
|
||||
System.out.println("Audit entries for node "+as.getAuditTrail(nodeRef).size());
|
||||
as.audit("UnAuditedApp", "Second", nodeRef);
|
||||
System.out.println("Audit entries for node "+as.getAuditTrail(nodeRef).size());
|
||||
as.audit("UnAuditedApp", "Third", new Object[] { "one", "two", "three" });
|
||||
System.out.println("Audit entries for node "+as.getAuditTrail(nodeRef).size());
|
||||
as.audit("UnAuditedApp", "Fourth", nodeRef, new Object[] { "one",
|
||||
"two", "three" });
|
||||
System.out.println("Audit entries for node "+as.getAuditTrail(nodeRef).size());
|
||||
}
|
||||
finally
|
||||
{
|
||||
AuthenticationUtil.clearCurrentSecurityContext();
|
||||
}
|
||||
tx.commit();
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* V3.2 from here on. Put all fixes to the older audit code before this point, please.
|
||||
*/
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @since 3.2
|
||||
|
@@ -1,297 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.audit;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.audit.model.AuditEntry;
|
||||
import org.alfresco.repo.audit.model.TrueFalseUnset;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
|
||||
import org.alfresco.repo.security.permissions.PermissionServiceSPI;
|
||||
import org.alfresco.repo.security.permissions.impl.ModelDAO;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.audit.AuditInfo;
|
||||
import org.alfresco.service.cmr.audit.AuditService;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.security.AuthorityService;
|
||||
import org.alfresco.service.cmr.security.MutableAuthenticationService;
|
||||
import org.alfresco.service.cmr.security.PersonService;
|
||||
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.BaseSpringTest;
|
||||
|
||||
/**
|
||||
* @author Andy Hind
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class AuditServiceTest extends BaseSpringTest
|
||||
{
|
||||
|
||||
private NodeService nodeService;
|
||||
|
||||
private DictionaryService dictionaryService;
|
||||
|
||||
private PermissionServiceSPI permissionService;
|
||||
|
||||
private NamespacePrefixResolver namespacePrefixResolver;
|
||||
|
||||
private MutableAuthenticationService authenticationService;
|
||||
|
||||
private AuthenticationComponent authenticationComponent;
|
||||
|
||||
private ServiceRegistry serviceRegistry;
|
||||
|
||||
private ModelDAO permissionModelDAO;
|
||||
|
||||
private PersonService personService;
|
||||
|
||||
private AuthorityService authorityService;
|
||||
|
||||
private MutableAuthenticationDao authenticationDAO;
|
||||
|
||||
private NodeRef rootNodeRef;
|
||||
|
||||
private NodeRef systemNodeRef;
|
||||
|
||||
private AuditService auditService;
|
||||
|
||||
private AuditEntry auditEntry;
|
||||
|
||||
private NodeRef typesNodeRef;
|
||||
|
||||
private QName children;
|
||||
|
||||
private QName system;
|
||||
|
||||
private QName container;
|
||||
|
||||
private QName types;
|
||||
|
||||
public AuditServiceTest()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
protected void onSetUpInTransaction() throws Exception
|
||||
{
|
||||
nodeService = (NodeService) applicationContext.getBean("nodeService");
|
||||
dictionaryService = (DictionaryService) applicationContext.getBean(ServiceRegistry.DICTIONARY_SERVICE
|
||||
.getLocalName());
|
||||
permissionService = (PermissionServiceSPI) applicationContext.getBean("permissionService");
|
||||
namespacePrefixResolver = (NamespacePrefixResolver) applicationContext
|
||||
.getBean(ServiceRegistry.NAMESPACE_SERVICE.getLocalName());
|
||||
authenticationService = (MutableAuthenticationService) applicationContext.getBean("authenticationService");
|
||||
authenticationComponent = (AuthenticationComponent) applicationContext.getBean("authenticationComponent");
|
||||
serviceRegistry = (ServiceRegistry) applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY);
|
||||
permissionModelDAO = (ModelDAO) applicationContext.getBean("permissionsModelDAO");
|
||||
personService = (PersonService) applicationContext.getBean("personService");
|
||||
authorityService = (AuthorityService) applicationContext.getBean("authorityService");
|
||||
|
||||
authenticationComponent.setCurrentUser(authenticationComponent.getSystemUserName());
|
||||
authenticationDAO = (MutableAuthenticationDao) applicationContext.getBean("authenticationDao");
|
||||
|
||||
auditService = (AuditService) applicationContext.getBean("AuditService");
|
||||
auditEntry = (AuditEntry) applicationContext.getBean("auditModel");
|
||||
|
||||
StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.nanoTime());
|
||||
rootNodeRef = nodeService.getRootNode(storeRef);
|
||||
|
||||
children = ContentModel.ASSOC_CHILDREN;
|
||||
system = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "system");
|
||||
container = ContentModel.TYPE_CONTAINER;
|
||||
types = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "people");
|
||||
|
||||
systemNodeRef = nodeService.createNode(rootNodeRef, children, system, container).getChildRef();
|
||||
typesNodeRef = nodeService.createNode(systemNodeRef, children, types, container).getChildRef();
|
||||
Map<QName, Serializable> props = createPersonProperties("andy");
|
||||
nodeService.createNode(typesNodeRef, children, ContentModel.TYPE_PERSON, container, props).getChildRef();
|
||||
props = createPersonProperties("lemur");
|
||||
nodeService.createNode(typesNodeRef, children, ContentModel.TYPE_PERSON, container, props).getChildRef();
|
||||
|
||||
// create an authentication object e.g. the user
|
||||
if (authenticationDAO.userExists("andy"))
|
||||
{
|
||||
authenticationService.deleteAuthentication("andy");
|
||||
}
|
||||
authenticationService.createAuthentication("andy", "andy".toCharArray());
|
||||
|
||||
if (authenticationDAO.userExists("lemur"))
|
||||
{
|
||||
authenticationService.deleteAuthentication("lemur");
|
||||
}
|
||||
authenticationService.createAuthentication("lemur", "lemur".toCharArray());
|
||||
|
||||
if (authenticationDAO.userExists(AuthenticationUtil.getAdminUserName()))
|
||||
{
|
||||
authenticationService.deleteAuthentication(AuthenticationUtil.getAdminUserName());
|
||||
}
|
||||
authenticationService.createAuthentication(AuthenticationUtil.getAdminUserName(), "admin".toCharArray());
|
||||
|
||||
authenticationComponent.clearCurrentSecurityContext();
|
||||
}
|
||||
|
||||
public void testApplicationAudit()
|
||||
{
|
||||
AuthenticationUtil.setRunAsUserSystem();
|
||||
try
|
||||
{
|
||||
|
||||
NodeRef nodeRef = new NodeRef(new StoreRef("test", "audit"), "id");
|
||||
int start = auditService.getAuditTrail(nodeRef).size();
|
||||
int increment = auditEntry.getEnabled() == TrueFalseUnset.TRUE ? 1 : 0;
|
||||
auditService.audit("AuditedApp", "First");
|
||||
assertEquals(start, auditService.getAuditTrail(nodeRef).size());
|
||||
auditService.audit("AuditedApp", "Second", nodeRef);
|
||||
assertEquals(start + (1 * increment), auditService.getAuditTrail(nodeRef).size());
|
||||
auditService.audit("AuditedApp", "Third", new Object[] { "one", "two", "three" });
|
||||
assertEquals(start + (1 * increment), auditService.getAuditTrail(nodeRef).size());
|
||||
auditService.audit("AuditedApp", "Fourth", nodeRef, new Object[] { "one", "two", "three" });
|
||||
assertEquals(start + (2 * increment), auditService.getAuditTrail(nodeRef).size());
|
||||
auditService.audit("UnAuditedApp", "First");
|
||||
assertEquals(start + (2 * increment), auditService.getAuditTrail(nodeRef).size());
|
||||
auditService.audit("UnAuditedApp", "Second", nodeRef);
|
||||
assertEquals(start + (3 * increment), auditService.getAuditTrail(nodeRef).size());
|
||||
auditService.audit("UnAuditedApp", "Third", new Object[] { "one", "two", "three" });
|
||||
assertEquals(start + (3 * increment), auditService.getAuditTrail(nodeRef).size());
|
||||
auditService.audit("UnAuditedApp", "Fourth", nodeRef, new Object[] { "one", "two", "three" });
|
||||
assertEquals(start + (4 * increment), auditService.getAuditTrail(nodeRef).size());
|
||||
}
|
||||
finally
|
||||
{
|
||||
AuthenticationUtil.clearCurrentSecurityContext();
|
||||
}
|
||||
}
|
||||
|
||||
public void testNodeServiceAudit()
|
||||
{
|
||||
AuthenticationUtil.setRunAsUserSystem();
|
||||
try
|
||||
{
|
||||
int start = auditService.getAuditTrail(typesNodeRef).size();
|
||||
int increment = auditEntry.getEnabled() == TrueFalseUnset.TRUE ? 1 : 0;
|
||||
|
||||
// Create
|
||||
|
||||
Map<QName, Serializable> props = createPersonProperties("woof");
|
||||
NodeRef created = serviceRegistry.getNodeService().createNode(typesNodeRef, children,
|
||||
ContentModel.TYPE_PERSON, container, props).getChildRef();
|
||||
assertEquals(start + (1 * increment), auditService.getAuditTrail(typesNodeRef).size());
|
||||
List<AuditInfo> list = auditService.getAuditTrail(typesNodeRef);
|
||||
assertEquals((1 * increment), auditService.getAuditTrail(created).size());
|
||||
|
||||
// Update
|
||||
|
||||
serviceRegistry.getNodeService().setProperty(created, ContentModel.PROP_FIRSTNAME, "New First Name");
|
||||
assertEquals((2 * increment), auditService.getAuditTrail(created).size());
|
||||
|
||||
// Update
|
||||
|
||||
serviceRegistry.getNodeService().setProperty(created, ContentModel.PROP_FIRSTNAME, "Next First Name");
|
||||
assertEquals((3 * increment), auditService.getAuditTrail(created).size());
|
||||
|
||||
// Delete
|
||||
|
||||
serviceRegistry.getNodeService().deleteNode(created);
|
||||
assertEquals((4 * increment), auditService.getAuditTrail(created).size());
|
||||
|
||||
list = auditService.getAuditTrail(created);
|
||||
assertNotNull(list);
|
||||
}
|
||||
finally
|
||||
{
|
||||
AuthenticationUtil.clearCurrentSecurityContext();
|
||||
}
|
||||
}
|
||||
|
||||
public void xtestCreateStore()
|
||||
{
|
||||
|
||||
AuthenticationUtil.setRunAsUserSystem();
|
||||
try
|
||||
{
|
||||
serviceRegistry.getNodeService()
|
||||
.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_Audit_" + System.nanoTime());
|
||||
// Should have a query to support this - check direct in the DB
|
||||
}
|
||||
finally
|
||||
{
|
||||
AuthenticationUtil.clearCurrentSecurityContext();
|
||||
}
|
||||
setComplete();
|
||||
}
|
||||
|
||||
public void xtestAuthenticartionDoesNotReportPasswords()
|
||||
{
|
||||
// Should have a query to support this - check direct in the DB
|
||||
AuthenticationUtil.setRunAsUserSystem();
|
||||
try
|
||||
{
|
||||
serviceRegistry.getAuthenticationService().createAuthentication("cabbage", "cabbage".toCharArray());
|
||||
serviceRegistry.getAuthenticationService().updateAuthentication("cabbage", "cabbage".toCharArray(),
|
||||
"red".toCharArray());
|
||||
}
|
||||
finally
|
||||
{
|
||||
AuthenticationUtil.clearCurrentSecurityContext();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
serviceRegistry.getAuthenticationService().authenticate("cabbage", "red".toCharArray());
|
||||
}
|
||||
finally
|
||||
{
|
||||
serviceRegistry.getAuthenticationService().clearCurrentSecurityContext();
|
||||
}
|
||||
setComplete();
|
||||
}
|
||||
|
||||
public void xtestAuthenticartionFailure()
|
||||
{
|
||||
// Should have a query to support this - check direct in the DB
|
||||
AuthenticationUtil.setRunAsUserSystem();
|
||||
|
||||
serviceRegistry.getAuthenticationService().createAuthentication("woof", "cabbage".toCharArray());
|
||||
serviceRegistry.getAuthenticationService().authenticate("woof", "red".toCharArray());
|
||||
|
||||
}
|
||||
|
||||
public void testThereIsAnAuditService()
|
||||
{
|
||||
assertNotNull(serviceRegistry.getAuditService());
|
||||
}
|
||||
|
||||
private Map<QName, Serializable> createPersonProperties(String userName)
|
||||
{
|
||||
HashMap<QName, Serializable> properties = new HashMap<QName, Serializable>();
|
||||
properties.put(ContentModel.PROP_USERNAME, userName);
|
||||
return properties;
|
||||
}
|
||||
|
||||
}
|
@@ -1,388 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.audit;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* A class to encapsulate audit information supplied to the DAO layer.
|
||||
*
|
||||
* Null entries should be stored.
|
||||
*
|
||||
* @author Andy Hind
|
||||
*/
|
||||
public class AuditState
|
||||
{
|
||||
private static Log s_logger = LogFactory.getLog(AuditState.class);
|
||||
|
||||
/**
|
||||
* The user identifier for the person who caused this audit entry
|
||||
*/
|
||||
private String userIdentifier;
|
||||
|
||||
/**
|
||||
* The date for this audit entry
|
||||
*/
|
||||
private Date date;
|
||||
|
||||
/**
|
||||
* The transaction id in which this entry was made
|
||||
*/
|
||||
private String txId;
|
||||
|
||||
/**
|
||||
* The session is for this action
|
||||
*/
|
||||
private String sessionId;
|
||||
|
||||
/**
|
||||
* The store in which the action occured.
|
||||
*/
|
||||
private StoreRef keyStore;
|
||||
|
||||
/**
|
||||
* For a node ref, the node for the action.
|
||||
*/
|
||||
private String keyGUID;
|
||||
|
||||
/**
|
||||
* The path of the key
|
||||
*/
|
||||
private String keyPath;
|
||||
|
||||
/**
|
||||
* The audit application
|
||||
* Internal uses the "System" key and will only audit method information.
|
||||
*/
|
||||
private String auditApplication;
|
||||
|
||||
/**
|
||||
* The service holding the audited method.
|
||||
*/
|
||||
private String auditService;
|
||||
|
||||
/**
|
||||
* The name of the audited method.
|
||||
*/
|
||||
private String auditMethod;
|
||||
|
||||
/**
|
||||
* Did this entry passa filter?
|
||||
* If false - all entries were being recorded.
|
||||
*/
|
||||
private boolean filtered;
|
||||
|
||||
/**
|
||||
* The audit configuration in use at the time.
|
||||
*/
|
||||
private AuditConfiguration auditConfiguration;
|
||||
|
||||
/**
|
||||
* The object returned by the audited method.
|
||||
*/
|
||||
private Serializable returnObject;
|
||||
|
||||
/**
|
||||
* The arguments to the audited method.
|
||||
*/
|
||||
private Serializable[] methodArguments;
|
||||
|
||||
/**
|
||||
* Any Exception thrown by the audited method.
|
||||
*/
|
||||
private Throwable throwable;
|
||||
|
||||
/**
|
||||
* Did the audited method throw an exception?
|
||||
*/
|
||||
private boolean fail;
|
||||
|
||||
/**
|
||||
* The host address for where the audit was generated.
|
||||
*/
|
||||
private InetAddress hostAddress;
|
||||
|
||||
private static InetAddress s_hostAddress;
|
||||
|
||||
/**
|
||||
* The client address causing the audit
|
||||
*/
|
||||
private InetAddress clientAddress;
|
||||
|
||||
/**
|
||||
* The properties of the key node before the method execution.
|
||||
*/
|
||||
private Map<QName, Serializable> keyPropertiesBefore;
|
||||
|
||||
/**
|
||||
* The properties of the key node after the method execution.
|
||||
*/
|
||||
private Map<QName, Serializable> keyPropertiesAfter;
|
||||
|
||||
/**
|
||||
* For general auditing - the audit message.
|
||||
*/
|
||||
private String message;
|
||||
|
||||
static
|
||||
{
|
||||
try
|
||||
{
|
||||
s_hostAddress = InetAddress.getLocalHost();
|
||||
}
|
||||
catch (UnknownHostException e)
|
||||
{
|
||||
s_logger.error(e);
|
||||
s_hostAddress = null;
|
||||
}
|
||||
}
|
||||
|
||||
public AuditState(AuditConfiguration auditConfiguration)
|
||||
{
|
||||
super();
|
||||
// Add default information
|
||||
userIdentifier = AuthenticationUtil.getFullyAuthenticatedUser();
|
||||
date = new Date();
|
||||
txId = AlfrescoTransactionSupport.getTransactionId();
|
||||
sessionId = "Unavailable";
|
||||
hostAddress = s_hostAddress;
|
||||
}
|
||||
|
||||
public String getAuditApplication()
|
||||
{
|
||||
return auditApplication;
|
||||
}
|
||||
|
||||
public void setAuditApplication(String auditApplication)
|
||||
{
|
||||
this.auditApplication = auditApplication;
|
||||
}
|
||||
|
||||
public AuditConfiguration getAuditConfiguration()
|
||||
{
|
||||
return auditConfiguration;
|
||||
}
|
||||
|
||||
public void setAuditConfiguration(AuditConfiguration auditConfiguration)
|
||||
{
|
||||
this.auditConfiguration = auditConfiguration;
|
||||
}
|
||||
|
||||
public String getAuditMethod()
|
||||
{
|
||||
return auditMethod;
|
||||
}
|
||||
|
||||
public void setAuditMethod(String auditMethod)
|
||||
{
|
||||
this.auditMethod = auditMethod;
|
||||
}
|
||||
|
||||
public String getAuditService()
|
||||
{
|
||||
return auditService;
|
||||
}
|
||||
|
||||
public void setAuditService(String auditService)
|
||||
{
|
||||
this.auditService = auditService;
|
||||
}
|
||||
|
||||
public InetAddress getClientAddress()
|
||||
{
|
||||
return clientAddress;
|
||||
}
|
||||
|
||||
public void setClientAddress(InetAddress clientAddress)
|
||||
{
|
||||
this.clientAddress = clientAddress;
|
||||
}
|
||||
|
||||
public Date getDate()
|
||||
{
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(Date date)
|
||||
{
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public boolean isFail()
|
||||
{
|
||||
return fail;
|
||||
}
|
||||
|
||||
public void setFail(boolean fail)
|
||||
{
|
||||
this.fail = fail;
|
||||
}
|
||||
|
||||
public boolean isFiltered()
|
||||
{
|
||||
return filtered;
|
||||
}
|
||||
|
||||
public void setFiltered(boolean filtered)
|
||||
{
|
||||
this.filtered = filtered;
|
||||
}
|
||||
|
||||
public InetAddress getHostAddress()
|
||||
{
|
||||
return hostAddress;
|
||||
}
|
||||
|
||||
public void setHostAddress(InetAddress hostAddress)
|
||||
{
|
||||
this.hostAddress = hostAddress;
|
||||
}
|
||||
|
||||
public String getKeyGUID()
|
||||
{
|
||||
return keyGUID;
|
||||
}
|
||||
|
||||
public void setKeyGUID(String keyGUID)
|
||||
{
|
||||
this.keyGUID = keyGUID;
|
||||
}
|
||||
|
||||
public Map<QName, Serializable> getKeyPropertiesAfter()
|
||||
{
|
||||
return keyPropertiesAfter;
|
||||
}
|
||||
|
||||
public void setKeyPropertiesAfter(Map<QName, Serializable> keyPropertiesAfter)
|
||||
{
|
||||
this.keyPropertiesAfter = keyPropertiesAfter;
|
||||
}
|
||||
|
||||
public Map<QName, Serializable> getKeyPropertiesBefore()
|
||||
{
|
||||
return keyPropertiesBefore;
|
||||
}
|
||||
|
||||
public void setKeyPropertiesBefore(Map<QName, Serializable> keyPropertiesBefore)
|
||||
{
|
||||
this.keyPropertiesBefore = keyPropertiesBefore;
|
||||
}
|
||||
|
||||
public StoreRef getKeyStore()
|
||||
{
|
||||
return keyStore;
|
||||
}
|
||||
|
||||
public void setKeyStore(StoreRef keyStore)
|
||||
{
|
||||
this.keyStore = keyStore;
|
||||
}
|
||||
|
||||
public String getMessage()
|
||||
{
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message)
|
||||
{
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Serializable[] getMethodArguments()
|
||||
{
|
||||
return methodArguments;
|
||||
}
|
||||
|
||||
public void setMethodArguments(Serializable[] methodArguments)
|
||||
{
|
||||
this.methodArguments = methodArguments;
|
||||
}
|
||||
|
||||
public String getPath()
|
||||
{
|
||||
return keyPath;
|
||||
}
|
||||
|
||||
public void setPath(String keyPath)
|
||||
{
|
||||
this.keyPath = keyPath;
|
||||
}
|
||||
|
||||
public Serializable getReturnObject()
|
||||
{
|
||||
return returnObject;
|
||||
}
|
||||
|
||||
public void setReturnObject(Serializable returnObject)
|
||||
{
|
||||
this.returnObject = returnObject;
|
||||
}
|
||||
|
||||
public String getSessionId()
|
||||
{
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
public void setSessionId(String sessionId)
|
||||
{
|
||||
this.sessionId = sessionId;
|
||||
}
|
||||
|
||||
public Throwable getThrowable()
|
||||
{
|
||||
return throwable;
|
||||
}
|
||||
|
||||
public void setThrowable(Throwable throwable)
|
||||
{
|
||||
this.throwable = throwable;
|
||||
}
|
||||
|
||||
public String getTxId()
|
||||
{
|
||||
return txId;
|
||||
}
|
||||
|
||||
public void setTxId(String txId)
|
||||
{
|
||||
this.txId = txId;
|
||||
}
|
||||
|
||||
public String getUserIdentifier()
|
||||
{
|
||||
return userIdentifier;
|
||||
}
|
||||
|
||||
public void setUserIdentifier(String userIdentifier)
|
||||
{
|
||||
this.userIdentifier = userIdentifier;
|
||||
}
|
||||
|
||||
}
|
@@ -18,25 +18,25 @@
|
||||
*/
|
||||
package org.alfresco.repo.audit;
|
||||
|
||||
import java.io.InputStream;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* An audit configuration is xml content from an input stream.
|
||||
*
|
||||
* @author Andy Hind
|
||||
* Suite for audit-related tests.
|
||||
*
|
||||
* @author Derek Hulley
|
||||
* @since 3.4
|
||||
*/
|
||||
public interface AuditConfiguration
|
||||
public class AuditTestSuite extends TestSuite
|
||||
{
|
||||
/**
|
||||
* Get the XML content for the configuration as a stream.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
InputStream getInputStream();
|
||||
|
||||
/**
|
||||
* Return last modified time of the XML
|
||||
* @return path
|
||||
*/
|
||||
long getLastModified();
|
||||
}
|
||||
public static Test suite()
|
||||
{
|
||||
TestSuite suite = new TestSuite();
|
||||
|
||||
suite.addTestSuite(AuditableAspectTest.class);
|
||||
suite.addTestSuite(AuditBootstrapTest.class);
|
||||
suite.addTestSuite(AuditComponentTest.class);
|
||||
|
||||
return suite;
|
||||
}
|
||||
}
|
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.audit;
|
||||
|
||||
import org.alfresco.repo.audit.model.TrueFalseUnset;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
|
||||
/**
|
||||
* The audit model used to audit method calls.
|
||||
*
|
||||
* @author andyh
|
||||
*/
|
||||
public interface MethodAuditModel
|
||||
{
|
||||
/**
|
||||
* Report if audit behaviour can be determined before the method call
|
||||
*
|
||||
* @param auditMode
|
||||
* @param mi
|
||||
* @return - the audit mode
|
||||
*/
|
||||
public AuditMode beforeExecution(AuditMode auditMode, MethodInvocation mi);
|
||||
|
||||
/**
|
||||
* Report if audit behaviour can be determined after the method call
|
||||
*
|
||||
* @param auditMode
|
||||
* @param mi
|
||||
* @return - the audit mode
|
||||
*/
|
||||
public AuditMode afterExecution(AuditMode auditMode, MethodInvocation mi);
|
||||
|
||||
/**
|
||||
* Report if audit behaviour should be invoked on error. It could be we look at the error and filter - this filter is not
|
||||
* supported at the moment.
|
||||
*
|
||||
* @param auditMode
|
||||
* @param mi
|
||||
* @return - the audit mode
|
||||
*/
|
||||
public AuditMode onError(AuditMode auditMode, MethodInvocation mi);
|
||||
|
||||
/**
|
||||
* Get the optional parameters that are to be recorded
|
||||
*
|
||||
* @param mi
|
||||
* @return - what to record
|
||||
*/
|
||||
public RecordOptions getAuditRecordOptions(MethodInvocation mi);
|
||||
|
||||
/**
|
||||
* Deteine if internal calls to public service shoud be audited
|
||||
* @param mi
|
||||
* @return - mode
|
||||
*/
|
||||
public TrueFalseUnset getAuditInternalServiceMethods(MethodInvocation mi);
|
||||
}
|
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.audit;
|
||||
|
||||
import org.alfresco.repo.audit.model.TrueFalseUnset;
|
||||
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||
import org.dom4j.Element;
|
||||
|
||||
public interface RecordOptions
|
||||
{
|
||||
public TrueFalseUnset getRecordFilters();
|
||||
|
||||
public TrueFalseUnset getRecordPath();
|
||||
|
||||
public TrueFalseUnset getRecordSerializedExceptions();
|
||||
|
||||
public TrueFalseUnset getRecordSerializedKeyPropertiesAfterEvaluation();
|
||||
|
||||
public TrueFalseUnset getRecordSerializedKeyPropertiesBeforeEvaluation();
|
||||
|
||||
public TrueFalseUnset getRecordSerializedMethodArguments();
|
||||
|
||||
public TrueFalseUnset getRecordSerializedReturnValue();
|
||||
}
|
@@ -1,203 +0,0 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
|
||||
<!DOCTYPE hibernate-mapping PUBLIC
|
||||
'-//Hibernate/Hibernate Mapping DTD 3.0//EN'
|
||||
'http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd'>
|
||||
|
||||
<!-- Hibernate mapping for storing audit information -->
|
||||
<!-- -->
|
||||
<!-- This generates a simple star schema for audit -->
|
||||
<!-- breakdown and roll up. -->
|
||||
<!-- -->
|
||||
|
||||
<hibernate-mapping>
|
||||
|
||||
<!-- The fact -->
|
||||
|
||||
<class name="org.alfresco.repo.audit.hibernate.AuditFactImpl" proxy="org.alfresco.repo.audit.hibernate.AuditFact" table="alf_audit_fact" dynamic-update="false" dynamic-insert="false"
|
||||
select-before-update="false" lazy="true" optimistic-lock="version">
|
||||
|
||||
<!-- An auto-generated id -->
|
||||
<id name="id" column="id" type="long">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
|
||||
<!-- Fact properties -->
|
||||
|
||||
<property name="userId" column="user_id" type="string" length="255" not-null="true" index="idx_alf_adtf_usr"/>
|
||||
<property name="date" column="timestamp" type="timestamp" not-null="true"/>
|
||||
<property name="transactionId" column="transaction_id" type="string" length="56" not-null="true"/>
|
||||
<property name="sessionId" column="session_id" type="string" length="56" not-null="false"/>
|
||||
<property name="storeProtocol" column="store_protocol" type="string" length="50" not-null="false" index="idx_alf_adtf_ref"/>
|
||||
<property name="storeId" column="store_id" type="string" length="100" not-null="false" index="idx_alf_adtf_ref"/>
|
||||
<property name="nodeUUID" column="node_uuid" type="string" length="36" not-null="false" index="idx_alf_adtf_ref"/>
|
||||
<property name="path" column="path" type="string" length="512" not-null="false"/>
|
||||
<property name="filtered" column="filtered" type="boolean" not-null="true"/>
|
||||
<property name="returnValue" column="return_val" type="string" length="1024" not-null="false"/>
|
||||
<property name="arg1" column="arg_1" type="string" length="1024" not-null="false"/>
|
||||
<property name="arg2" column="arg_2" type="string" length="1024" not-null="false"/>
|
||||
<property name="arg3" column="arg_3" type="string" length="1024" not-null="false"/>
|
||||
<property name="arg4" column="arg_4" type="string" length="1024" not-null="false"/>
|
||||
<property name="arg5" column="arg_5" type="string" length="1024" not-null="false"/>
|
||||
<property name="fail" column="fail" type="boolean" not-null="true"/>
|
||||
<!-- TODO: Check the URL length ...-->
|
||||
<property name="serialisedURL" column="serialized_url" type="string" length="1024" not-null="false"/>
|
||||
<property name="exception" column="exception_message" type="string" length="1024" not-null="false"/>
|
||||
<property name="hostInetAddress" column="host_address" type="string" length="1024" not-null="false"/>
|
||||
<property name="clientInetAddress" column="client_address" type="string" length="1024" not-null="false"/>
|
||||
<property name="message" column="message_text" type="string" length="1024" not-null="false"/>
|
||||
|
||||
<!-- Links to dimensions -->
|
||||
|
||||
<many-to-one name="auditDate" class="org.alfresco.repo.audit.hibernate.AuditDateImpl" not-null="true" lazy="proxy" column="audit_date_id" foreign-key="fk_alf_adtf_date" cascade="none" optimistic-lock="true" fetch="join"/>
|
||||
<many-to-one name="auditConfig" class="org.alfresco.repo.audit.hibernate.AuditConfigImpl" not-null="true" lazy="proxy" column="audit_conf_id" foreign-key="fk_alf_adtf_conf" cascade="none" optimistic-lock="true" fetch="join"/>
|
||||
<many-to-one name="auditSource" class="org.alfresco.repo.audit.hibernate.AuditSourceImpl" not-null="true" lazy="proxy" column="audit_source_id" foreign-key="fk_alf_adtf_src" cascade="none" optimistic-lock="true" fetch="join"/>
|
||||
|
||||
</class>
|
||||
|
||||
<!-- The audit date dimension -->
|
||||
|
||||
<class name="org.alfresco.repo.audit.hibernate.AuditDateImpl" proxy="org.alfresco.repo.audit.hibernate.AuditDate" table="alf_audit_date" dynamic-update="false" dynamic-insert="false"
|
||||
select-before-update="false" lazy="true" optimistic-lock="version">
|
||||
|
||||
<!-- An auto-generated id -->
|
||||
<id name="id" column="id" type="long">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
|
||||
<!-- Date is used as the key for look up -->
|
||||
|
||||
<property name="date" column="date_only" type="date" index="idx_alf_adtd_dat" not-null="true"/>
|
||||
<property name="dayOfYear" column="day_of_year" type="integer" index="idx_alf_adtd_doy" not-null="true"/>
|
||||
<property name="dayOfMonth" column="day_of_month" type="integer" index="idx_alf_adtd_dom" not-null="true"/>
|
||||
<property name="dayOfWeek" column="day_of_week" type="integer" index="idx_alf_adtd_dow" not-null="true"/>
|
||||
<property name="weekOfYear" column="week_of_year" type="integer" index="idx_alf_adtd_woy" not-null="true"/>
|
||||
<property name="weekOfMonth" column="week_of_month" type="integer" index="idx_alf_adtd_wom" not-null="true"/>
|
||||
<property name="month" column="month" type="integer" index="idx_alf_adtd_m" not-null="true"/>
|
||||
<property name="quarter" column="quarter" type="integer" index="idx_alf_adtd_q" not-null="true"/>
|
||||
<property name="halfYear" column="half_year" type="integer" index="idx_alf_adtd_hy" not-null="true"/>
|
||||
<property name="fullYear" column="full_year" type="integer" index="idx_alf_adtd_fy" not-null="true"/>
|
||||
|
||||
</class>
|
||||
|
||||
<!-- The audit configuration dimension -->
|
||||
|
||||
<class name="org.alfresco.repo.audit.hibernate.AuditConfigImpl" proxy="org.alfresco.repo.audit.hibernate.AuditConfig" table="alf_audit_config" dynamic-update="false" dynamic-insert="false"
|
||||
select-before-update="false" lazy="true" optimistic-lock="version">
|
||||
|
||||
<!-- Max id is used to find the latest audit configuration -->
|
||||
|
||||
<!-- An auto-generated id -->
|
||||
<id name="id" column="id" type="long">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
|
||||
<property name="configURL" column="config_url" type="string" length="256" not-null="true"/>
|
||||
|
||||
</class>
|
||||
|
||||
<!-- The audit source dimension -->
|
||||
|
||||
<class name="org.alfresco.repo.audit.hibernate.AuditSourceImpl" proxy="org.alfresco.repo.audit.hibernate.AuditSource" table="alf_audit_source" dynamic-update="false" dynamic-insert="false"
|
||||
select-before-update="false" lazy="true" optimistic-lock="version">
|
||||
|
||||
<!-- An auto-generated id -->
|
||||
<id name="id" column="id" type="long">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
|
||||
<!-- The app_source_idx index is used to find the app source -->
|
||||
<!-- The look up is always the tripple, the service and method or just the method may be null -->
|
||||
|
||||
<property name="application" column="application" type="string" length="255" not-null="true" index="idx_alf_adts_app"/>
|
||||
<property name="service" column="service" type="string" length="255" not-null="false" index="idx_alf_adts_ser"/>
|
||||
<property name="method" column="method" type="string" length="255" not-null="false" index="idx_alf_adts_met"/>
|
||||
|
||||
</class>
|
||||
|
||||
<query name="audit.GetLatestAuditDate" cacheable="true">
|
||||
select
|
||||
audit_date
|
||||
from
|
||||
org.alfresco.repo.audit.hibernate.AuditDateImpl as audit_date
|
||||
where
|
||||
audit_date.id = (select max(audit_date_2.id) from org.alfresco.repo.audit.hibernate.AuditDateImpl as audit_date_2)
|
||||
</query>
|
||||
|
||||
<query name="audit.GetAuditDate" cacheable="true">
|
||||
select
|
||||
audit_date
|
||||
from
|
||||
org.alfresco.repo.audit.hibernate.AuditDateImpl as audit_date
|
||||
where
|
||||
audit_date.id = (select max(audit_date_2.id) from org.alfresco.repo.audit.hibernate.AuditDateImpl as audit_date_2 where audit_date_2.date = :date)
|
||||
</query>
|
||||
|
||||
<query name="audit.GetLatestAuditConfig" cacheable="true">
|
||||
select
|
||||
audit_config
|
||||
from
|
||||
org.alfresco.repo.audit.hibernate.AuditConfigImpl as audit_config
|
||||
where
|
||||
audit_config.id = (select max(audit_config_2.id) from org.alfresco.repo.audit.hibernate.AuditConfigImpl as audit_config_2)
|
||||
</query>
|
||||
|
||||
<query name="audit.GetAuditSourceByApplication" cacheable="true" >
|
||||
select
|
||||
audit_store_byid
|
||||
from
|
||||
org.alfresco.repo.audit.hibernate.AuditSourceImpl as audit_store_byid
|
||||
where
|
||||
audit_store_byid =
|
||||
(select max(audit_store.id)
|
||||
from
|
||||
org.alfresco.repo.audit.hibernate.AuditSourceImpl as audit_store
|
||||
where
|
||||
audit_store.application = :application and
|
||||
audit_store.service is null and
|
||||
audit_store.method is null)
|
||||
</query>
|
||||
|
||||
<query name="audit.GetAuditSourceByApplicationServiceMethod" cacheable="true" >
|
||||
select
|
||||
audit_store_byid
|
||||
from
|
||||
org.alfresco.repo.audit.hibernate.AuditSourceImpl as audit_store_byid
|
||||
where
|
||||
audit_store_byid =
|
||||
(select max(audit_store.id)
|
||||
from
|
||||
org.alfresco.repo.audit.hibernate.AuditSourceImpl as audit_store
|
||||
where
|
||||
audit_store.application = :application and
|
||||
audit_store.service = :service and
|
||||
audit_store.method = :method)
|
||||
</query>
|
||||
|
||||
<query name="audit.GetAuditTrailForNode">
|
||||
select
|
||||
audit_fact
|
||||
from
|
||||
org.alfresco.repo.audit.hibernate.AuditFactImpl as audit_fact
|
||||
where
|
||||
(audit_fact.storeProtocol = :protocol and
|
||||
audit_fact.storeId = :store_id and
|
||||
audit_fact.nodeUUID = :node_id)
|
||||
or
|
||||
arg1 like :nodeRef
|
||||
or
|
||||
arg2 like :nodeRef
|
||||
or
|
||||
arg3 like :nodeRef
|
||||
or
|
||||
arg4 like :nodeRef
|
||||
or
|
||||
arg5 like :nodeRef
|
||||
or
|
||||
returnValue like :nodeRef
|
||||
order by
|
||||
audit_fact.date asc
|
||||
</query>
|
||||
|
||||
|
||||
</hibernate-mapping>
|
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.audit.hibernate;
|
||||
|
||||
|
||||
/**
|
||||
* Hibernate interface for audit configuration persistence.
|
||||
*
|
||||
* @author Andy Hind
|
||||
*/
|
||||
public interface AuditConfig
|
||||
{
|
||||
/**
|
||||
* Get the content URL for a copy of the configuration file.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract String getConfigURL();
|
||||
|
||||
/**
|
||||
* Get the surrogate key for the configuration entry.
|
||||
* The creation is managed by hibernate.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract Long getId();
|
||||
}
|
@@ -1,111 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.audit.hibernate;
|
||||
|
||||
import org.alfresco.util.EqualsHelper;
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.Session;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
public class AuditConfigImpl implements AuditConfig, InitializingBean
|
||||
{
|
||||
/**
|
||||
* The hibernate generated internal key.
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* The URL to the content that contains the configuration file
|
||||
*/
|
||||
private String configURL;
|
||||
|
||||
public AuditConfigImpl()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditContig#getConfigURL()
|
||||
*/
|
||||
public String getConfigURL()
|
||||
{
|
||||
return configURL;
|
||||
}
|
||||
|
||||
public void setConfigURL(String configURL)
|
||||
{
|
||||
this.configURL = configURL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
// Read the audit configuration
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditContig#getId()
|
||||
*/
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal setter for hibernate.
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if(!(o instanceof AuditConfigImpl))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
AuditConfigImpl other = (AuditConfigImpl)o;
|
||||
return EqualsHelper.nullSafeEquals(this.configURL, other.configURL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return configURL == null ? 0 : configURL.hashCode();
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -1,85 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.audit.hibernate;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Hibernate date dimension for audit roll ups
|
||||
*
|
||||
* @author Andy Hind
|
||||
*/
|
||||
public interface AuditDate
|
||||
{
|
||||
/**
|
||||
* @return the date object
|
||||
*/
|
||||
public abstract Date getDate();
|
||||
|
||||
/**
|
||||
* @return the day of the year
|
||||
*/
|
||||
public abstract int getDayOfYear();
|
||||
|
||||
/**
|
||||
* @return the day of the month
|
||||
*/
|
||||
public abstract int getDayOfMonth();
|
||||
|
||||
/**
|
||||
* @return the day of the week
|
||||
*/
|
||||
public abstract int getDayOfWeek();
|
||||
|
||||
/**
|
||||
* @return the half year
|
||||
*/
|
||||
public abstract int getHalfYear();
|
||||
|
||||
|
||||
/**
|
||||
* @return the surrogate key
|
||||
*/
|
||||
public abstract Long getId();
|
||||
|
||||
/**
|
||||
* @return the month of the year
|
||||
*/
|
||||
public abstract int getMonth();
|
||||
|
||||
/**
|
||||
* @return the quarter in the year
|
||||
*/
|
||||
public abstract int getQuarter();
|
||||
|
||||
/**
|
||||
* @return the week of the month
|
||||
*/
|
||||
public abstract int getWeekOfMonth();
|
||||
|
||||
/**
|
||||
* @return the week of the year
|
||||
*/
|
||||
public abstract int getWeekOfYear();
|
||||
|
||||
/**
|
||||
* @return the full year
|
||||
*/
|
||||
public abstract int getFullYear();
|
||||
}
|
@@ -1,249 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.audit.hibernate;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
import org.alfresco.util.EqualsHelper;
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.Session;
|
||||
|
||||
/**
|
||||
* Hibernate persistence for a date dimension.
|
||||
*
|
||||
* @author Andy Hind
|
||||
*/
|
||||
public class AuditDateImpl implements AuditDate
|
||||
{
|
||||
/**
|
||||
* Surrogate key
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* The date
|
||||
*/
|
||||
private Date date;
|
||||
|
||||
/**
|
||||
* The day
|
||||
*/
|
||||
private int dayOfYear;
|
||||
|
||||
/**
|
||||
* Day of month.
|
||||
*/
|
||||
private int dayOfMonth;
|
||||
|
||||
/**
|
||||
* The day of the week
|
||||
*/
|
||||
private int dayOfWeek;
|
||||
|
||||
/**
|
||||
* The week in the year
|
||||
*/
|
||||
private int weekOfYear;
|
||||
|
||||
/**
|
||||
* The week of the month
|
||||
*/
|
||||
private int weekOfMonth;
|
||||
|
||||
/**
|
||||
* The month in the year
|
||||
*/
|
||||
private int month;
|
||||
|
||||
/**
|
||||
* The quarter in the year
|
||||
*/
|
||||
private int quarter;
|
||||
|
||||
/**
|
||||
* The half year in the year
|
||||
*/
|
||||
private int halfYear;
|
||||
|
||||
/**
|
||||
* The year
|
||||
*/
|
||||
private int fullYear;
|
||||
|
||||
protected AuditDateImpl()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public AuditDateImpl(Date date)
|
||||
{
|
||||
super();
|
||||
setDate(date);
|
||||
}
|
||||
|
||||
public Date getDate()
|
||||
{
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(Date date)
|
||||
{
|
||||
Calendar cal = GregorianCalendar.getInstance();
|
||||
cal.setTime(date);
|
||||
cal.set(Calendar.MILLISECOND, 0);
|
||||
cal.set(Calendar.SECOND, 0);
|
||||
cal.set(Calendar.MINUTE, 0);
|
||||
cal.set(Calendar.HOUR_OF_DAY, 0);
|
||||
this.date = cal.getTime();
|
||||
|
||||
this.setDayOfYear(cal.get(Calendar.DAY_OF_YEAR));
|
||||
this.setDayOfMonth(cal.get(Calendar.DAY_OF_MONTH));
|
||||
this.setDayOfWeek(cal.get(Calendar.DAY_OF_WEEK));
|
||||
this.setMonth(cal.get(Calendar.MONTH));
|
||||
this.setHalfYear(getMonth() <= Calendar.JUNE ? 0 : 1);
|
||||
this.setQuarter((getMonth()/3));
|
||||
this.setWeekOfMonth(cal.get(Calendar.WEEK_OF_MONTH));
|
||||
this.setWeekOfYear(cal.get(Calendar.WEEK_OF_YEAR));
|
||||
this.setFullYear(cal.get(Calendar.YEAR));
|
||||
}
|
||||
|
||||
public int getDayOfYear()
|
||||
{
|
||||
return dayOfYear;
|
||||
}
|
||||
|
||||
protected void setDayOfYear(int dayOfYear)
|
||||
{
|
||||
this.dayOfYear = dayOfYear;
|
||||
}
|
||||
|
||||
public int getDayOfMonth()
|
||||
{
|
||||
return dayOfMonth;
|
||||
}
|
||||
|
||||
protected void setDayOfMonth(int dayOfMonth)
|
||||
{
|
||||
this.dayOfMonth = dayOfMonth;
|
||||
}
|
||||
|
||||
public int getDayOfWeek()
|
||||
{
|
||||
return dayOfWeek;
|
||||
}
|
||||
|
||||
protected void setDayOfWeek(int dayOfWeek)
|
||||
{
|
||||
this.dayOfWeek = dayOfWeek;
|
||||
}
|
||||
|
||||
public int getHalfYear()
|
||||
{
|
||||
return halfYear;
|
||||
}
|
||||
|
||||
protected void setHalfYear(int halfYear)
|
||||
{
|
||||
this.halfYear = halfYear;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
protected void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getMonth()
|
||||
{
|
||||
return month;
|
||||
}
|
||||
|
||||
protected void setMonth(int month)
|
||||
{
|
||||
this.month = month;
|
||||
}
|
||||
|
||||
public int getQuarter()
|
||||
{
|
||||
return quarter;
|
||||
}
|
||||
|
||||
protected void setQuarter(int quarter)
|
||||
{
|
||||
this.quarter = quarter;
|
||||
}
|
||||
|
||||
public int getWeekOfMonth()
|
||||
{
|
||||
return weekOfMonth;
|
||||
}
|
||||
|
||||
protected void setWeekOfMonth(int weekOfMonth)
|
||||
{
|
||||
this.weekOfMonth = weekOfMonth;
|
||||
}
|
||||
|
||||
public int getWeekOfYear()
|
||||
{
|
||||
return weekOfYear;
|
||||
}
|
||||
|
||||
protected void setWeekOfYear(int weekOfYear)
|
||||
{
|
||||
this.weekOfYear = weekOfYear;
|
||||
}
|
||||
|
||||
public int getFullYear()
|
||||
{
|
||||
return fullYear;
|
||||
}
|
||||
|
||||
protected void setFullYear(int year)
|
||||
{
|
||||
this.fullYear = year;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if(this == o)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if(!(o instanceof AuditDateImpl))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
AuditDateImpl that = (AuditDateImpl)o;
|
||||
return EqualsHelper.nullSafeEquals(this.date, that.date);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return this.date.hashCode();
|
||||
}
|
||||
|
||||
}
|
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.audit.hibernate;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public interface AuditFact
|
||||
{
|
||||
|
||||
public abstract String getArg1();
|
||||
|
||||
public abstract String getArg2();
|
||||
|
||||
public abstract String getArg3();
|
||||
|
||||
public abstract String getArg4();
|
||||
|
||||
public abstract String getArg5();
|
||||
|
||||
public abstract AuditConfig getAuditConfig();
|
||||
|
||||
public abstract AuditDate getAuditDate();
|
||||
|
||||
public abstract AuditSource getAuditSource();
|
||||
|
||||
public abstract String getClientInetAddress();
|
||||
|
||||
public abstract Date getDate();
|
||||
|
||||
public abstract String getException();
|
||||
|
||||
public abstract boolean isFail();
|
||||
|
||||
public abstract boolean isFiltered();
|
||||
|
||||
public abstract String getHostInetAddress();
|
||||
|
||||
public abstract Long getId();
|
||||
|
||||
public abstract String getMessage();
|
||||
|
||||
public abstract String getNodeUUID();
|
||||
|
||||
public abstract String getPath();
|
||||
|
||||
public abstract String getReturnValue();
|
||||
|
||||
public abstract String getSerialisedURL();
|
||||
|
||||
public abstract String getSessionId();
|
||||
|
||||
public abstract String getStoreId();
|
||||
|
||||
public abstract String getStoreProtocol();
|
||||
|
||||
public abstract String getTransactionId();
|
||||
|
||||
public abstract String getUserId();
|
||||
|
||||
}
|
@@ -1,584 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.audit.hibernate;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.Session;
|
||||
|
||||
/**
|
||||
* An Audit fact Rely on standard equals and hash code as they should all be unique.
|
||||
*
|
||||
* @author Andy Hind
|
||||
*/
|
||||
public class AuditFactImpl implements AuditFact
|
||||
{
|
||||
private Long id;
|
||||
|
||||
private AuditDate auditDate;
|
||||
|
||||
private AuditConfig auditConfig;
|
||||
|
||||
private AuditSource auditSource;
|
||||
|
||||
private String userId;
|
||||
|
||||
private Date date;
|
||||
|
||||
private String transactionId;
|
||||
|
||||
private String sessionId;
|
||||
|
||||
private String storeProtocol;
|
||||
|
||||
private String storeId;
|
||||
|
||||
private String nodeUUID;
|
||||
|
||||
private String path;
|
||||
|
||||
private boolean filtered;
|
||||
|
||||
private String returnValue;
|
||||
|
||||
private String arg1;
|
||||
|
||||
private String arg2;
|
||||
|
||||
private String arg3;
|
||||
|
||||
private String arg4;
|
||||
|
||||
private String arg5;
|
||||
|
||||
private boolean fail;
|
||||
|
||||
private String serialisedURL;
|
||||
|
||||
private String exception;
|
||||
|
||||
private String hostInetAddress;
|
||||
|
||||
private String clientInetAddress;
|
||||
|
||||
private String message;
|
||||
|
||||
public AuditFactImpl()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#getArg1()
|
||||
*/
|
||||
public String getArg1()
|
||||
{
|
||||
return arg1;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#setArg1(java.lang.String)
|
||||
*/
|
||||
public void setArg1(String arg1)
|
||||
{
|
||||
this.arg1 = arg1;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#getArg2()
|
||||
*/
|
||||
public String getArg2()
|
||||
{
|
||||
return arg2;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#setArg2(java.lang.String)
|
||||
*/
|
||||
public void setArg2(String arg2)
|
||||
{
|
||||
this.arg2 = arg2;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#getArg3()
|
||||
*/
|
||||
public String getArg3()
|
||||
{
|
||||
return arg3;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#setArg3(java.lang.String)
|
||||
*/
|
||||
public void setArg3(String arg3)
|
||||
{
|
||||
this.arg3 = arg3;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#getArg4()
|
||||
*/
|
||||
public String getArg4()
|
||||
{
|
||||
return arg4;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#setArg4(java.lang.String)
|
||||
*/
|
||||
public void setArg4(String arg4)
|
||||
{
|
||||
this.arg4 = arg4;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#getArg5()
|
||||
*/
|
||||
public String getArg5()
|
||||
{
|
||||
return arg5;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#setArg5(java.lang.String)
|
||||
*/
|
||||
public void setArg5(String arg5)
|
||||
{
|
||||
this.arg5 = arg5;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#getAuditConfig()
|
||||
*/
|
||||
public AuditConfig getAuditConfig()
|
||||
{
|
||||
return auditConfig;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#setAuditConfig(org.alfresco.repo.audit.hibernate.AuditConfig)
|
||||
*/
|
||||
public void setAuditConfig(AuditConfig auditConfig)
|
||||
{
|
||||
this.auditConfig = auditConfig;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#getAuditDate()
|
||||
*/
|
||||
public AuditDate getAuditDate()
|
||||
{
|
||||
return auditDate;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#setAuditDate(org.alfresco.repo.audit.hibernate.AuditDate)
|
||||
*/
|
||||
public void setAuditDate(AuditDate auditDate)
|
||||
{
|
||||
this.auditDate = auditDate;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#getAuditSource()
|
||||
*/
|
||||
public AuditSource getAuditSource()
|
||||
{
|
||||
return auditSource;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#setAuditSource(org.alfresco.repo.audit.hibernate.AuditSource)
|
||||
*/
|
||||
public void setAuditSource(AuditSource auditSource)
|
||||
{
|
||||
this.auditSource = auditSource;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#getClientInetAddress()
|
||||
*/
|
||||
public String getClientInetAddress()
|
||||
{
|
||||
return clientInetAddress;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#setClientInetAddress(java.net.InetAddress)
|
||||
*/
|
||||
public void setClientInetAddress(String clientInetAddress)
|
||||
{
|
||||
this.clientInetAddress = clientInetAddress;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#getDate()
|
||||
*/
|
||||
public Date getDate()
|
||||
{
|
||||
return date;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#setDate(java.util.Date)
|
||||
*/
|
||||
public void setDate(Date date)
|
||||
{
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#getException()
|
||||
*/
|
||||
public String getException()
|
||||
{
|
||||
return exception;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#setException(java.lang.String)
|
||||
*/
|
||||
public void setException(String exception)
|
||||
{
|
||||
this.exception = exception;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#isFail()
|
||||
*/
|
||||
public boolean isFail()
|
||||
{
|
||||
return fail;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#setFail(boolean)
|
||||
*/
|
||||
public void setFail(boolean fail)
|
||||
{
|
||||
this.fail = fail;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#isFiltered()
|
||||
*/
|
||||
public boolean isFiltered()
|
||||
{
|
||||
return filtered;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#setFiltered(boolean)
|
||||
*/
|
||||
public void setFiltered(boolean filtered)
|
||||
{
|
||||
this.filtered = filtered;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#getHostInetAddress()
|
||||
*/
|
||||
public String getHostInetAddress()
|
||||
{
|
||||
return hostInetAddress;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#setHostInetAddress(java.net.InetAddress)
|
||||
*/
|
||||
public void setHostInetAddress(String hostInetAddress)
|
||||
{
|
||||
this.hostInetAddress = hostInetAddress;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#getId()
|
||||
*/
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
protected void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#getMessage()
|
||||
*/
|
||||
public String getMessage()
|
||||
{
|
||||
return message;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#setMessage(java.lang.String)
|
||||
*/
|
||||
public void setMessage(String message)
|
||||
{
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#getNodeGUID()
|
||||
*/
|
||||
public String getNodeUUID()
|
||||
{
|
||||
return nodeUUID;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#setNodeGUID(java.lang.String)
|
||||
*/
|
||||
public void setNodeUUID(String nodeUUID)
|
||||
{
|
||||
this.nodeUUID = nodeUUID;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#getPath()
|
||||
*/
|
||||
public String getPath()
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#setPath(java.lang.String)
|
||||
*/
|
||||
public void setPath(String path)
|
||||
{
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#getReturnValue()
|
||||
*/
|
||||
public String getReturnValue()
|
||||
{
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#setReturnValue(java.lang.String)
|
||||
*/
|
||||
public void setReturnValue(String returnValue)
|
||||
{
|
||||
this.returnValue = returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#getSerialisedURL()
|
||||
*/
|
||||
public String getSerialisedURL()
|
||||
{
|
||||
return serialisedURL;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#setSerialisedURL(java.lang.String)
|
||||
*/
|
||||
public void setSerialisedURL(String serialisedURL)
|
||||
{
|
||||
this.serialisedURL = serialisedURL;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#getSessionId()
|
||||
*/
|
||||
public String getSessionId()
|
||||
{
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#setSessionId(java.lang.String)
|
||||
*/
|
||||
public void setSessionId(String sessionId)
|
||||
{
|
||||
this.sessionId = sessionId;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#getStoreId()
|
||||
*/
|
||||
public String getStoreId()
|
||||
{
|
||||
return storeId;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#setStoreId(java.lang.String)
|
||||
*/
|
||||
public void setStoreId(String storeId)
|
||||
{
|
||||
this.storeId = storeId;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#getStoreProtocol()
|
||||
*/
|
||||
public String getStoreProtocol()
|
||||
{
|
||||
return storeProtocol;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#setStoreProtocol(java.lang.String)
|
||||
*/
|
||||
public void setStoreProtocol(String storeProtocol)
|
||||
{
|
||||
this.storeProtocol = storeProtocol;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#getTransactionId()
|
||||
*/
|
||||
public String getTransactionId()
|
||||
{
|
||||
return transactionId;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#setTransactionId(java.lang.String)
|
||||
*/
|
||||
public void setTransactionId(String transactionId)
|
||||
{
|
||||
this.transactionId = transactionId;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#getUserId()
|
||||
*/
|
||||
public String getUserId()
|
||||
{
|
||||
return userId;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.audit.hibernate.AuditFact#setUserId(java.lang.String)
|
||||
*/
|
||||
public void setUserId(String userId)
|
||||
{
|
||||
this.userId = userId;
|
||||
}
|
||||
}
|
@@ -1,233 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.audit.hibernate;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.cmr.audit.AuditInfo;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
public class AuditInfoImpl implements AuditInfo
|
||||
{
|
||||
private String auditApplication;
|
||||
|
||||
private String auditMethod;
|
||||
|
||||
private String auditService;
|
||||
|
||||
private String clientAddress;
|
||||
|
||||
private Date date;
|
||||
|
||||
private boolean fail;
|
||||
|
||||
private boolean filtered;
|
||||
|
||||
private String hostAddress;
|
||||
|
||||
private String keyGUID;
|
||||
|
||||
private Map<QName, Serializable> keyPropertiesAfter;
|
||||
|
||||
private Map<QName, Serializable> keyPropertiesBefore;
|
||||
|
||||
private StoreRef keyStore;
|
||||
|
||||
private String message;
|
||||
|
||||
private Serializable[] methodArguments;
|
||||
|
||||
private String[] methodArgumentsAsStrings;
|
||||
|
||||
private String path;
|
||||
|
||||
private Serializable returnObject;
|
||||
|
||||
private String returnObjectAsString;
|
||||
|
||||
private String sessionId;
|
||||
|
||||
private Throwable throwable;
|
||||
|
||||
private String throwableAsString;
|
||||
|
||||
private String txId;
|
||||
|
||||
private String userIdentifier;
|
||||
|
||||
public AuditInfoImpl(AuditFact auditFact)
|
||||
{
|
||||
super();
|
||||
this.auditApplication = auditFact.getAuditSource().getApplication();
|
||||
this.auditMethod = auditFact.getAuditSource().getMethod();
|
||||
this.auditService = auditFact.getAuditSource().getService();
|
||||
this.clientAddress = auditFact.getClientInetAddress();
|
||||
this.date = auditFact.getDate();
|
||||
this.fail = auditFact.isFail();
|
||||
this.filtered = auditFact.isFiltered();
|
||||
this.hostAddress= auditFact.getHostInetAddress();
|
||||
this.keyGUID = auditFact.getNodeUUID();
|
||||
this.keyPropertiesAfter = null;
|
||||
this.keyPropertiesBefore = null;
|
||||
if((auditFact.getStoreProtocol() != null) && (auditFact.getStoreId() != null))
|
||||
{
|
||||
this.keyStore = new StoreRef(auditFact.getStoreProtocol(), auditFact.getStoreId());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.keyStore = null;
|
||||
}
|
||||
this.message = auditFact.getMessage();
|
||||
this.methodArguments = null;
|
||||
this.methodArgumentsAsStrings = new String[5];
|
||||
this.methodArgumentsAsStrings[0] = auditFact.getArg1();
|
||||
this.methodArgumentsAsStrings[1] = auditFact.getArg2();
|
||||
this.methodArgumentsAsStrings[2] = auditFact.getArg3();
|
||||
this.methodArgumentsAsStrings[3] = auditFact.getArg4();
|
||||
this.methodArgumentsAsStrings[4] = auditFact.getArg5();
|
||||
this.path = auditFact.getPath();
|
||||
this.returnObject = null;
|
||||
this.returnObjectAsString = auditFact.getReturnValue();
|
||||
this.sessionId = auditFact.getSessionId();
|
||||
this.throwable = null;
|
||||
this.throwableAsString = auditFact.getException();
|
||||
this.txId = auditFact.getTransactionId();
|
||||
this.userIdentifier = auditFact.getUserId();
|
||||
}
|
||||
|
||||
public String getAuditApplication()
|
||||
{
|
||||
return auditApplication;
|
||||
}
|
||||
|
||||
public String getAuditMethod()
|
||||
{
|
||||
return auditMethod;
|
||||
}
|
||||
|
||||
public String getAuditService()
|
||||
{
|
||||
return auditService;
|
||||
}
|
||||
|
||||
public String getClientAddress()
|
||||
{
|
||||
return clientAddress;
|
||||
}
|
||||
|
||||
public Date getDate()
|
||||
{
|
||||
return date;
|
||||
}
|
||||
|
||||
public boolean isFail()
|
||||
{
|
||||
return fail;
|
||||
}
|
||||
|
||||
public boolean isFiltered()
|
||||
{
|
||||
return filtered;
|
||||
}
|
||||
|
||||
public String getHostAddress()
|
||||
{
|
||||
return hostAddress;
|
||||
}
|
||||
|
||||
public String getKeyGUID()
|
||||
{
|
||||
return keyGUID;
|
||||
}
|
||||
|
||||
public Map<QName, Serializable> getKeyPropertiesAfter()
|
||||
{
|
||||
return keyPropertiesAfter;
|
||||
}
|
||||
|
||||
public Map<QName, Serializable> getKeyPropertiesBefore()
|
||||
{
|
||||
return keyPropertiesBefore;
|
||||
}
|
||||
|
||||
public StoreRef getKeyStore()
|
||||
{
|
||||
return keyStore;
|
||||
}
|
||||
|
||||
public String getMessage()
|
||||
{
|
||||
return message;
|
||||
}
|
||||
|
||||
public Serializable[] getMethodArguments()
|
||||
{
|
||||
return methodArguments;
|
||||
}
|
||||
|
||||
public String[] getMethodArgumentsAsStrings()
|
||||
{
|
||||
return methodArgumentsAsStrings;
|
||||
}
|
||||
|
||||
public String getPath()
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
public Serializable getReturnObject()
|
||||
{
|
||||
return returnObject;
|
||||
}
|
||||
|
||||
public String getReturnObjectAsString()
|
||||
{
|
||||
return returnObjectAsString;
|
||||
}
|
||||
|
||||
public String getSessionId()
|
||||
{
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
public Throwable getThrowable()
|
||||
{
|
||||
return throwable;
|
||||
}
|
||||
|
||||
public String getThrowableAsString()
|
||||
{
|
||||
return throwableAsString;
|
||||
}
|
||||
|
||||
public String getTxId()
|
||||
{
|
||||
return txId;
|
||||
}
|
||||
|
||||
public String getUserIdentifier()
|
||||
{
|
||||
return userIdentifier;
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.audit.hibernate;
|
||||
|
||||
public interface AuditSource
|
||||
{
|
||||
public String getApplication();
|
||||
|
||||
public Long getId();
|
||||
|
||||
public String getMethod();
|
||||
|
||||
public String getService();
|
||||
|
||||
void setApplication(String auditApplication);
|
||||
|
||||
void setService(String auditService);
|
||||
|
||||
void setMethod(String auditMethod);
|
||||
|
||||
}
|
@@ -1,125 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.audit.hibernate;
|
||||
|
||||
import org.alfresco.util.EqualsHelper;
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.Session;
|
||||
|
||||
public class AuditSourceImpl implements AuditSource
|
||||
{
|
||||
/**
|
||||
* The surrogate key
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* The auditing application (System for method audits)
|
||||
*/
|
||||
private String application;
|
||||
|
||||
/**
|
||||
* The audited service
|
||||
*/
|
||||
private String service;
|
||||
|
||||
/**
|
||||
* The audited method
|
||||
*/
|
||||
private String method;
|
||||
|
||||
public AuditSourceImpl()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public String getApplication()
|
||||
{
|
||||
return application;
|
||||
}
|
||||
|
||||
public void setApplication(String application)
|
||||
{
|
||||
this.application = application;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
protected void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getMethod()
|
||||
{
|
||||
return method;
|
||||
}
|
||||
|
||||
public void setMethod(String method)
|
||||
{
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
public String getService()
|
||||
{
|
||||
return service;
|
||||
}
|
||||
|
||||
public void setService(String service)
|
||||
{
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof AuditSourceImpl))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
AuditSourceImpl other = (AuditSourceImpl) o;
|
||||
return EqualsHelper.nullSafeEquals(this.application, other.application)
|
||||
&& EqualsHelper.nullSafeEquals(this.service, other.service)
|
||||
&& EqualsHelper.nullSafeEquals(this.method, other.method);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
int hash = application.hashCode();
|
||||
if(service != null)
|
||||
{
|
||||
hash = (hash * 37) + service.hashCode();
|
||||
}
|
||||
if(method != null)
|
||||
{
|
||||
hash = (hash * 37) + method.hashCode();
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
}
|
@@ -1,680 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.audit.hibernate;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.Serializable;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.repo.audit.AuditState;
|
||||
import org.alfresco.repo.content.ContentStore;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.content.filestore.FileContentStore;
|
||||
import org.alfresco.repo.domain.audit.AuditDAO;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.transaction.TransactionalDao;
|
||||
import org.alfresco.service.cmr.audit.AuditInfo;
|
||||
import org.alfresco.service.cmr.audit.AuditQueryParameters;
|
||||
import org.alfresco.service.cmr.audit.AuditService.AuditQueryCallback;
|
||||
import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.datatype.Duration;
|
||||
import org.alfresco.util.EqualsHelper;
|
||||
import org.alfresco.util.GUID;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.mapping.Column;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.springframework.orm.hibernate3.HibernateCallback;
|
||||
import org.springframework.orm.hibernate3.LocalSessionFactoryBean;
|
||||
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||
|
||||
/**
|
||||
* Assumes mimetype and encoding sent to the content store (we are not saving this anywhere)
|
||||
*
|
||||
* @author Andy Hind
|
||||
*/
|
||||
public class HibernateAuditDAO extends HibernateDaoSupport implements AuditDAO, TransactionalDao
|
||||
{
|
||||
/**
|
||||
* Logging
|
||||
*/
|
||||
private static Log s_logger = LogFactory.getLog(HibernateAuditDAO.class);
|
||||
|
||||
private static final String QUERY_LAST_AUDIT_DATE = "audit.GetLatestAuditDate";
|
||||
|
||||
private static final String QUERY_AUDIT_DATE = "audit.GetAuditDate";
|
||||
|
||||
private static final String QUERY_LAST_AUDIT_CONFIG = "audit.GetLatestAuditConfig";
|
||||
|
||||
private static final String QUERY_AUDIT_APP_SOURCE = "audit.GetAuditSourceByApplication";
|
||||
|
||||
private static final String QUERY_AUDIT_METHOD_SOURCE = "audit.GetAuditSourceByApplicationServiceMethod";
|
||||
|
||||
private static final String QUERY_AUDIT_APP_SOURCE_APP = "application";
|
||||
|
||||
private static final String QUERY_AUDIT_APP_SOURCE_SER = "service";
|
||||
|
||||
private static final String QUERY_AUDIT_APP_SOURCE_MET = "method";
|
||||
|
||||
private static final String QUERY_AUDIT_TRAIL = "audit.GetAuditTrailForNode";
|
||||
|
||||
private static final String QUERY_AUDIT_PROTOCOL = "protocol";
|
||||
|
||||
private static final String QUERY_AUDIT_STORE_ID = "store_id";
|
||||
|
||||
private static final String QUERY_AUDIT_NODE_ID = "node_id";
|
||||
|
||||
private static final String QUERY_AUDIT_NODE_REF = "nodeRef";
|
||||
|
||||
private static final String QUERY_AUDIT_DATE_PARAM = "date";
|
||||
|
||||
/** a uuid identifying this unique instance */
|
||||
private String uuid;
|
||||
|
||||
private ContentStore contentStore;
|
||||
|
||||
private LocalSessionFactoryBean localSessionFactory;
|
||||
|
||||
public HibernateAuditDAO()
|
||||
{
|
||||
super();
|
||||
this.uuid = GUID.generate();
|
||||
}
|
||||
|
||||
public ContentStore getContentStore()
|
||||
{
|
||||
return contentStore;
|
||||
}
|
||||
|
||||
public void setContentStore(ContentStore contentStore)
|
||||
{
|
||||
this.contentStore = contentStore;
|
||||
}
|
||||
|
||||
public void setLocalSessionFactory(LocalSessionFactoryBean localSessionFactory)
|
||||
{
|
||||
this.localSessionFactory = localSessionFactory;
|
||||
}
|
||||
|
||||
public void audit(AuditState auditInfo)
|
||||
{
|
||||
if (auditInfo.getUserIdentifier() == null)
|
||||
{
|
||||
auditInfo.setUserIdentifier(AuthenticationUtil.getSystemUserName());
|
||||
}
|
||||
if (AuthenticationUtil.getRunAsUser() == null)
|
||||
{
|
||||
AuthenticationUtil.setRunAsUserSystem();
|
||||
try
|
||||
{
|
||||
audit0(auditInfo);
|
||||
}
|
||||
finally
|
||||
{
|
||||
AuthenticationUtil.clearCurrentSecurityContext();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
audit0(auditInfo);
|
||||
}
|
||||
}
|
||||
|
||||
private void audit0(AuditState auditInfo)
|
||||
{
|
||||
// Find/Build the configuraton entry
|
||||
AuditConfig auditConfig = getAuditConfig(auditInfo);
|
||||
|
||||
// Find/Build any dates
|
||||
AuditDate auditDate = getAuditDate(auditInfo);
|
||||
|
||||
// Find/Build the source
|
||||
AuditSource auditSource = getAuditSource(auditInfo);
|
||||
|
||||
// Build the new audit fact information
|
||||
AuditFactImpl auditFact = new AuditFactImpl();
|
||||
auditFact.setAuditConfig(auditConfig);
|
||||
auditFact.setAuditDate(auditDate);
|
||||
auditFact.setAuditSource(auditSource);
|
||||
|
||||
// Properties
|
||||
|
||||
Serializable[] args = auditInfo.getMethodArguments();
|
||||
|
||||
if (args != null)
|
||||
{
|
||||
switch (args.length)
|
||||
{
|
||||
default:
|
||||
case 5:
|
||||
auditFact.setArg5(getStringOrNull(args[4], getColumnLength("org.alfresco.repo.audit.hibernate.AuditFactImpl", "arg5")));
|
||||
case 4:
|
||||
auditFact.setArg4(getStringOrNull(args[3], getColumnLength("org.alfresco.repo.audit.hibernate.AuditFactImpl", "arg4")));
|
||||
case 3:
|
||||
auditFact.setArg3(getStringOrNull(args[2], getColumnLength("org.alfresco.repo.audit.hibernate.AuditFactImpl", "arg3")));
|
||||
case 2:
|
||||
auditFact.setArg2(getStringOrNull(args[1], getColumnLength("org.alfresco.repo.audit.hibernate.AuditFactImpl", "arg2")));
|
||||
case 1:
|
||||
auditFact.setArg1(getStringOrNull(args[0], getColumnLength("org.alfresco.repo.audit.hibernate.AuditFactImpl", "arg1")));
|
||||
case 0:
|
||||
}
|
||||
}
|
||||
|
||||
auditFact.setClientInetAddress(getStringOrNull(auditInfo.getClientAddress(), getColumnLength("org.alfresco.repo.audit.hibernate.AuditFactImpl", "clientInetAddress")));
|
||||
auditFact.setDate(auditInfo.getDate());
|
||||
auditFact.setException(getStringOrNull((auditInfo.getThrowable() == null ? null : auditInfo.getThrowable().getMessage()), getColumnLength(
|
||||
"org.alfresco.repo.audit.hibernate.AuditFactImpl", "exception")));
|
||||
auditFact.setFail(auditInfo.isFail());
|
||||
auditFact.setFiltered(auditInfo.isFiltered());
|
||||
auditFact.setHostInetAddress(getStringOrNull(auditInfo.getHostAddress(), getColumnLength("org.alfresco.repo.audit.hibernate.AuditFactImpl", "hostInetAddress")));
|
||||
auditFact.setMessage(getStringOrNull(auditInfo.getMessage(), getColumnLength("org.alfresco.repo.audit.hibernate.AuditFactImpl", "message")));
|
||||
auditFact.setNodeUUID(getStringOrNull(auditInfo.getKeyGUID(), getColumnLength("org.alfresco.repo.audit.hibernate.AuditFactImpl", "nodeUUID")));
|
||||
auditFact.setPath(getStringOrNull(auditInfo.getPath(), getColumnLength("org.alfresco.repo.audit.hibernate.AuditFactImpl", "path")));
|
||||
auditFact.setReturnValue(getStringOrNull(auditInfo.getReturnObject(), getColumnLength("org.alfresco.repo.audit.hibernate.AuditFactImpl", "returnValue")));
|
||||
// auditFact.setSerialisedURL()
|
||||
auditFact.setSessionId(getStringOrNull(auditInfo.getSessionId(), getColumnLength("org.alfresco.repo.audit.hibernate.AuditFactImpl", "sessionId")));
|
||||
if (auditInfo.getKeyStore() != null)
|
||||
{
|
||||
auditFact.setStoreId(getStringOrNull(auditInfo.getKeyStore().getIdentifier(), getColumnLength("org.alfresco.repo.audit.hibernate.AuditFactImpl", "storeId")));
|
||||
auditFact.setStoreProtocol(getStringOrNull(auditInfo.getKeyStore().getProtocol(), getColumnLength("org.alfresco.repo.audit.hibernate.AuditFactImpl", "storeProtocol")));
|
||||
}
|
||||
auditFact.setTransactionId(getStringOrNull(auditInfo.getTxId(), getColumnLength("org.alfresco.repo.audit.hibernate.AuditFactImpl", "transactionId")));
|
||||
auditFact.setUserId(getStringOrNull(auditInfo.getUserIdentifier(), getColumnLength("org.alfresco.repo.audit.hibernate.AuditFactImpl", "userId")));
|
||||
|
||||
// Save
|
||||
getSession().save(auditFact);
|
||||
|
||||
}
|
||||
|
||||
private int getColumnLength(String entityName, String propertyName)
|
||||
{
|
||||
int length = -1;
|
||||
Iterator it = localSessionFactory.getConfiguration().getClassMapping(entityName).getProperty(propertyName).getValue().getColumnIterator();
|
||||
if (it.hasNext())
|
||||
{
|
||||
Column col = (Column) it.next();
|
||||
length = col.getLength();
|
||||
}
|
||||
if (s_logger.isDebugEnabled())
|
||||
{
|
||||
s_logger.debug(entityName + " " + propertyName + " is of length " + length);
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
private String getStringOrNull(Object o, int size)
|
||||
{
|
||||
if (o == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
String answer = o.toString();
|
||||
if ((size > -1) && (answer.length() > size))
|
||||
{
|
||||
answer = answer.substring(0, size);
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
String answer = "Throwable in toString implementation for " + o.getClass() + " was " + t.getMessage();
|
||||
if ((size > -1) && (answer.length() > size))
|
||||
{
|
||||
answer = answer.substring(0, size);
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private AuditSource getAuditSource(final AuditState auditInfo)
|
||||
{
|
||||
|
||||
AuditSource auditSourceImpl;
|
||||
|
||||
if ((auditInfo.getAuditService() != null)
|
||||
&& (auditInfo.getAuditService().length() > 0) && (auditInfo.getAuditMethod() != null) && (auditInfo.getAuditMethod().length() > 0))
|
||||
{
|
||||
auditSourceImpl = queryApplicationSource(auditInfo.getAuditApplication(), auditInfo.getAuditService(), auditInfo.getAuditMethod());
|
||||
if (auditSourceImpl == null)
|
||||
{
|
||||
auditSourceImpl = new AuditSourceImpl();
|
||||
auditSourceImpl.setApplication(auditInfo.getAuditApplication());
|
||||
auditSourceImpl.setService(auditInfo.getAuditService());
|
||||
auditSourceImpl.setMethod(auditInfo.getAuditMethod());
|
||||
Long id = (Long) getSession().save(auditSourceImpl);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
auditSourceImpl = queryApplicationSource(auditInfo.getAuditApplication());
|
||||
if (auditSourceImpl == null)
|
||||
{
|
||||
auditSourceImpl = new AuditSourceImpl();
|
||||
auditSourceImpl.setApplication(auditInfo.getAuditApplication());
|
||||
Long id = (Long) getSession().save(auditSourceImpl);
|
||||
}
|
||||
}
|
||||
|
||||
return auditSourceImpl;
|
||||
|
||||
}
|
||||
|
||||
private AuditDate getAuditDate(final AuditState auditInfo)
|
||||
{
|
||||
|
||||
Calendar cal = GregorianCalendar.getInstance();
|
||||
cal.setTime(auditInfo.getDate());
|
||||
cal.set(Calendar.MILLISECOND, 0);
|
||||
cal.set(Calendar.SECOND, 0);
|
||||
cal.set(Calendar.MINUTE, 0);
|
||||
cal.set(Calendar.HOUR_OF_DAY, 0);
|
||||
Date required = cal.getTime();
|
||||
|
||||
AuditDate auditDate;
|
||||
|
||||
auditDate = queryLatestDate(required);
|
||||
if (auditDate == null)
|
||||
{
|
||||
auditDate = queryLatestDate();
|
||||
if (auditDate == null)
|
||||
{
|
||||
// The first entry ever so we just make it
|
||||
auditDate = new AuditDateImpl(auditInfo.getDate());
|
||||
Long id = (Long) getSession().save(auditDate);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (required.compareTo(auditDate.getDate()) < 0)
|
||||
{
|
||||
auditDate = new AuditDateImpl(required);
|
||||
Long id = (Long) getSession().save(auditDate);
|
||||
}
|
||||
else if (required.compareTo(auditDate.getDate()) == 0)
|
||||
{
|
||||
// no action
|
||||
}
|
||||
else
|
||||
{
|
||||
while (!required.equals(auditDate.getDate()))
|
||||
{
|
||||
Date nextDate = Duration.add(auditDate.getDate(), new Duration("P1D"));
|
||||
auditDate = new AuditDateImpl(nextDate);
|
||||
Long id = (Long) getSession().save(auditDate);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// no action
|
||||
}
|
||||
return auditDate;
|
||||
|
||||
}
|
||||
|
||||
private AuditConfig getAuditConfig(final AuditState auditInfo)
|
||||
{
|
||||
|
||||
AuditConfig auditConfig;
|
||||
auditConfig = queryLatestConfig(getSession());
|
||||
if (auditConfig == null)
|
||||
{
|
||||
auditConfig = createNewAuditConfigImpl(auditInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (contentStore instanceof FileContentStore)
|
||||
{
|
||||
long currTimestamp = auditInfo.getAuditConfiguration().getLastModified();
|
||||
long timestamp = ((FileContentStore)contentStore).getReader(auditConfig.getConfigURL()).getLastModified();
|
||||
if (timestamp < currTimestamp)
|
||||
{
|
||||
// Files are different - require a new entry
|
||||
auditConfig = createNewAuditConfigImpl(auditInfo);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
auditConfig = createNewAuditConfigImpl(auditInfo);
|
||||
}
|
||||
}
|
||||
|
||||
return auditConfig;
|
||||
}
|
||||
|
||||
private AuditConfig createNewAuditConfigImpl(final AuditState auditInfo)
|
||||
{
|
||||
AuditConfigImpl auditConfig = new AuditConfigImpl();
|
||||
InputStream is = new BufferedInputStream(auditInfo.getAuditConfiguration().getInputStream());
|
||||
ContentWriter writer = contentStore.getWriter(ContentStore.NEW_CONTENT_CONTEXT);
|
||||
writer.setMimetype(MimetypeMap.MIMETYPE_XML);
|
||||
writer.setEncoding("UTF-8");
|
||||
writer.putContent(is);
|
||||
String contentUrl = writer.getContentUrl();
|
||||
auditConfig.setConfigURL(contentUrl);
|
||||
getSession().save(auditConfig);
|
||||
|
||||
return auditConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks equality by type and uuid
|
||||
*/
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (!(obj instanceof HibernateAuditDAO))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
HibernateAuditDAO that = (HibernateAuditDAO) obj;
|
||||
return this.uuid.equals(that.uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #uuid
|
||||
*/
|
||||
public int hashCode()
|
||||
{
|
||||
return uuid.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Does this <tt>Session</tt> contain any changes which must be synchronized with the store?
|
||||
*
|
||||
* @return true => changes are pending
|
||||
*/
|
||||
public boolean isDirty()
|
||||
{
|
||||
// create a callback for the task
|
||||
HibernateCallback callback = new HibernateCallback()
|
||||
{
|
||||
public Object doInHibernate(Session session)
|
||||
{
|
||||
return session.isDirty();
|
||||
}
|
||||
};
|
||||
// execute the callback
|
||||
return ((Boolean) getHibernateTemplate().execute(callback)).booleanValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Just flushes the session
|
||||
*/
|
||||
public void flush()
|
||||
{
|
||||
getSession().flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* NO-OP
|
||||
*/
|
||||
public void beforeCommit()
|
||||
{
|
||||
}
|
||||
|
||||
static class SourceKey
|
||||
{
|
||||
String application;
|
||||
|
||||
String service;
|
||||
|
||||
String method;
|
||||
|
||||
SourceKey(String application, String service, String method)
|
||||
{
|
||||
this.application = application;
|
||||
this.service = service;
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (!(this instanceof SourceKey))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
SourceKey other = (SourceKey) o;
|
||||
return EqualsHelper.nullSafeEquals(this.application, other.application)
|
||||
&& EqualsHelper.nullSafeEquals(this.service, other.service) && EqualsHelper.nullSafeEquals(this.method, other.method);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
int hash = application.hashCode();
|
||||
if (service != null)
|
||||
{
|
||||
hash = (hash * 37) + service.hashCode();
|
||||
}
|
||||
if (method != null)
|
||||
{
|
||||
hash = (hash * 37) + method.hashCode();
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
public List<AuditInfo> getAuditTrail(NodeRef nodeRef)
|
||||
{
|
||||
if (nodeRef == null)
|
||||
{
|
||||
return Collections.<AuditInfo> emptyList();
|
||||
}
|
||||
List<? extends AuditFact> internalTrail = queryAuditTrail(nodeRef);
|
||||
|
||||
ArrayList<AuditInfo> answer = new ArrayList<AuditInfo>(internalTrail.size());
|
||||
for (AuditFact auditFact : internalTrail)
|
||||
{
|
||||
AuditInfo info = new AuditInfoImpl(auditFact);
|
||||
answer.add(info);
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to get the latest audit config
|
||||
*/
|
||||
public static AuditConfig queryLatestConfig(Session session)
|
||||
{
|
||||
Query query = session.getNamedQuery(QUERY_LAST_AUDIT_CONFIG);
|
||||
return (AuditConfig) query.uniqueResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to get the latest audit date
|
||||
*/
|
||||
public AuditDate queryLatestDate()
|
||||
{
|
||||
Query query = getSession().getNamedQuery(QUERY_LAST_AUDIT_DATE);
|
||||
return (AuditDate) query.uniqueResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to get all the audit entries for a node.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<AuditFact> queryAuditTrail(NodeRef nodeRef)
|
||||
{
|
||||
Query query = getSession().getNamedQuery(QUERY_AUDIT_TRAIL);
|
||||
query.setParameter(QUERY_AUDIT_PROTOCOL, nodeRef.getStoreRef().getProtocol());
|
||||
query.setParameter(QUERY_AUDIT_STORE_ID, nodeRef.getStoreRef().getIdentifier());
|
||||
query.setParameter(QUERY_AUDIT_NODE_ID, nodeRef.getId());
|
||||
query.setParameter(QUERY_AUDIT_NODE_REF, "%" + nodeRef.toString() + "%");
|
||||
return (List<AuditFact>) query.list();
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to get the application source
|
||||
*
|
||||
* @param application
|
||||
* @return
|
||||
*/
|
||||
public AuditSource queryApplicationSource(String application)
|
||||
{
|
||||
Query query = getSession().getNamedQuery(QUERY_AUDIT_APP_SOURCE);
|
||||
query.setParameter(QUERY_AUDIT_APP_SOURCE_APP, application);
|
||||
return (AuditSource) query.uniqueResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to get the application source
|
||||
*
|
||||
* @param application
|
||||
* @return
|
||||
*/
|
||||
public AuditSource queryApplicationSource(String application, String service, String method)
|
||||
{
|
||||
Query query = getSession().getNamedQuery(HibernateAuditDAO.QUERY_AUDIT_METHOD_SOURCE);
|
||||
query.setParameter(QUERY_AUDIT_APP_SOURCE_APP, application);
|
||||
query.setParameter(QUERY_AUDIT_APP_SOURCE_SER, service);
|
||||
query.setParameter(QUERY_AUDIT_APP_SOURCE_MET, method);
|
||||
return (AuditSource) query.uniqueResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to get the latest audit date
|
||||
*/
|
||||
public AuditDate queryLatestDate(Date date)
|
||||
{
|
||||
Query query = getSession().getNamedQuery(HibernateAuditDAO.QUERY_AUDIT_DATE);
|
||||
query.setParameter(QUERY_AUDIT_DATE_PARAM, date);
|
||||
return (AuditDate) query.uniqueResult();
|
||||
}
|
||||
|
||||
/*
|
||||
* V3.2 from here on. Put all fixes to the older audit code before this point, please.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Fallout implementation from new audit DAO
|
||||
*
|
||||
* @throws UnsupportedOperationException always
|
||||
* @since 3.2
|
||||
*/
|
||||
public Pair<Long, ContentData> getOrCreateAuditModel(URL url)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fallout implementation from new audit DAO
|
||||
*
|
||||
* @throws UnsupportedOperationException always
|
||||
* @since 3.2
|
||||
*/
|
||||
public AuditApplicationInfo createAuditApplication(String application, Long modelId)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fallout implementation from new audit DAO
|
||||
*
|
||||
* @throws UnsupportedOperationException always
|
||||
* @since 3.2
|
||||
*/
|
||||
public AuditApplicationInfo getAuditApplication(String applicationName)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fallout implementation from new audit DAO
|
||||
*
|
||||
* @throws UnsupportedOperationException always
|
||||
* @since 3.2
|
||||
*/
|
||||
public void updateAuditApplicationModel(Long id, Long modelId)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fallout implementation from new audit DAO
|
||||
*
|
||||
* @throws UnsupportedOperationException always
|
||||
* @since 3.2
|
||||
*/
|
||||
public void updateAuditApplicationDisabledPaths(Long id, Set<String> disabledPaths)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fallout implementation from new audit DAO
|
||||
*
|
||||
* @throws UnsupportedOperationException always
|
||||
* @since 3.2
|
||||
*/
|
||||
public void deleteAuditEntries(Long applicationId, Long from, Long to)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fallout implementation from new audit DAO
|
||||
*
|
||||
* @throws UnsupportedOperationException always
|
||||
* @since 3.2
|
||||
*/
|
||||
public Long createAuditEntry(Long applicationId, long time, String username, Map<String, Serializable> values)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fallout implementation from new audit DAO
|
||||
*
|
||||
* @throws UnsupportedOperationException always
|
||||
* @since 3.2
|
||||
*/
|
||||
public void findAuditEntries(AuditQueryCallback callback, AuditQueryParameters parameters, int maxResults)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
@@ -1,305 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.audit.model;
|
||||
|
||||
import org.alfresco.repo.audit.AuditMode;
|
||||
import org.alfresco.repo.audit.AuditModel;
|
||||
import org.alfresco.repo.audit.PublicServiceIdentifier;
|
||||
import org.alfresco.repo.audit.RecordOptions;
|
||||
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.dom4j.Attribute;
|
||||
import org.dom4j.Element;
|
||||
|
||||
public abstract class AbstractAuditEntry
|
||||
{
|
||||
private static Log s_logger = LogFactory.getLog(AbstractAuditEntry.class);
|
||||
|
||||
private RecordOptionsImpl recordOptions = null;
|
||||
|
||||
private AbstractFilter filter = null;
|
||||
|
||||
private AuditMode auditMode = AuditMode.UNSET;
|
||||
|
||||
private TrueFalseUnset enabled = TrueFalseUnset.UNSET;
|
||||
|
||||
private TrueFalseUnset auditInternal = TrueFalseUnset.UNSET;
|
||||
|
||||
private AbstractAuditEntry parent;
|
||||
|
||||
private PublicServiceIdentifier publicServiceIdentifier;
|
||||
|
||||
public AbstractAuditEntry()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
PublicServiceIdentifier getPublicServiceIdentifier()
|
||||
{
|
||||
return publicServiceIdentifier;
|
||||
}
|
||||
|
||||
public void setPublicServiceIdentifier(PublicServiceIdentifier publicServiceIdentifier)
|
||||
{
|
||||
this.publicServiceIdentifier = publicServiceIdentifier;
|
||||
}
|
||||
|
||||
void configure(AbstractAuditEntry parent, Element element, NamespacePrefixResolver namespacePrefixResolver)
|
||||
{
|
||||
this.parent = parent;
|
||||
|
||||
Attribute auditModeAttribute = element.attribute(AuditModel.AT_MODE);
|
||||
if (auditModeAttribute != null)
|
||||
{
|
||||
auditMode = AuditMode.getAuditMode(auditModeAttribute.getValue());
|
||||
}
|
||||
if(s_logger.isDebugEnabled())
|
||||
{
|
||||
s_logger.debug("Audit Mode = "+auditMode);
|
||||
}
|
||||
|
||||
|
||||
Attribute enabledAttribute = element.attribute(AuditModel.AT_ENABLED);
|
||||
if (enabledAttribute != null)
|
||||
{
|
||||
enabled = TrueFalseUnset.getTrueFalseUnset(enabledAttribute.getValue());
|
||||
}
|
||||
if(s_logger.isDebugEnabled())
|
||||
{
|
||||
s_logger.debug("Enabled = "+enabled);
|
||||
}
|
||||
|
||||
Attribute auditInternalAttribute = element.attribute(AuditModel.AT_AUDIT_INTERNAL);
|
||||
if (auditInternalAttribute != null)
|
||||
{
|
||||
auditInternal = TrueFalseUnset.getTrueFalseUnset(auditInternalAttribute.getValue());
|
||||
}
|
||||
if(s_logger.isDebugEnabled())
|
||||
{
|
||||
s_logger.debug("Audit Internal = "+auditInternal);
|
||||
}
|
||||
|
||||
// Make record options
|
||||
Element recordOptionElement = element.element(AuditModel.EL_RECORD_OPTIONS);
|
||||
if (recordOptionElement != null)
|
||||
{
|
||||
recordOptions = new RecordOptionsImpl();
|
||||
recordOptions.configure(recordOptionElement, namespacePrefixResolver);
|
||||
}
|
||||
if(s_logger.isDebugEnabled())
|
||||
{
|
||||
s_logger.debug("Record Options = "+recordOptions);
|
||||
}
|
||||
|
||||
// Make filters
|
||||
Element filterElement = element.element(AuditModel.EL_FILTER);
|
||||
if (filterElement != null)
|
||||
{
|
||||
filter = AbstractFilter.createFilter(filterElement, namespacePrefixResolver);
|
||||
}
|
||||
if(s_logger.isDebugEnabled())
|
||||
{
|
||||
s_logger.debug("Filter = "+filter);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* package */TrueFalseUnset getAuditInternal()
|
||||
{
|
||||
return auditInternal;
|
||||
}
|
||||
|
||||
/* package */AuditMode getAuditMode()
|
||||
{
|
||||
return auditMode;
|
||||
}
|
||||
|
||||
public TrueFalseUnset getEnabled()
|
||||
{
|
||||
return enabled;
|
||||
}
|
||||
|
||||
/* package */AbstractFilter getFilter()
|
||||
{
|
||||
return filter;
|
||||
}
|
||||
|
||||
/* package */AbstractAuditEntry getParent()
|
||||
{
|
||||
return parent;
|
||||
}
|
||||
|
||||
/* package */RecordOptionsImpl getRecordOptions()
|
||||
{
|
||||
return recordOptions;
|
||||
}
|
||||
|
||||
|
||||
protected TrueFalseUnset getEffectiveAuditInternal()
|
||||
{
|
||||
TrueFalseUnset auditInternal;
|
||||
if (checkEnabled() == TrueFalseUnset.TRUE)
|
||||
{
|
||||
auditInternal = getAuditInternalOrParentAuditInternal();
|
||||
}
|
||||
else
|
||||
{
|
||||
auditInternal = TrueFalseUnset.FALSE;
|
||||
}
|
||||
if(s_logger.isDebugEnabled())
|
||||
{
|
||||
s_logger.debug("... Effective audit internal is = "+auditInternal);
|
||||
}
|
||||
return auditInternal;
|
||||
}
|
||||
|
||||
private TrueFalseUnset getAuditInternalOrParentAuditInternal()
|
||||
{
|
||||
TrueFalseUnset auditInternal = getAuditInternal();
|
||||
if(s_logger.isDebugEnabled())
|
||||
{
|
||||
s_logger.debug("... ... audit internal is = "+auditInternal);
|
||||
}
|
||||
if (auditInternal == TrueFalseUnset.UNSET)
|
||||
{
|
||||
if (getParent() == null)
|
||||
{
|
||||
return TrueFalseUnset.UNSET;
|
||||
}
|
||||
else
|
||||
{
|
||||
return getParent().getAuditInternalOrParentAuditInternal();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return auditInternal;
|
||||
}
|
||||
}
|
||||
|
||||
protected AuditMode getEffectiveAuditMode()
|
||||
{
|
||||
AuditMode auditMode;
|
||||
if (checkEnabled() == TrueFalseUnset.TRUE)
|
||||
{
|
||||
auditMode = getAuditModeOrParentAuditMode();
|
||||
}
|
||||
else
|
||||
{
|
||||
auditMode = AuditMode.NONE;
|
||||
}
|
||||
if(s_logger.isDebugEnabled())
|
||||
{
|
||||
s_logger.debug("... Effective audit mode is = "+auditMode);
|
||||
}
|
||||
return auditMode;
|
||||
}
|
||||
|
||||
private AuditMode getAuditModeOrParentAuditMode()
|
||||
{
|
||||
AuditMode auditMode = getAuditMode();
|
||||
if(s_logger.isDebugEnabled())
|
||||
{
|
||||
s_logger.debug("... ... audit mode is = "+auditMode);
|
||||
}
|
||||
if (auditMode == AuditMode.UNSET)
|
||||
{
|
||||
if (getParent() == null)
|
||||
{
|
||||
return AuditMode.UNSET;
|
||||
}
|
||||
else
|
||||
{
|
||||
return getParent().getAuditModeOrParentAuditMode();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return auditMode;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected RecordOptions getEffectiveRecordOptions()
|
||||
{
|
||||
RecordOptions recordOptions;
|
||||
if (checkEnabled() == TrueFalseUnset.TRUE)
|
||||
{
|
||||
recordOptions = getRecordOptionsOrParentRecordOptions();
|
||||
}
|
||||
else
|
||||
{
|
||||
recordOptions = null;
|
||||
}
|
||||
if(s_logger.isDebugEnabled())
|
||||
{
|
||||
s_logger.debug("...Record Options = "+recordOptions);
|
||||
}
|
||||
return recordOptions;
|
||||
}
|
||||
|
||||
private RecordOptions getRecordOptionsOrParentRecordOptions()
|
||||
{
|
||||
RecordOptions recordOptions = getRecordOptions();
|
||||
if(s_logger.isDebugEnabled())
|
||||
{
|
||||
s_logger.debug("... ... record options = "+recordOptions);
|
||||
}
|
||||
if (recordOptions == null)
|
||||
{
|
||||
if (getParent() == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return getParent().getRecordOptionsOrParentRecordOptions();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return recordOptions;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private TrueFalseUnset checkEnabled()
|
||||
{
|
||||
TrueFalseUnset effective = getEnabled();
|
||||
if (getParent() != null)
|
||||
{
|
||||
if ((getParent().checkEnabled() == TrueFalseUnset.TRUE) && (effective != TrueFalseUnset.FALSE))
|
||||
{
|
||||
return TrueFalseUnset.TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (effective == TrueFalseUnset.TRUE)
|
||||
{
|
||||
return TrueFalseUnset.TRUE;
|
||||
}
|
||||
}
|
||||
return TrueFalseUnset.FALSE;
|
||||
}
|
||||
|
||||
}
|
@@ -1,94 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.audit.model;
|
||||
|
||||
import org.alfresco.repo.audit.AuditModel;
|
||||
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.dom4j.Attribute;
|
||||
import org.dom4j.Element;
|
||||
|
||||
/**
|
||||
* The base class for filtering.
|
||||
*
|
||||
* This supports negating the filter, ie NOT.
|
||||
*
|
||||
* @author Andy Hind
|
||||
*/
|
||||
public abstract class AbstractFilter implements XMLModelElement
|
||||
{
|
||||
private static Log s_logger = LogFactory.getLog(AbstractFilter.class);
|
||||
|
||||
private boolean invert = false;
|
||||
|
||||
public AbstractFilter()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static AbstractFilter createFilter(Element filterElement, NamespacePrefixResolver namespacePrefixResolver)
|
||||
{
|
||||
AbstractFilter filter;
|
||||
|
||||
Attribute typeAttribute = filterElement.attribute(AuditModel.AT_TYPE);
|
||||
if (typeAttribute == null)
|
||||
{
|
||||
throw new AuditModelException("A filter must specify it concrete type using xsi:type");
|
||||
}
|
||||
if (typeAttribute.getStringValue().endsWith("FilterSet"))
|
||||
{
|
||||
filter = new FilterSet();
|
||||
}
|
||||
else if (typeAttribute.getStringValue().endsWith("KeyFilter"))
|
||||
{
|
||||
filter = new KeyFilter();
|
||||
}
|
||||
else if (typeAttribute.getStringValue().endsWith("ParameterFilter"))
|
||||
{
|
||||
filter = new ParameterFilter();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new AuditModelException(
|
||||
"Invalid filter type. It must be one of: FilterSet, KeyFilter, ParameterFilter ");
|
||||
}
|
||||
|
||||
filter.configure(filterElement, namespacePrefixResolver);
|
||||
return filter;
|
||||
}
|
||||
|
||||
public void configure(Element element, NamespacePrefixResolver namespacePrefixResolver)
|
||||
{
|
||||
Attribute invertAttribute = element.attribute(AuditModel.AT_INVERT);
|
||||
if (invertAttribute != null)
|
||||
{
|
||||
invert = Boolean.valueOf(invertAttribute.getStringValue()).booleanValue();
|
||||
}
|
||||
else
|
||||
{
|
||||
invert = false;
|
||||
}
|
||||
}
|
||||
|
||||
/* package */boolean isInvert()
|
||||
{
|
||||
return invert;
|
||||
}
|
||||
}
|
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.audit.model;
|
||||
|
||||
import org.alfresco.repo.audit.AuditModel;
|
||||
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.dom4j.Attribute;
|
||||
import org.dom4j.Element;
|
||||
|
||||
public abstract class AbstractNamedAuditEntry extends AbstractAuditEntry
|
||||
{
|
||||
private static Log s_logger = LogFactory.getLog(AbstractNamedAuditEntry.class);
|
||||
|
||||
private String name;
|
||||
|
||||
public AbstractNamedAuditEntry()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
void configure(AbstractAuditEntry parent, Element element, NamespacePrefixResolver namespacePrefixResolver)
|
||||
{
|
||||
Attribute nameAttribute = element.attribute(AuditModel.AT_NAME);
|
||||
if (nameAttribute != null)
|
||||
{
|
||||
name = nameAttribute.getStringValue();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new AuditModelException("The name attribute is mandatory");
|
||||
}
|
||||
if(s_logger.isDebugEnabled())
|
||||
{
|
||||
s_logger.debug("Name = "+name);
|
||||
}
|
||||
|
||||
super.configure(parent, element, namespacePrefixResolver);
|
||||
|
||||
}
|
||||
|
||||
/* package */String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.audit.model;
|
||||
|
||||
import org.alfresco.repo.audit.ApplicationAuditModel;
|
||||
import org.alfresco.repo.audit.AuditMode;
|
||||
import org.alfresco.repo.audit.RecordOptions;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
public class ApplicationAuditEntry extends AbstractNamedAuditEntry implements ApplicationAuditModel
|
||||
{
|
||||
private static Log s_logger = LogFactory.getLog(ApplicationAuditEntry.class);
|
||||
|
||||
public ApplicationAuditEntry()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public AuditMode beforeExecution(AuditMode auditMode, String application, String description, NodeRef key, Object... args)
|
||||
{
|
||||
if(s_logger.isDebugEnabled())
|
||||
{
|
||||
s_logger.debug("Evaluating if application is audited ..."+application);
|
||||
}
|
||||
return getEffectiveAuditMode();
|
||||
}
|
||||
|
||||
public AuditMode afterExecution(AuditMode auditMode, String application, String description, NodeRef key, Object... args)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public AuditMode onError(AuditMode auditMode, String application, String description, NodeRef key, Object... args)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public RecordOptions getAuditRecordOptions(String application)
|
||||
{
|
||||
return getEffectiveRecordOptions();
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -1,303 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.audit.model;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.repo.audit.AuditConfiguration;
|
||||
import org.alfresco.repo.audit.AuditMode;
|
||||
import org.alfresco.repo.audit.AuditModel;
|
||||
import org.alfresco.repo.audit.RecordOptions;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentException;
|
||||
import org.dom4j.Element;
|
||||
import org.dom4j.io.SAXReader;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
public class AuditEntry extends AbstractAuditEntry implements InitializingBean, AuditModel
|
||||
{
|
||||
private static Log s_logger = LogFactory.getLog(AuditEntry.class);
|
||||
|
||||
private Map<String, ServiceAuditEntry> services = new HashMap<String, ServiceAuditEntry>();
|
||||
|
||||
private Map<String, ApplicationAuditEntry> applications = new HashMap<String, ApplicationAuditEntry>();
|
||||
|
||||
private AuditConfiguration auditConfiguration;
|
||||
|
||||
private NamespacePrefixResolver namespacePrefixResolver;
|
||||
|
||||
public AuditEntry()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public AuditConfiguration getAuditConfiguration()
|
||||
{
|
||||
return auditConfiguration;
|
||||
}
|
||||
|
||||
public void setAuditConfiguration(AuditConfiguration auditConfiguration)
|
||||
{
|
||||
this.auditConfiguration = auditConfiguration;
|
||||
}
|
||||
|
||||
public void setNamespacePrefixResolver(NamespacePrefixResolver namespacePrefixResolver)
|
||||
{
|
||||
this.namespacePrefixResolver = namespacePrefixResolver;
|
||||
}
|
||||
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
Document document = createDocument();
|
||||
Element root = document.getRootElement();
|
||||
// Check it is the correct thing
|
||||
configure(null, root, namespacePrefixResolver);
|
||||
}
|
||||
|
||||
@Override
|
||||
void configure(AbstractAuditEntry parent, Element element, NamespacePrefixResolver namespacePrefixResolver)
|
||||
{
|
||||
if (!element.getNamespaceURI().equals(AuditModel.NAME_SPACE))
|
||||
{
|
||||
throw new AuditModelException("Audit model has incorrect name space");
|
||||
}
|
||||
if (!element.getName().equals(AuditModel.EL_AUDIT))
|
||||
{
|
||||
throw new AuditModelException("Audit model has incorrect root node");
|
||||
}
|
||||
if (s_logger.isDebugEnabled())
|
||||
{
|
||||
s_logger.debug("Audit configuration");
|
||||
}
|
||||
super.configure(parent, element, namespacePrefixResolver);
|
||||
|
||||
// Add services
|
||||
|
||||
if (s_logger.isDebugEnabled())
|
||||
{
|
||||
s_logger.debug("Adding services ...");
|
||||
}
|
||||
for (Iterator nsit = element.elementIterator(AuditModel.EL_SERVICE); nsit.hasNext(); /**/)
|
||||
{
|
||||
Element serviceElement = (Element) nsit.next();
|
||||
ServiceAuditEntry service = new ServiceAuditEntry();
|
||||
service.configure(this, serviceElement, namespacePrefixResolver);
|
||||
services.put(service.getName(), service);
|
||||
}
|
||||
|
||||
// Add Applications
|
||||
|
||||
if (s_logger.isDebugEnabled())
|
||||
{
|
||||
s_logger.debug("Adding applications ...");
|
||||
}
|
||||
for (Iterator nsit = element.elementIterator(AuditModel.EL_APPLICATION); nsit.hasNext(); /**/)
|
||||
{
|
||||
Element applicationElement = (Element) nsit.next();
|
||||
ApplicationAuditEntry application = new ApplicationAuditEntry();
|
||||
application.configure(this, applicationElement, namespacePrefixResolver);
|
||||
applications.put(application.getName(), application);
|
||||
}
|
||||
}
|
||||
|
||||
public AuditMode beforeExecution(AuditMode auditMode, MethodInvocation mi)
|
||||
{
|
||||
String serviceName = getPublicServiceIdentifier().getPublicServiceName(mi);
|
||||
ServiceAuditEntry service = services.get(serviceName);
|
||||
if (service != null)
|
||||
{
|
||||
MethodAuditEntry method = service.getMethodAuditEntry(mi.getMethod().getName());
|
||||
if (method != null)
|
||||
{
|
||||
return method.beforeExecution(auditMode, mi);
|
||||
}
|
||||
else
|
||||
{
|
||||
return service.beforeExecution(auditMode, mi);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (s_logger.isDebugEnabled())
|
||||
{
|
||||
s_logger.debug("No specific audit entry for service " + serviceName);
|
||||
}
|
||||
return getEffectiveAuditMode();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public AuditMode afterExecution(AuditMode auditMode, MethodInvocation mi)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public RecordOptions getAuditRecordOptions(MethodInvocation mi)
|
||||
{
|
||||
String serviceName = getPublicServiceIdentifier().getPublicServiceName(mi);
|
||||
ServiceAuditEntry service = services.get(serviceName);
|
||||
if (service != null)
|
||||
{
|
||||
MethodAuditEntry method = service.getMethodAuditEntry(mi.getMethod().getName());
|
||||
if (method != null)
|
||||
{
|
||||
return method.getAuditRecordOptions(mi);
|
||||
}
|
||||
else
|
||||
{
|
||||
return service.getAuditRecordOptions(mi);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (s_logger.isDebugEnabled())
|
||||
{
|
||||
s_logger.debug("No specific audit entry for service " + serviceName);
|
||||
}
|
||||
return getEffectiveRecordOptions();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public AuditMode onError(AuditMode auditMode, MethodInvocation mi)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
private Document createDocument()
|
||||
{
|
||||
InputStream is = null;
|
||||
try
|
||||
{
|
||||
is = auditConfiguration.getInputStream();
|
||||
if (is == null)
|
||||
{
|
||||
throw new AuditModelException("Audit configuration could not be opened");
|
||||
}
|
||||
SAXReader reader = new SAXReader();
|
||||
try
|
||||
{
|
||||
Document document = reader.read(is);
|
||||
return document;
|
||||
}
|
||||
catch (DocumentException e)
|
||||
{
|
||||
throw new AuditModelException("Failed to create audit model document ", e);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (is != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
is.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new AuditModelException("Failed to close audit model document ", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public AuditMode beforeExecution(AuditMode auditMode, String application, String description, NodeRef key, Object... args)
|
||||
{
|
||||
ApplicationAuditEntry aae = applications.get(application);
|
||||
if (aae != null)
|
||||
{
|
||||
return aae.beforeExecution(auditMode, application, description, key, args);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (s_logger.isDebugEnabled())
|
||||
{
|
||||
s_logger.debug("No specific audit entry for application " + application);
|
||||
}
|
||||
return getEffectiveAuditMode();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public AuditMode afterExecution(AuditMode auditMode, String application, String description, NodeRef key, Object... args)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public AuditMode onError(AuditMode auditMode, String application, String description, NodeRef key, Object... args)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public RecordOptions getAuditRecordOptions(String application)
|
||||
{
|
||||
ApplicationAuditEntry aae = applications.get(application);
|
||||
if (aae != null)
|
||||
{
|
||||
return aae.getAuditRecordOptions(application);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (s_logger.isDebugEnabled())
|
||||
{
|
||||
s_logger.debug("No specific audit entry for application " + application);
|
||||
}
|
||||
return getEffectiveRecordOptions();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public TrueFalseUnset getAuditInternalServiceMethods(MethodInvocation mi)
|
||||
{
|
||||
String serviceName = getPublicServiceIdentifier().getPublicServiceName(mi);
|
||||
ServiceAuditEntry service = services.get(serviceName);
|
||||
if (service != null)
|
||||
{
|
||||
MethodAuditEntry method = service.getMethodAuditEntry(mi.getMethod().getName());
|
||||
if (method != null)
|
||||
{
|
||||
return method.getAuditInternalServiceMethods(mi);
|
||||
}
|
||||
else
|
||||
{
|
||||
return service.getAuditInternalServiceMethods(mi);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (s_logger.isDebugEnabled())
|
||||
{
|
||||
s_logger.debug("No specific audit entry for service " + serviceName);
|
||||
}
|
||||
return getEffectiveAuditInternal();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.audit.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.repo.audit.AuditModel;
|
||||
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.dom4j.Attribute;
|
||||
import org.dom4j.Element;
|
||||
|
||||
/**
|
||||
* This groups a set of filters together using AND or OR. They are evaluated in definition order with short cut evaluation if possible. The default beahviour is to or Filters
|
||||
* together.
|
||||
*
|
||||
* @author Andy Hind
|
||||
*/
|
||||
public class FilterSet extends AbstractFilter implements XMLModelElement
|
||||
{
|
||||
private static Log s_logger = LogFactory.getLog(FilterSet.class);
|
||||
|
||||
private List<AbstractFilter> filters = new ArrayList<AbstractFilter>();
|
||||
|
||||
private FilterSetMode mode = FilterSetMode.OR;
|
||||
|
||||
public FilterSet()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(Element element, NamespacePrefixResolver namespacePrefixResolver)
|
||||
{
|
||||
super.configure(element, namespacePrefixResolver);
|
||||
|
||||
// Mode
|
||||
Attribute modeAttribute = element.attribute(AuditModel.AT_MODE);
|
||||
if (modeAttribute != null)
|
||||
{
|
||||
mode = FilterSetMode.getFilterSetMode(modeAttribute.getStringValue());
|
||||
}
|
||||
|
||||
// Filters
|
||||
|
||||
for (Iterator nsit = element.elementIterator(AuditModel.EL_FILTER); nsit.hasNext(); /**/)
|
||||
{
|
||||
Element filterElement = (Element) nsit.next();
|
||||
AbstractFilter filter = AbstractFilter.createFilter(filterElement, namespacePrefixResolver);
|
||||
filters.add(filter);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.audit.model;
|
||||
|
||||
/**
|
||||
* The enum to define if elements of a filter set are combined using AND or OR.
|
||||
*
|
||||
* @author Andy Hind
|
||||
*/
|
||||
public enum FilterSetMode
|
||||
{
|
||||
AND, OR;
|
||||
|
||||
public static FilterSetMode getFilterSetMode(String value)
|
||||
{
|
||||
if(value.equalsIgnoreCase("or"))
|
||||
{
|
||||
return FilterSetMode.OR;
|
||||
}
|
||||
else if(value.equalsIgnoreCase("or"))
|
||||
{
|
||||
return FilterSetMode.AND;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new AuditModelException("Invalid FilterSetMode: "+value);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.audit.model;
|
||||
|
||||
import org.alfresco.repo.audit.AuditModel;
|
||||
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.dom4j.Attribute;
|
||||
import org.dom4j.Element;
|
||||
|
||||
public class KeyFilter extends AbstractFilter
|
||||
{
|
||||
private static Log s_logger = LogFactory.getLog(KeyFilter.class);
|
||||
|
||||
private String expression;
|
||||
|
||||
private KeyFilterMode keyFilterMode;
|
||||
|
||||
public KeyFilter()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(Element element, NamespacePrefixResolver namespacePrefixResolver)
|
||||
{
|
||||
super.configure(element, namespacePrefixResolver);
|
||||
|
||||
// Filter mode
|
||||
Attribute keyFilterTypeAttribute = element.attribute(AuditModel.AT_MODE);
|
||||
if(keyFilterTypeAttribute != null)
|
||||
{
|
||||
keyFilterMode = KeyFilterMode.getKeyFilterMode(keyFilterTypeAttribute.getStringValue());
|
||||
}
|
||||
else
|
||||
{
|
||||
keyFilterMode = KeyFilterMode.ALL;
|
||||
}
|
||||
|
||||
// Expression
|
||||
|
||||
Element expressionElement = element.element(AuditModel.EL_EXPRESSION);
|
||||
if(expressionElement == null)
|
||||
{
|
||||
throw new AuditModelException("An expression is mandatory for a key filter");
|
||||
}
|
||||
else
|
||||
{
|
||||
expression = expressionElement.getText();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@@ -1,88 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.audit.model;
|
||||
|
||||
/**
|
||||
* This enum defines the type of restriction to apply to filter based on the key node ref.
|
||||
*
|
||||
* This restriction can be based upon:
|
||||
*
|
||||
* <ol>
|
||||
* <li> The path to the node
|
||||
* <li> The type of the node
|
||||
* <li> The presence of an aspect
|
||||
* <li> The NodeRef of the node
|
||||
* <li> An XPATH expression evaluated in the context of the node with the return tested for the node.
|
||||
* e.g. ".[@cm:content = 'woof']"
|
||||
* <li> A simple value for equality tests given a non node argument
|
||||
* <li> The protocol of the store containing the node
|
||||
* <li> The identifier of the store containing the node
|
||||
* <li> Or no restriction
|
||||
* </ol>
|
||||
*
|
||||
* @author Andy Hind
|
||||
*/
|
||||
public enum KeyFilterMode
|
||||
{
|
||||
PATH, TYPE, ASPECT, NODE_REF, ALL, XPATH, VALUE, STORE_PROTOCOL, STORE_IDENTIFIER;
|
||||
|
||||
public static KeyFilterMode getKeyFilterMode(String value)
|
||||
{
|
||||
if(value.equalsIgnoreCase("path"))
|
||||
{
|
||||
return KeyFilterMode.PATH;
|
||||
}
|
||||
else if(value.equalsIgnoreCase("type"))
|
||||
{
|
||||
return KeyFilterMode.TYPE;
|
||||
}
|
||||
else if(value.equalsIgnoreCase("aspect"))
|
||||
{
|
||||
return KeyFilterMode.ASPECT;
|
||||
}
|
||||
else if(value.equalsIgnoreCase("node_ref"))
|
||||
{
|
||||
return KeyFilterMode.NODE_REF;
|
||||
}
|
||||
else if(value.equalsIgnoreCase("all"))
|
||||
{
|
||||
return KeyFilterMode.ALL;
|
||||
}
|
||||
else if(value.equalsIgnoreCase("xpath"))
|
||||
{
|
||||
return KeyFilterMode.XPATH;
|
||||
}
|
||||
else if(value.equalsIgnoreCase("value"))
|
||||
{
|
||||
return KeyFilterMode.VALUE;
|
||||
}
|
||||
else if(value.equalsIgnoreCase("store_protocol"))
|
||||
{
|
||||
return KeyFilterMode.STORE_PROTOCOL;
|
||||
}
|
||||
else if(value.equalsIgnoreCase("store_identifier"))
|
||||
{
|
||||
return KeyFilterMode.STORE_IDENTIFIER;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new AuditModelException("Unknown KeyFilterMode: "+value);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.audit.model;
|
||||
|
||||
import org.alfresco.repo.audit.AuditMode;
|
||||
import org.alfresco.repo.audit.MethodAuditModel;
|
||||
import org.alfresco.repo.audit.RecordOptions;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
public class MethodAuditEntry extends AbstractNamedAuditEntry implements MethodAuditModel
|
||||
{
|
||||
private static Log s_logger = LogFactory.getLog(MethodAuditEntry.class);
|
||||
|
||||
public MethodAuditEntry()
|
||||
{
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public AuditMode beforeExecution(AuditMode auditMode, MethodInvocation mi)
|
||||
{
|
||||
if(s_logger.isDebugEnabled())
|
||||
{
|
||||
s_logger.debug("Evaluating if method is audited ..."+((ServiceAuditEntry)getParent()).getName()+"."+getName());
|
||||
}
|
||||
return getEffectiveAuditMode();
|
||||
}
|
||||
|
||||
public AuditMode afterExecution(AuditMode auditMode, MethodInvocation mi)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public AuditMode onError(AuditMode auditMode, MethodInvocation mi)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public RecordOptions getAuditRecordOptions(MethodInvocation mi)
|
||||
{
|
||||
return getEffectiveRecordOptions();
|
||||
}
|
||||
|
||||
public TrueFalseUnset getAuditInternalServiceMethods(MethodInvocation mi)
|
||||
{
|
||||
if(s_logger.isDebugEnabled())
|
||||
{
|
||||
s_logger.debug("Evaluating if method is internally audited ..."+((ServiceAuditEntry)getParent()).getName()+"."+getName());
|
||||
}
|
||||
return getEffectiveAuditInternal();
|
||||
}
|
||||
|
||||
}
|
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.audit.model;
|
||||
|
||||
import org.alfresco.repo.audit.AuditModel;
|
||||
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.dom4j.Element;
|
||||
|
||||
public class ParameterFilter extends KeyFilter implements XMLModelElement
|
||||
{
|
||||
private static Log s_logger = LogFactory.getLog(ParameterFilter.class);
|
||||
|
||||
private QName parameterName;
|
||||
|
||||
public ParameterFilter()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(Element element, NamespacePrefixResolver namespacePrefixResolver)
|
||||
{
|
||||
super.configure(element, namespacePrefixResolver);
|
||||
|
||||
Element parameterNameElement = element.element(AuditModel.EL_PARAMETER_NAME);
|
||||
if(parameterNameElement == null)
|
||||
{
|
||||
throw new AuditModelException("A parameter is mandatory for a parameter filter");
|
||||
}
|
||||
else
|
||||
{
|
||||
String stringQName = parameterNameElement.getStringValue();
|
||||
if (stringQName.charAt(1) == '{')
|
||||
{
|
||||
parameterName = QName.createQName(stringQName);
|
||||
}
|
||||
else
|
||||
{
|
||||
parameterName = QName.createQName(stringQName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -1,191 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.audit.model;
|
||||
|
||||
import org.alfresco.repo.audit.AuditModel;
|
||||
import org.alfresco.repo.audit.RecordOptions;
|
||||
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.dom4j.Element;
|
||||
|
||||
public class RecordOptionsImpl implements XMLModelElement, RecordOptions
|
||||
{
|
||||
private static Log s_logger = LogFactory.getLog(RecordOptionsImpl.class);
|
||||
|
||||
private TrueFalseUnset recordPath = TrueFalseUnset.UNSET;
|
||||
|
||||
private TrueFalseUnset recordFilters = TrueFalseUnset.UNSET;
|
||||
|
||||
private TrueFalseUnset recordSerializedReturnValue = TrueFalseUnset.UNSET;
|
||||
|
||||
private TrueFalseUnset recordSerializedExceptions = TrueFalseUnset.UNSET;
|
||||
|
||||
private TrueFalseUnset recordSerializedMethodArguments = TrueFalseUnset.UNSET;
|
||||
|
||||
private TrueFalseUnset recordSerializedKeyPropertiesBeforeEvaluation = TrueFalseUnset.UNSET;
|
||||
|
||||
private TrueFalseUnset recordSerializedKeyPropertiesAfterEvaluation = TrueFalseUnset.UNSET;
|
||||
|
||||
public RecordOptionsImpl()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static RecordOptionsImpl mergeRecordOptions(RecordOptions primary, RecordOptions secondary)
|
||||
{
|
||||
RecordOptionsImpl answer = new RecordOptionsImpl();
|
||||
setOptions(answer, primary, true);
|
||||
setOptions(answer, secondary, false);
|
||||
return answer;
|
||||
}
|
||||
|
||||
private static void setOptions(RecordOptionsImpl on, RecordOptions from, boolean force)
|
||||
{
|
||||
if(force || on.recordFilters.equals( TrueFalseUnset.UNSET))
|
||||
{
|
||||
on.recordFilters = from.getRecordFilters();
|
||||
}
|
||||
if(force || on.recordPath.equals( TrueFalseUnset.UNSET))
|
||||
{
|
||||
on.recordPath = from.getRecordPath();
|
||||
}
|
||||
if(force || on.recordSerializedExceptions.equals( TrueFalseUnset.UNSET))
|
||||
{
|
||||
on.recordSerializedExceptions = from.getRecordSerializedExceptions();
|
||||
}
|
||||
if(force || on.recordSerializedKeyPropertiesAfterEvaluation.equals( TrueFalseUnset.UNSET))
|
||||
{
|
||||
on.recordSerializedKeyPropertiesAfterEvaluation = from.getRecordSerializedKeyPropertiesAfterEvaluation();
|
||||
}
|
||||
if(force || on.recordSerializedKeyPropertiesBeforeEvaluation.equals( TrueFalseUnset.UNSET))
|
||||
{
|
||||
on.recordSerializedKeyPropertiesBeforeEvaluation = from.getRecordSerializedKeyPropertiesBeforeEvaluation();
|
||||
}
|
||||
if(force || on.recordSerializedMethodArguments.equals( TrueFalseUnset.UNSET))
|
||||
{
|
||||
on.recordSerializedMethodArguments = from.getRecordSerializedMethodArguments();
|
||||
}
|
||||
if(force || on.recordSerializedReturnValue.equals( TrueFalseUnset.UNSET))
|
||||
{
|
||||
on.recordSerializedReturnValue = from.getRecordSerializedReturnValue();
|
||||
}
|
||||
}
|
||||
|
||||
public TrueFalseUnset getRecordFilters()
|
||||
{
|
||||
return recordFilters;
|
||||
}
|
||||
|
||||
public TrueFalseUnset getRecordPath()
|
||||
{
|
||||
return recordPath;
|
||||
}
|
||||
|
||||
public TrueFalseUnset getRecordSerializedExceptions()
|
||||
{
|
||||
return recordSerializedExceptions;
|
||||
}
|
||||
|
||||
public TrueFalseUnset getRecordSerializedKeyPropertiesAfterEvaluation()
|
||||
{
|
||||
return recordSerializedKeyPropertiesAfterEvaluation;
|
||||
}
|
||||
|
||||
public TrueFalseUnset getRecordSerializedKeyPropertiesBeforeEvaluation()
|
||||
{
|
||||
return recordSerializedKeyPropertiesBeforeEvaluation;
|
||||
}
|
||||
|
||||
public TrueFalseUnset getRecordSerializedMethodArguments()
|
||||
{
|
||||
return recordSerializedMethodArguments;
|
||||
}
|
||||
|
||||
public TrueFalseUnset getRecordSerializedReturnValue()
|
||||
{
|
||||
return recordSerializedReturnValue;
|
||||
}
|
||||
|
||||
public void configure(Element recordOptionElement, NamespacePrefixResolver namespacePrefixResolver)
|
||||
{
|
||||
Element recordFiltersElement = recordOptionElement.element(AuditModel.EL_RECORD_FILTERS);
|
||||
if (recordFiltersElement != null)
|
||||
{
|
||||
recordFilters = TrueFalseUnset.getTrueFalseUnset(recordFiltersElement.getStringValue());
|
||||
}
|
||||
|
||||
Element recordPathElement = recordOptionElement.element(AuditModel.EL_RECORD_PATH);
|
||||
if (recordPathElement != null)
|
||||
{
|
||||
recordPath = TrueFalseUnset.getTrueFalseUnset(recordPathElement.getStringValue());
|
||||
}
|
||||
|
||||
Element recordSerAgrsElement = recordOptionElement.element(AuditModel.EL_RECORD_SER_ARGS);
|
||||
if (recordSerAgrsElement != null)
|
||||
{
|
||||
recordSerializedMethodArguments = TrueFalseUnset.getTrueFalseUnset(recordSerAgrsElement.getStringValue());
|
||||
}
|
||||
|
||||
Element recordSerExElement = recordOptionElement.element(AuditModel.EL_RECORD_SER_EX);
|
||||
if (recordSerExElement != null)
|
||||
{
|
||||
recordSerializedExceptions = TrueFalseUnset.getTrueFalseUnset(recordSerExElement.getStringValue());
|
||||
}
|
||||
|
||||
Element recordSerPropAfterElement = recordOptionElement.element(AuditModel.EL_RECORD_SER_PROP_AFTER);
|
||||
if (recordSerPropAfterElement != null)
|
||||
{
|
||||
recordSerializedKeyPropertiesAfterEvaluation = TrueFalseUnset.getTrueFalseUnset(recordSerPropAfterElement
|
||||
.getStringValue());
|
||||
}
|
||||
|
||||
Element recordSerPropBeforeElement = recordOptionElement.element(AuditModel.EL_RECORD_SER_PROP_BEFORE);
|
||||
if (recordSerPropBeforeElement != null)
|
||||
{
|
||||
recordSerializedKeyPropertiesBeforeEvaluation = TrueFalseUnset.getTrueFalseUnset(recordSerPropBeforeElement
|
||||
.getStringValue());
|
||||
}
|
||||
|
||||
Element recordSerRetElement = recordOptionElement.element(AuditModel.EL_RECORD_SER_RETURN_VAL);
|
||||
if (recordSerRetElement != null)
|
||||
{
|
||||
recordSerializedReturnValue = TrueFalseUnset.getTrueFalseUnset(recordSerRetElement.getStringValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("Record Options(");
|
||||
builder.append("Filters=").append(getRecordFilters());
|
||||
builder.append(",Path=").append(getRecordPath());
|
||||
builder.append(",Exception=").append(getRecordSerializedExceptions());
|
||||
builder.append(",PropertiesBefore=").append(getRecordSerializedKeyPropertiesAfterEvaluation());
|
||||
builder.append(",PropertiesAfter=").append(getRecordSerializedKeyPropertiesBeforeEvaluation());
|
||||
builder.append(",Args=").append(getRecordSerializedMethodArguments());
|
||||
builder.append(",Return=").append(getRecordSerializedReturnValue());
|
||||
builder.append(")");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -1,126 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.audit.model;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.repo.audit.AuditMode;
|
||||
import org.alfresco.repo.audit.AuditModel;
|
||||
import org.alfresco.repo.audit.MethodAuditModel;
|
||||
import org.alfresco.repo.audit.RecordOptions;
|
||||
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.dom4j.Element;
|
||||
|
||||
public class ServiceAuditEntry extends AbstractNamedAuditEntry implements MethodAuditModel
|
||||
{
|
||||
private static Log s_logger = LogFactory.getLog(ServiceAuditEntry.class);
|
||||
|
||||
private Map<String, MethodAuditEntry> methods = new HashMap<String, MethodAuditEntry>();
|
||||
|
||||
public ServiceAuditEntry()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
void configure(AbstractAuditEntry parent, Element element, NamespacePrefixResolver namespacePrefixResolver)
|
||||
{
|
||||
super.configure(parent, element, namespacePrefixResolver);
|
||||
|
||||
// Add Methods
|
||||
|
||||
if (s_logger.isDebugEnabled())
|
||||
{
|
||||
s_logger.debug("Adding methods to service " + getName());
|
||||
}
|
||||
for (Iterator nsit = element.elementIterator(AuditModel.EL_METHOD); nsit.hasNext(); /**/)
|
||||
{
|
||||
Element methodElement = (Element) nsit.next();
|
||||
MethodAuditEntry method = new MethodAuditEntry();
|
||||
method.configure(this, methodElement, namespacePrefixResolver);
|
||||
methods.put(method.getName(), method);
|
||||
}
|
||||
if (s_logger.isDebugEnabled())
|
||||
{
|
||||
s_logger.debug("...added methods for service " + getName());
|
||||
}
|
||||
}
|
||||
|
||||
public AuditMode beforeExecution(AuditMode auditMode, MethodInvocation mi)
|
||||
{
|
||||
String methodName = mi.getMethod().getName();
|
||||
MethodAuditEntry method = methods.get(methodName);
|
||||
if (method != null)
|
||||
{
|
||||
return method.beforeExecution(auditMode, mi);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (s_logger.isDebugEnabled())
|
||||
{
|
||||
s_logger.debug("Evaluating if service is audited (no specific setting) for " + getName() + "." + methodName);
|
||||
}
|
||||
return getEffectiveAuditMode();
|
||||
}
|
||||
}
|
||||
|
||||
public AuditMode afterExecution(AuditMode auditMode, MethodInvocation mi)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public AuditMode onError(AuditMode auditMode, MethodInvocation mi)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public RecordOptions getAuditRecordOptions(MethodInvocation mi)
|
||||
{
|
||||
return getEffectiveRecordOptions();
|
||||
}
|
||||
|
||||
public TrueFalseUnset getAuditInternalServiceMethods(MethodInvocation mi)
|
||||
{
|
||||
String methodName = mi.getMethod().getName();
|
||||
MethodAuditEntry method = methods.get(methodName);
|
||||
if (method != null)
|
||||
{
|
||||
return method.getAuditInternalServiceMethods(mi);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (s_logger.isDebugEnabled())
|
||||
{
|
||||
s_logger.debug("Evaluating if service is internally audited (no specific setting) for " + getName() + "." + methodName);
|
||||
}
|
||||
return getEffectiveAuditInternal();
|
||||
}
|
||||
}
|
||||
|
||||
public MethodAuditEntry getMethodAuditEntry(String name)
|
||||
{
|
||||
return methods.get(name);
|
||||
}
|
||||
|
||||
}
|
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.audit.model;
|
||||
|
||||
/**
|
||||
* An enum for the values
|
||||
* <ol>
|
||||
* <li> TRUE
|
||||
* <li> FALSE
|
||||
* <li> UNSET
|
||||
* </ol>
|
||||
*
|
||||
* @author Andy Hind
|
||||
*/
|
||||
public enum TrueFalseUnset
|
||||
{
|
||||
TRUE, FALSE, UNSET;
|
||||
|
||||
public static TrueFalseUnset getTrueFalseUnset(String value)
|
||||
{
|
||||
if(value.equalsIgnoreCase("true"))
|
||||
{
|
||||
return TrueFalseUnset.TRUE;
|
||||
}
|
||||
else if(value.equalsIgnoreCase("false"))
|
||||
{
|
||||
return TrueFalseUnset.FALSE;
|
||||
}
|
||||
else if(value.equalsIgnoreCase("unset"))
|
||||
{
|
||||
return TrueFalseUnset.UNSET;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new AuditModelException("Invalid value for TrueFalseUnset: "+value);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.audit.model;
|
||||
|
||||
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||
import org.dom4j.Element;
|
||||
|
||||
public interface XMLModelElement
|
||||
{
|
||||
void configure(Element element, NamespacePrefixResolver namespacePrefixResolver );
|
||||
}
|
@@ -30,18 +30,14 @@ import java.util.Set;
|
||||
import java.util.zip.CRC32;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.repo.audit.AuditState;
|
||||
import org.alfresco.repo.audit.hibernate.HibernateAuditDAO;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.domain.contentdata.ContentDataDAO;
|
||||
import org.alfresco.repo.domain.propval.PropertyIdSearchRow;
|
||||
import org.alfresco.repo.domain.propval.PropertyValueDAO;
|
||||
import org.alfresco.service.cmr.audit.AuditInfo;
|
||||
import org.alfresco.service.cmr.audit.AuditService.AuditQueryCallback;
|
||||
import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -57,16 +53,10 @@ public abstract class AbstractAuditDAOImpl implements AuditDAO
|
||||
{
|
||||
protected final Log logger = LogFactory.getLog(this.getClass());
|
||||
|
||||
private HibernateAuditDAO oldDAO;
|
||||
private ContentService contentService;
|
||||
private ContentDataDAO contentDataDAO;
|
||||
protected PropertyValueDAO propertyValueDAO;
|
||||
|
||||
public void setOldDAO(HibernateAuditDAO oldDAO)
|
||||
{
|
||||
this.oldDAO = oldDAO;
|
||||
}
|
||||
|
||||
public void setContentService(ContentService contentService)
|
||||
{
|
||||
this.contentService = contentService;
|
||||
@@ -87,28 +77,6 @@ public abstract class AbstractAuditDAOImpl implements AuditDAO
|
||||
return this.propertyValueDAO;
|
||||
}
|
||||
|
||||
/*
|
||||
* Support for older audit DAO
|
||||
*/
|
||||
|
||||
/**
|
||||
* Uses {@link HibernateAuditDAO older DAO}
|
||||
* @since 3.2
|
||||
*/
|
||||
public void audit(AuditState auditInfo)
|
||||
{
|
||||
oldDAO.audit(auditInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses {@link HibernateAuditDAO older DAO}
|
||||
* @since 3.2
|
||||
*/
|
||||
public List<AuditInfo> getAuditTrail(NodeRef nodeRef)
|
||||
{
|
||||
return oldDAO.getAuditTrail(nodeRef);
|
||||
}
|
||||
|
||||
/*
|
||||
* alf_audit_model
|
||||
*/
|
||||
|
@@ -20,15 +20,11 @@ package org.alfresco.repo.domain.audit;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.repo.audit.AuditState;
|
||||
import org.alfresco.service.cmr.audit.AuditInfo;
|
||||
import org.alfresco.service.cmr.audit.AuditService.AuditQueryCallback;
|
||||
import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.util.Pair;
|
||||
|
||||
/**
|
||||
@@ -42,21 +38,6 @@ import org.alfresco.util.Pair;
|
||||
*/
|
||||
public interface AuditDAO
|
||||
{
|
||||
/**
|
||||
* Create an audit entry.
|
||||
*
|
||||
* @param auditInfo
|
||||
* @since 2.1
|
||||
*/
|
||||
public void audit(AuditState auditInfo);
|
||||
|
||||
/**
|
||||
* Get the audit trail for a node.
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public List<AuditInfo> getAuditTrail(NodeRef nodeRef);
|
||||
|
||||
/*
|
||||
* V3.2 methods after here only, please
|
||||
*/
|
||||
|
@@ -21,25 +21,17 @@ package org.alfresco.repo.security.authentication;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.repo.audit.AuditComponent;
|
||||
import org.alfresco.repo.management.subsystems.ActivateableBean;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationComponent.UserNameValidationMode;
|
||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||
|
||||
public class AuthenticationServiceImpl extends AbstractAuthenticationService implements ActivateableBean
|
||||
{
|
||||
AuthenticationComponent authenticationComponent;
|
||||
|
||||
TicketComponent ticketComponent;
|
||||
|
||||
AuditComponent auditComponent;
|
||||
|
||||
private String domain;
|
||||
|
||||
private boolean allowsUserCreation = true;
|
||||
|
||||
private boolean allowsUserDeletion = true;
|
||||
|
||||
private boolean allowsUserPasswordChange = true;
|
||||
|
||||
public AuthenticationServiceImpl()
|
||||
@@ -57,26 +49,12 @@ public class AuthenticationServiceImpl extends AbstractAuthenticationService imp
|
||||
this.authenticationComponent = authenticationComponent;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param auditComponent the auditComponent to set
|
||||
*/
|
||||
public void setAuditComponent(AuditComponent auditComponent)
|
||||
{
|
||||
this.auditComponent = auditComponent;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.repo.management.subsystems.ActivateableBean#isActive()
|
||||
*/
|
||||
public boolean isActive()
|
||||
{
|
||||
return !(this.authenticationComponent instanceof ActivateableBean)
|
||||
|| ((ActivateableBean) this.authenticationComponent).isActive();
|
||||
}
|
||||
|
||||
|
||||
public void authenticate(String userName, char[] password) throws AuthenticationException
|
||||
{
|
||||
try
|
||||
@@ -161,7 +139,6 @@ public class AuthenticationServiceImpl extends AbstractAuthenticationService imp
|
||||
|
||||
public String getNewTicket(String sessionId)
|
||||
{
|
||||
auditComponent.beforeMethodCallManualAudit(AuthenticationService.class, this, "getNewTicket", "");
|
||||
String userName = getCurrentUserName();
|
||||
try
|
||||
{
|
||||
|
@@ -32,7 +32,6 @@ import org.alfresco.repo.avm.AVMNodeConverter;
|
||||
import org.alfresco.repo.domain.PropertyValue;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.audit.AuditInfo;
|
||||
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
|
||||
import org.alfresco.service.cmr.avm.locking.AVMLockingService.LockState;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
@@ -539,19 +538,6 @@ public class AVMTemplateNode extends BasePermissionsNode implements NamespacePre
|
||||
return this.services.getAVMService().getContentDataForRead(this.avmRef).getSize();
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Audit API
|
||||
|
||||
/**
|
||||
* @return a list of AuditInfo objects describing the Audit Trail for this node instance
|
||||
*/
|
||||
public List<AuditInfo> getAuditTrail()
|
||||
{
|
||||
return this.services.getAuditService().getAuditTrail(this.nodeRef);
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Node Helper API
|
||||
|
||||
|
@@ -29,7 +29,6 @@ import java.util.Set;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.audit.AuditInfo;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.lock.LockStatus;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
@@ -525,19 +524,6 @@ public class TemplateNode extends BasePermissionsNode implements NamespacePrefix
|
||||
return new NodeSearchResultsMap(this, this.services);
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Audit API
|
||||
|
||||
/**
|
||||
* @return a list of AuditInfo objects describing the Audit Trail for this node instance
|
||||
*/
|
||||
public List<AuditInfo> getAuditTrail()
|
||||
{
|
||||
return this.services.getAuditService().getAuditTrail(this.nodeRef);
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Misc helpers
|
||||
|
||||
|
@@ -19,88 +19,18 @@
|
||||
package org.alfresco.service.cmr.audit;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.NotAuditable;
|
||||
import org.alfresco.service.PublicService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* The public API by which applications can create audit entries.
|
||||
* This does not affect auditing using method interceptors.
|
||||
* The information recorded can not be confused between the two.
|
||||
* The public API by which applications can query the audit logs and enable or disable auditing.
|
||||
*
|
||||
* This API could be used by an audit action.
|
||||
*
|
||||
* @author Andy Hind
|
||||
* @author Derek Hulley
|
||||
*/
|
||||
@PublicService
|
||||
public interface AuditService
|
||||
{
|
||||
/**
|
||||
* Add an application audit entry.
|
||||
*
|
||||
* @param source -
|
||||
* a string that represents the application
|
||||
* @param description -
|
||||
* the audit entry
|
||||
*/
|
||||
@NotAuditable
|
||||
public void audit(String source, String description);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param source -
|
||||
* a string that represents the application
|
||||
* @param description -
|
||||
* the audit entry
|
||||
* @param key -
|
||||
* a node ref to use as the key for filtering etc
|
||||
*/
|
||||
@NotAuditable
|
||||
public void audit(String source, String description, NodeRef key);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param source -
|
||||
* a string that represents the application
|
||||
* @param description -
|
||||
* the audit entry
|
||||
* @param args -
|
||||
* an arbitrary list of parameters
|
||||
*/
|
||||
@NotAuditable
|
||||
public void audit(String source, String description, Object... args);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param source -
|
||||
* a string that represents the application
|
||||
* @param description -
|
||||
* the audit entry *
|
||||
* @param key -
|
||||
* a node ref to use as the key for filtering etc
|
||||
* @param args -
|
||||
* an arbitrary list of parameters
|
||||
*/
|
||||
@NotAuditable
|
||||
public void audit(String source, String description, NodeRef key, Object... args);
|
||||
|
||||
|
||||
/**
|
||||
* Get the audit trail for a node ref.
|
||||
*
|
||||
* @param nodeRef - the node ref for which to get the audit trail.
|
||||
* @return - tha audit trail
|
||||
*/
|
||||
@NotAuditable
|
||||
public List<AuditInfo> getAuditTrail(NodeRef nodeRef);
|
||||
|
||||
/*
|
||||
* V3.2 from here on. Put all fixes to the older audit code before this point, please.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param applicationName the name of the application to check
|
||||
* @param path the path to check
|
||||
|
@@ -29,16 +29,12 @@ import org.alfresco.service.PublicService;
|
||||
* against a user id.
|
||||
*
|
||||
* @author Andy Hind
|
||||
*
|
||||
*/
|
||||
@PublicService
|
||||
public interface AuthenticationService
|
||||
{
|
||||
/**
|
||||
* Is an authentication enabled or disabled?
|
||||
*
|
||||
* @param userName
|
||||
* @return
|
||||
*/
|
||||
@Auditable(parameters = {"userName"})
|
||||
public boolean getAuthenticationEnabled(String userName) throws AuthenticationException;
|
||||
@@ -90,9 +86,6 @@ public interface AuthenticationService
|
||||
|
||||
/**
|
||||
* Invalidate any tickets held by the user.
|
||||
*
|
||||
* @param userName
|
||||
* @throws AuthenticationException
|
||||
*/
|
||||
@Auditable(parameters = {"userName"})
|
||||
public void invalidateUserSession(String userName) throws AuthenticationException;
|
||||
@@ -100,7 +93,6 @@ public interface AuthenticationService
|
||||
/**
|
||||
* Invalidate a single ticket by ID or remove its association with a given session ID.
|
||||
*
|
||||
* @param ticket
|
||||
* @param sessionId
|
||||
* the app server session ID (e.g. HttpSession ID) or <code>null</code> if not applicable.
|
||||
* @throws AuthenticationException
|
||||
@@ -145,22 +137,18 @@ public interface AuthenticationService
|
||||
* Get a new ticket as a string
|
||||
* @param sessionId
|
||||
* the app server session ID (e.g. HttpSession ID) or <code>null</code> if not applicable.
|
||||
* @return
|
||||
*/
|
||||
@Auditable(parameters = {"sessionId"}, recordable = {false})
|
||||
public String getNewTicket(String sessionId);
|
||||
|
||||
/**
|
||||
* Remove the current security information
|
||||
*
|
||||
*/
|
||||
@Auditable
|
||||
public void clearCurrentSecurityContext();
|
||||
|
||||
/**
|
||||
* Is the current user the system user?
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Auditable
|
||||
public boolean isCurrentUserTheSystemUser();
|
||||
@@ -175,24 +163,18 @@ public interface AuthenticationService
|
||||
|
||||
/**
|
||||
* Does this instance alow user to be created?
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Auditable
|
||||
public Set<String> getDomainsThatAllowUserCreation();
|
||||
|
||||
/**
|
||||
* Does this instance allow users to be deleted?
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Auditable
|
||||
public Set<String> getDomainsThatAllowUserDeletion();
|
||||
|
||||
/**
|
||||
* Does this instance allow users to update their passwords?
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Auditable
|
||||
public Set<String> getDomiansThatAllowUserPasswordChanges();
|
||||
|
Reference in New Issue
Block a user