summaryrefslogtreecommitdiff
path: root/eaaf_core
diff options
context:
space:
mode:
authorThomas Lenz <thomas.lenz@egiz.gv.at>2021-02-19 20:05:50 +0100
committerThomas Lenz <thomas.lenz@egiz.gv.at>2021-02-19 20:05:50 +0100
commit2b275ced46a283882bfb2042df18341968fc3450 (patch)
tree6076ac7146be75ee5693580533445322c2181b95 /eaaf_core
parentd54c57cda552224f90961f8b2036389551bc3329 (diff)
parentb16cc99a8533a65b2bf8764a2f017a5882eed0cd (diff)
downloadEAAF-Components-2b275ced46a283882bfb2042df18341968fc3450.tar.gz
EAAF-Components-2b275ced46a283882bfb2042df18341968fc3450.tar.bz2
EAAF-Components-2b275ced46a283882bfb2042df18341968fc3450.zip
Merge branch 'feature/small_changes' into 'nightlyBuild'
fix wrong bPK calculation for XZVR and XERSB bpkTargets See merge request egiz/eaaf_components!17
Diffstat (limited to 'eaaf_core')
-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
3 files changed, 44 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));
}