summaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-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));
}