summaryrefslogtreecommitdiff
path: root/eaaf_core/src/main/java/at/gv
diff options
context:
space:
mode:
authorThomas Lenz <thomas.lenz@egiz.gv.at>2020-02-20 09:43:03 +0100
committerThomas Lenz <thomas.lenz@egiz.gv.at>2020-02-20 09:43:03 +0100
commita57a2ed851b818456421f3ce082dc6813da6b736 (patch)
treeb4c9c4c9f7c317ff3f0686d7427366203bdd9347 /eaaf_core/src/main/java/at/gv
parent9e26dd0833cd3a6bfb6f15cc11727cdc8e14d260 (diff)
downloadEAAF-Components-a57a2ed851b818456421f3ce082dc6813da6b736.tar.gz
EAAF-Components-a57a2ed851b818456421f3ce082dc6813da6b736.tar.bz2
EAAF-Components-a57a2ed851b818456421f3ce082dc6813da6b736.zip
add two jUnit test and CodeStyle modifications
Diffstat (limited to 'eaaf_core/src/main/java/at/gv')
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/AbstractAuthenticationDataBuilder.java35
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/data/AuthProcessDataWrapper.java37
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/protocols/RequestImpl.java20
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/logging/EaafCoreMessageSource.java16
4 files changed, 79 insertions, 29 deletions
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/AbstractAuthenticationDataBuilder.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/AbstractAuthenticationDataBuilder.java
index f5c687f1..8f87cbfa 100644
--- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/AbstractAuthenticationDataBuilder.java
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/AbstractAuthenticationDataBuilder.java
@@ -26,17 +26,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Map.Entry;
-import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.lang.NonNull;
-import org.springframework.util.Assert;
-import org.springframework.util.Base64Utils;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
import at.gv.egiz.eaaf.core.api.IRequest;
import at.gv.egiz.eaaf.core.api.data.EaafConstants;
import at.gv.egiz.eaaf.core.api.data.ExtendedPvpAttributeDefinitions;
@@ -60,6 +49,17 @@ import at.gv.egiz.eaaf.core.impl.idp.auth.data.AuthProcessDataWrapper;
import at.gv.egiz.eaaf.core.impl.idp.auth.data.SimpleIdentityLinkAssertionParser;
import at.gv.egiz.eaaf.core.impl.utils.XPathUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.lang.NonNull;
+import org.springframework.util.Assert;
+import org.springframework.util.Base64Utils;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
public abstract class AbstractAuthenticationDataBuilder implements IAuthenticationDataBuilder {
private static final Logger log =
LoggerFactory.getLogger(AbstractAuthenticationDataBuilder.class);
@@ -145,10 +145,11 @@ public abstract class AbstractAuthenticationDataBuilder implements IAuthenticati
* @param authProcessData Authentication information holder from current pending
* request
* @param pendingReq current pending request
+ * @throws EaafAuthenticationException In case inconsistent authentication data
*/
private void buildInternalAuthDataGeneric(@NonNull final IAuthData authData,
@NonNull final IAuthProcessDataContainer authProcessData,
- @NonNull final IRequest pendingReq) {
+ @NonNull final IRequest pendingReq) throws EaafAuthenticationException {
Assert.notNull(pendingReq, "PendingRequest is null");
Assert.notNull(authData, "AuthData is null");
Assert.notNull(authProcessData, "AuthProcessData is null");
@@ -227,9 +228,10 @@ public abstract class AbstractAuthenticationDataBuilder implements IAuthenticati
* @param authData Current authentication data
* @param authProcessData Authentication information holder from current pending
* request
+ * @throws EaafAuthenticationException In case inconsistent authentication data
*/
private void setCitizenCountryCode(final AuthenticationData authData,
- final IAuthProcessDataContainer authProcessData) {
+ final IAuthProcessDataContainer authProcessData) throws EaafAuthenticationException {
includedToGenericAuthData.remove(PvpAttributeDefinitions.EID_ISSUING_NATION_NAME);
final String pvpCccAttr = authProcessData
.getGenericDataFromSession(PvpAttributeDefinitions.EID_ISSUING_NATION_NAME, String.class);
@@ -239,8 +241,9 @@ public abstract class AbstractAuthenticationDataBuilder implements IAuthenticati
} else {
if (authData.isForeigner()) {
- // TODO:
- log.warn("Foreign citizen country NOT set yet!");
+ log.warn("EID_Issuing_Nation NOT SET for foreign citizen.");
+ throw new EaafAuthenticationException("builder.11",
+ new Object[] { "EID_Issuing_Nation NOT SET for foreign citizen." });
} else {
authData.setCiticenCountryCode(basicConfig.getBasicConfiguration(
@@ -324,7 +327,7 @@ public abstract class AbstractAuthenticationDataBuilder implements IAuthenticati
protected void generateDeprecatedBasicAuthData(final AuthenticationData authData,
final IRequest pendingReq, final IAuthProcessDataContainer authProcessData)
throws EaafBuilderException, EaafConfigurationException, XPathException, DOMException,
- EaafParserException {
+ EaafParserException, EaafAuthenticationException {
if (authProcessData.getGenericSessionDataStorage() != null
&& !authProcessData.getGenericSessionDataStorage().isEmpty()) {
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/data/AuthProcessDataWrapper.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/data/AuthProcessDataWrapper.java
index a6017789..988a78b6 100644
--- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/data/AuthProcessDataWrapper.java
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/data/AuthProcessDataWrapper.java
@@ -19,13 +19,11 @@
package at.gv.egiz.eaaf.core.impl.idp.auth.data;
+import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
-
-import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import java.util.TimeZone;
import at.gv.egiz.eaaf.core.api.data.EaafConstants;
import at.gv.egiz.eaaf.core.api.idp.EaafAuthProcessDataConstants;
@@ -33,6 +31,10 @@ import at.gv.egiz.eaaf.core.api.idp.auth.data.IAuthProcessDataContainer;
import at.gv.egiz.eaaf.core.api.idp.auth.data.IIdentityLink;
import at.gv.egiz.eaaf.core.exceptions.EaafStorageException;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
public class AuthProcessDataWrapper
implements IAuthProcessDataContainer, EaafAuthProcessDataConstants {
private static final Logger log = LoggerFactory.getLogger(AuthProcessDataWrapper.class);
@@ -72,6 +74,19 @@ public class AuthProcessDataWrapper
* (non-Javadoc)
*
* @see
+ * at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#setIssueInstant(
+ * java.lang.String)
+ */
+ @Override
+ public void setIssueInstant(final Date issueInstant) {
+ authProcessData.put(VALUE_ISSUEINSTANT, buildDateTimeUtc(issueInstant));
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
* at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#isAuthenticated()
*/
@Override
@@ -305,4 +320,18 @@ public class AuthProcessDataWrapper
}
}
+
+ /**
+ * Builds a <code>dateTime</code> value in UTC from a <code>Calendar</code> value.
+ *
+ * @param date the <code>Calendar</code> value
+ * @return the <code>dateTime</code> value
+ */
+ public static String buildDateTimeUtc(final Date date) {
+
+ final SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
+ f.setTimeZone(TimeZone.getTimeZone("UTC"));
+
+ return f.format(date.getTime());
+ }
}
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/protocols/RequestImpl.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/protocols/RequestImpl.java
index 07fc652a..5110d2bf 100644
--- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/protocols/RequestImpl.java
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/protocols/RequestImpl.java
@@ -32,13 +32,6 @@ import java.util.UUID;
import javax.annotation.Nonnull;
import javax.servlet.http.HttpServletRequest;
-import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.lang.NonNull;
-import org.springframework.lang.Nullable;
-import org.springframework.util.Assert;
-
import at.gv.egiz.eaaf.core.api.IRequest;
import at.gv.egiz.eaaf.core.api.data.EaafConstants;
import at.gv.egiz.eaaf.core.api.idp.IConfiguration;
@@ -52,12 +45,21 @@ import at.gv.egiz.eaaf.core.impl.utils.HttpUtils;
import at.gv.egiz.eaaf.core.impl.utils.Random;
import at.gv.egiz.eaaf.core.impl.utils.TransactionIdUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.lang.NonNull;
+import org.springframework.lang.Nullable;
+import org.springframework.util.Assert;
+
public abstract class RequestImpl implements IRequest, Serializable {
private static final Logger log = LoggerFactory.getLogger(RequestImpl.class);
public static final String DATAID_REQUESTER_IP_ADDRESS = "reqestImpl_requesterIPAddr";
+ private static final String ERROR_CODE_INTERNAL_00 = "eaaf.core.00";
+
private static final long serialVersionUID = 1L;
private String module = null;
@@ -143,14 +145,14 @@ public abstract class RequestImpl implements IRequest, Serializable {
} catch (final MalformedURLException e) {
log.error("IDP AuthenticationServiceURL Prefix is not a valid URL." + authUrlString, e);
- throw new EaafAuthenticationException("errorId", new Object[] { authUrlString }, e);
+ throw new EaafAuthenticationException(ERROR_CODE_INTERNAL_00, new Object[] { authUrlString }, e);
}
this.idpAuthUrl = authConfig.validateIdpUrl(authReqUrl);
if (this.idpAuthUrl == null) {
log.warn(
"Extract AuthenticationServiceURL: " + authReqUrl + " is NOT found in configuration.");
- throw new EaafAuthenticationException("errorId", new Object[] { authUrlString });
+ throw new EaafAuthenticationException(ERROR_CODE_INTERNAL_00, new Object[] { authUrlString });
}
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/logging/EaafCoreMessageSource.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/logging/EaafCoreMessageSource.java
new file mode 100644
index 00000000..852c65b1
--- /dev/null
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/logging/EaafCoreMessageSource.java
@@ -0,0 +1,16 @@
+package at.gv.egiz.eaaf.core.impl.logging;
+
+import java.util.Arrays;
+import java.util.List;
+
+import at.gv.egiz.eaaf.core.api.logging.IMessageSourceLocation;
+
+public class EaafCoreMessageSource implements IMessageSourceLocation {
+
+ @Override
+ public List<String> getMessageSourceLocation() {
+ return Arrays.asList("classpath:messages/eaaf_core_messages");
+
+ }
+
+}