diff options
author | Thomas <> | 2021-02-19 16:48:53 +0100 |
---|---|---|
committer | Thomas <> | 2021-02-19 16:48:53 +0100 |
commit | b16cc99a8533a65b2bf8764a2f017a5882eed0cd (patch) | |
tree | 6076ac7146be75ee5693580533445322c2181b95 /eaaf_core/src/main | |
parent | 2b77cd297aee2081ad8c99ba9f79483cf35178a7 (diff) | |
download | EAAF-Components-b16cc99a8533a65b2bf8764a2f017a5882eed0cd.tar.gz EAAF-Components-b16cc99a8533a65b2bf8764a2f017a5882eed0cd.tar.bz2 EAAF-Components-b16cc99a8533a65b2bf8764a2f017a5882eed0cd.zip |
fix wrong bPK calculation for XZVR and XERSB bpkTargets
Diffstat (limited to 'eaaf_core/src/main')
2 files changed, 32 insertions, 6 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)); } |