From 1c82a3ded39f97ecec53419eda86fb673600a255 Mon Sep 17 00:00:00 2001 From: David Coutadeur Date: Fri, 17 May 2024 18:15:36 +0200 Subject: [PATCH] remove audit feature (#107) --- etc/lsc.xml-sample | 20 ------ sample/asyncldap/etc-opendj2openldap/lsc.xml | 15 ---- sample/asyncldap/etc-openldap2opendj/lsc.xml | 15 ---- sample/hsqldb/etc/lsc.xml | 1 - sample/ldap2hsqldb/etc/lsc.xml | 1 - src/main/java/org/lsc/Configuration.java | 58 ---------------- .../lsc/configuration/LscConfiguration.java | 38 +--------- src/main/resources/schemas/lsc-core-2.2.xjc | 13 ---- src/main/resources/schemas/lsc-core-2.2.xsd | 69 ------------------- .../ConfigurationLoaderTest.java | 12 ---- src/test/resources/etc/lsc.xml | 1 - .../test-config-xml/simple-config.xml | 13 ---- src/test/resources/test-config.xml | 23 +------ src/test/resources/test.xml | 10 --- .../resources/test_with_env_variables.xml | 10 --- .../test_with_funky_env_variables.xml | 10 --- 16 files changed, 3 insertions(+), 306 deletions(-) diff --git a/etc/lsc.xml-sample b/etc/lsc.xml-sample index f4f0a9fa..92a3b8e8 100644 --- a/etc/lsc.xml-sample +++ b/etc/lsc.xml-sample @@ -65,26 +65,6 @@ - - - - - - - csv - - true - - create, delete - - /tmp/dump.csv - - cn, dn - - , - - - diff --git a/sample/asyncldap/etc-opendj2openldap/lsc.xml b/sample/asyncldap/etc-opendj2openldap/lsc.xml index f4f7c361..bd3f9809 100644 --- a/sample/asyncldap/etc-opendj2openldap/lsc.xml +++ b/sample/asyncldap/etc-opendj2openldap/lsc.xml @@ -28,21 +28,6 @@ false - - - csv - true - create, delete - /tmp/audit.csv - cn, dn - ; - - - ldif - false - /tmp/audit.ldif - - People diff --git a/sample/asyncldap/etc-openldap2opendj/lsc.xml b/sample/asyncldap/etc-openldap2opendj/lsc.xml index 4cce4543..80218436 100644 --- a/sample/asyncldap/etc-openldap2opendj/lsc.xml +++ b/sample/asyncldap/etc-openldap2opendj/lsc.xml @@ -28,21 +28,6 @@ false - - - csv - true - create, delete - /tmp/audit.csv - cn, dn - ; - - - ldif - false - /tmp/audit.ldif - - People diff --git a/sample/hsqldb/etc/lsc.xml b/sample/hsqldb/etc/lsc.xml index eeb5967e..0d63227a 100644 --- a/sample/hsqldb/etc/lsc.xml +++ b/sample/hsqldb/etc/lsc.xml @@ -23,7 +23,6 @@ org.hsqldb.jdbcDriver - MySyncTask diff --git a/sample/ldap2hsqldb/etc/lsc.xml b/sample/ldap2hsqldb/etc/lsc.xml index 5decab36..32b71758 100644 --- a/sample/ldap2hsqldb/etc/lsc.xml +++ b/sample/ldap2hsqldb/etc/lsc.xml @@ -24,7 +24,6 @@ org.hsqldb.jdbcDriver - LDAP2JDBCTask diff --git a/src/main/java/org/lsc/Configuration.java b/src/main/java/org/lsc/Configuration.java index 1c2d0067..4958de2f 100644 --- a/src/main/java/org/lsc/Configuration.java +++ b/src/main/java/org/lsc/Configuration.java @@ -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; @@ -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+") !"); } @@ -312,53 +303,4 @@ public static boolean isLoggingSetup() { return loggingSetup; } - protected static void setUpCsvLogging(LoggerContext context) { - CsvAuditType audit = (CsvAuditType) LscConfiguration.getAudit("CSV"); - - FileAppender appender = new FileAppender(); - 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 appender = new FileAppender(); - 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); - } - } diff --git a/src/main/java/org/lsc/configuration/LscConfiguration.java b/src/main/java/org/lsc/configuration/LscConfiguration.java index 25975c0a..6bfcca29 100644 --- a/src/main/java/org/lsc/configuration/LscConfiguration.java +++ b/src/main/java/org/lsc/configuration/LscConfiguration.java @@ -90,8 +90,6 @@ public class LscConfiguration { private ArrayList connections; - private ArrayList audits; - private ArrayList tasks; private boolean underInitialization; @@ -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()); @@ -143,27 +140,11 @@ private LscConfiguration() { underInitialization = true; modified = false; connections = new ArrayList(); - audits = new ArrayList(); tasks = new ArrayList(); // otherSettings = new HashMap(); revision = 0; } - public static Collection 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 getConnections() { List connectionsList = new ArrayList(); if(getInstance().getLsc().getConnections() != null) { @@ -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(); // } @@ -237,9 +208,6 @@ public static void finalizeInitialization() { public LscConfiguration clone() { LscConfiguration clone = new LscConfiguration(); clone.revision = revision; - if(audits != null) { - clone.audits = (ArrayList) audits.clone(); - } if(connections != null) { clone.connections = (ArrayList) connections.clone(); } @@ -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; } @@ -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); } @@ -591,4 +557,4 @@ public static boolean pivotOriginMatchesFromSource(PivotOriginType pivotOrigin, } } } - \ No newline at end of file + diff --git a/src/main/resources/schemas/lsc-core-2.2.xjc b/src/main/resources/schemas/lsc-core-2.2.xjc index 420c8554..c1b0711a 100644 --- a/src/main/resources/schemas/lsc-core-2.2.xjc +++ b/src/main/resources/schemas/lsc-core-2.2.xjc @@ -66,19 +66,6 @@ - - - - - - - - - - - - - diff --git a/src/main/resources/schemas/lsc-core-2.2.xsd b/src/main/resources/schemas/lsc-core-2.2.xsd index 5aaf4e55..25028169 100644 --- a/src/main/resources/schemas/lsc-core-2.2.xsd +++ b/src/main/resources/schemas/lsc-core-2.2.xsd @@ -186,59 +186,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -549,12 +496,6 @@ minOccurs="0" /> - - - - - - @@ -570,15 +511,6 @@ --> - - - - - - - - - @@ -613,7 +545,6 @@ - diff --git a/src/test/java/org/lsc/configuration/ConfigurationLoaderTest.java b/src/test/java/org/lsc/configuration/ConfigurationLoaderTest.java index fc1050de..73178f0b 100644 --- a/src/test/java/org/lsc/configuration/ConfigurationLoaderTest.java +++ b/src/test/java/org/lsc/configuration/ConfigurationLoaderTest.java @@ -13,7 +13,6 @@ import java.util.Map; import org.junit.Test; -import org.lsc.configuration.TaskType.AuditLog; import org.lsc.exception.LscConfigurationException; import com.google.common.collect.ImmutableMap; @@ -66,7 +65,6 @@ public void testLoadSimpleConfiguration() throws FileNotFoundException, LscConfi assertNotNull(c); LscConfiguration.loadFromInstance(c); assertEquals(3, LscConfiguration.getConnections().size()); - assertEquals(1, LscConfiguration.getAudits().size()); assertEquals(2, LscConfiguration.getTasks().size()); } @@ -131,16 +129,6 @@ public void testDumpSimpleConfiguration() throws IOException, LscConfigurationEx Lsc c = getFile(this.getClass().getClassLoader().getResource("test.xml").getPath(), ImmutableMap.of()); LscConfiguration.loadFromInstance(c); - CsvAuditType csvAudit = new CsvAuditType(); - csvAudit.setId("csvAudit-1"); - csvAudit.setAppend(false); - csvAudit.setDatasets("cn, sn, givenName"); - csvAudit.setName("csvAudit-1"); - csvAudit.setSeparator(";"); - LscConfiguration.addAudit(csvAudit); - AuditLog auditLog = new AuditLog(); - auditLog.setReference(csvAudit); - LscConfiguration.getTasks().iterator().next().getAuditLog().add(auditLog); new JaxbXmlConfigurationHelper().saveConfiguration(new File(this.getClass().getClassLoader().getResource("etc").getFile(),"test-dump.xml").toString(), LscConfiguration.getInstance().getLsc()); } diff --git a/src/test/resources/etc/lsc.xml b/src/test/resources/etc/lsc.xml index 9891c1e3..255f6cf0 100644 --- a/src/test/resources/etc/lsc.xml +++ b/src/test/resources/etc/lsc.xml @@ -76,7 +76,6 @@ org.hsqldb.jdbcDriver - ldap2ldapTestTask diff --git a/src/test/resources/test-config-xml/simple-config.xml b/src/test/resources/test-config-xml/simple-config.xml index 3b2fee03..e9ec0eab 100644 --- a/src/test/resources/test-config-xml/simple-config.xml +++ b/src/test/resources/test-config-xml/simple-config.xml @@ -18,19 +18,6 @@ org.hsqldb.blabla - - csv - create, delete - cn, dn - ; - true - /tmp/log.csv - - - create, delete - false - /tmp/log.ldif - myTask diff --git a/src/test/resources/test-config.xml b/src/test/resources/test-config.xml index 2cb336ee..6402bc22 100644 --- a/src/test/resources/test-config.xml +++ b/src/test/resources/test-config.xml @@ -22,23 +22,6 @@ - - - csv - create, delete - cn, dn - ; - true - /tmp/log.csv - - - ldif - create, delete - false - /tmp/log.ldif - - - myADAccount @@ -61,10 +44,6 @@ myTask myADAccount myDestination - - csv - ldif - 1 > 0 src.getAttr('updateTimeStamp') > dst.getAttr('updateTimeStamp') @@ -82,4 +61,4 @@ - \ No newline at end of file + diff --git a/src/test/resources/test.xml b/src/test/resources/test.xml index 40d57b7c..e7beb69a 100644 --- a/src/test/resources/test.xml +++ b/src/test/resources/test.xml @@ -35,15 +35,6 @@ false - - - csvAudit - false - $TEMP/log.csv - cn, sn, givenName - ; - - ldap2ldapTestTask @@ -146,7 +137,6 @@ - db2ldapTestTask diff --git a/src/test/resources/test_with_env_variables.xml b/src/test/resources/test_with_env_variables.xml index a3549dbf..e0f8ccb1 100644 --- a/src/test/resources/test_with_env_variables.xml +++ b/src/test/resources/test_with_env_variables.xml @@ -35,15 +35,6 @@ false - - - csvAudit - false - $TEMP/log.csv - cn, sn, givenName - ; - - ldap2ldapTestTask @@ -146,7 +137,6 @@ - db2ldapTestTask diff --git a/src/test/resources/test_with_funky_env_variables.xml b/src/test/resources/test_with_funky_env_variables.xml index fa135186..15fa7c57 100644 --- a/src/test/resources/test_with_funky_env_variables.xml +++ b/src/test/resources/test_with_funky_env_variables.xml @@ -35,15 +35,6 @@ false - - - csvAudit - false - $TEMP/log.csv - cn, sn, givenName - ; - - ldap2ldapTestTask @@ -146,7 +137,6 @@ - db2ldapTestTask