summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas <>2021-06-18 08:18:59 +0200
committerThomas <>2021-06-18 08:18:59 +0200
commit108df5e1cc640070d1b03fb2dfd99306e661b8fe (patch)
tree3480ccccbf20011572f2dc3b3db743d9f12d1482
parent5a2544a18d44eec63ace935b1869da9c67d73f6c (diff)
downloadEAAF-Components-108df5e1cc640070d1b03fb2dfd99306e661b8fe.tar.gz
EAAF-Components-108df5e1cc640070d1b03fb2dfd99306e661b8fe.tar.bz2
EAAF-Components-108df5e1cc640070d1b03fb2dfd99306e661b8fe.zip
update some log messages
-rw-r--r--eaaf-springboot-utils/src/main/java/at/gv/egiz/eaaf/utils/springboot/utils/VersionHolder.java42
-rw-r--r--eaaf-springboot-utils/src/test/java/at/gv/egiz/eaaf/utils/springboot/test/SimpleSpringBootStarterTest.java21
-rw-r--r--eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/credential/SymmetricKeyConfiguration.java2
-rw-r--r--eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/tasks/AbstractReceiveQualEidTask.java3
-rw-r--r--eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/SL20HttpBindingUtils.java12
5 files changed, 68 insertions, 12 deletions
diff --git a/eaaf-springboot-utils/src/main/java/at/gv/egiz/eaaf/utils/springboot/utils/VersionHolder.java b/eaaf-springboot-utils/src/main/java/at/gv/egiz/eaaf/utils/springboot/utils/VersionHolder.java
new file mode 100644
index 00000000..9d996853
--- /dev/null
+++ b/eaaf-springboot-utils/src/main/java/at/gv/egiz/eaaf/utils/springboot/utils/VersionHolder.java
@@ -0,0 +1,42 @@
+package at.gv.egiz.eaaf.utils.springboot.utils;
+
+import java.util.Optional;
+
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.ApplicationContext;
+import org.springframework.stereotype.Service;
+
+/**
+ * SpringBoot based implementation of an application-version holder.
+ *
+ * @author tlenz
+ *
+ */
+@Service
+public class VersionHolder {
+
+ private final String version;
+
+ /**
+ * Holder that extracts the current version of the SpringBoot application.
+ *
+ * @param context Spring ApplicationContext
+ */
+ public VersionHolder(ApplicationContext context) {
+ version = context.getBeansWithAnnotation(SpringBootApplication.class).entrySet().stream()
+ .findFirst()
+ .flatMap(es -> Optional.ofNullable(es.getValue().getClass().getPackage().getImplementationVersion()))
+ .orElse("unknown");
+
+ }
+
+ /**
+ * Get version of this application.
+ *
+ * @return version
+ */
+ public String getVersion() {
+ return version;
+
+ }
+}
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
index 611cc3aa..e0c478af 100644
--- 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
@@ -1,5 +1,8 @@
package at.gv.egiz.eaaf.utils.springboot.test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
import java.io.IOException;
import org.apache.http.client.ClientProtocolException;
@@ -17,6 +20,7 @@ import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactor
import org.springframework.context.ConfigurableApplicationContext;
import at.gv.egiz.eaaf.utils.springboot.test.dummy.DummySpringBootApp;
+import at.gv.egiz.eaaf.utils.springboot.utils.VersionHolder;
public class SimpleSpringBootStarterTest {
@@ -29,13 +33,15 @@ public class SimpleSpringBootStarterTest {
ConfigurableApplicationContext ctx = DummySpringBootApp.getCtx();
Assert.assertNotNull("SpringBootContext", ctx);
- //check if AJP Connector config was set
+ // check if AJP Connector config was set
TomcatServletWebServerFactory ajp = ctx.getBean(TomcatServletWebServerFactory.class);
Assert.assertNotNull("No AJP connector", ajp);
- //check simple http calls
+ // check simple http calls
testSimpleHttpCall();
+ // check version holder
+ checkVersionHolder(ctx);
SpringApplication.exit(ctx, new ExitCodeGenerator() {
@@ -51,12 +57,17 @@ public class SimpleSpringBootStarterTest {
// check if authentication works on actuator end-point
final HttpClientBuilder builder = HttpClients.custom();
final CloseableHttpClient client = builder.build();
- Assert.assertNotNull("httpClient", client);
+ 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());
+ assertEquals("http statusCode", 200, httpResp1.getStatusLine().getStatusCode());
+
+ }
+
+ private void checkVersionHolder(ConfigurableApplicationContext ctx) {
+ VersionHolder versionHolder = ctx.getBean(VersionHolder.class);
+ assertEquals("can not extract version", "unknown", versionHolder.getVersion());
}
-
}
diff --git a/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/credential/SymmetricKeyConfiguration.java b/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/credential/SymmetricKeyConfiguration.java
index 45b51975..9477789c 100644
--- a/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/credential/SymmetricKeyConfiguration.java
+++ b/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/credential/SymmetricKeyConfiguration.java
@@ -146,7 +146,7 @@ public class SymmetricKeyConfiguration {
log.trace("Validate HSM-Facade symmetric key ... ");
checkConfigurationValue(keyStoreName, EaafKeyStoreFactory.ERRORCODE_07,
friendlyName, "Missing 'KeyStoreName' for HSM-Facade");
- checkConfigurationValue(keyStoreName, EaafKeyStoreFactory.ERRORCODE_07,
+ checkConfigurationValue(keyAlias, EaafKeyStoreFactory.ERRORCODE_07,
friendlyName, "Missing 'KeyAlias' for HSM-Facade");
} else {
diff --git a/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/tasks/AbstractReceiveQualEidTask.java b/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/tasks/AbstractReceiveQualEidTask.java
index 0d0f990a..84ad06e7 100644
--- a/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/tasks/AbstractReceiveQualEidTask.java
+++ b/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/tasks/AbstractReceiveQualEidTask.java
@@ -81,8 +81,7 @@ public abstract class AbstractReceiveQualEidTask extends AbstractAuthServletTask
sl20ReqObj = new JsonMapper().getMapper().readTree(Base64Url.decodeToUtf8String(sl20Result));
} catch (final JsonParseException e) {
- log.warn("SL2.0 command or result is NOT valid JSON.", e);
- log.debug("SL2.0 msg: " + sl20Result);
+ log.error("SL2.0 command or result is NOT valid JSON. Received msg: {}", sl20Result, e);
throw new SL20Exception("sl20.02", new Object[] { "SL2.0 command or result is NOT valid JSON." },
e);
diff --git a/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/SL20HttpBindingUtils.java b/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/SL20HttpBindingUtils.java
index cc2a8430..2b6ddb96 100644
--- a/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/SL20HttpBindingUtils.java
+++ b/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/SL20HttpBindingUtils.java
@@ -16,6 +16,7 @@ import org.apache.http.ParseException;
import org.apache.http.StatusLine;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.entity.ContentType;
import org.apache.http.util.EntityUtils;
import org.jose4j.base64url.Base64Url;
import org.slf4j.Logger;
@@ -57,10 +58,13 @@ public class SL20HttpBindingUtils {
throw new SlCommandoParserException("SL20 response contains NO ContentType");
}
-
- if (!response.getEntity().getContentType().getValue().startsWith("application/json")) {
+
+ final ContentType contentType = ContentType.getOrDefault(response.getEntity());
+ if (!ContentType.APPLICATION_JSON.getMimeType().equals(contentType.getMimeType())) {
+ log.error("SL20 response with statuscode: {} has wrong http ContentType: {}",
+ response.getStatusLine(), contentType);
throw new SlCommandoParserException(
- "SL20 response with a wrong ContentType: " + response.getEntity().getContentType().getValue());
+ "SL20 response with a wrong http ContentType: " + contentType);
}
@@ -190,7 +194,7 @@ public class SL20HttpBindingUtils {
}
} else {
- throw new SlCommandoParserException("Can NOT find content in http response");
+ throw new SlCommandoParserException("Can NOT find any content in http response");
}