aboutsummaryrefslogtreecommitdiff
path: root/id.server/src/at/gv/egovernment/moa/id/auth/builder/BPKBuilder.java
diff options
context:
space:
mode:
authorrudolf <rudolf@d688527b-c9ab-4aba-bd8d-4036d912da1d>2004-03-15 16:07:52 +0000
committerrudolf <rudolf@d688527b-c9ab-4aba-bd8d-4036d912da1d>2004-03-15 16:07:52 +0000
commit56ed4518d7978c064af5f240494bf587136c93b0 (patch)
treef7d9a57b7915d3b269d2550c9282138b624efa57 /id.server/src/at/gv/egovernment/moa/id/auth/builder/BPKBuilder.java
parent747a8963ec0ffde4c6883dd1c42ad758a88b084c (diff)
downloadmoa-id-spss-56ed4518d7978c064af5f240494bf587136c93b0.tar.gz
moa-id-spss-56ed4518d7978c064af5f240494bf587136c93b0.tar.bz2
moa-id-spss-56ed4518d7978c064af5f240494bf587136c93b0.zip
RSCH
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@99 d688527b-c9ab-4aba-bd8d-4036d912da1d
Diffstat (limited to 'id.server/src/at/gv/egovernment/moa/id/auth/builder/BPKBuilder.java')
-rw-r--r--id.server/src/at/gv/egovernment/moa/id/auth/builder/BPKBuilder.java50
1 files changed, 50 insertions, 0 deletions
diff --git a/id.server/src/at/gv/egovernment/moa/id/auth/builder/BPKBuilder.java b/id.server/src/at/gv/egovernment/moa/id/auth/builder/BPKBuilder.java
new file mode 100644
index 000000000..706d0a39a
--- /dev/null
+++ b/id.server/src/at/gv/egovernment/moa/id/auth/builder/BPKBuilder.java
@@ -0,0 +1,50 @@
+package at.gv.egovernment.moa.id.auth.builder;
+
+import java.security.MessageDigest;
+
+import at.gv.egovernment.moa.id.BuildException;
+import at.gv.egovernment.moa.util.Base64Utils;
+
+/**
+ * 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 Ivancsics
+ * @version $Id$
+ */
+public class BPKBuilder {
+
+ /**
+ * Builds the BPK from given parameters.
+ * @param identificationValue Base64 encoded "Stammzahl"
+ * @param target "Verfahrensname"; will be transformed to lower case
+ * @return PBK in a BASE64 encoding
+ * @throws BuildException while 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 = identificationValue + "+" + 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);
+ }
+ }
+
+}