aboutsummaryrefslogtreecommitdiff
path: root/id/server/modules/moa-id-module-bkaMobilaAuthSAML2Test/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'id/server/modules/moa-id-module-bkaMobilaAuthSAML2Test/src/main/java')
-rw-r--r--id/server/modules/moa-id-module-bkaMobilaAuthSAML2Test/src/main/java/at/gv/egovernment/moa/id/auth/modules/bkamobileauthtests/BKAMobileAuthModule.java14
-rw-r--r--id/server/modules/moa-id-module-bkaMobilaAuthSAML2Test/src/main/java/at/gv/egovernment/moa/id/auth/modules/bkamobileauthtests/tasks/FirstBKAMobileAuthTask.java25
-rw-r--r--id/server/modules/moa-id-module-bkaMobilaAuthSAML2Test/src/main/java/at/gv/egovernment/moa/id/auth/modules/bkamobileauthtests/tasks/SecondBKAMobileAuthTask.java24
3 files changed, 43 insertions, 20 deletions
diff --git a/id/server/modules/moa-id-module-bkaMobilaAuthSAML2Test/src/main/java/at/gv/egovernment/moa/id/auth/modules/bkamobileauthtests/BKAMobileAuthModule.java b/id/server/modules/moa-id-module-bkaMobilaAuthSAML2Test/src/main/java/at/gv/egovernment/moa/id/auth/modules/bkamobileauthtests/BKAMobileAuthModule.java
index 2e09bf55c..1269229d0 100644
--- a/id/server/modules/moa-id-module-bkaMobilaAuthSAML2Test/src/main/java/at/gv/egovernment/moa/id/auth/modules/bkamobileauthtests/BKAMobileAuthModule.java
+++ b/id/server/modules/moa-id-module-bkaMobilaAuthSAML2Test/src/main/java/at/gv/egovernment/moa/id/auth/modules/bkamobileauthtests/BKAMobileAuthModule.java
@@ -29,13 +29,13 @@ import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
-import at.gv.egiz.eaaf.core.impl.idp.auth.AuthenticationManager;
-import at.gv.egiz.eaaf.core.impl.idp.auth.modules.AuthModule;
+import at.gv.egiz.eaaf.core.api.data.EAAFConstants;
+import at.gv.egiz.eaaf.core.api.idp.auth.IAuthenticationManager;
+import at.gv.egiz.eaaf.core.api.idp.auth.modules.AuthModule;
+import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext;
import at.gv.egiz.eaaf.core.impl.utils.KeyValueUtils;
import at.gv.egovernment.moa.id.auth.modules.bkamobileauthtests.tasks.FirstBKAMobileAuthTask;
-import at.gv.egovernment.moa.id.commons.MOAIDAuthConstants;
import at.gv.egovernment.moa.id.commons.api.AuthConfiguration;
-import at.gv.egovernment.moa.id.process.api.ExecutionContext;
import at.gv.egovernment.moa.logging.Logger;
import at.gv.egovernment.moa.util.MiscUtil;
@@ -48,7 +48,7 @@ public class BKAMobileAuthModule implements AuthModule {
private int priority = 1;
@Autowired(required=true) protected AuthConfiguration authConfig;
- @Autowired(required=true) private AuthenticationManager authManager;
+ @Autowired(required=true) private IAuthenticationManager authManager;
private List<String> uniqueIDsDummyAuthEnabled = new ArrayList<String>();
@@ -71,7 +71,7 @@ public class BKAMobileAuthModule implements AuthModule {
@PostConstruct
public void initialDummyAuthWhiteList() {
- String sensitiveSpIdentifier = authConfig.getBasicMOAIDConfiguration("modules.bkamobileAuth.entityID");
+ String sensitiveSpIdentifier = authConfig.getBasicConfiguration("modules.bkamobileAuth.entityID");
if (MiscUtil.isNotEmpty(sensitiveSpIdentifier)) {
uniqueIDsDummyAuthEnabled.addAll(KeyValueUtils.getListOfCSVValues(sensitiveSpIdentifier));
@@ -91,7 +91,7 @@ public class BKAMobileAuthModule implements AuthModule {
*/
@Override
public String selectProcess(ExecutionContext context) {
- String spEntityID = (String) context.get(MOAIDAuthConstants.PROCESSCONTEXT_UNIQUE_OA_IDENTFIER);
+ String spEntityID = (String) context.get(EAAFConstants.PROCESS_ENGINE_SERVICE_PROVIDER_ENTITYID);
if (MiscUtil.isNotEmpty(spEntityID)) {
if (uniqueIDsDummyAuthEnabled.contains(spEntityID)) {
String eIDBlob = (String)context.get(FirstBKAMobileAuthTask.REQ_PARAM_eID_BLOW);
diff --git a/id/server/modules/moa-id-module-bkaMobilaAuthSAML2Test/src/main/java/at/gv/egovernment/moa/id/auth/modules/bkamobileauthtests/tasks/FirstBKAMobileAuthTask.java b/id/server/modules/moa-id-module-bkaMobilaAuthSAML2Test/src/main/java/at/gv/egovernment/moa/id/auth/modules/bkamobileauthtests/tasks/FirstBKAMobileAuthTask.java
index 37ee3f201..68b944814 100644
--- a/id/server/modules/moa-id-module-bkaMobilaAuthSAML2Test/src/main/java/at/gv/egovernment/moa/id/auth/modules/bkamobileauthtests/tasks/FirstBKAMobileAuthTask.java
+++ b/id/server/modules/moa-id-module-bkaMobilaAuthSAML2Test/src/main/java/at/gv/egovernment/moa/id/auth/modules/bkamobileauthtests/tasks/FirstBKAMobileAuthTask.java
@@ -29,6 +29,7 @@ import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.KeySpec;
+import java.util.Date;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
@@ -54,15 +55,17 @@ import com.google.gson.JsonParseException;
import com.google.gson.JsonParser;
import at.gv.egiz.eaaf.core.api.IRequest;
+import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext;
+import at.gv.egiz.eaaf.core.exceptions.EAAFStorageException;
import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException;
import at.gv.egiz.eaaf.core.impl.idp.auth.modules.AbstractAuthServletTask;
+import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;
import at.gv.egovernment.moa.id.auth.invoke.SignatureVerificationInvoker;
import at.gv.egovernment.moa.id.auth.parser.IdentityLinkAssertionParser;
import at.gv.egovernment.moa.id.commons.api.AuthConfiguration;
import at.gv.egovernment.moa.id.commons.api.data.IAuthenticationSession;
import at.gv.egovernment.moa.id.commons.api.data.IIdentityLink;
import at.gv.egovernment.moa.id.commons.api.exceptions.MOAIDException;
-import at.gv.egovernment.moa.id.process.api.ExecutionContext;
import at.gv.egovernment.moa.id.protocols.pvp2x.PVPConstants;
import at.gv.egovernment.moa.logging.Logger;
import at.gv.egovernment.moa.spss.api.cmsverify.VerifyCMSSignatureRequest;
@@ -90,7 +93,7 @@ public class FirstBKAMobileAuthTask extends AbstractAuthServletTask {
private static final String EIDCONTAINER_EID = "eid";
private static final String EIDCONTAINER_KEY_IDL = "idl";
private static final String EIDCONTAINER_KEY_BINDINGCERT = "cert";
-
+
public static final String REQ_PARAM_eID_BLOW = "eidToken";
@Autowired(required=true) private AuthConfiguration authConfig;
@@ -111,7 +114,7 @@ public class FirstBKAMobileAuthTask extends AbstractAuthServletTask {
throw new MOAIDException("NO eID data blob included!", null);
}
- parseDemoValuesIntoMOASession(pendingReq, pendingReq.getMOASession(), eIDBlobRawB64);
+ parseDemoValuesIntoMOASession(pendingReq, eIDBlobRawB64);
} catch (MOAIDException e) {
throw new TaskExecutionException(pendingReq, e.getMessage(), e);
@@ -133,7 +136,9 @@ public class FirstBKAMobileAuthTask extends AbstractAuthServletTask {
* @throws MOAIDException
* @throws IOException
*/
- private void parseDemoValuesIntoMOASession(IRequest pendingReq, IAuthenticationSession moaSession, String eIDBlobRawB64) throws MOAIDException, IOException {
+ private void parseDemoValuesIntoMOASession(IRequest pendingReq, String eIDBlobRawB64) throws MOAIDException, IOException {
+ IAuthenticationSession moaSession = new AuthenticationSession("1235", new Date());
+
Logger.debug("Check eID blob signature ... ");
byte[] eIDBlobRaw = Base64Utils.decode(eIDBlobRawB64.trim(), false);
@@ -209,6 +214,8 @@ public class FirstBKAMobileAuthTask extends AbstractAuthServletTask {
Logger.info("Session Restore completed");
+ pendingReq.setGenericDataToSession(moaSession.getKeyValueRepresentationFromAuthSession());
+
} catch (MOAIDException e) {
throw e;
@@ -236,6 +243,10 @@ public class FirstBKAMobileAuthTask extends AbstractAuthServletTask {
Logger.error("Can not extract mobile-app binding-certificate from eID blob.", e);
throw new MOAIDException("Can not extract mobile-app binding-certificate from eID blob.", null, e);
+ } catch (EAAFStorageException e) {
+ Logger.error("Can not populate pending-request with eID data.", e);
+ throw new MOAIDException("Can not populate pending-request with eID data.", null, e);
+
} finally {
}
@@ -243,7 +254,7 @@ public class FirstBKAMobileAuthTask extends AbstractAuthServletTask {
}
private SecretKey generateDecryptionKey(byte[] salt) throws MOAIDException {
- String decryptionPassPhrase = authConfig.getBasicMOAIDConfiguration(CONF_EID_TOKEN_ENCRYPTION_KEY, "DEFAULTPASSWORD");
+ String decryptionPassPhrase = authConfig.getBasicConfiguration(CONF_EID_TOKEN_ENCRYPTION_KEY, "DEFAULTPASSWORD");
try {
SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256");
KeySpec spec = new PBEKeySpec(decryptionPassPhrase.toCharArray(), salt, 2000, 128);
@@ -276,7 +287,7 @@ public class FirstBKAMobileAuthTask extends AbstractAuthServletTask {
}
SignerInfo signerInfos = verifySigResult.getSignerInfo();
DateTime date = new DateTime(signerInfos.getSigningTime().getTime());
- Integer signingTimeJitter = Integer.valueOf(authConfig.getBasicMOAIDConfiguration(CONF_SIGNING_TIME_JITTER, "5"));
+ Integer signingTimeJitter = Integer.valueOf(authConfig.getBasicConfiguration(CONF_SIGNING_TIME_JITTER, "5"));
if (date.plusMinutes(signingTimeJitter).isBeforeNow()) {
Logger.warn("CMS signature-time is before: " + date.plusMinutes(signingTimeJitter));
throw new MOAIDException("CMS signature-time is before: " + date.plusMinutes(signingTimeJitter), null);
@@ -290,7 +301,7 @@ public class FirstBKAMobileAuthTask extends AbstractAuthServletTask {
cmsSigVerifyReq.setSignatories(VerifyCMSSignatureRequestImpl.ALL_SIGNATORIES);
cmsSigVerifyReq.setExtended(false);
cmsSigVerifyReq.setPDF(false);
- cmsSigVerifyReq.setTrustProfileId(authConfig.getBasicMOAIDConfiguration(CONF_MOASPSS_TRUSTPROFILE, "!!NOT SET!!!"));
+ cmsSigVerifyReq.setTrustProfileId(authConfig.getBasicConfiguration(CONF_MOASPSS_TRUSTPROFILE, "!!NOT SET!!!"));
cmsSigVerifyReq.setCMSSignature(new ByteArrayInputStream(eIDBlobRaw));
return cmsSigVerifyReq;
}
diff --git a/id/server/modules/moa-id-module-bkaMobilaAuthSAML2Test/src/main/java/at/gv/egovernment/moa/id/auth/modules/bkamobileauthtests/tasks/SecondBKAMobileAuthTask.java b/id/server/modules/moa-id-module-bkaMobilaAuthSAML2Test/src/main/java/at/gv/egovernment/moa/id/auth/modules/bkamobileauthtests/tasks/SecondBKAMobileAuthTask.java
index 5c70b2628..9ce987956 100644
--- a/id/server/modules/moa-id-module-bkaMobilaAuthSAML2Test/src/main/java/at/gv/egovernment/moa/id/auth/modules/bkamobileauthtests/tasks/SecondBKAMobileAuthTask.java
+++ b/id/server/modules/moa-id-module-bkaMobilaAuthSAML2Test/src/main/java/at/gv/egovernment/moa/id/auth/modules/bkamobileauthtests/tasks/SecondBKAMobileAuthTask.java
@@ -25,21 +25,26 @@ package at.gv.egovernment.moa.id.auth.modules.bkamobileauthtests.tasks;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
+import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import at.gv.egiz.eaaf.core.api.IRequest;
+import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext;
+import at.gv.egiz.eaaf.core.exceptions.EAAFStorageException;
import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException;
import at.gv.egiz.eaaf.core.impl.idp.auth.modules.AbstractAuthServletTask;
+import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;
import at.gv.egovernment.moa.id.auth.exception.ParseException;
import at.gv.egovernment.moa.id.auth.parser.IdentityLinkAssertionParser;
+import at.gv.egovernment.moa.id.commons.api.AuthConfiguration;
import at.gv.egovernment.moa.id.commons.api.data.IAuthenticationSession;
import at.gv.egovernment.moa.id.commons.api.data.IIdentityLink;
import at.gv.egovernment.moa.id.commons.api.exceptions.MOAIDException;
-import at.gv.egovernment.moa.id.process.api.ExecutionContext;
import at.gv.egovernment.moa.id.protocols.pvp2x.PVPConstants;
import at.gv.egovernment.moa.logging.Logger;
import at.gv.egovernment.moa.util.FileUtils;
@@ -50,7 +55,9 @@ import at.gv.egovernment.moa.util.FileUtils;
*/
@Component("SecondBKAMobileAuthTask")
public class SecondBKAMobileAuthTask extends AbstractAuthServletTask {
-
+
+ @Autowired AuthConfiguration moaAuthConfig;
+
/* (non-Javadoc)
* @see at.gv.egovernment.moa.id.auth.modules.AbstractAuthServletTask#execute(at.gv.egovernment.moa.id.process.api.ExecutionContext, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
@@ -60,7 +67,7 @@ public class SecondBKAMobileAuthTask extends AbstractAuthServletTask {
try {
Logger.info("Add user credentials for BKA MobileAuth SAML2 test and finalize authentication");
- parseDemoValuesIntoMOASession(pendingReq, pendingReq.getMOASession());
+ parseDemoValuesIntoMOASession(pendingReq);
// store MOASession into database
requestStoreage.storePendingRequest(pendingReq);
@@ -78,8 +85,11 @@ public class SecondBKAMobileAuthTask extends AbstractAuthServletTask {
* @param pendingReq
* @param moaSession
* @throws MOAIDException
+ * @throws EAAFStorageException
*/
- private void parseDemoValuesIntoMOASession(IRequest pendingReq, IAuthenticationSession moaSession) throws MOAIDException {
+ private void parseDemoValuesIntoMOASession(IRequest pendingReq) throws MOAIDException, EAAFStorageException {
+ IAuthenticationSession moaSession = new AuthenticationSession("1233", new Date());
+
moaSession.setUseMandates(false);
moaSession.setForeigner(false);
@@ -87,18 +97,20 @@ public class SecondBKAMobileAuthTask extends AbstractAuthServletTask {
moaSession.setQAALevel(PVPConstants.STORK_QAA_1_4);
try {
- String idlurl = FileUtils.makeAbsoluteURL(authConfig.getMonitoringTestIdentityLinkURL(), authConfig.getRootConfigFileDir());
+ String idlurl = FileUtils.makeAbsoluteURL(moaAuthConfig.getMonitoringTestIdentityLinkURL(), moaAuthConfig.getRootConfigFileDir());
URL keystoreURL = new URL(idlurl);
InputStream idlstream = keystoreURL.openStream();
IIdentityLink identityLink = new IdentityLinkAssertionParser(idlstream).parseIdentityLink();
moaSession.setIdentityLink(identityLink);
-
+
} catch (ParseException | IOException e) {
Logger.error("IdentityLink is not parseable.", e);
throw new MOAIDException("IdentityLink is not parseable.", null);
}
+ pendingReq.setGenericDataToSession(moaSession.getKeyValueRepresentationFromAuthSession());
+
}
}