summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorThomas Lenz <thomas.lenz@egiz.gv.at>2014-11-06 11:11:18 +0100
committerThomas Lenz <thomas.lenz@egiz.gv.at>2014-11-06 11:11:18 +0100
commit0b80629de22e6c45225a6516829b293062875c0e (patch)
tree11dc358e202913b6b84109539cd6f6cff26d1a48 /src/main
parent8eb65febb84af1472513fdecbf9553817d2ab93b (diff)
downloadegovutils-0b80629de22e6c45225a6516829b293062875c0e.tar.gz
egovutils-0b80629de22e6c45225a6516829b293062875c0e.tar.bz2
egovutils-0b80629de22e6c45225a6516829b293062875c0e.zip
updte bPK builder
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/gv/util/BpkUtil.java34
1 files changed, 27 insertions, 7 deletions
diff --git a/src/main/java/at/gv/util/BpkUtil.java b/src/main/java/at/gv/util/BpkUtil.java
index 5c256c4..31dfa6d 100644
--- a/src/main/java/at/gv/util/BpkUtil.java
+++ b/src/main/java/at/gv/util/BpkUtil.java
@@ -53,7 +53,10 @@ public final class BpkUtil {
public static final String SECTOR_DELIVERY = "ZU";
public static final String PUBLIC_KEY_ZUSEKOPF_SN01_BASE64 = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDfGFFEzWl1kSbzmk4pWVeftyD2aWTVQ8xSIwb6ECLdFTy4zE9LI6a87zlPbOOzvvdO+Nv1VCvT+WqD9HOCtPwealwwRKS2cHI9aqYyozqDOIGBRIz7MDBKuqaTwCvonFe0MUBxVWDDTmqhDIjkN0uDQidQtqqjzupEzuQ59lVpBQIDAQAB";
- public static final String prefix = "urn:publicid:gv.at:cdid+";
+ public static final String PREFIX_BPK_TYPE = "urn:publicid:gv.at:cdid+";
+ public static final String PREFIX_WBPK_TYPE = "urn:publicid:gv.at:wbpk+";
+ public static final String PREFIX_STORK_TYPE = "urn:publicid:gv.at:storkid+";
+
private static String calcDigest(String data)
@@ -64,19 +67,36 @@ public final class BpkUtil {
}
+ public static String calcbPKorwbPKorSTORKID(String baseID, String sector) {
+ MiscUtil.assertNotEmpty(baseID, "BaseID");
+ MiscUtil.assertNotEmpty(sector, "Sector");
+
+ if (sector.startsWith(PREFIX_BPK_TYPE))
+ return calcBPK(baseID, sector);
+
+ else if (sector.startsWith(PREFIX_WBPK_TYPE))
+ return calcWBPK(baseID, sector);
+
+ else if (sector.startsWith(PREFIX_STORK_TYPE))
+ return calcWBPK(baseID, sector);
+
+ else
+ throw new InternalErrorException("Sector is not of bPK or wbPK or stork type");
+
+ }
+
public static String calcBPK(String baseID, String sector) {
MiscUtil.assertNotEmpty(baseID, "BaseID");
MiscUtil.assertNotEmpty(sector, "Sector");
// prefix according to specification
- String prefix = "urn:publicid:gv.at:cdid+";
-
+
// concatenation according to algorithm
String data;
- if (sector.startsWith(prefix))
+ if (sector.startsWith(PREFIX_BPK_TYPE))
data = baseID + "+" + sector;
else
- data = baseID + "+" + prefix + sector;
+ data = baseID + "+" + PREFIX_BPK_TYPE + sector;
String hash = null;
try {
@@ -91,8 +111,8 @@ public final class BpkUtil {
public static BPK createBPK(String baseID, String sector) {
- if (sector.startsWith(prefix))
- sector = sector.substring(prefix.length());
+ if (sector.startsWith(PREFIX_BPK_TYPE))
+ sector = sector.substring(PREFIX_BPK_TYPE.length());
return new BPK(sector, calcBPK(baseID, sector));
}