Skip to content

Commit

Permalink
remove audit feature (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
David Coutadeur committed May 17, 2024
1 parent 1b800cc commit 81d1491
Show file tree
Hide file tree
Showing 16 changed files with 3 additions and 306 deletions.
20 changes: 0 additions & 20 deletions etc/lsc.xml-sample
Original file line number Diff line number Diff line change
Expand Up @@ -65,26 +65,6 @@
</ldapConnection>
</connections>

<!-- ./audits Audits list node -->
<audits>

<!--./audit Audit node, here a CSV audit, may also be a LDIF or any contributed audit type -->
<csvAudit>
<!-- ./name mandatory, audit name -->
<name>csv</name>
<!-- ./append optional, default to false, specify to create a new log file or to append to the existing one -->
<append>true</append>
<!-- ./operations optional, comma separated list of operations (create, delete, update or rename) -->
<operations>create, delete</operations>
<!-- ./file mandatory, define the location of the file where the CSV data will be written -->
<file>/tmp/dump.csv</file>
<!-- ./datasets optional, comma separated list of datasets modification to log -->
<datasets>cn, dn</datasets>
<!-- ./separator optional, default to ";", specify the values separator -->
<separator>,</separator>
</csvAudit>
</audits>

<!-- ./tasks Task list node, must contain at least one task -->
<tasks>

Expand Down
15 changes: 0 additions & 15 deletions sample/asyncldap/etc-opendj2openldap/lsc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,6 @@
<tlsActivated>false</tlsActivated>
</ldapConnection>
</connections>
<audits>
<csvAudit>
<name>csv</name>
<append>true</append>
<operations>create, delete</operations>
<file>/tmp/audit.csv</file>
<datasets>cn, dn</datasets>
<separator>;</separator>
</csvAudit>
<ldifAudit>
<name>ldif</name>
<append>false</append>
<file>/tmp/audit.ldif</file>
</ldifAudit>
</audits>
<tasks>
<task>
<name>People</name>
Expand Down
15 changes: 0 additions & 15 deletions sample/asyncldap/etc-openldap2opendj/lsc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,6 @@
<tlsActivated>false</tlsActivated>
</ldapConnection>
</connections>
<audits>
<csvAudit>
<name>csv</name>
<append>true</append>
<operations>create, delete</operations>
<file>/tmp/audit.csv</file>
<datasets>cn, dn</datasets>
<separator>;</separator>
</csvAudit>
<ldifAudit>
<name>ldif</name>
<append>false</append>
<file>/tmp/audit.ldif</file>
</ldifAudit>
</audits>
<tasks>
<task>
<name>People</name>
Expand Down
1 change: 0 additions & 1 deletion sample/hsqldb/etc/lsc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
<driver>org.hsqldb.jdbcDriver</driver>
</databaseConnection>
</connections>
<audits/>
<tasks>
<task>
<name>MySyncTask</name>
Expand Down
1 change: 0 additions & 1 deletion sample/ldap2hsqldb/etc/lsc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
<driver>org.hsqldb.jdbcDriver</driver>
</databaseConnection>
</connections>
<audits />
<tasks>
<task>
<name>LDAP2JDBCTask</name>
Expand Down
58 changes: 0 additions & 58 deletions src/main/java/org/lsc/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@
import java.io.File;
import java.util.Properties;

import org.lsc.configuration.CsvAuditType;
import org.lsc.configuration.JaxbXmlConfigurationHelper;
import org.lsc.configuration.LdifAuditType;
import org.lsc.configuration.LscConfiguration;
import org.lsc.exception.LscConfigurationException;
import org.lsc.exception.LscException;
Expand Down Expand Up @@ -258,13 +256,6 @@ public static void setUp(String lscConfigurationPath, boolean validate) throws L
try {
configurator.doConfigure(logBackXMLPropertiesFile);
LOGGER.info("Logging configuration successfully loaded from " + logBackXMLPropertiesFile + " ");
if(LscConfiguration.getAudit("CSV") != null) {
setUpCsvLogging(context);
}

if(LscConfiguration.getAudit("LDIF") != null) {
setUpLdifLogging(context);
}
} catch (JoranException je) {
System.err.println("Cannot find logging configuration file ("+logBackXMLPropertiesFile+") !");
}
Expand Down Expand Up @@ -312,53 +303,4 @@ public static boolean isLoggingSetup() {
return loggingSetup;
}

protected static void setUpCsvLogging(LoggerContext context) {
CsvAuditType audit = (CsvAuditType) LscConfiguration.getAudit("CSV");

FileAppender<ILoggingEvent> appender = new FileAppender<ILoggingEvent>();
appender.setName(audit.getName());
appender.setAppend(audit.isAppend());
appender.setFile(audit.getFile());
appender.setContext(context);

CsvLayout csvLayout = new CsvLayout();
csvLayout.setLogOperations(audit.getOperations());
csvLayout.setAttrs(audit.getDatasets());
csvLayout.setSeparator(audit.getSeparator());
csvLayout.setOutputHeader(audit.isOutputHeader());
if(audit.getTaskNames() != null && audit.getTaskNames().getString() != null) {
csvLayout.setTaskNames(audit.getTaskNames().getString().toArray(new String[audit.getTaskNames().getString().size()]));
}
csvLayout.setContext(context);
csvLayout.start();

appender.setLayout(csvLayout);
appender.start();
ch.qos.logback.classic.Logger rootLogger = context.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME);
rootLogger.addAppender(appender);
}

protected static void setUpLdifLogging(LoggerContext context) {
LdifAuditType audit = (LdifAuditType) LscConfiguration.getAudit("LDIF");

FileAppender<ILoggingEvent> appender = new FileAppender<ILoggingEvent>();
appender.setName(audit.getName());
appender.setAppend(audit.isAppend());
appender.setFile(audit.getFile());
appender.setContext(context);

LdifLayout ldifLayout = new LdifLayout();
ldifLayout.setLogOperations(audit.getOperations());
if(audit.isLogOnlyLdif() != null) {
ldifLayout.setOnlyLdif(audit.isLogOnlyLdif());
}
ldifLayout.setContext(context);
ldifLayout.start();

appender.setLayout(ldifLayout);
appender.start();
ch.qos.logback.classic.Logger rootLogger = context.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME);
rootLogger.addAppender(appender);
}

}
38 changes: 2 additions & 36 deletions src/main/java/org/lsc/configuration/LscConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ public class LscConfiguration {

private ArrayList<ConnectionType> connections;

private ArrayList<AuditType> audits;

private ArrayList<TaskType> tasks;

private boolean underInitialization;
Expand Down Expand Up @@ -120,7 +118,6 @@ public static void loadFromInstance(Lsc lscInstance) {
original = instance;
}
instance.lscObject = new Lsc();
instance.lscObject.setAudits(lscInstance.getAudits());
instance.lscObject.setConnections(lscInstance.getConnections());
instance.lscObject.setId(lscInstance.getId());
instance.lscObject.setRevision(lscInstance.getRevision());
Expand All @@ -143,27 +140,11 @@ private LscConfiguration() {
underInitialization = true;
modified = false;
connections = new ArrayList<ConnectionType>();
audits = new ArrayList<AuditType>();
tasks = new ArrayList<TaskType>();
// otherSettings = new HashMap<String, String>();
revision = 0;
}

public static Collection<AuditType> getAudits() {
return Collections.unmodifiableCollection(getInstance().getLsc().getAudits().getCsvAuditOrLdifAuditOrPluginAudit());
}

public static AuditType getAudit(String name) {
if(getInstance().getLsc().getAudits() != null) {
for(AuditType audit: getInstance().getLsc().getAudits().getCsvAuditOrLdifAuditOrPluginAudit()) {
if(audit.getName().equalsIgnoreCase(name)) {
return audit;
}
}
}
return null;
}

public static Collection<ConnectionType> getConnections() {
List<ConnectionType> connectionsList = new ArrayList<ConnectionType>();
if(getInstance().getLsc().getConnections() != null) {
Expand Down Expand Up @@ -214,16 +195,6 @@ public static void removeConnection(ConnectionType connection) {
getInstance().getLsc().getConnections().getLdapConnectionOrDatabaseConnectionOrPluginConnection().remove(connection);
}

public static void addAudit(AuditType audit) {
logModification(audit);
getInstance().getLsc().getAudits().getCsvAuditOrLdifAuditOrPluginAudit().add(audit);
}

public static void removeAudit(AuditType audit) {
logModification(audit);
getInstance().getLsc().getAudits().getCsvAuditOrLdifAuditOrPluginAudit().remove(audit);
}

// public static void reinitialize() {
// getInstance().lscObject = new Lsc();
// }
Expand All @@ -237,9 +208,6 @@ public static void finalizeInitialization() {
public LscConfiguration clone() {
LscConfiguration clone = new LscConfiguration();
clone.revision = revision;
if(audits != null) {
clone.audits = (ArrayList<AuditType>) audits.clone();
}
if(connections != null) {
clone.connections = (ArrayList<ConnectionType>) connections.clone();
}
Expand Down Expand Up @@ -279,11 +247,9 @@ public boolean isModified() {
}

public static void revertToInitialState() {
instance.audits = original.audits;
instance.connections = original.connections;
instance.tasks = original.tasks;
instance.security = original.security;
instance.audits = original.audits;
instance.revision = original.revision;
instance.modified = false;
}
Expand Down Expand Up @@ -313,7 +279,7 @@ public void setSecurity(SecurityType sec) {
}

public void validate() throws LscException {
// Tasks will check used audits and connections
// Tasks will check used connections
for(TaskType task: getTasks()) {
validate(task);
}
Expand Down Expand Up @@ -591,4 +557,4 @@ public static boolean pivotOriginMatchesFromSource(PivotOriginType pivotOrigin,
}
}
}


13 changes: 0 additions & 13 deletions src/main/resources/schemas/lsc-core-2.2.xjc
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,6 @@
</jaxb:bindings>
</jaxb:bindings>
</jaxb:bindings>
<jaxb:bindings node="xsd:complexType[@name='taskType']">
<jaxb:bindings node="xsd:sequence">
<jaxb:bindings node="xsd:element[@name='auditLog']">
<jaxb:bindings node="xsd:complexType">
<jaxb:bindings node="xsd:attribute[@name='reference']">
<jaxb:property>
<jaxb:baseType name="org.lsc.configuration.AuditType"/>
</jaxb:property>
</jaxb:bindings>
</jaxb:bindings>
</jaxb:bindings>
</jaxb:bindings>
</jaxb:bindings>
<jaxb:bindings node="xsd:complexType[@name='multiDestinationServiceType']">
<jaxb:bindings node="xsd:complexContent">
<jaxb:bindings node="xsd:extension">
Expand Down
69 changes: 0 additions & 69 deletions src/main/resources/schemas/lsc-core-2.2.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -186,59 +186,6 @@
<xsd:attribute name="id" type="xsd:string" use="optional" />
</xsd:complexType>

<xsd:complexType name="auditType">
<xsd:sequence>
<xsd:element name="name" type="xsd:ID" />
<xsd:element name="append" type="xsd:boolean" minOccurs="0"
default="true" />
<xsd:element name="operations" type="xsd:string"
minOccurs="0" />
<xsd:element name="file" type="xsd:string" />
</xsd:sequence>
<xsd:attribute name="id" type="xsd:string" use="optional" />
</xsd:complexType>

<xsd:complexType name="ldifAuditType">
<xsd:complexContent>
<xsd:extension base="auditType">
<xsd:sequence>
<xsd:element name="logOnlyLdif" type="xsd:boolean"
default="true" minOccurs="0" />
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

<xsd:complexType name="csvAuditType">
<xsd:complexContent>
<xsd:extension base="auditType">
<xsd:sequence>
<xsd:element name="datasets" type="xsd:string"
minOccurs="0" />
<xsd:element name="separator" type="xsd:string"
minOccurs="0" default=";" />
<xsd:element name="outputHeader" type="xsd:boolean"
minOccurs="0" default="true" />
<xsd:element name="taskNames" type="valuesType"
minOccurs="0" />
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

<xsd:complexType name="pluginAuditType">
<xsd:complexContent>
<xsd:extension base="auditType">
<xsd:sequence>
<xsd:any namespace="##any" minOccurs="0" maxOccurs="unbounded"
processContents="lax" />
</xsd:sequence>
<xsd:attribute name="configurationClass" type="xsd:string" />
<xsd:attribute name="implementationClass" type="xsd:string" />
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

<xsd:complexType name="serviceType">
<xsd:sequence>
<xsd:element name="name" type="xsd:ID" />
Expand Down Expand Up @@ -549,12 +496,6 @@
minOccurs="0" />
<xsd:element name="scriptInclude" type="valuesType"
minOccurs="0" />
<!-- The following element is unsupported at this time -->
<xsd:element name="auditLog" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:attribute name="reference" type="xsd:IDREF" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:string" use="optional" />
</xsd:complexType>
Expand All @@ -570,15 +511,6 @@
<xs:selector xpath="connection"/> <xs:field xpath="@name"/> </xs:key> -->
</xsd:complexType>

<xsd:complexType name="auditsType">
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="csvAudit" type="csvAuditType" />
<xsd:element name="ldifAudit" type="ldifAuditType" />
<xsd:element name="pluginAudit" type="pluginAuditType" />
</xsd:choice>
<xsd:attribute name="id" type="xsd:string" use="optional" />
</xsd:complexType>

<xsd:complexType name="tasksType">
<xsd:sequence>
<xsd:element name="task" type="taskType" maxOccurs="unbounded" />
Expand Down Expand Up @@ -613,7 +545,6 @@
<xsd:complexType>
<xsd:all>
<xsd:element name="connections" type="connectionsType" />
<xsd:element name="audits" type="auditsType" minOccurs="0" />
<xsd:element name="tasks" type="tasksType" />
<xsd:element name="security" type="securityType"
minOccurs="0" />
Expand Down
Loading

0 comments on commit 81d1491

Please sign in to comment.