summaryrefslogtreecommitdiff
path: root/eaaf_modules/eaaf_module_auth_sl20
diff options
context:
space:
mode:
Diffstat (limited to 'eaaf_modules/eaaf_module_auth_sl20')
-rw-r--r--eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/tasks/AbstractCreateQualEidRequestTask.java11
-rw-r--r--eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/tasks/AbstractReceiveQualEidTask.java21
-rw-r--r--eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/SL20HttpBindingUtils.java24
3 files changed, 39 insertions, 17 deletions
diff --git a/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/tasks/AbstractCreateQualEidRequestTask.java b/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/tasks/AbstractCreateQualEidRequestTask.java
index a1d5591a..1c1a8f78 100644
--- a/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/tasks/AbstractCreateQualEidRequestTask.java
+++ b/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/tasks/AbstractCreateQualEidRequestTask.java
@@ -9,11 +9,13 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.time.StopWatch;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
@@ -52,6 +54,8 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
public abstract class AbstractCreateQualEidRequestTask extends AbstractAuthServletTask {
+ private static final String FRIENDLYNAME_HTTP_CLIENT = "A-Trust Client";
+
@Autowired(required = true)
private IHttpClientFactory httpClientFactory;
@Autowired(required = true)
@@ -115,9 +119,16 @@ public abstract class AbstractCreateQualEidRequestTask extends AbstractAuthServl
Base64Url.encode(sl20Req.toString().getBytes(StandardCharsets.UTF_8)));
// request VDA
+
+ final StopWatch watch = StopWatch.createStarted();
+ log.info("Requesting {} for authentication ... ", FRIENDLYNAME_HTTP_CLIENT);
final Sl20ResponseHolder httpResp = httpClientFactory.getHttpClient(false).execute(
httpReq, SL20HttpBindingUtils.sl20ResponseHandler());
+ watch.stop();
+ log.info("Respone from {} received after: {}[ms] with statusCode: {}", FRIENDLYNAME_HTTP_CLIENT,
+ watch.getTime(TimeUnit.MILLISECONDS), httpResp.getResponseStatus().getStatusCode());
+
//check on error on http channel
if (httpResp.getError() != null) {
log.info("Basic SL2.0 response processing has an error. HTTP-StatusCode: {} ErrorMsg: {}",
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 7591b3bd..0d0f990a 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
@@ -6,6 +6,13 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.commons.lang3.StringUtils;
+import org.jose4j.base64url.Base64Url;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonNode;
+
import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext;
import at.gv.egiz.eaaf.core.exceptions.EaafAuthenticationException;
import at.gv.egiz.eaaf.core.exceptions.EaafStorageException;
@@ -26,18 +33,10 @@ import at.gv.egiz.eaaf.modules.auth.sl20.utils.JsonMapper;
import at.gv.egiz.eaaf.modules.auth.sl20.utils.SL20Constants;
import at.gv.egiz.eaaf.modules.auth.sl20.utils.SL20JsonExtractorUtils;
import at.gv.egiz.eaaf.modules.auth.sl20.utils.SL20ResponseUtils;
+import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.StringUtils;
-import org.jose4j.base64url.Base64Url;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonNode;
-
+@Slf4j
public abstract class AbstractReceiveQualEidTask extends AbstractAuthServletTask {
- private static final Logger log = LoggerFactory.getLogger(AbstractReceiveQualEidTask.class);
@Autowired(required = true)
private IJoseTools joseTools;
@@ -89,6 +88,8 @@ public abstract class AbstractReceiveQualEidTask extends AbstractAuthServletTask
}
+ log.info("Receive response from A-Trust. Starting response-message validation ... ");
+
// check on errorMessage
final VerificationResult payLoadContainerErrorCheck = SL20JsonExtractorUtils.extractSL20PayLoad(
sl20ReqObj,
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 d07c0e66..cc2a8430 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
@@ -96,7 +96,7 @@ public class SL20HttpBindingUtils {
return holder;
} catch (final IOException | ParseException e) {
- log.warn("SL20 response contains no valid JSON", e);
+ log.warn("SL20 response contains no )valid JSON", e);
throw new SlCommandoParserException(MessageFormat.format(
"SL20 response with http-code: {0} with body: {1} and generic response-processing error: {2}",
httpStatusCode, bodyMsg, e.getMessage()));
@@ -170,18 +170,28 @@ public class SL20HttpBindingUtils {
private static JsonNode parseSL20ResultFromResponse(final HttpEntity resp) throws Exception {
if (resp != null && resp.getContent() != null) {
final String rawSL20Resp = EntityUtils.toString(resp);
- final JsonNode sl20Resp = mapper.getMapper().readTree(rawSL20Resp);
+ try {
+ final JsonNode sl20Resp = mapper.getMapper().readTree(rawSL20Resp);
+ if (sl20Resp != null) {
+ return sl20Resp;
- // TODO: check sl20Resp type like && sl20Resp.isJsonObject()
- if (sl20Resp != null) {
- return sl20Resp;
-
- } else {
+ } else {
+ log.error("SL2.0 can NOT parse to a JSON object from msg: {}", rawSL20Resp);
+ throw new SlCommandoParserException("SL2.0 can NOT parse to a JSON object");
+ }
+
+ } catch (SlCommandoParserException e) {
+ throw e;
+
+ } catch (Exception e) {
+ log.error("SL2.0 can NOT parse to a JSON object from msg: {}", rawSL20Resp);
throw new SlCommandoParserException("SL2.0 can NOT parse to a JSON object");
+
}
} else {
throw new SlCommandoParserException("Can NOT find content in http response");
+
}
}