summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/BpkBuilder.java36
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/builder/attributes/EidSectorForIdAttributeBuilder.java2
-rw-r--r--eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/BpkBuilderTest.java24
-rw-r--r--eaaf_core_api/src/main/java/at/gv/egiz/eaaf/core/api/data/EaafConstants.java21
4 files changed, 65 insertions, 18 deletions
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/BpkBuilder.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/BpkBuilder.java
index 8e827303..17d0099e 100644
--- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/BpkBuilder.java
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/BpkBuilder.java
@@ -116,9 +116,10 @@ public class BpkBuilder {
} else if (targetIdentifier.startsWith(EaafConstants.URN_PREFIX_WBPK)) {
log.trace("Calculate wbPK identifier for target: " + targetIdentifier);
+ String commonBpkTarget = normalizeBpkTargetIdentifierToCommonFormat(targetIdentifier);
return Pair.newInstance(calculatebPKwbPK(
- baseID + "+" + normalizeBpkTargetIdentifierToCalculationFormat(targetIdentifier)),
- normalizeBpkTargetIdentifierToCommonFormat(targetIdentifier));
+ baseID + "+" + normalizeBpkTargetIdentifierToBpkCalculationFormat(commonBpkTarget)),
+ commonBpkTarget);
} else if (targetIdentifier.startsWith(EaafConstants.URN_PREFIX_EIDAS)) {
log.trace("Calculate eIDAS identifier for target: " + targetIdentifier);
@@ -179,7 +180,8 @@ public class BpkBuilder {
}
- target = normalizeBpkTargetIdentifierToCalculationFormat(target);
+ target = normalizeBpkTargetIdentifierToBpkCalculationFormat(
+ normalizeBpkTargetIdentifierToCommonFormat(target));
final String input =
"V1::" + target + "::" + bpk + "::" + sdf.format(new Date());
@@ -274,7 +276,7 @@ public class BpkBuilder {
}
/**
- * Normalize wbPK target identifier for XFN, XZVR, and XERSB to bPK calculation format like, FN, ZVR, and ERSB.
+ * Normalize wbPK target identifier for XFN, XZVR, and XERSB to bPK non-X format like, FN, ZVR, and ERSB.
*
* <p>If the target is not of this types the target will be returned as it is</p>
*
@@ -282,7 +284,7 @@ public class BpkBuilder {
* @return FN, ZVR, ERSB, or targetIdentfier if no normalization is required
*/
@Nullable
- public static String normalizeBpkTargetIdentifierToCalculationFormat(@Nullable String targetIdentifier) {
+ public static String normalizeBpkTargetIdentifierToNonXFormat(@Nullable String targetIdentifier) {
if (targetIdentifier != null && targetIdentifier.startsWith(EaafConstants.URN_PREFIX_WBPK)) {
for (Entry<String, String> mapper : EaafConstants.URN_WBPK_TARGET_X_TO_NONE_MAPPER.entrySet()) {
if (targetIdentifier.startsWith(mapper.getKey())) {
@@ -298,6 +300,30 @@ public class BpkBuilder {
}
/**
+ * Normalize wbPK target identifier for XFN, XZVR, and XERSB to bPK calculation format like, FN, VR, and ERJ.
+ *
+ * <p>If the target is not of this types the target will be returned as it is</p>
+ *
+ * @param targetIdentifier bPK input target
+ * @return FN, VR, ERJ, or targetIdentfier if no normalization is required
+ */
+ @Nullable
+ public static String normalizeBpkTargetIdentifierToBpkCalculationFormat(@Nullable String targetIdentifier) {
+ if (targetIdentifier != null && targetIdentifier.startsWith(EaafConstants.URN_PREFIX_WBPK)) {
+ for (Entry<String, String> mapper : EaafConstants.URN_WBPK_TARGET_X_TO_CALC_TARGET_MAPPER.entrySet()) {
+ if (targetIdentifier.startsWith(mapper.getKey())) {
+ String wbpkTarget = mapper.getValue() + targetIdentifier.substring(mapper.getKey().length());
+ log.trace("Find new wbPK target: {}. Replace it by: {}", targetIdentifier, wbpkTarget);
+ return wbpkTarget;
+
+ }
+ }
+ }
+
+ return targetIdentifier;
+ }
+
+ /**
* Remove prefixes from bPK target identifier and get only the SP specific part.
*
* @param type full qualified bPK target with 'urn:publicid:gv.at:' prefix
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/builder/attributes/EidSectorForIdAttributeBuilder.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/builder/attributes/EidSectorForIdAttributeBuilder.java
index 48d7a3a3..42b729fe 100644
--- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/builder/attributes/EidSectorForIdAttributeBuilder.java
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/builder/attributes/EidSectorForIdAttributeBuilder.java
@@ -48,7 +48,7 @@ public class EidSectorForIdAttributeBuilder implements IPvpAttributeBuilder {
return g.buildStringAttribute(EID_SECTOR_FOR_IDENTIFIER_FRIENDLY_NAME,
EID_SECTOR_FOR_IDENTIFIER_NAME,
- BpkBuilder.normalizeBpkTargetIdentifierToCalculationFormat(bpktype));
+ BpkBuilder.normalizeBpkTargetIdentifierToNonXFormat(bpktype));
}
diff --git a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/BpkBuilderTest.java b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/BpkBuilderTest.java
index 889a62ee..b8c630fe 100644
--- a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/BpkBuilderTest.java
+++ b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/BpkBuilderTest.java
@@ -228,7 +228,7 @@ public class BpkBuilderTest {
Pair<String, String> result1 = BpkBuilder.generateAreaSpecificPersonIdentifier(
BASEID, EaafConstants.URN_PREFIX_WBPK + "ZVR+123456");
- Assert.assertEquals("wbPK", "g4JRKGS+AJxd9FU8k2tG8Lxrx6M=",
+ Assert.assertEquals("wbPK", "1WvaBLiTxcc3kVzfB71Zh2sCtvA=",
result1.getFirst());
Assert.assertEquals("wbPK", "urn:publicid:gv.at:wbpk+XZVR+123456",
result1.getSecond());
@@ -241,7 +241,7 @@ public class BpkBuilderTest {
Pair<String, String> result1 = BpkBuilder.generateAreaSpecificPersonIdentifier(
BASEID, EaafConstants.URN_PREFIX_WBPK + "ERSB+123456");
- Assert.assertEquals("wbPK", "Bjnl0BofeJGgqynJP1r/ff6E1Rk=",
+ Assert.assertEquals("wbPK", "xtAWGAiblvhYJiCpUB3dwdRFPpg=",
result1.getFirst());
Assert.assertEquals("wbPK", "urn:publicid:gv.at:wbpk+XERSB+123456",
result1.getSecond());
@@ -267,7 +267,7 @@ public class BpkBuilderTest {
Pair<String, String> result1 = BpkBuilder.generateAreaSpecificPersonIdentifier(
BASEID, EaafConstants.URN_PREFIX_WBPK + "XZVR+123456");
- Assert.assertEquals("wbPK", "g4JRKGS+AJxd9FU8k2tG8Lxrx6M=",
+ Assert.assertEquals("wbPK", "1WvaBLiTxcc3kVzfB71Zh2sCtvA=",
result1.getFirst());
Assert.assertEquals("wbPK", "urn:publicid:gv.at:wbpk+XZVR+123456",
result1.getSecond());
@@ -280,7 +280,7 @@ public class BpkBuilderTest {
Pair<String, String> result1 = BpkBuilder.generateAreaSpecificPersonIdentifier(
BASEID, EaafConstants.URN_PREFIX_WBPK + "XERSB+123456");
- Assert.assertEquals("wbPK", "Bjnl0BofeJGgqynJP1r/ff6E1Rk=",
+ Assert.assertEquals("wbPK", "xtAWGAiblvhYJiCpUB3dwdRFPpg=",
result1.getFirst());
Assert.assertEquals("wbPK", "urn:publicid:gv.at:wbpk+XERSB+123456",
result1.getSecond());
@@ -384,7 +384,7 @@ public class BpkBuilderTest {
@Test
public void calcNormalizeNullTarget() {
Assert.assertNull("Wrong normalized target",
- BpkBuilder.normalizeBpkTargetIdentifierToCalculationFormat(null));
+ BpkBuilder.normalizeBpkTargetIdentifierToNonXFormat(null));
}
@@ -393,7 +393,7 @@ public class BpkBuilderTest {
String target = EaafConstants.URN_PREFIX_CDID + RandomStringUtils.randomAlphabetic(2);
Assert.assertEquals("Wrong normalized target",
target,
- BpkBuilder.normalizeBpkTargetIdentifierToCalculationFormat(target));
+ BpkBuilder.normalizeBpkTargetIdentifierToNonXFormat(target));
}
@@ -402,7 +402,7 @@ public class BpkBuilderTest {
Assert.assertEquals("Wrong normalized target",
EaafConstants.URN_PREFIX_WBPK + "FN+123456i",
- BpkBuilder.normalizeBpkTargetIdentifierToCalculationFormat(EaafConstants.URN_PREFIX_WBPK + "FN+123456i"));
+ BpkBuilder.normalizeBpkTargetIdentifierToNonXFormat(EaafConstants.URN_PREFIX_WBPK + "FN+123456i"));
}
@@ -411,7 +411,7 @@ public class BpkBuilderTest {
String target = EaafConstants.URN_PREFIX_WBPK + RandomStringUtils.randomAlphabetic(2);
Assert.assertEquals("Wrong normalized target",
target,
- BpkBuilder.normalizeBpkTargetIdentifierToCalculationFormat(target));
+ BpkBuilder.normalizeBpkTargetIdentifierToNonXFormat(target));
}
@@ -419,7 +419,7 @@ public class BpkBuilderTest {
public void calcNormalizeWbpkTargetWithXMappingFn() {
Assert.assertEquals("Wrong normalized target",
EaafConstants.URN_PREFIX_WBPK + "FN+123456i",
- BpkBuilder.normalizeBpkTargetIdentifierToCalculationFormat(EaafConstants.URN_PREFIX_WBPK + "XFN+123456i"));
+ BpkBuilder.normalizeBpkTargetIdentifierToNonXFormat(EaafConstants.URN_PREFIX_WBPK + "XFN+123456i"));
}
@@ -427,7 +427,7 @@ public class BpkBuilderTest {
public void calcNormalizeWbpkTargetWithXMappingZvr() {
Assert.assertEquals("Wrong normalized target",
EaafConstants.URN_PREFIX_WBPK + "ZVR+1122334455",
- BpkBuilder.normalizeBpkTargetIdentifierToCalculationFormat(EaafConstants.URN_PREFIX_WBPK + "XZVR+1122334455"));
+ BpkBuilder.normalizeBpkTargetIdentifierToNonXFormat(EaafConstants.URN_PREFIX_WBPK + "XZVR+1122334455"));
}
@@ -435,7 +435,7 @@ public class BpkBuilderTest {
public void calcNormalizeWbpkTargetWithXMappingErsb() {
Assert.assertEquals("Wrong normalized target",
EaafConstants.URN_PREFIX_WBPK + "ERSB+998877665544",
- BpkBuilder.normalizeBpkTargetIdentifierToCalculationFormat(
+ BpkBuilder.normalizeBpkTargetIdentifierToNonXFormat(
EaafConstants.URN_PREFIX_WBPK + "XERSB+998877665544"));
}
@@ -446,7 +446,7 @@ public class BpkBuilderTest {
+ "+" + RandomStringUtils.randomAlphabetic(2);
Assert.assertEquals("Wrong normalized target",
target,
- BpkBuilder.normalizeBpkTargetIdentifierToCalculationFormat(target));
+ BpkBuilder.normalizeBpkTargetIdentifierToNonXFormat(target));
}
diff --git a/eaaf_core_api/src/main/java/at/gv/egiz/eaaf/core/api/data/EaafConstants.java b/eaaf_core_api/src/main/java/at/gv/egiz/eaaf/core/api/data/EaafConstants.java
index cb947219..1bbfe1b7 100644
--- a/eaaf_core_api/src/main/java/at/gv/egiz/eaaf/core/api/data/EaafConstants.java
+++ b/eaaf_core_api/src/main/java/at/gv/egiz/eaaf/core/api/data/EaafConstants.java
@@ -74,6 +74,10 @@ public class EaafConstants {
private static final String WBPK_TARGET_ZVR = "ZVR";
private static final String WBPK_TARGET_ERSB = "ERSB";
+ private static final String WBPK_CALC_TARGET_ZVR = "VR";
+ private static final String WBPK_CALC_TARGET_ERSB = "ERJ";
+
+
private static final String URN_PREFIX_WBPK_TARGET_XFN_TARGET =
EaafConstants.URN_PREFIX_WBPK_TARGET_WITH_X + WBPK_TARGET_FN;
private static final String URN_PREFIX_WBPK_TARGET_XZVR_TARGET =
@@ -85,6 +89,12 @@ public class EaafConstants {
private static final String URN_PREFIX_WBPK_TARGET_ZVR_TARGET = EaafConstants.URN_PREFIX_WBPK + WBPK_TARGET_ZVR;
private static final String URN_PREFIX_WBPK_TARGET_ERSB_TARGET = EaafConstants.URN_PREFIX_WBPK + WBPK_TARGET_ERSB;
+ private static final String URN_PREFIX_WBPK_CALC_TARGET_ZVR_TARGET =
+ EaafConstants.URN_PREFIX_WBPK + WBPK_CALC_TARGET_ZVR;
+ private static final String URN_PREFIX_WBPK_CALC_TARGET_ERSB_TARGET =
+ EaafConstants.URN_PREFIX_WBPK + WBPK_CALC_TARGET_ERSB;
+
+
public static final Map<String, String> URN_WBPK_TARGET_X_TO_NONE_MAPPER;
static {
@@ -96,6 +106,17 @@ public class EaafConstants {
}
+ public static final Map<String, String> URN_WBPK_TARGET_X_TO_CALC_TARGET_MAPPER;
+
+ static {
+ final Map<String, String> intMap = new LinkedHashMap<>();
+ intMap.put(URN_PREFIX_WBPK_TARGET_XFN_TARGET, URN_PREFIX_WBPK_TARGET_FN_TARGET);
+ intMap.put(URN_PREFIX_WBPK_TARGET_XZVR_TARGET, URN_PREFIX_WBPK_CALC_TARGET_ZVR_TARGET);
+ intMap.put(URN_PREFIX_WBPK_TARGET_XERSB_TARGET, URN_PREFIX_WBPK_CALC_TARGET_ERSB_TARGET);
+ URN_WBPK_TARGET_X_TO_CALC_TARGET_MAPPER = Collections.unmodifiableMap(intMap);
+
+ }
+
// Authentication process data_constants
public static final String UNIQUESESSIONIDENTIFIER = "eaaf_uniqueSessionIdentifier";