You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rg...@apache.org on 2017/09/03 02:18:41 UTC
[30/33] logging-log4j-audit git commit: Initial commit
http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-audit/log4j-audit-maven-plugin/src/main/java/org/apache/logging/log4j/audit/plugin/AuditMojo.java
----------------------------------------------------------------------
diff --git a/log4j-audit/log4j-audit-maven-plugin/src/main/java/org/apache/logging/log4j/audit/plugin/AuditMojo.java b/log4j-audit/log4j-audit-maven-plugin/src/main/java/org/apache/logging/log4j/audit/plugin/AuditMojo.java
new file mode 100644
index 0000000..8879de5
--- /dev/null
+++ b/log4j-audit/log4j-audit-maven-plugin/src/main/java/org/apache/logging/log4j/audit/plugin/AuditMojo.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.plugin;
+
+import java.io.File;
+import java.lang.reflect.Constructor;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.logging.log4j.audit.generator.InterfacesGenerator;
+import org.apache.logging.log4j.catalog.api.CatalogReader;
+import org.apache.logging.log4j.catalog.api.dao.JsonCatalogReader;
+import org.apache.logging.log4j.util.LoaderUtil;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.MavenProject;
+
+/**
+ * Goal which generates the audit interfaces.
+ */
+@Mojo(name = "generate", defaultPhase = LifecyclePhase.GENERATE_SOURCES)
+public class AuditMojo extends AbstractMojo {
+
+ private static final String BASEDIR = "baseDir";
+ private static final String BUILDDIR = "buildDir";
+ private static final int MAX_KEY_LENGTH = 32;
+ private static final int DEFAULT_ENTERPRISE_ID = 18060;
+
+ @Parameter(defaultValue = "${project}")
+ private MavenProject project;
+
+ @Parameter(property = "catalogReaderClassName", defaultValue = "org.apache.logging.log4j.catalog.api.dao.FileCatalogReader")
+ private String catalogReaderClassName;
+
+ @Parameter(property = "catalogReaderAttributes", required = false)
+ private Map<String, String> catalogReaderAttributes;
+
+ @Parameter(property = "packageName", required = true)
+ private String packageName;
+ /**
+ * Location of the file.
+ */
+ @Parameter(defaultValue = "${project.build.directory}/generated-sources/log4j-audit", property = "outputDir")
+ private File outputDirectory;
+
+ @Parameter(required = false)
+ private int maxKeyLength;
+
+ @Parameter(required = false)
+ private int enterpriseId;
+
+ @SuppressWarnings("unchecked")
+ public void execute() throws MojoExecutionException {
+ if (maxKeyLength <= 0) {
+ maxKeyLength = MAX_KEY_LENGTH;
+ }
+ if (enterpriseId <= 0) {
+ enterpriseId = DEFAULT_ENTERPRISE_ID;
+ }
+ CatalogReader catalogReader = null;
+ try {
+ File basedir = project.getBasedir();
+ Class<?> clazz = LoaderUtil.loadClass(catalogReaderClassName);
+ Constructor<CatalogReader>[] constructors = (Constructor<CatalogReader>[]) clazz.getConstructors();
+
+ for (Constructor<CatalogReader> constructor : constructors) {
+ if (constructor.getParameterCount() == 1 && constructor.getParameterTypes()[0].isAssignableFrom(Map.class)) {
+ if (catalogReaderAttributes == null) {
+ catalogReaderAttributes = new HashMap<>();
+ }
+ if (!catalogReaderAttributes.containsKey(BASEDIR)) {
+ catalogReaderAttributes.put(BASEDIR, project.getBasedir().getAbsolutePath());
+ }
+ if (!catalogReaderAttributes.containsKey(BUILDDIR)) {
+ catalogReaderAttributes.put(BUILDDIR, project.getBuild().getDirectory());
+ }
+ catalogReader = constructor.newInstance(catalogReaderAttributes);
+ break;
+ }
+ }
+ if (catalogReader == null) {
+ catalogReader = LoaderUtil.newInstanceOf(catalogReaderClassName);
+ }
+
+ } catch (Exception ex) {
+ getLog().error("Unable to load catalog reader " + catalogReaderClassName, ex);
+ return;
+ }
+ InterfacesGenerator generator = new InterfacesGenerator();
+ JsonCatalogReader jsonCatalogReader = new JsonCatalogReader();
+ jsonCatalogReader.setCatalogReader(catalogReader);
+ jsonCatalogReader.init();
+ generator.setCatalogReader(jsonCatalogReader);
+ generator.setOutputDirectory(outputDirectory.getAbsolutePath());
+ generator.setPackageName(packageName);
+ generator.setMaxKeyLength(maxKeyLength);
+ generator.setEnterpriseId(enterpriseId);
+ try {
+ generator.generateSource();
+ project.addCompileSourceRoot(outputDirectory.getAbsolutePath());
+ } catch (Exception ex) {
+ throw new MojoExecutionException("Error generating Audit interfaces", ex);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-audit/log4j-audit-maven-plugin/src/main/resources/log4j2.xml
----------------------------------------------------------------------
diff --git a/log4j-audit/log4j-audit-maven-plugin/src/main/resources/log4j2.xml b/log4j-audit/log4j-audit-maven-plugin/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..89c2c66
--- /dev/null
+++ b/log4j-audit/log4j-audit-maven-plugin/src/main/resources/log4j2.xml
@@ -0,0 +1,29 @@
+<?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="ERROR">
+ <Appenders>
+ <Console name="Console" target="SYSTEM_OUT">
+ <PatternLayout pattern="%d{ABSOLUTE} %-5level # %class.%method %m%n" />
+ </Console>
+ </Appenders>
+ <Loggers>
+ <Root level="INFO">
+ <AppenderRef 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-war/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-audit/log4j-audit-war/pom.xml b/log4j-audit/log4j-audit-war/pom.xml
new file mode 100644
index 0000000..efab88b
--- /dev/null
+++ b/log4j-audit/log4j-audit-war/pom.xml
@@ -0,0 +1,187 @@
+<?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-war</artifactId>
+ <packaging>war</packaging>
+ <name>Log4j Audit Service</name>
+ <url>http://maven.apache.org</url>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>io.springfox</groupId>
+ <artifactId>springfox-swagger2</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjrt</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.springfox</groupId>
+ <artifactId>springfox-swagger-ui</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>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context-support</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-web</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-webmvc</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.data</groupId>
+ <artifactId>spring-data-rest-webmvc</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <version>3.0.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax</groupId>
+ <artifactId>javaee-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <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-slf4j-impl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-web</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.datatype</groupId>
+ <artifactId>jackson-datatype-jsr310</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.data</groupId>
+ <artifactId>spring-data-jpa</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.modelmapper</groupId>
+ <artifactId>modelmapper</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.modelmapper.extensions</groupId>
+ <artifactId>modelmapper-spring</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.modelmapper.extensions</groupId>
+ <artifactId>modelmapper-jackson</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-catalog-git</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>2.6</version>
+ <configuration>
+ <failOnMissingWebXml>false</failOnMissingWebXml>
+ </configuration>
+ <executions>
+ <execution>
+ <id>default-war</id>
+ <goals>
+ <goal>war</goal>
+ </goals>
+ <phase>prepare-package</phase>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-audit/log4j-audit-war/src/main/java/org/apache/logging/log4j/audit/service/Versions.java
----------------------------------------------------------------------
diff --git a/log4j-audit/log4j-audit-war/src/main/java/org/apache/logging/log4j/audit/service/Versions.java b/log4j-audit/log4j-audit-war/src/main/java/org/apache/logging/log4j/audit/service/Versions.java
new file mode 100644
index 0000000..cdb4527
--- /dev/null
+++ b/log4j-audit/log4j-audit-war/src/main/java/org/apache/logging/log4j/audit/service/Versions.java
@@ -0,0 +1,26 @@
+/*
+ * 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.service;
+
+import org.springframework.http.MediaType;
+
+public final class Versions {
+ public static final MediaType V1_0 = new MediaType("application", "vnd.apache.logging.log4j.audit-v1.0+json");
+ public static final String V1_0_VALUE = "application/vnd.apache.logging.log4j.audit-v1.0+json";
+
+ private Versions() { }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-audit/log4j-audit-war/src/main/java/org/apache/logging/log4j/audit/service/config/ApplicationConfiguration.java
----------------------------------------------------------------------
diff --git a/log4j-audit/log4j-audit-war/src/main/java/org/apache/logging/log4j/audit/service/config/ApplicationConfiguration.java b/log4j-audit/log4j-audit-war/src/main/java/org/apache/logging/log4j/audit/service/config/ApplicationConfiguration.java
new file mode 100644
index 0000000..5c8925b
--- /dev/null
+++ b/log4j-audit/log4j-audit-war/src/main/java/org/apache/logging/log4j/audit/service/config/ApplicationConfiguration.java
@@ -0,0 +1,23 @@
+/*
+ * 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.service.config;
+
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class ApplicationConfiguration {
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-audit/log4j-audit-war/src/main/java/org/apache/logging/log4j/audit/service/config/ConfigurationService.java
----------------------------------------------------------------------
diff --git a/log4j-audit/log4j-audit-war/src/main/java/org/apache/logging/log4j/audit/service/config/ConfigurationService.java b/log4j-audit/log4j-audit-war/src/main/java/org/apache/logging/log4j/audit/service/config/ConfigurationService.java
new file mode 100644
index 0000000..b3ba06f
--- /dev/null
+++ b/log4j-audit/log4j-audit-war/src/main/java/org/apache/logging/log4j/audit/service/config/ConfigurationService.java
@@ -0,0 +1,33 @@
+/*
+ * 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.service.config;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+/**
+ *
+ */
+@Service
+public class ConfigurationService {
+ @Value("${auditServiceAuthToken:LabAuditService}")
+ private String auditServiceAuthToken;
+
+ public String getAuditServiceAuthToken() {
+ return auditServiceAuthToken;
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-audit/log4j-audit-war/src/main/java/org/apache/logging/log4j/audit/service/config/SwaggerConfig.java
----------------------------------------------------------------------
diff --git a/log4j-audit/log4j-audit-war/src/main/java/org/apache/logging/log4j/audit/service/config/SwaggerConfig.java b/log4j-audit/log4j-audit-war/src/main/java/org/apache/logging/log4j/audit/service/config/SwaggerConfig.java
new file mode 100644
index 0000000..3a64883
--- /dev/null
+++ b/log4j-audit/log4j-audit-war/src/main/java/org/apache/logging/log4j/audit/service/config/SwaggerConfig.java
@@ -0,0 +1,63 @@
+/*
+ * 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.service.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.EnableWebMvc;
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+
+/**
+ * This will configure Swagger to produce an API for all of our REST endpoints.
+ */
+@Configuration
+@EnableSwagger2
+@EnableWebMvc
+public class SwaggerConfig {
+ @Bean
+ public Docket api() {
+ return new Docket(DocumentationType.SWAGGER_2)
+ .apiInfo(apiInfo())
+ .select()
+ .apis(RequestHandlerSelectors.any())
+ .paths(PathSelectors.any())
+ .build()
+ .directModelSubstitute(LocalDate.class, java.sql.Date.class)
+ .directModelSubstitute(LocalDateTime.class, java.util.Date.class);
+ }
+
+ private ApiInfo apiInfo() {
+ return new ApiInfoBuilder()
+ .title("Audit Service")
+ .description("Audits events")
+ .termsOfServiceUrl("http://logging.apache.org")
+ .contact("Apache Logging")
+ .license("1.0")
+ .licenseUrl("http://www.apache.org/licenses/")
+ .version("1.0")
+ .build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-audit/log4j-audit-war/src/main/java/org/apache/logging/log4j/audit/service/config/WebAppInitializer.java
----------------------------------------------------------------------
diff --git a/log4j-audit/log4j-audit-war/src/main/java/org/apache/logging/log4j/audit/service/config/WebAppInitializer.java b/log4j-audit/log4j-audit-war/src/main/java/org/apache/logging/log4j/audit/service/config/WebAppInitializer.java
new file mode 100644
index 0000000..d7a5388
--- /dev/null
+++ b/log4j-audit/log4j-audit-war/src/main/java/org/apache/logging/log4j/audit/service/config/WebAppInitializer.java
@@ -0,0 +1,48 @@
+/*
+ * 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.service.config;
+
+import org.springframework.web.WebApplicationInitializer;
+import org.springframework.web.context.ContextLoaderListener;
+import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
+import org.springframework.web.servlet.DispatcherServlet;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRegistration;
+
+public class WebAppInitializer implements WebApplicationInitializer {
+ private static final String APPLICATION_NAME = "AuditService";
+
+ @Override
+ public void onStartup(ServletContext servletContext) throws ServletException {
+ servletContext.setInitParameter("applicationName", APPLICATION_NAME);
+ System.setProperty("applicationName", APPLICATION_NAME);
+ AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
+ rootContext.setDisplayName(APPLICATION_NAME);
+ rootContext.register(ApplicationConfiguration.class);
+ servletContext.addListener(new ContextLoaderListener(rootContext));
+
+ // MVC Context
+ AnnotationConfigWebApplicationContext mvcContext = new AnnotationConfigWebApplicationContext();
+ mvcContext.register(WebMvcAppContext.class);
+
+ ServletRegistration.Dynamic restServlet = servletContext.addServlet("restServlet", new DispatcherServlet(mvcContext));
+ restServlet.setLoadOnStartup(1);
+ restServlet.addMapping("/*");
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-audit/log4j-audit-war/src/main/java/org/apache/logging/log4j/audit/service/config/WebMvcAppContext.java
----------------------------------------------------------------------
diff --git a/log4j-audit/log4j-audit-war/src/main/java/org/apache/logging/log4j/audit/service/config/WebMvcAppContext.java b/log4j-audit/log4j-audit-war/src/main/java/org/apache/logging/log4j/audit/service/config/WebMvcAppContext.java
new file mode 100644
index 0000000..a5c9e1c
--- /dev/null
+++ b/log4j-audit/log4j-audit-war/src/main/java/org/apache/logging/log4j/audit/service/config/WebMvcAppContext.java
@@ -0,0 +1,176 @@
+/*
+ * 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.service.config;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.audit.AuditLogger;
+import org.apache.logging.log4j.audit.catalog.CatalogManager;
+import org.apache.logging.log4j.audit.catalog.CatalogManagerImpl;
+import org.apache.logging.log4j.audit.service.security.LocalAuthorizationInterceptor;
+import org.apache.logging.log4j.audit.util.JsonObjectMapperFactory;
+import org.apache.logging.log4j.catalog.api.dao.CatalogDao;
+import org.apache.logging.log4j.catalog.api.CatalogReader;
+import org.apache.logging.log4j.catalog.api.dao.ClassPathCatalogReader;
+import org.apache.logging.log4j.catalog.git.dao.GitCatalogDao;
+import org.eclipse.jgit.transport.CredentialsProvider;
+import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
+import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.MessageSource;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.support.ResourceBundleMessageSource;
+import org.springframework.http.client.ClientHttpRequestInterceptor;
+import org.springframework.http.converter.HttpMessageConverter;
+import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.web.servlet.ViewResolver;
+import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
+import org.springframework.web.servlet.config.annotation.EnableWebMvc;
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
+import org.springframework.web.servlet.view.InternalResourceViewResolver;
+import org.springframework.web.servlet.view.JstlView;
+
+
+@Configuration
+@EnableWebMvc
+@EnableScheduling
+@ComponentScan(basePackages = {"org.apache.logging.log4j.audit.service"})
+//@ImportResource("classpath*:propertySources.xml")
+public class WebMvcAppContext extends WebMvcConfigurerAdapter {
+
+ private static final Logger LOGGER = LogManager.getLogger(WebMvcAppContext.class);
+
+ @Autowired
+ ConfigurationService configurationService;
+
+ @Override
+ public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
+ configurer.enable();
+ }
+
+ @Override
+ public void addResourceHandlers(final ResourceHandlerRegistry registry) {
+ registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
+ registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
+ }
+
+ @Override
+ public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
+ converters.add(jsonMessageConverter());
+ }
+
+
+ @Override
+ public void addInterceptors(InterceptorRegistry registry) {
+ registry.addInterceptor(localAuthorizationInterceptor())
+ .addPathPatterns("/api/**")
+ .excludePathPatterns("/swagger**")
+ .excludePathPatterns("/v2/api-docs**")
+ .excludePathPatterns("/configuration/security**")
+ .excludePathPatterns("/configuration/ui**")
+ .excludePathPatterns("/webjars/**");
+ }
+
+ @Bean
+ public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() {
+ DefaultAdvisorAutoProxyCreator proxyCreator = new DefaultAdvisorAutoProxyCreator();
+ proxyCreator.setProxyTargetClass(true);
+ return proxyCreator;
+ }
+
+ @Bean
+ public ViewResolver viewResolver() {
+ InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
+ viewResolver.setViewClass(JstlView.class);
+ viewResolver.setPrefix("/WEB-INF/views/");
+ viewResolver.setSuffix(".jsp");
+ return viewResolver;
+ }
+
+ @Bean
+ public MessageSource messageSource() {
+ ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
+ messageSource.setBasename("messages");
+ return messageSource;
+ }
+
+ @Bean
+ public LocalAuthorizationInterceptor localAuthorizationInterceptor() {
+
+ return new LocalAuthorizationInterceptor(configurationService.getAuditServiceAuthToken());
+ }
+
+ @Bean
+ public ObjectMapper objectMapper() {
+ return JsonObjectMapperFactory.createMapper();
+ }
+
+ @Bean
+ public MappingJackson2HttpMessageConverter jsonMessageConverter() {
+ return new MappingJackson2HttpMessageConverter(objectMapper());
+ }
+
+ @Bean
+ public List<ClientHttpRequestInterceptor> restInterceptors() {
+ return Arrays.asList(new ClientHttpRequestInterceptor[] {});
+ }
+
+ @Bean
+ public CatalogDao catalogDao(@Value("${gitLocalRepoPath}") String gitLocalRepoPath, @Value("${gitRemoteRepoUri}") String gitRemoteRepoUri) {
+ GitCatalogDao catalogDao = new GitCatalogDao();
+ catalogDao.setLocalRepoPath(gitLocalRepoPath);
+ catalogDao.setRemoteRepoUri(gitRemoteRepoUri);
+ CredentialsProvider credentialsProvider = new UsernamePasswordCredentialsProvider("waymirec", "w4ym1r3c");
+ catalogDao.setCredentialsProvider(credentialsProvider);
+ return catalogDao;
+ }
+
+ @Bean
+ public CatalogReader catalogReader() {
+ try {
+ return new ClassPathCatalogReader();
+ } catch (IOException ioe) {
+ LOGGER.error("Unable to create ClassPathCatalogReader", ioe);
+ return null;
+ }
+ }
+
+ @Bean
+ public CatalogManager catalogManager() {
+ return new CatalogManagerImpl(catalogReader());
+ }
+
+ @Bean
+ AuditLogger auditLogger() {
+ AuditLogger auditLogger = new AuditLogger();
+ auditLogger.setCatalogManager(catalogManager());
+ return auditLogger;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-audit/log4j-audit-war/src/main/java/org/apache/logging/log4j/audit/service/controller/AuditController.java
----------------------------------------------------------------------
diff --git a/log4j-audit/log4j-audit-war/src/main/java/org/apache/logging/log4j/audit/service/controller/AuditController.java b/log4j-audit/log4j-audit-war/src/main/java/org/apache/logging/log4j/audit/service/controller/AuditController.java
new file mode 100644
index 0000000..b005956
--- /dev/null
+++ b/log4j-audit/log4j-audit-war/src/main/java/org/apache/logging/log4j/audit/service/controller/AuditController.java
@@ -0,0 +1,61 @@
+/*
+ * 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.service.controller;
+
+import java.util.Map;
+
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.ThreadContext;
+import org.apache.logging.log4j.audit.AuditLogger;
+import org.apache.logging.log4j.audit.service.Versions;
+import org.apache.logging.log4j.audit.dto.AuditDto;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+
+import io.swagger.annotations.ApiOperation;
+
+@RestController
+public class AuditController {
+
+ private static final Logger LOGGER = LogManager.getLogger();
+
+ @Autowired
+ private AuditLogger auditLogger;
+
+ @ApiImplicitParams( {@ApiImplicitParam(dataType = "String", name = "Authorization", paramType = "header")})
+ @ApiOperation(value = "Generate an Audit event", notes = "Causes an Audit event to be logged", tags = {"Audit"})
+ @PostMapping(value = "/event/log", produces = Versions.V1_0_VALUE)
+ @ResponseStatus(value = HttpStatus.OK)
+ public void logEvent(@RequestBody AuditDto auditDto) {
+ ThreadContext.clearMap();
+ try {
+ for (Map.Entry<String, String> entry : auditDto.getRequestContextMap().entrySet()) {
+ ThreadContext.put(entry.getKey(), entry.getValue());
+ }
+ auditLogger.logEvent(auditDto.getEventName(), auditDto.getProperties());
+ } finally {
+ ThreadContext.clearMap();
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-audit/log4j-audit-war/src/main/java/org/apache/logging/log4j/audit/service/controller/RestResponseEntityExceptionHandler.java
----------------------------------------------------------------------
diff --git a/log4j-audit/log4j-audit-war/src/main/java/org/apache/logging/log4j/audit/service/controller/RestResponseEntityExceptionHandler.java b/log4j-audit/log4j-audit-war/src/main/java/org/apache/logging/log4j/audit/service/controller/RestResponseEntityExceptionHandler.java
new file mode 100644
index 0000000..83eae7e
--- /dev/null
+++ b/log4j-audit/log4j-audit-war/src/main/java/org/apache/logging/log4j/audit/service/controller/RestResponseEntityExceptionHandler.java
@@ -0,0 +1,55 @@
+/*
+ * 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.service.controller;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.springframework.data.rest.webmvc.support.ExceptionMessage;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
+
+@ControllerAdvice
+public class RestResponseEntityExceptionHandler extends ResponseEntityExceptionHandler {
+ private static final Logger LOGGER = LogManager.getLogger();
+
+ @ExceptionHandler({ Exception.class })
+ @ResponseBody
+ public ResponseEntity<?> handleAnyException(Exception e) {
+ return errorResponse(e, HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+
+ protected ResponseEntity<ExceptionMessage> errorResponse(Throwable throwable,
+ HttpStatus status) {
+ if (null != throwable) {
+ LOGGER.error("error caught: " + throwable.getMessage(), throwable);
+ return response(new ExceptionMessage(throwable), status);
+ } else {
+ LOGGER.error("unknown error caught in RESTController, {}", status);
+ return response(null, status);
+ }
+ }
+
+ protected <T> ResponseEntity<T> response(T body, HttpStatus status) {
+ LOGGER.debug("Responding with a status of {}", status);
+ return new ResponseEntity<>(body, new HttpHeaders(), status);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-audit/log4j-audit-war/src/main/java/org/apache/logging/log4j/audit/service/security/LocalAuthorizationInterceptor.java
----------------------------------------------------------------------
diff --git a/log4j-audit/log4j-audit-war/src/main/java/org/apache/logging/log4j/audit/service/security/LocalAuthorizationInterceptor.java b/log4j-audit/log4j-audit-war/src/main/java/org/apache/logging/log4j/audit/service/security/LocalAuthorizationInterceptor.java
new file mode 100644
index 0000000..06b5714
--- /dev/null
+++ b/log4j-audit/log4j-audit-war/src/main/java/org/apache/logging/log4j/audit/service/security/LocalAuthorizationInterceptor.java
@@ -0,0 +1,57 @@
+/*
+ * 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.service.security;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
+
+public class LocalAuthorizationInterceptor extends HandlerInterceptorAdapter {
+ private static final Logger LOGGER = LogManager.getLogger();
+ private final String token;
+
+ public LocalAuthorizationInterceptor(String token) {
+ this.token = token;
+ }
+
+ @Override
+ public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
+ throws Exception {
+ LOGGER.traceEntry();
+ try {
+ if (request.getServletPath().startsWith("/swagger")) {
+ return true;
+ }
+
+ String authHeader = request.getHeader("Authorization");
+ if (authHeader == null || !authHeader.equals(token)) {
+ LOGGER.error("Authorization value of " + authHeader + " does not match expected value of " + token);
+ response.sendError(HttpStatus.UNAUTHORIZED.value());
+ return false;
+ }
+
+ return true;
+ } finally {
+ LOGGER.traceExit();
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-audit/log4j-audit-war/src/main/resources/log4j2.xml
----------------------------------------------------------------------
diff --git a/log4j-audit/log4j-audit-war/src/main/resources/log4j2.xml b/log4j-audit/log4j-audit-war/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..5abe300
--- /dev/null
+++ b/log4j-audit/log4j-audit-war/src/main/resources/log4j2.xml
@@ -0,0 +1,80 @@
+<?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="ERROR">
+ <properties>
+ <property name="LOG_DIR">${sys:catalina.home}/logs/AuditService</property>
+ </properties>
+ <MarkerFilter marker="FLOW" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
+ <MarkerFilter marker="Audit" omMatch="ACCEPT" onMisMatch="NEUTRAL"/>
+ <Appenders>
+ <Console name="Console" target="SYSTEM_OUT">
+ <PatternLayout pattern="%d{ABSOLUTE} %-5level # %class.%method %m%n" />
+ </Console>
+
+ <RollingFile name="log4j" fileName="${LOG_DIR}/log4j.txt" filePattern="${LOG_DIR}/archive/log4j.txt.%d{yyyyMMdd_HHmmss}-%i">
+ <PatternLayout>
+ <MarkerPatternSelector defaultPattern="%d [%t] %-5p %X{loginId, userId, ipAddress, corpAcctNumber} %C{1.}.%M:%L - %m%n">
+ <PatternMatch key="FLOW" pattern="%d [%t] %-5p %X{loginId, userId, ipAddress, corpAcctNumber} -------- %C{1.}.%M:%L %msg --------%n"/>
+ </MarkerPatternSelector>
+ </PatternLayout>
+ <Policies>
+ <SizeBasedTriggeringPolicy size="30 MB"/>
+ </Policies>
+ <!-- A max of 20 will allow 20 files per second with the date pattern specified on the RollingFile declaration.
+ Hopefully that is a ridiculous value -->
+ <DefaultRolloverStrategy min="1" max="20">
+ <Delete basePath="${LOG_DIR}/archive">
+ <!-- Nested conditions: the inner condition is only evaluated on files for which the outer conditions are true. -->
+ <IfFileName glob="log4j.txt.*">
+ <!-- Only allow 1 GB of files to accumulate -->
+ <IfAccumulatedFileSize exceeds="1 GB"/>
+ </IfFileName>
+ </Delete>
+ </DefaultRolloverStrategy>
+ </RollingFile>
+ <RollingFile name="audit" fileName="${LOG_DIR}/audit.log" filePattern="${LOG_DIR}/archive/audit.log.%d{yyyyMMdd_HHmmss}-%i">
+ <RFC5424Layout enterpriseNumber="18060" includeMDC="true" mdcId="RequestContext" appName="Platform"
+ mdcPrefix="ReqCtx_"/>
+ <Policies>
+ <SizeBasedTriggeringPolicy size="30 MB"/>
+ </Policies>
+ <!-- A max of 20 will allow 20 files per second with the date pattern specified on the RollingFile declaration.
+ Hopefully that is a ridiculous value -->
+ <DefaultRolloverStrategy min="1" max="20">
+ <Delete basePath="${LOG_DIR}/archive">
+ <!-- Nested conditions: the inner condition is only evaluated on files for which the outer conditions are true. -->
+ <IfFileName glob="audit.log.*">
+ <!-- Only allow 1 GB of files to accumulate -->
+ <IfAccumulatedFileSize exceeds="1 GB"/>
+ </IfFileName>
+ </Delete>
+ </DefaultRolloverStrategy>
+ </RollingFile>
+ </Appenders>
+ <Loggers>
+ <Logger name="org.apache.logging.log4j.audit" level="info" additivity="false">
+ <AppenderRef ref="log4j"/>
+ </Logger>
+ <Logger name="AuditLogger" level="trace" additivty="false">
+ <AppenderRef ref="audit"/>
+ </Logger>
+ <Root level="warn">
+ <AppenderRef ref="log4j" />
+ </Root>
+ </Loggers>
+</Configuration>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-audit/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-audit/pom.xml b/log4j-audit/pom.xml
new file mode 100644
index 0000000..61d8438
--- /dev/null
+++ b/log4j-audit/pom.xml
@@ -0,0 +1,33 @@
+<?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/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-audit-parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>log4j-audit</artifactId>
+ <packaging>pom</packaging>
+ <name>Log4j Audit</name>
+ <modules>
+ <module>log4j-audit-api</module>
+ <module>log4j-audit-war</module>
+ <module>log4j-audit-maven-plugin</module>
+ </modules>
+</project>
http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-catalog/log4j-catalog-api/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-catalog/log4j-catalog-api/pom.xml b/log4j-catalog/log4j-catalog-api/pom.xml
new file mode 100644
index 0000000..9660bca
--- /dev/null
+++ b/log4j-catalog/log4j-catalog-api/pom.xml
@@ -0,0 +1,105 @@
+<?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-catalog</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>log4j-catalog-api</artifactId>
+ <name>Log4j Catalog API</name>
+ <url>http://maven.apache.org</url>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>io.springfox</groupId>
+ <artifactId>springfox-swagger2</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjrt</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </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>com.fasterxml</groupId>
+ <artifactId>classmate</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-core</artifactId>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context-support</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-aop</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax</groupId>
+ <artifactId>javaee-api</artifactId>
+ </dependency>
+ </dependencies>
+</project>
http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-catalog/log4j-catalog-api/src/main/java/org/apache/logging/log4j/catalog/api/Attribute.java
----------------------------------------------------------------------
diff --git a/log4j-catalog/log4j-catalog-api/src/main/java/org/apache/logging/log4j/catalog/api/Attribute.java b/log4j-catalog/log4j-catalog-api/src/main/java/org/apache/logging/log4j/catalog/api/Attribute.java
new file mode 100644
index 0000000..cc5fddf
--- /dev/null
+++ b/log4j-catalog/log4j-catalog-api/src/main/java/org/apache/logging/log4j/catalog/api/Attribute.java
@@ -0,0 +1,315 @@
+/*
+ * 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.catalog.api;
+
+import java.io.Serializable;
+import java.util.Set;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
+/**
+ * A Catalog AttributeDto.
+ */
+public class Attribute implements Serializable {
+
+ private static final long serialVersionUID = -756109102178482698L;
+ private Long id;
+ private String name;
+ private String displayName;
+ private String description;
+ private DataType dataType;
+ private boolean indexed;
+ private boolean sortable;
+ private boolean required;
+ private boolean requestContext;
+ private Set<String> examples;
+ private Set<String> aliases;
+ private Set<Constraint> constraints;
+ @JsonIgnore
+ private String catalogId;
+
+ /**
+ * Set default values.
+ */
+ public Attribute() {
+ catalogId = "DEFAULT";
+ }
+
+ /**
+ * Return the attribute's id.
+ * @return the Attribute's id.
+ */
+ public Long getId() {
+ return id;
+ }
+
+ /**
+ * Set the Attribute's id.
+ * @param id the Attribute's id.
+ */
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ /**
+ * Returns the name of the AttributeDto.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Set the name of the AttributeDto.
+ * @param name the name of the attribute.
+ * @return this Attribute.
+ */
+ public Attribute setName(String name) {
+ this.name = name;
+ return this;
+ }
+
+ /**
+ * Returns the name used when displaying the attribute.
+ * @return the display name of the attribute.
+ */
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ /**
+ * Set the name to be displayed for this attribute.
+ * @param name the display name for the attribute.
+ * @return this Attribute.
+ */
+ public Attribute setDisplayName(String name) {
+ this.displayName = name;
+ return this;
+ }
+
+ /**
+ * Returns the description of the attribute.
+ * @return the description of the attribute.
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Set the description of the attribute.
+ * @param description the description of the attribute.
+ * @return this Attribute.
+ */
+ public Attribute setDescription(String description) {
+ this.description = description;
+ return this;
+ }
+
+ /**
+ * Returns the data type of this attribute.
+ * @return the data type of the attribute.
+ */
+ public DataType getDataType() {
+ return dataType;
+ }
+
+ /**
+ * Set the data type of the attribute.
+ * @param dataType the data type of the attribute.
+ * @return this Attribute.
+ */
+ public Attribute setDataType(DataType dataType) {
+ this.dataType = dataType;
+ return this;
+ }
+
+ /**
+ * Identifies whether this attribute is an index.
+ * @return true if this attribute is an index, false otherwise.
+ */
+ public boolean isIndexed() {
+ return indexed;
+ }
+
+ /**
+ * Set whether this attribute is an index.
+ * @param indexed true if this attribute is an index, false otherwise.
+ * @return this Attribute.
+ */
+ public Attribute setIndexed(boolean indexed) {
+ this.indexed = indexed;
+ return this;
+ }
+
+ /**
+ * Returns whether a sort may be performed on this attribute.
+ * @return true if a sort can be performed on this attribute, false otherwise.
+ */
+ public boolean isSortable() {
+ return sortable;
+ }
+
+ /**
+ * Set whether a sort may be performed on this attribute.
+ * @param sortable true if a sort may be performed on this attribute, false otherwise.
+ * @return this Attribute.
+ */
+ public Attribute setSortable(boolean sortable) {
+ this.sortable = sortable;
+ return this;
+ }
+
+ /**
+ * Returns whether this attribute is required.
+ * @return true if this attribute is required, false otherwise.
+ */
+ public boolean isRequired() {
+ return required;
+ }
+
+ /**
+ * Set whether this attribute is required.
+ * @param required true if this attribute is required, false otherwise.
+ * @return this Attribute.
+ */
+ public Attribute setRequired(boolean required) {
+ this.required = required;
+ return this;
+ }
+
+ /**
+ * Returns whether this attribute is part of the RequestContext.
+ * @return true if this attribute is part of the RequestContext, false otherwise.
+ */
+ public boolean isRequestContext() {
+ return requestContext;
+ }
+
+ /**
+ * Set whether this attribute is part of the RequestContext.
+ * @param isRequestContext true if this attribute is part of the RequestContext, false otherwise.
+ * @return this Attribute.
+ */
+ public Attribute setRequestContext(boolean isRequestContext) {
+ this.requestContext = isRequestContext;
+ return this;
+ }
+
+ /**
+ * Returns the List of example Strings.
+ * @return the List of example Strings.
+ */
+ public Set<String> getExamples() {
+ return examples;
+ }
+
+ /**
+ * Sets the List of example Strings.
+ * @param examples the List of example Strings.
+ * @return this Attribute.
+ */
+ public Attribute setExamples(Set<String> examples) {
+ this.examples = examples;
+ return this;
+ }
+
+ /**
+ * Returns the List of alias Strings.
+ * @return the List of alias Strings.
+ */
+ public Set<String> getAliases() {
+ return aliases;
+ }
+
+ /**
+ * Sets List of alias Strings.
+ * @param aliases The List of alias Strings.
+ * @return this Attribute.
+ */
+ public Attribute setAliases(Set<String> aliases) {
+ this.aliases = aliases;
+ return this;
+ }
+
+ /**
+ * Returns the constraints on this attribute.
+ * @return The list of constraints.
+ */
+ public Set<Constraint> getConstraints() {
+ return constraints;
+ }
+
+ /**
+ * Sets the Constraints onf the attribute.
+ * @param constraints The List of constraints.
+ * @return This Attribute.
+ */
+ public Attribute setConstraints(Set<Constraint> constraints) {
+ this.constraints = constraints;
+ return this;
+ }
+
+ /**
+ * Get the Catalog Id this attribute is associated with.
+ * @return the catalog id or null.
+ */
+ public String getCatalogId() {
+ return catalogId;
+ }
+
+ /**
+ * Set the catalog id this attribute is associated with.
+ * @param catalogId The catalog id or null.
+ */
+ public void setCatalogId(String catalogId) {
+ this.catalogId = catalogId;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("{");
+ sb.append("id=\"").append(id).append("\" ");
+ sb.append("catalog id=\"").append(catalogId).append("\" ");
+ sb.append("name=\"").append(name).append("\" ");
+ sb.append("displayName=\"").append(displayName).append("\" ");
+ sb.append("description=\"").append(description).append("\" ");
+ sb.append("dataType=\"");
+ if (dataType == null) {
+ sb.append("null");
+ } else {
+ sb.append(dataType.getTypeName());
+ }
+ sb.append("\" ");
+ sb.append("indexed=\"").append(indexed).append("\" ");
+ sb.append("sortable=\"").append(sortable).append("\" ");
+ sb.append("required=\"").append(required).append("\" ");
+ sb.append("requestContext=\"").append(requestContext).append("\" ");
+ if (constraints != null) {
+ sb.append("constraints[");
+ boolean first = true;
+ for (Constraint constraint : constraints) {
+ if (!first) {
+ sb.append(" ");
+ }
+ sb.append("name=\"").append(constraint.getConstraintType().getName()).append("\"");
+ sb.append("value=\"").append(constraint.getValue()).append("\"");
+ }
+ sb.append("]");
+ }
+ sb.append("}");
+ return sb.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-catalog/log4j-catalog-api/src/main/java/org/apache/logging/log4j/catalog/api/CatalogData.java
----------------------------------------------------------------------
diff --git a/log4j-catalog/log4j-catalog-api/src/main/java/org/apache/logging/log4j/catalog/api/CatalogData.java b/log4j-catalog/log4j-catalog-api/src/main/java/org/apache/logging/log4j/catalog/api/CatalogData.java
new file mode 100644
index 0000000..76ce076
--- /dev/null
+++ b/log4j-catalog/log4j-catalog-api/src/main/java/org/apache/logging/log4j/catalog/api/CatalogData.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.catalog.api;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * Container for the data in the catalog.
+ */
+public class CatalogData implements Serializable {
+
+ private static final long serialVersionUID = -6772374346223539136L;
+ private List<Product> products;
+ private List<Category> categories;
+ private List<Event> events;
+ private List<Attribute> attributes;
+
+ /**
+ * Returns the Products associated with the Catalog.
+ * @return the List of Products.
+ */
+ public List<Product> getProducts() {
+ return products;
+ }
+
+ /**
+ * Sets the Products represented in the Catalog.
+ *
+ * @param products The List of Products.
+ */
+ public void setProducts(List<Product> products) {
+ this.products = products;
+ }
+
+ /**
+ * Returns the List of Categories.
+ * @return the List of CategoryDto objects or null.
+ */
+ public List<Category> getCategories() {
+ return categories;
+ }
+
+ /**
+ * Sets List of CategoryDto objects.
+ * @param categories the List of Categories or null.
+ */
+ public void setCategories(List<Category> categories) {
+ this.categories = categories;
+ }
+
+ /**
+ * Returns the List of EventDto objects.
+ * @return the List of Events.
+ */
+ public List<Event> getEvents() {
+ return events;
+ }
+
+ /**
+ * Sets the List of EventDto objects.
+ * @param events the List of Events or null.
+ */
+ public void setEvents(List<Event> events) {
+ this.events = events;
+ }
+
+ /**
+ * Returns the List of AttributeDto objects.
+ *
+ * @return the List of AttributeDto objects or null.
+ */
+ public List<Attribute> getAttributes() {
+ return attributes;
+ }
+
+ /**
+ * Sets the List of AttributeDto objects.
+ *
+ * @param attributes the List of Attributes.
+ */
+ public void setAttributes(List<Attribute> attributes) {
+ this.attributes = attributes;
+ }
+
+ /**
+ * The supported EventLogger types.
+ * @return the List of EventLogger type names.
+ */
+ /* public List<String> getEventLoggerTypes() {
+ return eventLoggerTypes;
+ } */
+
+ /**
+ * Set the List of EventLogger types.
+ * @param eventTypes the EventLogger types.
+ */
+ /* public void setEventLoggerTypes(List<String> eventTypes) {
+ this.eventLoggerTypes = eventTypes;
+ } */
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-catalog/log4j-catalog-api/src/main/java/org/apache/logging/log4j/catalog/api/CatalogReader.java
----------------------------------------------------------------------
diff --git a/log4j-catalog/log4j-catalog-api/src/main/java/org/apache/logging/log4j/catalog/api/CatalogReader.java b/log4j-catalog/log4j-catalog-api/src/main/java/org/apache/logging/log4j/catalog/api/CatalogReader.java
new file mode 100644
index 0000000..91c75ed
--- /dev/null
+++ b/log4j-catalog/log4j-catalog-api/src/main/java/org/apache/logging/log4j/catalog/api/CatalogReader.java
@@ -0,0 +1,72 @@
+/*
+ * 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.catalog.api;
+
+import java.util.Map;
+
+/**
+ *
+ */
+public interface CatalogReader {
+
+ /**
+ * Returns the Catalog object.
+ * @return the Catalog.
+ */
+ CatalogData read();
+
+ /**
+ * Returns a String representation of the Catalog. The representation format is implementation specific.
+ * @return a String containing the Catalog data.
+ */
+ String readCatalog();
+
+ /**
+ * Return all the Attributes as a Map.
+ * @return A map of the attributes where the key is the Attribute's name.
+ */
+ Map<String, Attribute> getAttributes();
+
+ /**
+ * Retrieves an Attribute.
+ * @param name The attribute name.
+ * @return The Attribute or null if no attribute with the specified name exists.
+ */
+ Attribute getAttribute(String name);
+
+ /**
+ * Retrieves a Category.
+ * not called.
+ * @param name The category name.
+ * @return The Category.
+ */
+ Category getCategory(String name);
+
+ /**
+ *
+ * @param name
+ * @return
+ */
+ Event getEvent(String name);
+
+ /**
+ *
+ * @param name
+ * @return
+ */
+ Product getProduct(String name);
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-catalog/log4j-catalog-api/src/main/java/org/apache/logging/log4j/catalog/api/CatalogWriter.java
----------------------------------------------------------------------
diff --git a/log4j-catalog/log4j-catalog-api/src/main/java/org/apache/logging/log4j/catalog/api/CatalogWriter.java b/log4j-catalog/log4j-catalog-api/src/main/java/org/apache/logging/log4j/catalog/api/CatalogWriter.java
new file mode 100644
index 0000000..79a206f
--- /dev/null
+++ b/log4j-catalog/log4j-catalog-api/src/main/java/org/apache/logging/log4j/catalog/api/CatalogWriter.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.catalog.api;
+
+public interface CatalogWriter {
+ void write(CatalogData catalogData);
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-catalog/log4j-catalog-api/src/main/java/org/apache/logging/log4j/catalog/api/Category.java
----------------------------------------------------------------------
diff --git a/log4j-catalog/log4j-catalog-api/src/main/java/org/apache/logging/log4j/catalog/api/Category.java b/log4j-catalog/log4j-catalog-api/src/main/java/org/apache/logging/log4j/catalog/api/Category.java
new file mode 100644
index 0000000..5f26af9
--- /dev/null
+++ b/log4j-catalog/log4j-catalog-api/src/main/java/org/apache/logging/log4j/catalog/api/Category.java
@@ -0,0 +1,154 @@
+/*
+ * 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.catalog.api;
+
+import java.io.Serializable;
+import java.util.List;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
+/**
+ * A Catalog Category.
+ */
+public class Category implements Serializable {
+
+ private static final long serialVersionUID = 5776108323599073407L;
+ private Long id;
+ private String name;
+ private String displayName;
+ private String description;
+ @JsonIgnore
+ private String catalogId;
+ private List<String> events;
+
+ /**
+ * Set default values;
+ */
+ public Category() {
+ catalogId = "DEFAULT";
+ }
+
+ /**
+ * Return the id of the Category.
+ * @return the Category's id.
+ */
+ public Long getId() {
+ return id;
+ }
+
+ /**
+ * Set the id of the Category.
+ * @param id the id of the Category.
+ */
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ /**
+ * Gets the value of the name property.
+ *
+ * @return possible object is
+ * {@link String }
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Sets the value of the name property.
+ *
+ * @param value allowed object is
+ * {@link String }
+ * @return this Category.
+ */
+ public Category setName(String value) {
+ this.name = value;
+ return this;
+ }
+
+ /**
+ * Returns the name used when displaying the category.
+ * @return the display name of the category.
+ */
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ /**
+ * Set the name to be displayed for this category.
+ * @param name the display name for the category.
+ * @return this Category.
+ */
+ public Category setDisplayName(String name) {
+ this.displayName = name;
+ return this;
+ }
+
+ /**
+ * Gets the value of the description property.
+ *
+ * @return possible object is
+ * {@link String }
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Sets the value of the description property.
+ *
+ * @param value The description of the category.
+ * @return this Category.
+ */
+ public Category setDescription(String value) {
+ this.description = value;
+ return this;
+ }
+
+ /**
+ * Get the Catalog Id this Category is associated with.
+ * @return the catalog id or null.
+ */
+ public String getCatalogId() {
+ return catalogId;
+ }
+
+ /**
+ * Set the catalog id this Category is associated with.
+ * @param catalogId The catalog id or null.
+ */
+ public void setCatalogId(String catalogId) {
+ this.catalogId = catalogId;
+ }
+
+ /**
+ * Return the List of Event names.
+ * @return the List of Event names or null.
+ */
+ public List<String> getEvents() {
+ return events;
+ }
+
+ /**
+ * Sets the List of Event names.
+ * @param events the List of Events.
+ */
+ public Category setEvents(List<String> events) {
+ this.events = events;
+ return this;
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-catalog/log4j-catalog-api/src/main/java/org/apache/logging/log4j/catalog/api/Constraint.java
----------------------------------------------------------------------
diff --git a/log4j-catalog/log4j-catalog-api/src/main/java/org/apache/logging/log4j/catalog/api/Constraint.java b/log4j-catalog/log4j-catalog-api/src/main/java/org/apache/logging/log4j/catalog/api/Constraint.java
new file mode 100644
index 0000000..775dcae
--- /dev/null
+++ b/log4j-catalog/log4j-catalog-api/src/main/java/org/apache/logging/log4j/catalog/api/Constraint.java
@@ -0,0 +1,69 @@
+/*
+ * 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.catalog.api;
+
+import java.io.Serializable;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import org.apache.logging.log4j.catalog.api.ConstraintType;
+
+/**
+ *
+ */
+public class Constraint implements Serializable {
+
+ private static final long serialVersionUID = -6880181600556259104L;
+
+ @JsonIgnore
+ private Long id;
+
+ /**
+ * The type of constraint to be applied.
+ */
+ private ConstraintType constraintType;
+
+ /**
+ * The data value to be used to apply this constraint.
+ */
+ private String value;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public ConstraintType getConstraintType() {
+ return constraintType;
+ }
+
+ public Constraint setConstraintType(ConstraintType constraintType) {
+ this.constraintType = constraintType;
+ return this;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public Constraint setValue(String value) {
+ this.value = value;
+ return this;
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-catalog/log4j-catalog-api/src/main/java/org/apache/logging/log4j/catalog/api/ConstraintType.java
----------------------------------------------------------------------
diff --git a/log4j-catalog/log4j-catalog-api/src/main/java/org/apache/logging/log4j/catalog/api/ConstraintType.java b/log4j-catalog/log4j-catalog-api/src/main/java/org/apache/logging/log4j/catalog/api/ConstraintType.java
new file mode 100644
index 0000000..962afd1
--- /dev/null
+++ b/log4j-catalog/log4j-catalog-api/src/main/java/org/apache/logging/log4j/catalog/api/ConstraintType.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.catalog.api;
+
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import org.apache.logging.log4j.catalog.api.exception.NameNotFoundException;
+import org.apache.logging.log4j.catalog.api.plugins.ConstraintTypeDeserializer;
+import org.apache.logging.log4j.catalog.api.plugins.ConstraintTypeSerializer;
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+
+/**
+ *
+ */
+@JsonDeserialize(using = ConstraintTypeDeserializer.class)
+@JsonSerialize(using = ConstraintTypeSerializer.class)
+public interface ConstraintType {
+
+ public static final String CATEGORY = "Constraint";
+
+ default String getName() {
+ Plugin annotation = this.getClass().getAnnotation(Plugin.class);
+ if (annotation == null || annotation.name().length() == 0) {
+ throw new NameNotFoundException("No name could be found for plugin class " + this.getClass().getName());
+ }
+
+ return annotation.name();
+ }
+
+ void validate(boolean isRequestContext, String name, String value, String constraintValue, StringBuilder error);
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j-audit/blob/f0884aeb/log4j-catalog/log4j-catalog-api/src/main/java/org/apache/logging/log4j/catalog/api/DataType.java
----------------------------------------------------------------------
diff --git a/log4j-catalog/log4j-catalog-api/src/main/java/org/apache/logging/log4j/catalog/api/DataType.java b/log4j-catalog/log4j-catalog-api/src/main/java/org/apache/logging/log4j/catalog/api/DataType.java
new file mode 100644
index 0000000..b37ec94
--- /dev/null
+++ b/log4j-catalog/log4j-catalog-api/src/main/java/org/apache/logging/log4j/catalog/api/DataType.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.catalog.api;
+
+/**
+ * Mapping of attribute data types.
+ */
+public enum DataType {
+
+ STRING("String", null),
+ BIG_DECIMAL("BigDecimal", "java.math.BigDecimal"),
+ DOUBLE("double", null),
+ FLOAT("float", null),
+ INT("int", null),
+ LONG("long", null),
+ BOOLEAN("boolean", null),
+ LIST("List<String>", "java.util.List"),
+ MAP("Map<String, String>", "java.util.Map");
+
+ private final String typeName;
+
+ public final String importClass;
+
+ DataType(String typeName, String importClass) {
+ this.typeName = typeName;
+ this.importClass = importClass;
+ }
+
+ public String getTypeName() {
+ return typeName;
+ }
+
+ public String getImportClass() {
+ return importClass;
+ }
+
+ public static DataType fromName(String typeName) {
+ for (DataType dataType: DataType.values()) {
+ if (dataType.typeName.equalsIgnoreCase(typeName)) {
+ return dataType;
+ }
+ }
+ throw new IllegalArgumentException("Unknown data type: " + typeName);
+ }
+
+}