aboutsummaryrefslogtreecommitdiff
path: root/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/BPKBuilder.java
diff options
context:
space:
mode:
Diffstat (limited to 'id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/BPKBuilder.java')
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/BPKBuilder.java31
1 files changed, 21 insertions, 10 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 866c5a923..7039a1fe0 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
@@ -46,6 +46,7 @@
package at.gv.egovernment.moa.id.auth.builder;
+import at.gv.egovernment.moa.id.auth.data.IdentityLink;
import at.gv.egovernment.moa.id.auth.exception.BuildException;
import at.gv.egovernment.moa.logging.Logger;
import at.gv.egovernment.moa.util.Base64Utils;
@@ -137,28 +138,37 @@ public class BPKBuilder {
/**
* Builds the storkeid from the given parameters.
*
- * @param identificationValue Base64 encoded "Stammzahl"
+ * @param identityLink identity link
* @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 buildStorkbPK(String identificationValue, String destinationCountry)
+ public String buildStorkeIdentifier(IdentityLink identityLink, String destinationCountry)
throws BuildException {
- return buildStorkbPK(identificationValue, "AT", destinationCountry);
+ return buildStorkbPK(identityLink, "AT", destinationCountry);
}
/**
* Builds the storkeid from the given parameters.
*
- * @param identificationValue Base64 encoded "Stammzahl"
+ * @param identityLink identity link
* @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 buildStorkbPK(String identificationValue, String sourceCountry, String destinationCountry)
+ public String buildStorkbPK(IdentityLink identityLink, String sourceCountry, String destinationCountry)
throws BuildException {
+ String identificationValue = null;
+
+ // check if we have been called by public sector application
+ if (identityLink.getIdentificationType().startsWith(Constants.URN_PREFIX_BASEID)) {
+ identificationValue = calculateStorkeIdentifierBase(identityLink, sourceCountry, destinationCountry);
+ } else { // if not, sector identification value is already calculated by BKU
+ Logger.info("STORK eIdentifier already provided by BKU");
+ identificationValue = identityLink.getIdentificationValue();
+ }
if ((identificationValue == null ||
identificationValue.length() == 0 ||
@@ -173,20 +183,21 @@ public class BPKBuilder {
Logger.info("Building STORK identification from: " + sourceCountry+"/"+destinationCountry+"/" + "[identValue]");
String eIdentifier = sourceCountry+"/"+destinationCountry+"/"+identificationValue;
- /* Commented - it is already done by BKU, we need only to add Stork values
- String basisbegriff = identificationValue + "+" + Constants.URN_PREFIX_STORK + "+" + sourceCountry + "+" + destinationCountry;
+ return eIdentifier;
+ }
+
+ private String calculateStorkeIdentifierBase(IdentityLink identityLink, String sourceCountry, String destinationCountry) throws BuildException {
+ String basisbegriff = identityLink.getIdentificationValue() + "+" + Constants.URN_PREFIX_STORK + "+" + sourceCountry + "+" + destinationCountry;
Logger.info("Building STORK identification from: [identValue]+" + 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);
- Logger.info("STORK identification defined as: " + hashBase64);
+ Logger.debug("STORK identification defined as: " + hashBase64);
return hashBase64;
} catch (Exception ex) {
throw new BuildException("builder.00", new Object[]{"storkid", ex.toString()}, ex);
}
- */
- return eIdentifier;
}