summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Lenz <thomas.lenz@egiz.gv.at>2020-12-25 21:03:24 +0100
committerThomas Lenz <thomas.lenz@egiz.gv.at>2020-12-25 21:03:24 +0100
commit7b83b319fce24faf12a3d69db9ccce87d0dde4f6 (patch)
treea1772907af9e12feff748bc68062d0e89e1cea97
parenta378db97e9f14bfa81bd490186c065d77f5806c7 (diff)
parenta3b7c488300b9b231959663bbd2dd96a4a452ec0 (diff)
downloadEAAF-Components-7b83b319fce24faf12a3d69db9ccce87d0dde4f6.tar.gz
EAAF-Components-7b83b319fce24faf12a3d69db9ccce87d0dde4f6.tar.bz2
EAAF-Components-7b83b319fce24faf12a3d69db9ccce87d0dde4f6.zip
Merge branch 'feature/add_springboot_commons' into 'nightlyBuild'
Feature/add springboot commons See merge request egiz/eaaf_components!8
-rw-r--r--.gitlab-ci.yml2
-rw-r--r--build_reporting/pom.xml4
-rw-r--r--eaaf-springboot-utils/checks/spotbugs-exclude.xml11
-rw-r--r--eaaf-springboot-utils/pom.xml140
-rw-r--r--eaaf-springboot-utils/src/main/java/at/gv/egiz/eaaf/utils/springboot/ajp/TomcatAjpConfiguration.java145
-rw-r--r--eaaf-springboot-utils/src/main/java/at/gv/egiz/eaaf/utils/springboot/ajp/TomcatProperties.java72
-rw-r--r--eaaf-springboot-utils/src/main/java/at/gv/egiz/eaaf/utils/springboot/ajp/logging/LoggingProperties.java94
-rw-r--r--eaaf-springboot-utils/src/main/java/at/gv/egiz/eaaf/utils/springboot/ajp/logging/MdcEnhancerFilter.java99
-rw-r--r--eaaf-springboot-utils/src/main/resources/tomcat.properties15
-rw-r--r--eaaf-springboot-utils/src/test/java/at/gv/egiz/eaaf/utils/springboot/test/SimpleSpringBootStarterTest.java62
-rw-r--r--eaaf-springboot-utils/src/test/java/at/gv/egiz/eaaf/utils/springboot/test/dummy/DummyController.java23
-rw-r--r--eaaf-springboot-utils/src/test/java/at/gv/egiz/eaaf/utils/springboot/test/dummy/DummySpringBootApp.java26
-rw-r--r--eaaf-springboot-utils/src/test/resources/jUnit_application.properties19
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/RequestStorage.java4
-rw-r--r--eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/utils/TransactionIdUtils.java2
-rw-r--r--eaaf_modules/eaaf_module_pvp2_core/pom.xml1
-rw-r--r--pom.xml24
17 files changed, 740 insertions, 3 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index f6db61b0..0e5e74e1 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -15,7 +15,6 @@ variables:
include:
- template: Dependency-Scanning.gitlab-ci.yml
- template: Secret-Detection.gitlab-ci.yml
- - template: Code-Quality.gitlab-ci.yml
stages:
- assemble
@@ -65,6 +64,7 @@ publishToGitlab:
stage: package
except:
- tags
+ - /^feature/.*$/i
before_script:
- mkdir -p ~/.ssh
- ssh-keyscan apps.egiz.gv.at >> ~/.ssh/known_hosts
diff --git a/build_reporting/pom.xml b/build_reporting/pom.xml
index 5300ff74..8320fa29 100644
--- a/build_reporting/pom.xml
+++ b/build_reporting/pom.xml
@@ -45,6 +45,10 @@
<groupId>at.gv.egiz.eaaf</groupId>
<artifactId>eaaf_module_pvp2_sp</artifactId>
</dependency>
+ <dependency>
+ <groupId>at.gv.egiz.eaaf</groupId>
+ <artifactId>eaaf-springboot-utils</artifactId>
+ </dependency>
</dependencies>
<build>
diff --git a/eaaf-springboot-utils/checks/spotbugs-exclude.xml b/eaaf-springboot-utils/checks/spotbugs-exclude.xml
new file mode 100644
index 00000000..7bb320ee
--- /dev/null
+++ b/eaaf-springboot-utils/checks/spotbugs-exclude.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<FindBugsFilter>
+ <Match>
+ <!-- Paths and URLs only loaded from configuration -->
+ <Class name="at.gv.egiz.eaaf.utils.springboot.ajp.TomcatAjpConfiguration" />
+ <Method name="servletContainer" />
+ <OR>
+ <Bug pattern="PATH_TRAVERSAL_IN" />
+ </OR>
+ </Match>
+</FindBugsFilter>
diff --git a/eaaf-springboot-utils/pom.xml b/eaaf-springboot-utils/pom.xml
new file mode 100644
index 00000000..1e6a85be
--- /dev/null
+++ b/eaaf-springboot-utils/pom.xml
@@ -0,0 +1,140 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>at.gv.egiz</groupId>
+ <artifactId>eaaf</artifactId>
+ <version>1.1.11-SNAPSHOT</version>
+ </parent>
+ <groupId>at.gv.egiz.eaaf</groupId>
+ <artifactId>eaaf-springboot-utils</artifactId>
+ <name>EAAF SpringBoot Utils</name>
+ <description>Common utils for SpringBoot applications</description>
+
+ <licenses>
+ <license>
+ <name>European Union Public License, version 1.2 (EUPL-1.2)</name>
+ <url>https://opensource.org/licenses/EUPL-1.2</url>
+ <distribution>repo</distribution>
+ </license>
+ </licenses>
+
+ <developers>
+ <developer>
+ <name>Thomas Lenz</name>
+ <email>thomas.lenz@egiz.gv.at</email>
+ <organization>eGovernment Innovation Center (EGIZ)</organization>
+ <organizationUrl>https://www.egiz.gv.at</organizationUrl>
+ </developer>
+ </developers>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-configuration-processor</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-access</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ </dependency>
+
+ <!-- Test dependencies -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>eaaf-springboot-utils</finalName>
+
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ </resource>
+ </resources>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.7.0</version>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>compile</goal>
+ <goal>testCompile</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>3.1.0</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- enable co-existence of testng and junit -->
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>${surefire.version}</version>
+ <configuration>
+ <threadCount>1</threadCount>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>surefire-junit47</artifactId>
+ <version>${surefire.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+
+ <plugin>
+ <groupId>com.github.spotbugs</groupId>
+ <artifactId>spotbugs-maven-plugin</artifactId>
+ <version>${spotbugs-maven-plugin.version}</version>
+ <configuration>
+ <failOnError>true</failOnError>
+ <excludeFilterFile>checks/spotbugs-exclude.xml</excludeFilterFile>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
+</project> \ No newline at end of file
diff --git a/eaaf-springboot-utils/src/main/java/at/gv/egiz/eaaf/utils/springboot/ajp/TomcatAjpConfiguration.java b/eaaf-springboot-utils/src/main/java/at/gv/egiz/eaaf/utils/springboot/ajp/TomcatAjpConfiguration.java
new file mode 100644
index 00000000..c665edb3
--- /dev/null
+++ b/eaaf-springboot-utils/src/main/java/at/gv/egiz/eaaf/utils/springboot/ajp/TomcatAjpConfiguration.java
@@ -0,0 +1,145 @@
+package at.gv.egiz.eaaf.utils.springboot.ajp;
+
+import java.io.File;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Map;
+
+import org.apache.catalina.connector.Connector;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.coyote.AbstractProtocol;
+import org.apache.coyote.ProtocolHandler;
+import org.apache.coyote.ajp.AbstractAjpProtocol;
+import org.apache.tomcat.util.net.NioChannel;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
+import org.springframework.boot.web.servlet.FilterRegistrationBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+
+import at.gv.egiz.eaaf.utils.springboot.ajp.logging.LoggingProperties;
+import at.gv.egiz.eaaf.utils.springboot.ajp.logging.MdcEnhancerFilter;
+import ch.qos.logback.access.tomcat.LogbackValve;
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+@Configuration
+@EnableConfigurationProperties(value = {LoggingProperties.class, TomcatProperties.class})
+@PropertySource("classpath:tomcat.properties")
+@PropertySource(value = "classpath:tomcat-${spring.profiles.active}.properties", ignoreResourceNotFound = true)
+public class TomcatAjpConfiguration {
+ private static final String PROTOCOL = "AJP/1.3";
+
+ @Autowired
+ private LoggingProperties loggingProperties;
+
+ @Autowired
+ private TomcatProperties tomcatProperties;
+
+ @Value("${tomcat.workingdir:./work}")
+ String tomcatWorkDirectory;
+
+ /**
+ * Set MDC variables for embedded Tomcat access-logging.
+ *
+ * @param filter {@link MdcEnhancerFilter} that injects MDS variables
+ * @return
+ */
+ @Bean
+ public FilterRegistrationBean<MdcEnhancerFilter> enhacedMdcFilter(@Autowired MdcEnhancerFilter filter) {
+ FilterRegistrationBean<MdcEnhancerFilter> registration = new FilterRegistrationBean<>(filter);
+ registration.setEnabled(loggingProperties.getMdc().isEnabled());
+ return registration;
+
+ }
+
+ /**
+ * Adds AJP Connector to embedded Tomcat.
+ *
+ * @return
+ */
+ @Bean
+ public TomcatServletWebServerFactory servletContainer() {
+ final TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
+
+ //set working directory
+ final File workDirFile = new File(tomcatWorkDirectory);
+ checkBasekDirectory(workDirFile);
+ tomcat.setBaseDirectory(workDirFile);
+ log.info("Set embedded Tomcat workingDirectory to: {}",
+ workDirFile.getAbsolutePath());
+
+ //set logger configuration
+ if (loggingProperties.getAccessLog().isEnabled()) {
+ LogbackValve valve = new LogbackValve();
+ valve.setFilename(loggingProperties.getAccessLog().getFilename());
+ tomcat.addEngineValves(valve);
+ }
+
+ final TomcatProperties.Ajp ajp = tomcatProperties.getAjp();
+ if (ajp != null && ajp.isEnabled()) {
+ final Connector ajpConnector = new Connector(PROTOCOL);
+ ajpConnector.setPort(ajp.getPort());
+ ajpConnector.setSecure(ajp.isSecure());
+ ajpConnector.setAllowTrace(ajp.isAllowTrace());
+ ajpConnector.setScheme(ajp.getScheme());
+ setNetworkAddress(ajpConnector.getProtocolHandler(),
+ ajp.getNetworkAddress());
+
+ if (ajp.getAdditionalAttributes() != null) {
+ for (final Map.Entry<String, String> entry :
+ ajp.getAdditionalAttributes().entrySet()) {
+ log.debug("Set Tomcat AJP property: {} with value: {}",
+ entry.getKey(), entry.getValue());
+ ajpConnector.setAttribute(entry.getKey(), entry.getValue());
+ }
+ }
+ log.debug("AJP connector requires secret: {}",
+ ((AbstractAjpProtocol<?>) ajpConnector.getProtocolHandler()).getSecretRequired());
+
+ tomcat.addAdditionalTomcatConnectors(ajpConnector);
+ }
+
+ return tomcat;
+ }
+
+ private void setNetworkAddress(ProtocolHandler protocolHandler, String address) {
+ log.trace("Set network address: {} to ProtocolHandler: {}", address, protocolHandler.getClass().getName());
+ if (StringUtils.isNotEmpty(address)
+ && protocolHandler instanceof AbstractProtocol<?>) {
+ try {
+ ((AbstractProtocol<NioChannel>) protocolHandler).setAddress(InetAddress.getByName(address));
+ log.info("Bind connector: {} to address: {}", PROTOCOL, address);
+
+ } catch (UnknownHostException e) {
+ log.error("Can NOT set network address: {} to connector: {}", address, PROTOCOL);
+
+ }
+
+ } else {
+ log.debug("Bind connector: {} to default address", PROTOCOL);
+
+ }
+ }
+
+ private void checkBasekDirectory(File workDirFile) {
+ if (!workDirFile.exists()) {
+ log.debug("Embedded Tomcat workingDirectory: {} not exist. Create it ... ",
+ workDirFile.getAbsolutePath());
+ if (workDirFile.mkdirs()) {
+ log.info("Embedded Tomcat workingDirectory created");
+
+ }
+ }
+
+ if (!workDirFile.isDirectory()) {
+ log.error("Path to embedded Tomcat workingDirectory: {} is NOT directory",
+ workDirFile.getAbsolutePath());
+
+ }
+ }
+
+}
diff --git a/eaaf-springboot-utils/src/main/java/at/gv/egiz/eaaf/utils/springboot/ajp/TomcatProperties.java b/eaaf-springboot-utils/src/main/java/at/gv/egiz/eaaf/utils/springboot/ajp/TomcatProperties.java
new file mode 100644
index 00000000..acddafa0
--- /dev/null
+++ b/eaaf-springboot-utils/src/main/java/at/gv/egiz/eaaf/utils/springboot/ajp/TomcatProperties.java
@@ -0,0 +1,72 @@
+package at.gv.egiz.eaaf.utils.springboot.ajp;
+
+import java.util.Map;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * Embedded tomcat configuration properties.
+ */
+@ConfigurationProperties(prefix = "tomcat", ignoreInvalidFields = true)
+@Getter
+@Setter
+public class TomcatProperties {
+
+ /**
+ * AJP connector properties.
+ */
+ private Ajp ajp;
+
+ /**
+ * AJP connector properties.
+ */
+ @Getter
+ @Setter
+ public static class Ajp {
+
+ /**
+ * Should the AJP port be enabled.
+ */
+ private boolean enabled;
+
+ /**
+ * AJP protocol.
+ */
+ private String protocol = "AJP/1.3";
+
+ /**
+ * AJP port.
+ */
+ private int port = 8009;
+
+ /**
+ * Secure connection flag.
+ */
+ private boolean secure;
+
+ /**
+ * Flag, to disable or enable the TRACE HTTP method.
+ */
+ private boolean allowTrace;
+
+ /**
+ * Scheme that will be assigned to requests received through this connector.
+ */
+ private String scheme = "http";
+
+ /**
+ * Network address to bind this connector.
+ */
+ private String networkAddress = null;
+
+ /**
+ * Additional AJP Connector Attributes e.g. packetSize.
+ */
+ private Map<String, String> additionalAttributes;
+
+ }
+
+}
diff --git a/eaaf-springboot-utils/src/main/java/at/gv/egiz/eaaf/utils/springboot/ajp/logging/LoggingProperties.java b/eaaf-springboot-utils/src/main/java/at/gv/egiz/eaaf/utils/springboot/ajp/logging/LoggingProperties.java
new file mode 100644
index 00000000..b3d5d846
--- /dev/null
+++ b/eaaf-springboot-utils/src/main/java/at/gv/egiz/eaaf/utils/springboot/ajp/logging/LoggingProperties.java
@@ -0,0 +1,94 @@
+package at.gv.egiz.eaaf.utils.springboot.ajp.logging;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * Logger configuration for embedded Tomcat.
+ *
+ * @author BRZ development team
+ * @author tlenz
+ *
+ */
+@ConfigurationProperties(prefix = "logging")
+@Getter
+@Setter
+public class LoggingProperties {
+ /**
+ * Whether to log in JSON format.
+ */
+ private boolean json = true;
+ /**
+ * Whether to log in plain text.
+ */
+ private boolean text = false;
+ /**
+ * Default Logback Pattern.
+ */
+ private String pattern = "### unused property ###";
+ /**
+ * Logback Mapped Diagnostic Context.
+ */
+ private Mdc mdc = new Mdc();
+
+ /**
+ * Logback Mapped Diagnostic Context.
+ */
+
+ @Getter
+ @Setter
+ public static class Mdc {
+ /**
+ * Whether to use Logback's MDC.
+ */
+ private boolean enabled = false;
+ /**
+ * List of HTTP Headers to make available in Logback's MDC.
+ */
+ private List<String> headers = Collections.emptyList();
+ private String headerPrefix = "";
+ private String headerPostfix = "";
+ /**
+ * List of HTTP Cookies to make available in Logback's MDC.
+ */
+ private List<String> cookies = Collections.emptyList();
+ private String cookiePrefix = "";
+ private String cookiePostfix = "";
+ /**
+ * List of HTTP Session Attributes to make available in Logback's MDC.
+ */
+ private List<String> sessionAttributes = Collections.emptyList();
+ private String sessionAttributePrefix = "";
+ private String sessionAttributePostfix = "";
+ /**
+ * Value to use if a configured MDC entry would be null.
+ */
+ private String nullValue = null;
+ }
+
+ /**
+ * Tomcat AccessLog.
+ */
+ private AccessLog accessLog = new AccessLog();
+
+ /**
+ * Tomcat AccessLog.
+ */
+ @Getter
+ @Setter
+ public static class AccessLog {
+ /**
+ * Enable AccessLog.
+ */
+ private boolean enabled = false;
+ /**
+ * Logback access log filename.
+ */
+ private String filename = "logback-access.xml";
+ }
+}
diff --git a/eaaf-springboot-utils/src/main/java/at/gv/egiz/eaaf/utils/springboot/ajp/logging/MdcEnhancerFilter.java b/eaaf-springboot-utils/src/main/java/at/gv/egiz/eaaf/utils/springboot/ajp/logging/MdcEnhancerFilter.java
new file mode 100644
index 00000000..d63c47c9
--- /dev/null
+++ b/eaaf-springboot-utils/src/main/java/at/gv/egiz/eaaf/utils/springboot/ajp/logging/MdcEnhancerFilter.java
@@ -0,0 +1,99 @@
+package at.gv.egiz.eaaf.utils.springboot.ajp.logging;
+
+import java.io.IOException;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.MDC;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+@Component
+@EnableConfigurationProperties(LoggingProperties.class)
+public class MdcEnhancerFilter implements Filter {
+
+ /**
+ * Logging properties.
+ */
+ @Autowired
+ private LoggingProperties loggingProperties;
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse,
+ final FilterChain filterChain) throws IOException, ServletException {
+ final HttpServletRequest request = (HttpServletRequest) servletRequest;
+
+ String key;
+ String value;
+ for (final String header : loggingProperties.getMdc().getHeaders()) {
+ key = loggingProperties.getMdc().getHeaderPrefix() + header + loggingProperties.getMdc()
+ .getHeaderPostfix();
+ value = request.getHeader(header);
+ if (!StringUtils.isEmpty(value)) {
+ MDC.put(key, value);
+ } else if (loggingProperties.getMdc().getNullValue() != null) {
+ MDC.put(key, loggingProperties.getMdc().getNullValue());
+ }
+ }
+
+ for (final String cookie : loggingProperties.getMdc().getCookies()) {
+ key = loggingProperties.getMdc().getCookiePrefix() + cookie + loggingProperties.getMdc()
+ .getCookiePostfix();
+ value = getCookie(cookie, request.getCookies());
+ if (!StringUtils.isEmpty(value)) {
+ MDC.put(key, value);
+ } else if (loggingProperties.getMdc().getNullValue() != null) {
+ MDC.put(key, loggingProperties.getMdc().getNullValue());
+ }
+ }
+
+ Object object;
+ for (final String attribute : loggingProperties.getMdc().getSessionAttributes()) {
+ key = loggingProperties.getMdc().getSessionAttributePrefix() + attribute + loggingProperties.getMdc()
+ .getSessionAttributePostfix();
+ object = request.getSession(true).getAttribute(attribute);
+ if (object != null) {
+ MDC.put(key, object.toString());
+ } else if (loggingProperties.getMdc().getNullValue() != null) {
+ MDC.put(key, loggingProperties.getMdc().getNullValue());
+ }
+ }
+
+ try {
+ filterChain.doFilter(servletRequest, servletResponse);
+ } finally {
+ for (final String header : loggingProperties.getMdc().getHeaders()) {
+ MDC.remove(header);
+ }
+ for (final String cookie : loggingProperties.getMdc().getCookies()) {
+ MDC.remove(cookie);
+ }
+ for (final String attribute : loggingProperties.getMdc().getSessionAttributes()) {
+ MDC.remove(attribute);
+ }
+ }
+ }
+
+ private static String getCookie(final String cookie, final Cookie[] cookies) {
+ if (cookies == null || StringUtils.isEmpty(cookie)) {
+ return null;
+ }
+ for (final Cookie c : cookies) {
+ if (c.getName().equals(cookie)) {
+ return c.getValue();
+ }
+ }
+ return null;
+ }
+} \ No newline at end of file
diff --git a/eaaf-springboot-utils/src/main/resources/tomcat.properties b/eaaf-springboot-utils/src/main/resources/tomcat.properties
new file mode 100644
index 00000000..38ab5a64
--- /dev/null
+++ b/eaaf-springboot-utils/src/main/resources/tomcat.properties
@@ -0,0 +1,15 @@
+tomcat.ajp.enabled=true
+#tomcat.ajp.port=41009
+#tomcat.ajp.additionalAttributes.secretrequired=true
+#tomcat.ajp.additionalAttributes.secret=
+
+server.tomcat.accesslog.buffered=false
+server.tomcat.accesslog.prefix=tomcat-access_log
+server.tomcat.accesslog.directory=logs/
+server.tomcat.accesslog.enabled=true
+server.tomcat.accesslog.file-date-format=.yyyy-MM-dd
+server.tomcat.accesslog.pattern=common
+server.tomcat.accesslog.rename-on-rotate=false
+server.tomcat.accesslog.request-attributes-enabled=true
+server.tomcat.accesslog.rotate=true
+server.tomcat.accesslog.suffix=.log \ No newline at end of file
diff --git a/eaaf-springboot-utils/src/test/java/at/gv/egiz/eaaf/utils/springboot/test/SimpleSpringBootStarterTest.java b/eaaf-springboot-utils/src/test/java/at/gv/egiz/eaaf/utils/springboot/test/SimpleSpringBootStarterTest.java
new file mode 100644
index 00000000..3313d36e
--- /dev/null
+++ b/eaaf-springboot-utils/src/test/java/at/gv/egiz/eaaf/utils/springboot/test/SimpleSpringBootStarterTest.java
@@ -0,0 +1,62 @@
+package at.gv.egiz.eaaf.utils.springboot.test;
+
+import java.io.IOException;
+
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpUriRequest;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.client.HttpClients;
+import org.junit.Assert;
+import org.junit.Test;
+import org.springframework.boot.ExitCodeGenerator;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
+import org.springframework.context.ConfigurableApplicationContext;
+
+import at.gv.egiz.eaaf.utils.springboot.test.dummy.DummySpringBootApp;
+
+public class SimpleSpringBootStarterTest {
+
+ @Test
+ public void Test() throws ClientProtocolException, IOException {
+
+ DummySpringBootApp.main(new String[] {
+ "--spring.config.location=classpath:/jUnit_application.properties"});
+
+ ConfigurableApplicationContext ctx = DummySpringBootApp.getCtx();
+ Assert.assertNotNull("SpringBootContext", ctx);
+
+ //check if AJP Connector config was set
+ TomcatServletWebServerFactory ajp = ctx.getBean(TomcatServletWebServerFactory.class);
+ Assert.assertNotNull("No AJP connector", ajp);
+
+ //check simple http calls
+ testSimpleHttpCall();
+
+
+
+ SpringApplication.exit(ctx, new ExitCodeGenerator() {
+ @Override
+ public int getExitCode() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+ });
+ }
+
+ private void testSimpleHttpCall() throws ClientProtocolException, IOException {
+ // check if authentication works on actuator end-point
+ final HttpClientBuilder builder = HttpClients.custom();
+ final CloseableHttpClient client = builder.build();
+ Assert.assertNotNull("httpClient", client);
+
+ final HttpUriRequest httpGet1 = new HttpGet("http://localhost:8080/junit");
+ final CloseableHttpResponse httpResp1 = client.execute(httpGet1);
+ Assert.assertEquals("http statusCode", 200, httpResp1.getStatusLine().getStatusCode());
+
+ }
+
+}
diff --git a/eaaf-springboot-utils/src/test/java/at/gv/egiz/eaaf/utils/springboot/test/dummy/DummyController.java b/eaaf-springboot-utils/src/test/java/at/gv/egiz/eaaf/utils/springboot/test/dummy/DummyController.java
new file mode 100644
index 00000000..65dcf5c1
--- /dev/null
+++ b/eaaf-springboot-utils/src/test/java/at/gv/egiz/eaaf/utils/springboot/test/dummy/DummyController.java
@@ -0,0 +1,23 @@
+package at.gv.egiz.eaaf.utils.springboot.test.dummy;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+
+@Controller
+public class DummyController {
+
+ @RequestMapping(value = {"/junit"},
+ method = { RequestMethod.POST, RequestMethod.GET })
+ public void performGenericAuthenticationProcess(HttpServletRequest req, HttpServletResponse resp)
+ throws IOException {
+ resp.setStatus(200);
+
+ }
+}
diff --git a/eaaf-springboot-utils/src/test/java/at/gv/egiz/eaaf/utils/springboot/test/dummy/DummySpringBootApp.java b/eaaf-springboot-utils/src/test/java/at/gv/egiz/eaaf/utils/springboot/test/dummy/DummySpringBootApp.java
new file mode 100644
index 00000000..bc742371
--- /dev/null
+++ b/eaaf-springboot-utils/src/test/java/at/gv/egiz/eaaf/utils/springboot/test/dummy/DummySpringBootApp.java
@@ -0,0 +1,26 @@
+package at.gv.egiz.eaaf.utils.springboot.test.dummy;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.annotation.ComponentScan;
+
+import lombok.Getter;
+
+@ComponentScan(basePackages = {"at.gv.egiz.eaaf.utils.springboot"})
+@EnableAutoConfiguration
+@SpringBootApplication
+public class DummySpringBootApp {
+
+ @Getter
+ private static ConfigurableApplicationContext ctx;
+
+ public static void main(String[] args) {
+
+ final SpringApplication springApp = new SpringApplication(DummySpringBootApp.class);
+ ctx = springApp.run(args);
+
+ }
+
+}
diff --git a/eaaf-springboot-utils/src/test/resources/jUnit_application.properties b/eaaf-springboot-utils/src/test/resources/jUnit_application.properties
new file mode 100644
index 00000000..dd7a77c1
--- /dev/null
+++ b/eaaf-springboot-utils/src/test/resources/jUnit_application.properties
@@ -0,0 +1,19 @@
+## embbeded Tomcat
+tomcat.workingdir=./target/work
+tomcat.ajp.enabled=true
+tomcat.ajp.port=8009
+tomcat.ajp.networkAddress=127.0.0.1
+tomcat.ajp.additionalAttributes.secretrequired=true
+tomcat.ajp.additionalAttributes.secret=junit
+
+#############################################################################
+## Embedded Tomcat Logging
+logging.accesslog.enabled=true
+logging.mdc.enabled=true
+logging.mdc.headers[0]=header1
+logging.mdc.headers[1]=header2
+logging.mdc.cookies[0]=cookie1
+logging.mdc.cookies[1]=cookie2
+logging.mdc.sessionAttributes[0]=attr1
+logging.mdc.sessionAttributes[1]=attr2
+logging.mdc.nullvalue=null \ No newline at end of file
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/RequestStorage.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/RequestStorage.java
index 86c50be0..db13bf71 100644
--- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/RequestStorage.java
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/RequestStorage.java
@@ -74,6 +74,10 @@ public class RequestStorage implements IRequestStorage {
log.debug("Searching for expired pendingRequest with Id: {} ... ", e.getInvalidInternalPendingReqId());
invalidPendingRequest =
transactionStorage.get(e.getInvalidInternalPendingReqId(), IRequest.class);
+
+ // If pendingReq. was found, set transactionID and sessionID to Logger
+ TransactionIdUtils.setAllLoggingVariables(invalidPendingRequest);
+
log.debug("{} expired pendingReq. Set it into Exception ...",
invalidPendingRequest != null ? "Find" : "Find NO ");
diff --git a/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/utils/TransactionIdUtils.java b/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/utils/TransactionIdUtils.java
index d1613d16..212460d7 100644
--- a/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/utils/TransactionIdUtils.java
+++ b/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/utils/TransactionIdUtils.java
@@ -69,7 +69,7 @@ public class TransactionIdUtils {
setServiceProviderId(pendingRequest.getServiceProviderConfiguration().getUniqueIdentifier());
} else {
- log.warn("Can NOT set MDC variables from pendingRequest because it is 'null'");
+ log.info("Can NOT set MDC variables from pendingRequest because it is 'null'");
}
}
diff --git a/eaaf_modules/eaaf_module_pvp2_core/pom.xml b/eaaf_modules/eaaf_module_pvp2_core/pom.xml
index 45819787..d22d8c37 100644
--- a/eaaf_modules/eaaf_module_pvp2_core/pom.xml
+++ b/eaaf_modules/eaaf_module_pvp2_core/pom.xml
@@ -20,7 +20,6 @@
<dependency>
<groupId>at.gv.egiz.eaaf</groupId>
<artifactId>eaaf-core</artifactId>
- <version>${egiz.eaaf.version}</version>
</dependency>
<dependency>
<groupId>org.opensaml</groupId>
diff --git a/pom.xml b/pom.xml
index 585310ce..88b17165 100644
--- a/pom.xml
+++ b/pom.xml
@@ -47,6 +47,7 @@
<io.grpc-core.version>1.34.0</io.grpc-core.version>
<!-- Other third-party libs -->
+ <spring-boot-starter-web.version>2.3.7.RELEASE</spring-boot-starter-web.version>
<org.springframework.version>5.2.8.RELEASE</org.springframework.version>
<org.opensaml.version>3.4.5</org.opensaml.version>
<org.apache.santuario.xmlsec.version>2.2.0</org.apache.santuario.xmlsec.version>
@@ -55,6 +56,7 @@
<org.bouncycastle.bctls-jdk15to18.version>1.67</org.bouncycastle.bctls-jdk15to18.version>
<org.slf4j.version>1.7.30</org.slf4j.version>
+ <ch.qos.logback-access.version>1.2.3</ch.qos.logback-access.version>
<commons-codec.version>1.15</commons-codec.version>
<org.apache.commons-lang3.version>3.11</org.apache.commons-lang3.version>
<org.apache.commons-text.version>1.9</org.apache.commons-text.version>
@@ -208,6 +210,7 @@
<module>eaaf_core</module>
<module>eaaf_modules</module>
<module>build_reporting</module>
+ <module>eaaf-springboot-utils</module>
</modules>
<dependencyManagement>
@@ -252,6 +255,12 @@
<artifactId>eaaf_module_pvp2_sp</artifactId>
<version>${egiz.eaaf.version}</version>
</dependency>
+ <dependency>
+ <groupId>at.gv.egiz.eaaf</groupId>
+ <artifactId>eaaf-springboot-utils</artifactId>
+ <version>${egiz.eaaf.version}</version>
+ </dependency>
+
<dependency>
<groupId>at.gv.egiz.components</groupId>
@@ -407,6 +416,16 @@
<version>${commons-io.version}</version>
</dependency>
<dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ <version>${spring-boot-starter-web.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-configuration-processor</artifactId>
+ <version>${spring-boot-starter-web.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework.version}</version>
@@ -422,6 +441,11 @@
<version>${org.slf4j.version}</version>
</dependency>
<dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-access</artifactId>
+ <version>${ch.qos.logback-access.version}</version>
+ </dependency>
+ <dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>${commons-codec.version}</version>