aboutsummaryrefslogtreecommitdiff
path: root/id/server
diff options
context:
space:
mode:
Diffstat (limited to 'id/server')
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/BPKBuilder.java196
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AuthenticationRequest.java13
2 files changed, 136 insertions, 73 deletions
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/BPKBuilder.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/BPKBuilder.java
index bd87737ed..fd8f3f875 100644
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/BPKBuilder.java
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/BPKBuilder.java
@@ -2,19 +2,19 @@
* Copyright 2014 Federal Chancellery Austria
* MOA-ID has been developed in a cooperation between BRZ, the Federal
* Chancellery Austria - ICT staff unit, and Graz University of Technology.
- *
+ *
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
* the European Commission - subsequent versions of the EUPL (the "Licence");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
* http://www.osor.eu/eupl/
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
- *
+ *
* This product combines work with different licenses. See the "NOTICE" text
* file for details on the various modules and licenses.
* The "NOTICE" text file is part of the distribution. Any derivative works
@@ -46,91 +46,143 @@
package at.gv.egovernment.moa.id.auth.builder;
-import java.security.MessageDigest;
-
import at.gv.egovernment.moa.id.auth.exception.BuildException;
import at.gv.egovernment.moa.util.Base64Utils;
import at.gv.egovernment.moa.util.Constants;
+import java.security.MessageDigest;
+
/**
* Builder for the bPK, as defined in
* <code>&quot;Ableitung f&uml;r die bereichsspezifische Personenkennzeichnung&quot;</code>
* version <code>1.0.1</code> from <code>&quot;reference.e-government.gv.at&quot;</code>.
- *
+ *
* @author Paul Schamberger
* @version $Id$
*/
public class BPKBuilder {
- /**
- * Builds the bPK from the given parameters.
- * @param identificationValue Base64 encoded "Stammzahl"
- * @param target "Bereich lt. Verordnung des BKA"
- * @return bPK in a BASE64 encoding
- * @throws BuildException if an error occurs on building the bPK
- */
- public String buildBPK(String identificationValue, String target)
- throws BuildException {
-
- if ((identificationValue == null ||
- identificationValue.length() == 0 ||
- target == null ||
- target.length() == 0))
- {
- throw new BuildException("builder.00",
- new Object[] {"BPK", "Unvollständige Parameterangaben: identificationValue=" +
- identificationValue + ",target=" + target});
+ /**
+ * Builds the bPK from the given parameters.
+ *
+ * @param identificationValue Base64 encoded "Stammzahl"
+ * @param target "Bereich lt. Verordnung des BKA"
+ * @return bPK in a BASE64 encoding
+ * @throws BuildException if an error occurs on building the bPK
+ */
+ public String buildBPK(String identificationValue, String target)
+ throws BuildException {
+
+ if ((identificationValue == null ||
+ identificationValue.length() == 0 ||
+ target == null ||
+ target.length() == 0)) {
+ throw new BuildException("builder.00",
+ new Object[]{"BPK", "Unvollständige Parameterangaben: identificationValue=" +
+ identificationValue + ",target=" + target});
+ }
+ String basisbegriff;
+ if (target.startsWith(Constants.URN_PREFIX_CDID + "+"))
+ basisbegriff = identificationValue + "+" + target;
+ else
+ basisbegriff = identificationValue + "+" + Constants.URN_PREFIX_CDID + "+" + target;
+
+ try {
+ MessageDigest md = MessageDigest.getInstance("SHA-1");
+ byte[] hash = md.digest(basisbegriff.getBytes("ISO-8859-1"));
+ String hashBase64 = Base64Utils.encode(hash);
+ return hashBase64;
+ } catch (Exception ex) {
+ throw new BuildException("builder.00", new Object[]{"bPK", ex.toString()}, ex);
+ }
}
- String basisbegriff;
- if (target.startsWith(Constants.URN_PREFIX_CDID + "+"))
- basisbegriff = identificationValue + "+" + target;
- else
- basisbegriff = identificationValue + "+" + Constants.URN_PREFIX_CDID + "+" + target;
-
- try {
- MessageDigest md = MessageDigest.getInstance("SHA-1");
- byte[] hash = md.digest(basisbegriff.getBytes("ISO-8859-1"));
- String hashBase64 = Base64Utils.encode(hash);
- return hashBase64;
- } catch (Exception ex) {
- throw new BuildException("builder.00", new Object[] {"bPK", ex.toString()}, ex);
+
+ /**
+ * Builds the wbPK from the given parameters.
+ *
+ * @param identificationValue Base64 encoded "Stammzahl"
+ * @param registerAndOrdNr type of register + "+" + number in register.
+ * @return wbPK in a BASE64 encoding
+ * @throws BuildException if an error occurs on building the wbPK
+ */
+ public String buildWBPK(String identificationValue, String registerAndOrdNr)
+ throws BuildException {
+
+ if ((identificationValue == null ||
+ identificationValue.length() == 0 ||
+ registerAndOrdNr == null ||
+ registerAndOrdNr.length() == 0)) {
+ throw new BuildException("builder.00",
+ new Object[]{"wbPK", "Unvollständige Parameterangaben: identificationValue=" +
+ identificationValue + ",Register+Registernummer=" + registerAndOrdNr});
+ }
+
+ String basisbegriff;
+ if (registerAndOrdNr.startsWith(Constants.URN_PREFIX_WBPK + "+"))
+ basisbegriff = identificationValue + "+" + registerAndOrdNr;
+ else
+ basisbegriff = identificationValue + "+" + Constants.URN_PREFIX_WBPK + "+" + registerAndOrdNr;
+
+ try {
+ MessageDigest md = MessageDigest.getInstance("SHA-1");
+ byte[] hash = md.digest(basisbegriff.getBytes("ISO-8859-1"));
+ String hashBase64 = Base64Utils.encode(hash);
+ return hashBase64;
+ } catch (Exception ex) {
+ throw new BuildException("builder.00", new Object[]{"wbPK", ex.toString()}, ex);
+ }
}
- }
-
- /**
- * Builds the wbPK from the given parameters.
- * @param identificationValue Base64 encoded "Stammzahl"
- * @param registerAndOrdNr type of register + "+" + number in register.
- * @return wbPK in a BASE64 encoding
- * @throws BuildException if an error occurs on building the wbPK
- */
- public String buildWBPK(String identificationValue, String registerAndOrdNr)
- throws BuildException {
-
- if ((identificationValue == null ||
- identificationValue.length() == 0 ||
- registerAndOrdNr == null ||
- registerAndOrdNr.length() == 0))
- {
- throw new BuildException("builder.00",
- new Object[] {"wbPK", "Unvollständige Parameterangaben: identificationValue=" +
- identificationValue + ",Register+Registernummer=" + registerAndOrdNr});
+
+ /**
+ * Builds the wbPK from the given parameters.
+ *
+ * @param identificationValue Base64 encoded "Stammzahl"
+ * @param destinationCountry destination country code (2 chars)
+ * @return storkid in a BASE64 encoding
+ * @throws BuildException if an error occurs on building the wbPK
+ */
+ public String buildStorkPK(String identificationValue, String destinationCountry)
+ throws BuildException {
+ return buildStorkPK(identificationValue, "AT", destinationCountry);
}
-
- String basisbegriff;
- if (registerAndOrdNr.startsWith(Constants.URN_PREFIX_WBPK + "+" ))
- basisbegriff = identificationValue + "+" + registerAndOrdNr;
- else
- basisbegriff = identificationValue + "+" + Constants.URN_PREFIX_WBPK + "+" + registerAndOrdNr;
-
- try {
- MessageDigest md = MessageDigest.getInstance("SHA-1");
- byte[] hash = md.digest(basisbegriff.getBytes("ISO-8859-1"));
- String hashBase64 = Base64Utils.encode(hash);
- return hashBase64;
- } catch (Exception ex) {
- throw new BuildException("builder.00", new Object[] {"wbPK", ex.toString()}, ex);
+
+
+ /**
+ * Builds the wbPK from the given parameters.
+ *
+ * @param identificationValue Base64 encoded "Stammzahl"
+ * @param sourceCountry source country code (2 chars)
+ * @param destinationCountry destination country code (2 chars)
+ * @return storkid in a BASE64 encoding
+ * @throws BuildException if an error occurs on building the wbPK
+ */
+ public String buildStorkPK(String identificationValue, String sourceCountry, String destinationCountry)
+ throws BuildException {
+
+ if ((identificationValue == null ||
+ identificationValue.length() == 0 ||
+ destinationCountry == null ||
+ destinationCountry.length() == 0 ||
+ destinationCountry.length() != 2 ||
+ sourceCountry == null ||
+ sourceCountry.length() == 0 ||
+ sourceCountry.length() != 2)) {
+ throw new BuildException("builder.00",
+ new Object[]{"storkid", "Unvollständige Parameterangaben: identificationValue=" +
+ identificationValue + ", Zielland=" + destinationCountry + ", Ursprungsland=" + sourceCountry});
+ }
+
+ String basisbegriff = identificationValue + "+" + Constants.URN_PREFIX_STORK + "+" + sourceCountry + "+" + destinationCountry;
+
+ try {
+ MessageDigest md = MessageDigest.getInstance("SHA-1");
+ byte[] hash = md.digest(basisbegriff.getBytes("ISO-8859-1"));
+ String hashBase64 = Base64Utils.encode(hash);
+ return hashBase64;
+ } catch (Exception ex) {
+ throw new BuildException("builder.00", new Object[]{"storkid", ex.toString()}, ex);
+ }
}
- }
+
}
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AuthenticationRequest.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AuthenticationRequest.java
index d4996c26a..3288e064f 100644
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AuthenticationRequest.java
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AuthenticationRequest.java
@@ -10,6 +10,7 @@ import at.gv.egovernment.moa.id.config.auth.OAAuthParameter;
import at.gv.egovernment.moa.id.moduls.IAction;
import at.gv.egovernment.moa.id.moduls.IRequest;
import at.gv.egovernment.moa.id.storage.AssertionStorage;
+import at.gv.egovernment.moa.id.util.client.mis.simple.MISMandate;
import at.gv.egovernment.moa.logging.Logger;
import edu.emory.mathcs.backport.java.util.Collections;
import eu.stork.peps.auth.commons.*;
@@ -29,6 +30,7 @@ import javax.servlet.http.HttpSession;
import java.io.*;
import java.util.HashMap;
import eu.stork.peps.auth.engine.SAMLEngine;
+import org.w3c.dom.Element;
/**
@@ -52,6 +54,15 @@ public class AuthenticationRequest implements IAction {
this.moaSession = moasession;
this.moaStorkAuthnRequest = (MOASTORKAuthnRequest)req;
+ MISMandate mandate = moasession.getMISMandate();
+ String owbpk = mandate.getOWbPK();
+ byte[] mand = mandate.getMandate();
+ String profprep = mandate.getProfRep();
+ //String textdesc = mandate.getTextualDescriptionOfOID();
+ Element mndt = moasession.getMandate();
+
+
+ Logger.debug("mandate encoded: " + new String(org.bouncycastle.util.encoders.Base64.encode(mand)));
Logger.debug("Starting AuthenticationRequest");
//AuthenticationServer.getInstance().startSTORKAuthentication(httpReq, httpResp, moasession);
@@ -61,7 +72,7 @@ public class AuthenticationRequest implements IAction {
httpResp.reset();
STORKAuthnResponse authnResponse = new STORKAuthnResponse();
- authnResponse.setCountry("AT");
+ authnResponse.setCountry("EU");
OAAuthParameter oaParam = AuthConfigurationProvider.getInstance().getOnlineApplicationParameter(moasession.getPublicOAURLPrefix());
if (oaParam == null)