http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-audit/log4j-audit-api/src/main/java/org/apache/logging/log4j/audit/util/JsonObjectMapperFactory.java ---------------------------------------------------------------------- diff --git a/log4j-audit/log4j-audit-api/src/main/java/org/apache/logging/log4j/audit/util/JsonObjectMapperFactory.java b/log4j-audit/log4j-audit-api/src/main/java/org/apache/logging/log4j/audit/util/JsonObjectMapperFactory.java new file mode 100644 index 0000000..5c435c4 --- /dev/null +++ b/log4j-audit/log4j-audit-api/src/main/java/org/apache/logging/log4j/audit/util/JsonObjectMapperFactory.java @@ -0,0 +1,164 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache license, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the license for the specific language governing permissions and + * limitations under the license. + */ +package org.apache.logging.log4j.audit.util; + +import java.io.IOException; +import java.time.DateTimeException; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; + +import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.module.SimpleModule; + +/** + * Extends Jackson ObjectMapper to support Java LocalDateTime. + */ +public final class JsonObjectMapperFactory { + + /** + * Date/Time format. + */ + public static final String LOCAL_DATE_TIME_FORMAT = "yyyyMMddHHmmss.SSS"; + + /** + * LocalDateTime formatter that converts to and from a format usable in REST requests. + */ + public static final DateTimeFormatter LOCAL_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern(LOCAL_DATE_TIME_FORMAT); + + /** + * Date/Time format. + */ + public static final String LOCAL_DATE_FORMAT = "yyyyMMdd"; + + /** + * LocalDateTime formatter that converts to and from a format usable in REST requests. + */ + public static final DateTimeFormatter LOCAL_DATE_FORMATTER = DateTimeFormatter.ofPattern(LOCAL_DATE_FORMAT); + + /** + * Date/Time format. + */ + public static final String ZONED_DATE_TIME_FORMAT = "yyyyMMddHHmmss.SSSZ"; + + /** + * LocalDateTime formatter that converts to and from a format usable in REST requests. + */ + public static final DateTimeFormatter ZONED_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern(ZONED_DATE_TIME_FORMAT); + + private JsonObjectMapperFactory() { + } + + /** + * Create an ObjectMapper using the standard LocalDateTime format. + * @return The ObjectMapper. + */ + public static ObjectMapper createMapper() { + ObjectMapper mapper = Jackson2ObjectMapperBuilder.json().build(); + DateTimeFormatter dateTimeFormatter = LOCAL_DATE_TIME_FORMATTER; + DateTimeFormatter dateFormatter = LOCAL_DATE_FORMATTER; + DateTimeFormatter zonedTimeFormatter = ZONED_DATE_TIME_FORMATTER; + SimpleModule module = new SimpleModule(); + module.addSerializer(LocalDateTime.class, new JsonSerializer<LocalDateTime>() { + @Override + public void serialize(LocalDateTime localDateTime, JsonGenerator jsonGenerator, + SerializerProvider serializerProvider) throws IOException, JsonProcessingException { + jsonGenerator.writeString(dateTimeFormatter.format(localDateTime)); + } + }); + module.addDeserializer(LocalDateTime.class, new JsonDeserializer<LocalDateTime>() { + @Override + public LocalDateTime deserialize(JsonParser parser, DeserializationContext context) throws IOException { + String string = parser.getText().trim(); + if (string.length() == 0) { + return null; + } + try { + return LocalDateTime.parse(string, dateTimeFormatter); + } catch (DateTimeException e) { + throw JsonMappingException.from(parser, + String.format("Failed to deserialize %s: (%s) %s", + handledType().getName(), e.getClass().getName(), e.getMessage()), e); + } + } + }); + module.addSerializer(ZonedDateTime.class, new JsonSerializer<ZonedDateTime>() { + @Override + public void serialize(ZonedDateTime zonedDateTime, JsonGenerator jsonGenerator, + SerializerProvider serializerProvider) throws IOException, JsonProcessingException { + jsonGenerator.writeString(zonedTimeFormatter.format(zonedDateTime)); + } + }); + module.addDeserializer(ZonedDateTime.class, new JsonDeserializer<ZonedDateTime>() { + @Override + public ZonedDateTime deserialize(JsonParser parser, DeserializationContext context) throws IOException { + String string = parser.getText().trim(); + if (string.length() == 0) { + return null; + } + try { + return ZonedDateTime.parse(string, zonedTimeFormatter); + } catch (DateTimeException e) { + throw JsonMappingException.from(parser, + String.format("Failed to deserialize %s: (%s) %s", + handledType().getName(), e.getClass().getName(), e.getMessage()), e); + } + } + }); + module.addSerializer(LocalDate.class, new JsonSerializer<LocalDate>() { + @Override + public void serialize(LocalDate localDate, JsonGenerator jsonGenerator, + SerializerProvider serializerProvider) throws IOException, JsonProcessingException { + jsonGenerator.writeString(dateFormatter.format(localDate)); + } + }); + module.addDeserializer(LocalDate.class, new JsonDeserializer<LocalDate>() { + @Override + public LocalDate deserialize(JsonParser parser, DeserializationContext context) throws IOException { + String string = parser.getText().trim(); + if (string.length() == 0) { + return null; + } + try { + return LocalDate.parse(string, dateFormatter); + } catch (DateTimeException e) { + throw JsonMappingException.from(parser, + String.format("Failed to deserialize %s: (%s) %s", + handledType().getName(), e.getClass().getName(), e.getMessage()), e); + } + } + }); + mapper.registerModule(module); + mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); + mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); + return mapper; + } + +}
http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-audit/log4j-audit-api/src/main/java/org/apache/logging/log4j/audit/util/NamingUtils.java ---------------------------------------------------------------------- diff --git a/log4j-audit/log4j-audit-api/src/main/java/org/apache/logging/log4j/audit/util/NamingUtils.java b/log4j-audit/log4j-audit-api/src/main/java/org/apache/logging/log4j/audit/util/NamingUtils.java new file mode 100644 index 0000000..6fb5063 --- /dev/null +++ b/log4j-audit/log4j-audit-api/src/main/java/org/apache/logging/log4j/audit/util/NamingUtils.java @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache license, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the license for the specific language governing permissions and + * limitations under the license. + */ +package org.apache.logging.log4j.audit.util; + +public final class NamingUtils { + + private NamingUtils() { + } + + public static String getPackageName(String className) { + return className.substring(0, className.lastIndexOf(".")); + } + + public static String getSimpleName(String className) { + return className.substring(className.lastIndexOf(".") + 1); + } + + public static String getMethodShortName(String name) { + return name.replaceFirst("(get|set|is|has)", ""); + } + + public static String upperFirst(String name) { + return String.valueOf(name.charAt(0)).toUpperCase() + name.substring(1); + } + + public static String lowerFirst(String name) { + return String.valueOf(name.charAt(0)).toLowerCase() + name.substring(1); + } + + public static String getSetterName(String fieldName) { + return "set" + upperFirst(fieldName); + } + + public static String getGetterName(String fieldName, String type) { + if ("boolean".equals(type)) { + return "is" + upperFirst(fieldName); + } else { + return "get" + upperFirst(fieldName); + } + } + + public static String getClassName(String className) { + return upperFirst(className.replaceAll("[^a-zA-Z0-9_]+", "")); + } + + public static String getFieldName(String fieldName) { + return fieldName.replaceAll("[^a-zA-Z0-9_]+", ""); + } + + public static String methodCaseName(String variable) { + return variable.substring(0, 1).toUpperCase() + variable.substring(1); + } + + public static String getAccessorName(String type, String methodName) { + String prefix = "get"; + if (type.equals("boolean")) { + prefix = "is"; + } + return prefix + methodCaseName(methodName); + } + + public static String getMutatorName(String methodName) { + return "set" + methodCaseName(methodName); + } +} http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-audit/log4j-audit-api/src/main/java/org/apache/logging/log4j/audit/util/StringUtil.java ---------------------------------------------------------------------- diff --git a/log4j-audit/log4j-audit-api/src/main/java/org/apache/logging/log4j/audit/util/StringUtil.java b/log4j-audit/log4j-audit-api/src/main/java/org/apache/logging/log4j/audit/util/StringUtil.java new file mode 100644 index 0000000..18e933f --- /dev/null +++ b/log4j-audit/log4j-audit-api/src/main/java/org/apache/logging/log4j/audit/util/StringUtil.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache license, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the license for the specific language governing permissions and + * limitations under the license. + */ +package org.apache.logging.log4j.audit.util; + +public class StringUtil { + + public static String filterContent(String content, String name, String type) { + return content.replaceAll("@name", name).replace("@type", type); + } + + public static void main(String[] args) { + String input = "co_nf.No."; + String alphaAndDigits = input.replaceAll("[^a-zA-Z0-9_]+", ""); + System.out.println(alphaAndDigits); + } + +} http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-audit/log4j-audit-api/src/test/java/org/apache/logging/log4j/audit/AuditLoggerTest.java ---------------------------------------------------------------------- diff --git a/log4j-audit/log4j-audit-api/src/test/java/org/apache/logging/log4j/audit/AuditLoggerTest.java b/log4j-audit/log4j-audit-api/src/test/java/org/apache/logging/log4j/audit/AuditLoggerTest.java new file mode 100644 index 0000000..abe6eb8 --- /dev/null +++ b/log4j-audit/log4j-audit-api/src/test/java/org/apache/logging/log4j/audit/AuditLoggerTest.java @@ -0,0 +1,115 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache license, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the license for the specific language governing permissions and + * limitations under the license. + */ +package org.apache.logging.log4j.audit; + + +import org.apache.logging.log4j.ThreadContext; +import org.apache.logging.log4j.audit.catalog.CatalogManager; +import org.apache.logging.log4j.audit.catalog.CatalogManagerImpl; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.audit.catalog.StringCatalogReader; +import org.apache.logging.log4j.audit.exception.AuditException; +import org.apache.logging.log4j.core.Appender; +import org.apache.logging.log4j.core.LoggerContext; +import org.apache.logging.log4j.core.config.Configuration; +import org.apache.logging.log4j.test.appender.ListAppender; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +/** + * + */ +public class AuditLoggerTest { + + private static AbstractEventLogger auditLogger; + + private static CatalogManager catalogManager; + + private static LoggerContext ctx; + private static ListAppender app; + + @BeforeClass + public static void setupClass() throws Exception { + catalogManager = new CatalogManagerImpl(new StringCatalogReader()); + auditLogger = new AuditLogger(); + auditLogger.setCatalogManager(catalogManager); + ctx = (LoggerContext) LogManager.getContext(false); + Configuration config = ctx.getConfiguration(); + for (Map.Entry<String, Appender> entry : config.getAppenders().entrySet()) { + if (entry.getKey().equals("List")) { + app = (ListAppender) entry.getValue(); + break; + } + } + assertNotNull("No Appender", app); + } + + @Before + public void before() { + app.clear(); + } + + @Test + public void testAuditLogger() { + ThreadContext.put("companyId", "12345"); + ThreadContext.put("ipAddress", "127.0.0.1"); + ThreadContext.put("environment", "dev"); + ThreadContext.put("product", "TestProduct"); + ThreadContext.put("timeZone", "America/Phoenix"); + ThreadContext.put("loginId", "TestUser"); + Map<String, String> properties = new HashMap<String, String>(); + properties.put("toAccount", "123456"); + properties.put("fromAccount", "111111"); + properties.put("amount", "111.55"); + try { + auditLogger.logEvent("transfer", properties); + } catch (Exception ex) { + ex.printStackTrace(); + fail(); + } + List<String> msgs = app.getMessages(); + assertNotNull("No messages", msgs); + assertTrue("No messages", msgs.size() == 1); + String msg = msgs.get(0); + assertTrue("No companyId", msg.contains("companyId=\"12345\"")); + assertTrue("No ipAddress", msg.contains("ipAddress=\"127.0.0.1\"")); + assertTrue("No toAccount", msg.contains("toAccount=\"123456\"")); + } + + @Test(expected = AuditException.class) + public void testBadAttribute() { + ThreadContext.put("companyId", "12345"); + ThreadContext.put("ipAddress", "127.0.0.1"); + ThreadContext.put("environment", "dev"); + ThreadContext.put("product", "TestProduct"); + ThreadContext.put("timeZone", "America/Phoenix"); + ThreadContext.put("loginId", "TestUser"); + Map<String, String> properties = new HashMap<String, String>(); + properties.put("toAccount", "123456"); + properties.put("amount", "111.55"); + auditLogger.logEvent("transfer", properties); + } +} http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-audit/log4j-audit-api/src/test/java/org/apache/logging/log4j/audit/TransferTest.java ---------------------------------------------------------------------- diff --git a/log4j-audit/log4j-audit-api/src/test/java/org/apache/logging/log4j/audit/TransferTest.java b/log4j-audit/log4j-audit-api/src/test/java/org/apache/logging/log4j/audit/TransferTest.java new file mode 100644 index 0000000..7c5ce5e --- /dev/null +++ b/log4j-audit/log4j-audit-api/src/test/java/org/apache/logging/log4j/audit/TransferTest.java @@ -0,0 +1,162 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache license, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the license for the specific language governing permissions and + * limitations under the license. + */ +package org.apache.logging.log4j.audit; + +import java.math.BigDecimal; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.ThreadContext; +import org.apache.logging.log4j.audit.event.Transfer; +import org.apache.logging.log4j.audit.exception.AuditException; +import org.apache.logging.log4j.catalog.api.exception.ConstraintValidationException; +import org.apache.logging.log4j.core.Appender; +import org.apache.logging.log4j.core.LoggerContext; +import org.apache.logging.log4j.core.config.Configuration; +import org.apache.logging.log4j.test.appender.ListAppender; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +/** + * + */ +public class TransferTest { + + private static LoggerContext ctx; + private static ListAppender app; + + @BeforeClass + public static void setupClass() throws Exception { + ctx = (LoggerContext) LogManager.getContext(false); + Configuration config = ctx.getConfiguration(); + for (Map.Entry<String, Appender> entry : config.getAppenders().entrySet()) { + if (entry.getKey().equals("List")) { + app = (ListAppender) entry.getValue(); + break; + } + } + assertNotNull("No Appender", app); + } + + @Before + public void before() { + app.clear(); + ThreadContext.clearMap(); + } + + @Test(expected = ConstraintValidationException.class) + public void testValidationFailure() { + Transfer transfer = LogEventFactory.getEvent(Transfer.class); + ThreadContext.put("companyId", "12345"); + ThreadContext.put("ipAddress", "127.0.0.1"); + ThreadContext.put("environment", "dev"); + ThreadContext.put("product", "TestProduct"); + ThreadContext.put("timeZone", "America/Phoenix"); + ThreadContext.put("loginId", "TestUser"); + transfer.setToAccount(123456); + transfer.setFromAccount(111111); + transfer.setAmount(new BigDecimal(111.55)); + transfer.logEvent(); + fail("Should have thrown an AuditException"); + } + + @Test + public void testAuditClass() { + Transfer transfer = LogEventFactory.getEvent(Transfer.class); + ThreadContext.put("accountNumber", "12345"); + ThreadContext.put("companyId", "12345"); + ThreadContext.put("userId", "JohnDoe"); + ThreadContext.put("ipAddress", "127.0.0.1"); + ThreadContext.put("environment", "dev"); + ThreadContext.put("product", "TestProduct"); + ThreadContext.put("timeZone", "America/Phoenix"); + ThreadContext.put("loginId", "TestUser"); + transfer.setToAccount(123456); + transfer.setFromAccount(111111); + transfer.setAmount(new BigDecimal(111.55)); + try { + transfer.logEvent(); + } catch (Exception ex) { + ex.printStackTrace(); + fail(); + } + transfer.setCompletionStatus("Success"); + try { + transfer.logEvent(); + } catch (Exception ex) { + ex.printStackTrace(); + fail(); + } + List<String> msgs = app.getMessages(); + assertNotNull("No messages", msgs); + assertTrue("No messages", msgs.size() == 2); + String msg = msgs.get(0); + assertTrue("No companyId", msg.contains("companyId=\"12345\"")); + assertTrue("No ipAddress", msg.contains("ipAddress=\"127.0.0.1\"")); + assertTrue("No toAccount", msg.contains("toAccount=\"123456\"")); + } + + @Test(expected = ConstraintValidationException.class) + public void testAuditLogException() { + ThreadContext.put("userId", "JohnDoe"); + ThreadContext.put("ipAddress", "127.0.0.1"); + ThreadContext.put("environment", "dev"); + ThreadContext.put("product", "TestProduct"); + ThreadContext.put("timeZone", "America/Phoenix"); + ThreadContext.put("loginId", "TestUser"); + Map<String, String> properties = new HashMap<>(); + properties.put("toAccount", "123456"); + properties.put("fromAccount", "111111"); + properties.put("amount", "111.55"); + LogEventFactory.logEvent(Transfer.class, properties); + } + + @Test + public void testAuditLog() { + ThreadContext.put("accountNumber", "12345"); + ThreadContext.put("companyId", "12345"); + ThreadContext.put("userId", "JohnDoe"); + ThreadContext.put("ipAddress", "127.0.0.1"); + ThreadContext.put("environment", "dev"); + ThreadContext.put("product", "TestProduct"); + ThreadContext.put("timeZone", "America/Phoenix"); + ThreadContext.put("loginId", "TestUser"); + Map<String, String> properties = new HashMap<>(); + properties.put("toAccount", "123456"); + properties.put("fromAccount", "111111"); + properties.put("amount", "111.55"); + try { + LogEventFactory.logEvent(Transfer.class, properties); + } catch (Exception ex) { + ex.printStackTrace(); + fail(); + } + List<String> msgs = app.getMessages(); + assertNotNull("No messages", msgs); + assertTrue("No messages", msgs.size() == 1); + String msg = msgs.get(0); + assertTrue("No companyId", msg.contains("companyId=\"12345\"")); + assertTrue("No ipAddress", msg.contains("ipAddress=\"127.0.0.1\"")); + assertTrue("No toAccount", msg.contains("toAccount=\"123456\"")); + } +} http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-audit/log4j-audit-api/src/test/java/org/apache/logging/log4j/audit/catalog/CatalogManagerTest.java ---------------------------------------------------------------------- diff --git a/log4j-audit/log4j-audit-api/src/test/java/org/apache/logging/log4j/audit/catalog/CatalogManagerTest.java b/log4j-audit/log4j-audit-api/src/test/java/org/apache/logging/log4j/audit/catalog/CatalogManagerTest.java new file mode 100644 index 0000000..e63a080 --- /dev/null +++ b/log4j-audit/log4j-audit-api/src/test/java/org/apache/logging/log4j/audit/catalog/CatalogManagerTest.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache license, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the license for the specific language governing permissions and + * limitations under the license. + */ +package org.apache.logging.log4j.audit.catalog; + +import org.apache.logging.log4j.catalog.api.Event; +import org.junit.Test; + +import static org.junit.Assert.assertNotNull; + +/** + * + */ +public class CatalogManagerTest { + + @Test + public void testCatalog() throws Exception { + CatalogManager manager = new CatalogManagerImpl(new StringCatalogReader()); + Event event = manager.getEvent("transfer"); + assertNotNull("No transfer event", event); + } +} http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-audit/log4j-audit-api/src/test/java/org/apache/logging/log4j/audit/catalog/StringCatalogReader.java ---------------------------------------------------------------------- diff --git a/log4j-audit/log4j-audit-api/src/test/java/org/apache/logging/log4j/audit/catalog/StringCatalogReader.java b/log4j-audit/log4j-audit-api/src/test/java/org/apache/logging/log4j/audit/catalog/StringCatalogReader.java new file mode 100644 index 0000000..db027bf --- /dev/null +++ b/log4j-audit/log4j-audit-api/src/test/java/org/apache/logging/log4j/audit/catalog/StringCatalogReader.java @@ -0,0 +1,228 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache license, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the license for the specific language governing permissions and + * limitations under the license. + */ +package org.apache.logging.log4j.audit.catalog; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.logging.log4j.catalog.api.Attribute; +import org.apache.logging.log4j.catalog.api.CatalogData; +import org.apache.logging.log4j.catalog.api.Category; +import org.apache.logging.log4j.catalog.api.Constraint; +import org.apache.logging.log4j.catalog.api.DataType; +import org.apache.logging.log4j.catalog.api.Event; +import org.apache.logging.log4j.catalog.api.EventAttribute; +import org.apache.logging.log4j.catalog.api.Product; +import org.apache.logging.log4j.catalog.api.CatalogReader; +import org.apache.logging.log4j.catalog.api.plugins.MinValueConstraint; +import org.apache.logging.log4j.catalog.api.plugins.PatternConstraint; +import static org.junit.Assert.assertNotNull; + +/** + * + */ +public class StringCatalogReader implements CatalogReader { + private final String json; + + private final CatalogData catalogData; + + private final Map<String, Attribute> attributeMap = new HashMap<>(); + + public StringCatalogReader() throws Exception { + JsonFactory factory = new JsonFactory(); + factory.enable(JsonParser.Feature.ALLOW_COMMENTS); + ObjectMapper mapper = new ObjectMapper(factory); + catalogData = createCatalogData(); + json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(catalogData); + assertNotNull("No json catalog created", json); + File file = new File("target/testCatalog.json"); + PrintStream ps = new PrintStream(new FileOutputStream(file)); + ps.print(json); + ps.close(); + } + + @Override + public String readCatalog() { + return json; + } + + @Override + public CatalogData read() { + return catalogData; + } + + @Override + public Map<String, Attribute> getAttributes() { + return attributeMap; + } + + + @Override + public Attribute getAttribute(String name) { + return attributeMap.get(name); + } + + @Override + public Category getCategory(String name) { + if (catalogData.getCategories() != null) { + return catalogData.getCategories().stream().filter(a -> a.getName().equals(name)).findFirst().orElse(null); + } + return null; + } + + + @Override + public Event getEvent(String name) { + if (catalogData.getEvents() != null) { + return catalogData.getEvents().stream().filter(e -> e.getName().equals(name)).findFirst().orElse(null); + } + return null; + } + + + @Override + public Product getProduct(String name) { + if (catalogData.getProducts() != null) { + return catalogData.getProducts().stream().filter(p -> p.getName().equals(name)).findFirst().orElse(null); + } + return null; + } + + private CatalogData createCatalogData() { + CatalogData catalogData = new CatalogData(); + List<Product> products = new ArrayList<>(); + Product banking = new Product(); + banking.setName("banking").setDisplayName("Banking").setDescription("Fictional banking product"); + List<String> bankingEvents = new ArrayList<>(); + banking.setEvents(bankingEvents); + products.add(banking); + List<Category> categories = new ArrayList<>(); + Category accountCategory = new Category(); + accountCategory.setName("account").setDisplayName("Account").setDescription("Events related to accounts"); + categories.add(accountCategory); + List<String> accountEvents = new ArrayList<>(); + accountCategory.setEvents(accountEvents); + Category billPay = new Category(); + billPay.setName("billPay").setDisplayName("Bill Pay").setDescription("Events related to bill payment"); + List<String> billPayEvents = new ArrayList<>(); + billPay.setEvents(billPayEvents); + categories.add(billPay); + List<Attribute> attributes = new ArrayList<>(); + List<Event> events = new ArrayList<>(); + Attribute attribute = new Attribute(); + attribute.setName("accountNumber").setDisplayName("Account Number").setDescription("Company account number"); + attribute.setDataType(DataType.INT).setIndexed(true).setSortable(true).setRequired(true).setRequestContext(true); + attributes.add(attribute); + attribute = new Attribute(); + attribute.setName("ipAddress").setDisplayName("IP Address").setDescription("IP Address of the caller"); + attribute.setDataType(DataType.STRING).setIndexed(true).setSortable(true).setRequired(false).setRequestContext(true); + Set<Constraint> constraints = new HashSet<>(); + Constraint constraint = new Constraint(); + constraint.setConstraintType(new PatternConstraint()).setValue("^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"); + constraints.add(constraint); + attribute.setConstraints(constraints); + attributes.add(attribute); + attribute = new Attribute(); + attribute.setName("userId").setDisplayName("UserId").setDescription("Id of the User").setDataType(DataType.INT); + attribute.setIndexed(true).setSortable(true).setRequired(true).setRequestContext(true); + attributes.add(attribute); + attribute = new Attribute(); + attribute.setName("loginId").setDisplayName("LoginId").setDescription("Id user logs in with"); + attribute.setDataType(DataType.INT).setIndexed(true).setSortable(true).setRequired(true).setRequestContext(true); + attributes.add(attribute); + attribute = new Attribute(); + attribute.setName("hostName").setDisplayName("Host Name").setDescription("Name of the server"); + attribute.setDataType(DataType.STRING).setIndexed(true).setSortable(true).setRequired(false).setRequestContext(true); + attributes.add(attribute); + Attribute toAccount = new Attribute(); + toAccount.setName("toAccount").setDisplayName("To Account Number").setDescription("Destination account"); + toAccount.setDataType(DataType.INT).setIndexed(false).setSortable(false).setRequired(true).setRequestContext(false); + constraints = new HashSet<>(); + constraint = new Constraint(); + constraint.setConstraintType(new MinValueConstraint()).setValue("1"); + constraints.add(constraint); + toAccount.setConstraints(constraints); + attributes.add(toAccount); + Attribute fromAccount = new Attribute(); + fromAccount.setName("fromAccount").setDisplayName("From Account Number").setDescription("Source of funds"); + fromAccount.setDataType(DataType.INT).setIndexed(false).setSortable(false).setRequired(true).setRequestContext(false); + attributes.add(fromAccount); + Attribute amount = new Attribute(); + amount.setName("amount").setDisplayName("Amount").setDescription("Amount to transfer"); + amount.setDataType(DataType.BIG_DECIMAL).setIndexed(false).setSortable(false).setRequired(true).setRequestContext(false); + attributes.add(amount); + Attribute account = new Attribute(); + account.setName("account").setDisplayName("Account Number").setDescription("Accopunt number"); + account.setDataType(DataType.INT).setIndexed(false).setSortable(false).setRequired(true).setRequestContext(false); + attributes.add(account); + Attribute payee = new Attribute(); + payee.setName("payee").setDisplayName("Payee").setDescription("Recipient of payment"); + payee.setDataType(DataType.STRING).setIndexed(false).setSortable(false).setRequired(true).setRequestContext(false); + attributes.add(payee); + Event event = new Event(); + event.setName("login").setDisplayName("Login").setDescription("User Login"); + events.add(event); + bankingEvents.add(event.getName()); + event = new Event(); + event.setName("transfer").setDisplayName("Transfer").setDescription("Transfer between accounts"); + List<EventAttribute> eventAttributes = new ArrayList<>(); + eventAttributes.add(new EventAttribute(toAccount.getName(), true)); + eventAttributes.add(new EventAttribute(fromAccount.getName(), true)); + eventAttributes.add(new EventAttribute(amount.getName(), true)); + event.setAttributes(eventAttributes); + events.add(event); + bankingEvents.add(event.getName()); + accountEvents.add(event.getName()); + event = new Event(); + event.setName("deposit").setDisplayName("Deposit").setDescription("Deposit funds"); + eventAttributes = new ArrayList<>(); + eventAttributes.add(new EventAttribute(account.getName(), true)); + eventAttributes.add(new EventAttribute(amount.getName(), true)); + event.setAttributes(eventAttributes); + events.add(event); + bankingEvents.add(event.getName()); + accountEvents.add(event.getName()); + event = new Event(); + event.setName("billPay").setDisplayName("Bill Pay").setDescription("Payment of a bill"); + eventAttributes = new ArrayList<>(); + eventAttributes.add(new EventAttribute(fromAccount.getName(), true)); + eventAttributes.add(new EventAttribute(payee.getName(), true)); + eventAttributes.add(new EventAttribute(amount.getName(), true)); + event.setAttributes(eventAttributes); + events.add(event); + billPayEvents.add(event.getName()); + bankingEvents.add(event.getName()); + catalogData.setAttributes(attributes); + catalogData.setEvents(events); + catalogData.setProducts(products); + catalogData.setCategories(categories); + for (Attribute attr : attributes) { + attributeMap.put(attr.getName(), attr); + } + return catalogData; + } +} http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-audit/log4j-audit-api/src/test/java/org/apache/logging/log4j/audit/event/Transfer.java ---------------------------------------------------------------------- diff --git a/log4j-audit/log4j-audit-api/src/test/java/org/apache/logging/log4j/audit/event/Transfer.java b/log4j-audit/log4j-audit-api/src/test/java/org/apache/logging/log4j/audit/event/Transfer.java new file mode 100644 index 0000000..6f988d3 --- /dev/null +++ b/log4j-audit/log4j-audit-api/src/test/java/org/apache/logging/log4j/audit/event/Transfer.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache license, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the license for the specific language governing permissions and + * limitations under the license. + */ +package org.apache.logging.log4j.audit.event; + +import java.math.BigDecimal; +import org.apache.logging.log4j.audit.AuditEvent; +import org.apache.logging.log4j.audit.annotation.Constraint; +import org.apache.logging.log4j.audit.annotation.MaxLength; +import org.apache.logging.log4j.audit.annotation.RequestContext; +import org.apache.logging.log4j.audit.annotation.Required; + +/** + * Transfer between accounts + * @author generated + */ +@MaxLength(32) +@RequestContext(key="hostName") +@RequestContext(key="loginId", required=true) +@RequestContext(key="ipAddress", constraints={@Constraint(constraintType="pattern", constraintValue="^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$")}) +@RequestContext(key="accountNumber", required=true) +@RequestContext(key="userId", required=true) +public interface Transfer extends AuditEvent { + + /** + * Amount : Amount to transfer + * @param amount Amount to transfer + */ + @Required + public void setAmount(BigDecimal amount); + + /** + * From Account Number : Source of funds + * @param fromAccount Source of funds + */ + @Required + public void setFromAccount(int fromAccount); + + /** + * To Account Number : Destination account + * @param toAccount Destination account + */ + @Required + @Constraint(constraintType="minValue", constraintValue="1") + public void setToAccount(int toAccount); + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-audit/log4j-audit-api/src/test/java/org/apache/logging/log4j/audit/generator/TestInterfacesGenerator.java ---------------------------------------------------------------------- diff --git a/log4j-audit/log4j-audit-api/src/test/java/org/apache/logging/log4j/audit/generator/TestInterfacesGenerator.java b/log4j-audit/log4j-audit-api/src/test/java/org/apache/logging/log4j/audit/generator/TestInterfacesGenerator.java new file mode 100644 index 0000000..ac9aba7 --- /dev/null +++ b/log4j-audit/log4j-audit-api/src/test/java/org/apache/logging/log4j/audit/generator/TestInterfacesGenerator.java @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache license, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the license for the specific language governing permissions and + * limitations under the license. + */ +package org.apache.logging.log4j.audit.generator; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.junit.BeforeClass; +import org.junit.Test; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; +import static org.junit.Assert.*; + +public class TestInterfacesGenerator { + private static Logger logger = LogManager.getLogger(TestInterfacesGenerator.class); + private static ApplicationContext context; + private static final String GENERATED_SOURCE_DIR = "target/generated-sources/log4j-audit/"; + + @BeforeClass + public static void initTest() { + try { + context = new ClassPathXmlApplicationContext("interfacesGeneratorContext.xml"); + assertNotNull("No application context", context); + } catch (RuntimeException ex) { + logger.error("Unable to create beans for interfacesGeneratorContext.xml", ex); + throw ex; + } + } + + @Test + public void testInterfaceGenerator() throws Exception { + InterfacesGenerator interfacesGenerator = + (InterfacesGenerator) context.getBean("interfacesGenerator"); + assertNotNull("No interfaces generator", interfacesGenerator); + try { + interfacesGenerator.generateSource(); + } catch (Exception ex) { + ex.printStackTrace(); + throw ex; + } + Path p = Paths.get(GENERATED_SOURCE_DIR); + assertNotNull("Could not locate generated source path", p); + int maxDepth = 10; + List<String> fileNames = new ArrayList<>(); + Files.find(p, maxDepth, (path, basicFileAttributes) -> String.valueOf(path).endsWith(".java")) + .map(path -> path.getFileName().toString()).forEach(fileNames::add); + assertTrue("Incorrect number of files generated. Expected 4 was " + fileNames.size(), fileNames.size() == 4); + } +} http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-audit/log4j-audit-api/src/test/java/org/apache/logging/log4j/audit/util/NamingUtilsTest.java ---------------------------------------------------------------------- diff --git a/log4j-audit/log4j-audit-api/src/test/java/org/apache/logging/log4j/audit/util/NamingUtilsTest.java b/log4j-audit/log4j-audit-api/src/test/java/org/apache/logging/log4j/audit/util/NamingUtilsTest.java new file mode 100644 index 0000000..20f764a --- /dev/null +++ b/log4j-audit/log4j-audit-api/src/test/java/org/apache/logging/log4j/audit/util/NamingUtilsTest.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache license, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the license for the specific language governing permissions and + * limitations under the license. + */ +package org.apache.logging.log4j.audit.util; + + +import static org.apache.logging.log4j.audit.util.NamingUtils.*; + +/** + * + */ +public class NamingUtilsTest { + + public static void main(String[] args) { + String blah = "com.test.generator.Classname"; + System.out.println(getSimpleName(blah)); + System.out.println(lowerFirst(getSimpleName(blah))); + + System.out.println(getPackageName(blah)); + + System.out.println(getMethodShortName("getName")); + System.out.println(getMethodShortName("setName")); + } +} http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-audit/log4j-audit-api/src/test/resources/InterfacesGeneratorContext.xml ---------------------------------------------------------------------- diff --git a/log4j-audit/log4j-audit-api/src/test/resources/InterfacesGeneratorContext.xml b/log4j-audit/log4j-audit-api/src/test/resources/InterfacesGeneratorContext.xml new file mode 100644 index 0000000..46afaa6 --- /dev/null +++ b/log4j-audit/log4j-audit-api/src/test/resources/InterfacesGeneratorContext.xml @@ -0,0 +1,64 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one or more + ~ contributor license agreements. See the NOTICE file distributed with + ~ this work for additional information regarding copyright ownership. + ~ The ASF licenses this file to You under the Apache license, Version 2.0 + ~ (the "License"); you may not use this file except in compliance with + ~ the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the license for the specific language governing permissions and + ~ limitations under the license. + --> +<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:tx="http://www.springframework.org/schema/tx" + xmlns:context="http://www.springframework.org/schema/context" + xmlns:util="http://www.springframework.org/schema/util" + xmlns="http://www.springframework.org/schema/beans" + xmlns:mvc="http://www.springframework.org/schema/mvc" + xsi:schemaLocation="http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans-2.5.xsd + http://www.springframework.org/schema/mvc + http://www.springframework.org/schema/mvc/spring-mvc.xsd + http://www.springframework.org/schema/tx + http://www.springframework.org/schema/tx/spring-tx-2.5.xsd + http://www.springframework.org/schema/context + http://www.springframework.org/schema/context/spring-context-2.5.xsd + http://www.springframework.org/schema/util + http://www.springframework.org/schema/util/spring-util-2.5.xsd"> + + <context:property-placeholder location="classpath:interfacesGenerator.properties" /> + <context:component-scan base-package="org.apache.logging.log4j.catalog.api.dao" /> + <context:component-scan base-package="org.apache.logging.log4j.audit" /> + + <mvc:annotation-driven> <!-- this is added for validations to work --> + <mvc:message-converters register-defaults="true"> + <ref bean="jsonMessageConverter"/> + </mvc:message-converters> + </mvc:annotation-driven> + + <bean id="objectMapper" class="org.apache.logging.log4j.audit.util.JsonObjectMapperFactory" + factory-method="createMapper" /> + + <!-- Configure bean to convert JSON to POJO and vice versa --> + <bean id="jsonMessageConverter" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"> + <constructor-arg ref="objectMapper" /> + </bean> + + + + <bean id="org.apache.logging.log4j.catalog.api.CatalogReader" class="org.apache.logging.log4j.catalog.api.dao.JsonCatalogReader" init-method="init"> + <property name="catalogReader"> + <bean class="org.apache.logging.log4j.audit.catalog.StringCatalogReader"/> + </property> + </bean> + <!-- <bean id="org.apache.logging.log4j.audit.generator.InterfacesGenerator" class="org.apache.logging.log4j.audit.generator.InterfacesGenerator"> + <property name="catalogDao" ref="org.apache.logging.log4j.catalog.api.dao.CatalogDao"/> + </bean>--> + +</beans> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-audit/log4j-audit-api/src/test/resources/catalog.zip ---------------------------------------------------------------------- diff --git a/log4j-audit/log4j-audit-api/src/test/resources/catalog.zip b/log4j-audit/log4j-audit-api/src/test/resources/catalog.zip new file mode 100644 index 0000000..9a29c5a Binary files /dev/null and b/log4j-audit/log4j-audit-api/src/test/resources/catalog.zip differ http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-audit/log4j-audit-api/src/test/resources/interfacesGenerator.properties ---------------------------------------------------------------------- diff --git a/log4j-audit/log4j-audit-api/src/test/resources/interfacesGenerator.properties b/log4j-audit/log4j-audit-api/src/test/resources/interfacesGenerator.properties new file mode 100644 index 0000000..8d77eea --- /dev/null +++ b/log4j-audit/log4j-audit-api/src/test/resources/interfacesGenerator.properties @@ -0,0 +1,14 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache license, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the license for the specific language governing permissions and +# limitations under the license. http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-audit/log4j-audit-api/src/test/resources/log4j2-test.xml ---------------------------------------------------------------------- diff --git a/log4j-audit/log4j-audit-api/src/test/resources/log4j2-test.xml b/log4j-audit/log4j-audit-api/src/test/resources/log4j2-test.xml new file mode 100644 index 0000000..b35889d --- /dev/null +++ b/log4j-audit/log4j-audit-api/src/test/resources/log4j2-test.xml @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one or more + ~ contributor license agreements. See the NOTICE file distributed with + ~ this work for additional information regarding copyright ownership. + ~ The ASF licenses this file to You under the Apache license, Version 2.0 + ~ (the "License"); you may not use this file except in compliance with + ~ the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the license for the specific language governing permissions and + ~ limitations under the license. + --> +<configuration status="warn" name="DTOClient" packages="org.apache.logging.log4j.test"> + <Filters> + <MarkerFilter marker="Audit" onMatch="ACCEPT" onMismatch="NEUTRAL"/> + </Filters> + <appenders> + <List name="List"> + <RFC5424Layout enterpriseNumber="18060" includeMDC="true" mdcId="RequestContext" appName="Banking" /> + </List> + <Console name="console"> + <PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %class{36}:%L %M - %msg%n" /> + </Console> + </appenders> + + <loggers> + + <logger name="AuditLogger" level="INFO" additivity="false"> + <appender-ref ref="List"/> + </logger> + <root level="error"> + <appender-ref ref="console"/> + </root> + </loggers> + +</configuration> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-audit/log4j-audit-api/testCatalog.json ---------------------------------------------------------------------- diff --git a/log4j-audit/log4j-audit-api/testCatalog.json b/log4j-audit/log4j-audit-api/testCatalog.json new file mode 100644 index 0000000..2bee559 --- /dev/null +++ b/log4j-audit/log4j-audit-api/testCatalog.json @@ -0,0 +1,193 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache license, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the license for the specific language governing permissions and + * limitations under the license. + */ +{ + "products" : [ { + "name" : "banking", + "displayName" : "Banking", + "description" : "Fictional banking product", + "events" : [ "login", "transfer", "deposit", "billPay" ] + } ], + "categories" : [ { + "name" : "account", + "displayName" : "Account", + "description" : "Events related to accounts", + "events" : [ "transfer", "deposit" ] + }, { + "name" : "billPay", + "displayName" : "Bill Pay", + "description" : "Events related to bill payment", + "events" : [ "billPay" ] + } ], + "events" : [ { + "name" : "login", + "displayName" : "Login", + "description" : "User Login", + "aliases" : null, + "attributes" : null + }, { + "name" : "transfer", + "displayName" : "Transfer", + "description" : "Transfer between accounts", + "aliases" : null, + "attributes" : [ {"name" : "toAccount", "required" : true}, {"name" : "fromAccount", "required" : true}, + {"name" :"amount", "required" : true} ] + }, { + "name" : "deposit", + "displayName" : "Deposit", + "description" : "Deposit funds", + "aliases" : null, + "attributes" : [ {"name" : "account", "required" : true}, {"name" : "amount", "required" : true} ] + }, { + "name" : "billPay", + "displayName" : "Bill Pay", + "description" : "Payment of a bill", + "aliases" : null, + "attributes" : [ {"name" : "fromAccount", "required" : true}, {"name" : "payee", "required" : true}, + {"name" : "amount", "required" : true} ] + } ], + "attributes" : [ { + "name" : "accountNumber", + "displayName" : "Account Number", + "description" : "Company account number", + "dataType" : "INT", + "indexed" : true, + "sortable" : true, + "required" : true, + "requestContext" : true, + "examples" : null, + "aliases" : null, + "constraints" : null + }, { + "name" : "ipAddress", + "displayName" : "IP Address", + "description" : "IP Address of the caller", + "dataType" : "STRING", + "indexed" : true, + "sortable" : true, + "required" : false, + "requestContext" : true, + "examples" : null, + "aliases" : null, + "constraints" : [ { + "constraintType" : { + "name" : "pattern" + }, + "value" : "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$" + } ] + }, { + "name" : "userId", + "displayName" : "UserId", + "description" : "Id of the User", + "dataType" : "INT", + "indexed" : true, + "sortable" : true, + "required" : true, + "requestContext" : true, + "examples" : null, + "aliases" : null, + "constraints" : null + }, { + "name" : "loginId", + "displayName" : "LoginId", + "description" : "Id user logs in with", + "dataType" : "INT", + "indexed" : true, + "sortable" : true, + "required" : true, + "requestContext" : true, + "examples" : null, + "aliases" : null, + "constraints" : null + }, { + "name" : "hostName", + "displayName" : "Host Name", + "description" : "Name of the server", + "dataType" : "STRING", + "indexed" : true, + "sortable" : true, + "required" : false, + "requestContext" : true, + "examples" : null, + "aliases" : null, + "constraints" : null + }, { + "name" : "toAccount", + "displayName" : "To Account Number", + "description" : "Destination account", + "dataType" : "INT", + "indexed" : false, + "sortable" : false, + "required" : true, + "requestContext" : false, + "examples" : null, + "aliases" : null, + "constraints" : [ { + "constraintType" : { + "name" : "minValue" + }, + "value" : "1" + } ] + }, { + "name" : "fromAccount", + "displayName" : "From Account Number", + "description" : "Source of funds", + "dataType" : "INT", + "indexed" : false, + "sortable" : false, + "required" : true, + "requestContext" : false, + "examples" : null, + "aliases" : null, + "constraints" : null + }, { + "name" : "amount", + "displayName" : "Amount", + "description" : "Amount to transfer", + "dataType" : "BIG_DECIMAL", + "indexed" : false, + "sortable" : false, + "required" : true, + "requestContext" : false, + "examples" : null, + "aliases" : null, + "constraints" : null + }, { + "name" : "account", + "displayName" : "Account Number", + "description" : "Accopunt number", + "dataType" : "INT", + "indexed" : false, + "sortable" : false, + "required" : true, + "requestContext" : false, + "examples" : null, + "aliases" : null, + "constraints" : null + }, { + "name" : "payee", + "displayName" : "Payee", + "description" : "Recipient of payment", + "dataType" : "STRING", + "indexed" : false, + "sortable" : false, + "required" : true, + "requestContext" : false, + "examples" : null, + "aliases" : null, + "constraints" : null + } ] +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-audit/log4j-audit-maven-plugin/pom.xml ---------------------------------------------------------------------- diff --git a/log4j-audit/log4j-audit-maven-plugin/pom.xml b/log4j-audit/log4j-audit-maven-plugin/pom.xml new file mode 100644 index 0000000..c36ce23 --- /dev/null +++ b/log4j-audit/log4j-audit-maven-plugin/pom.xml @@ -0,0 +1,156 @@ +<?xml version="1.0"?> +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one or more + ~ contributor license agreements. See the NOTICE file distributed with + ~ this work for additional information regarding copyright ownership. + ~ The ASF licenses this file to You under the Apache license, Version 2.0 + ~ (the "License"); you may not use this file except in compliance with + ~ the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the license for the specific language governing permissions and + ~ limitations under the license. + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-audit</artifactId> + <version>1.0.0-SNAPSHOT</version> + </parent> + <artifactId>log4j-audit-maven-plugin</artifactId> + <packaging>maven-plugin</packaging> + + <name>log4j-audit-maven-plugin Maven Plugin</name> + <dependencies> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-api</artifactId> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-audit-api</artifactId> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-catalog-api</artifactId> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-core</artifactId> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-databind</artifactId> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-annotations</artifactId> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.datatype</groupId> + <artifactId>jackson-datatype-jsr310</artifactId> + </dependency> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-plugin-api</artifactId> + </dependency> + <dependency> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-tools-api</artifactId> + </dependency> + <dependency> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-annotations</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-utils</artifactId> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-plugin-plugin</artifactId> + <version>3.5</version> + <configuration> + <goalPrefix>log4j-audit</goalPrefix> + <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound> + </configuration> + <executions> + <execution> + <id>mojo-descriptor</id> + <goals> + <goal>descriptor</goal> + </goals> + </execution> + <execution> + <id>help-goal</id> + <goals> + <goal>helpmojo</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + <profiles> + <profile> + <id>run-its</id> + <build> + + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-invoker-plugin</artifactId> + <version>1.7</version> + <configuration> + <debug>true</debug> + <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo> + <pomIncludes> + <pomInclude>*/pom.xml</pomInclude> + </pomIncludes> + <postBuildHookScript>verify</postBuildHookScript> + <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath> + <settingsFile>src/it/settings.xml</settingsFile> + <goals> + <goal>clean</goal> + <goal>test-compile</goal> + </goals> + <properties> + <log4j-audit.version>${project.version}</log4j-audit.version> + </properties> + </configuration> + <executions> + <execution> + <id>integration-test</id> + <goals> + <goal>install</goal> + <goal>integration-test</goal> + <goal>verify</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + + </build> + </profile> + </profiles> +</project> http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-audit/log4j-audit-maven-plugin/src/it/default-generate/pom.xml ---------------------------------------------------------------------- diff --git a/log4j-audit/log4j-audit-maven-plugin/src/it/default-generate/pom.xml b/log4j-audit/log4j-audit-maven-plugin/src/it/default-generate/pom.xml new file mode 100644 index 0000000..53c7357 --- /dev/null +++ b/log4j-audit/log4j-audit-maven-plugin/src/it/default-generate/pom.xml @@ -0,0 +1,154 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one or more + ~ contributor license agreements. See the NOTICE file distributed with + ~ this work for additional information regarding copyright ownership. + ~ The ASF licenses this file to You under the Apache license, Version 2.0 + ~ (the "License"); you may not use this file except in compliance with + ~ the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the license for the specific language governing permissions and + ~ limitations under the license. + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.logging.log4j.it</groupId> + <artifactId>simple-it</artifactId> + <version>1.0.0-SNAPSHOT</version> + + <description>A simple IT verifying the basic use case.</description> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <log4j.version>2.8.2</log4j.version> + <jackson.version>2.8.5</jackson.version> + <classmate.version>1.2.0</classmate.version> + </properties> + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-audit-api</artifactId> + <version>${log4j-audit.version}</version> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-catalog-api</artifactId> + <version>${log4j-audit.version}</version> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-api</artifactId> + <version>${log4j.version}</version> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> + <version>${log4j.version}</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-core</artifactId> + <version>${jackson.version}</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-databind</artifactId> + <version>${jackson.version}</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-annotations</artifactId> + <version>${jackson.version}</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.datatype</groupId> + <artifactId>jackson-datatype-jsr310</artifactId> + <version>${jackson.version}</version> + </dependency> + <dependency> + <groupId>com.fasterxml</groupId> + <artifactId>classmate</artifactId> + <version>${classmate.version}</version> + </dependency> + </dependencies> + </dependencyManagement> + <dependencies> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-api</artifactId> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-audit-api</artifactId> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-catalog-api</artifactId> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-core</artifactId> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-databind</artifactId> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-annotations</artifactId> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.datatype</groupId> + <artifactId>jackson-datatype-jsr310</artifactId> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-audit-maven-plugin</artifactId> + <version>1.0.0-SNAPSHOT</version> + <executions> + <execution> + <id>generate</id> + <phase>generate-sources</phase> + <goals> + <goal>generate</goal> + </goals> + <configuration> + <packageName>org.apache.logging.log4j.audit.it</packageName> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.6.1</version> + <configuration> + <source>1.8</source> + <target>1.8</target> + <showDeprecation>true</showDeprecation> + <showWarnings>true</showWarnings> + <compilerArguments> + <Xmaxwarns>10000</Xmaxwarns> + <Xlint/> + </compilerArguments> + <encoding>UTF-8</encoding> + </configuration> + </plugin> + </plugins> + </build> +</project> http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-audit/log4j-audit-maven-plugin/src/it/default-generate/src/main/resources/catalog.json ---------------------------------------------------------------------- diff --git a/log4j-audit/log4j-audit-maven-plugin/src/it/default-generate/src/main/resources/catalog.json b/log4j-audit/log4j-audit-maven-plugin/src/it/default-generate/src/main/resources/catalog.json new file mode 100644 index 0000000..2bee559 --- /dev/null +++ b/log4j-audit/log4j-audit-maven-plugin/src/it/default-generate/src/main/resources/catalog.json @@ -0,0 +1,193 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache license, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the license for the specific language governing permissions and + * limitations under the license. + */ +{ + "products" : [ { + "name" : "banking", + "displayName" : "Banking", + "description" : "Fictional banking product", + "events" : [ "login", "transfer", "deposit", "billPay" ] + } ], + "categories" : [ { + "name" : "account", + "displayName" : "Account", + "description" : "Events related to accounts", + "events" : [ "transfer", "deposit" ] + }, { + "name" : "billPay", + "displayName" : "Bill Pay", + "description" : "Events related to bill payment", + "events" : [ "billPay" ] + } ], + "events" : [ { + "name" : "login", + "displayName" : "Login", + "description" : "User Login", + "aliases" : null, + "attributes" : null + }, { + "name" : "transfer", + "displayName" : "Transfer", + "description" : "Transfer between accounts", + "aliases" : null, + "attributes" : [ {"name" : "toAccount", "required" : true}, {"name" : "fromAccount", "required" : true}, + {"name" :"amount", "required" : true} ] + }, { + "name" : "deposit", + "displayName" : "Deposit", + "description" : "Deposit funds", + "aliases" : null, + "attributes" : [ {"name" : "account", "required" : true}, {"name" : "amount", "required" : true} ] + }, { + "name" : "billPay", + "displayName" : "Bill Pay", + "description" : "Payment of a bill", + "aliases" : null, + "attributes" : [ {"name" : "fromAccount", "required" : true}, {"name" : "payee", "required" : true}, + {"name" : "amount", "required" : true} ] + } ], + "attributes" : [ { + "name" : "accountNumber", + "displayName" : "Account Number", + "description" : "Company account number", + "dataType" : "INT", + "indexed" : true, + "sortable" : true, + "required" : true, + "requestContext" : true, + "examples" : null, + "aliases" : null, + "constraints" : null + }, { + "name" : "ipAddress", + "displayName" : "IP Address", + "description" : "IP Address of the caller", + "dataType" : "STRING", + "indexed" : true, + "sortable" : true, + "required" : false, + "requestContext" : true, + "examples" : null, + "aliases" : null, + "constraints" : [ { + "constraintType" : { + "name" : "pattern" + }, + "value" : "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$" + } ] + }, { + "name" : "userId", + "displayName" : "UserId", + "description" : "Id of the User", + "dataType" : "INT", + "indexed" : true, + "sortable" : true, + "required" : true, + "requestContext" : true, + "examples" : null, + "aliases" : null, + "constraints" : null + }, { + "name" : "loginId", + "displayName" : "LoginId", + "description" : "Id user logs in with", + "dataType" : "INT", + "indexed" : true, + "sortable" : true, + "required" : true, + "requestContext" : true, + "examples" : null, + "aliases" : null, + "constraints" : null + }, { + "name" : "hostName", + "displayName" : "Host Name", + "description" : "Name of the server", + "dataType" : "STRING", + "indexed" : true, + "sortable" : true, + "required" : false, + "requestContext" : true, + "examples" : null, + "aliases" : null, + "constraints" : null + }, { + "name" : "toAccount", + "displayName" : "To Account Number", + "description" : "Destination account", + "dataType" : "INT", + "indexed" : false, + "sortable" : false, + "required" : true, + "requestContext" : false, + "examples" : null, + "aliases" : null, + "constraints" : [ { + "constraintType" : { + "name" : "minValue" + }, + "value" : "1" + } ] + }, { + "name" : "fromAccount", + "displayName" : "From Account Number", + "description" : "Source of funds", + "dataType" : "INT", + "indexed" : false, + "sortable" : false, + "required" : true, + "requestContext" : false, + "examples" : null, + "aliases" : null, + "constraints" : null + }, { + "name" : "amount", + "displayName" : "Amount", + "description" : "Amount to transfer", + "dataType" : "BIG_DECIMAL", + "indexed" : false, + "sortable" : false, + "required" : true, + "requestContext" : false, + "examples" : null, + "aliases" : null, + "constraints" : null + }, { + "name" : "account", + "displayName" : "Account Number", + "description" : "Accopunt number", + "dataType" : "INT", + "indexed" : false, + "sortable" : false, + "required" : true, + "requestContext" : false, + "examples" : null, + "aliases" : null, + "constraints" : null + }, { + "name" : "payee", + "displayName" : "Payee", + "description" : "Recipient of payment", + "dataType" : "STRING", + "indexed" : false, + "sortable" : false, + "required" : true, + "requestContext" : false, + "examples" : null, + "aliases" : null, + "constraints" : null + } ] +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-audit/log4j-audit-maven-plugin/src/it/default-generate/verify.groovy ---------------------------------------------------------------------- diff --git a/log4j-audit/log4j-audit-maven-plugin/src/it/default-generate/verify.groovy b/log4j-audit/log4j-audit-maven-plugin/src/it/default-generate/verify.groovy new file mode 100644 index 0000000..bfedd91 --- /dev/null +++ b/log4j-audit/log4j-audit-maven-plugin/src/it/default-generate/verify.groovy @@ -0,0 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache license, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the license for the specific language governing permissions and + * limitations under the license. + */ +File touchFile = new File( basedir, "target/generated-sources/log4j-audit/org/apache/logging/log4j/audit/it/BillPay.java" ); + +assert touchFile.isFile() http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-audit/log4j-audit-maven-plugin/src/it/settings.xml ---------------------------------------------------------------------- diff --git a/log4j-audit/log4j-audit-maven-plugin/src/it/settings.xml b/log4j-audit/log4j-audit-maven-plugin/src/it/settings.xml new file mode 100644 index 0000000..bb3ed85 --- /dev/null +++ b/log4j-audit/log4j-audit-maven-plugin/src/it/settings.xml @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +<settings> + <profiles> + <profile> + <id>it-repo</id> + <activation> + <activeByDefault>true</activeByDefault> + </activation> + <repositories> + <repository> + <id>local.central</id> + <url>http://repository.apache.org/content/groups/public</url> + <releases> + <enabled>true</enabled> + </releases> + <snapshots> + <enabled>true</enabled> + </snapshots> + </repository> + </repositories> + <pluginRepositories> + <pluginRepository> + <id>local.central</id> + <url>http://repository.apache.org/content/groups/public</url> + <releases> + <enabled>true</enabled> + </releases> + <snapshots> + <enabled>true</enabled> + </snapshots> + </pluginRepository> + </pluginRepositories> + </profile> + </profiles> +</settings>
