From b7bb75a4b642df6b8ce1c84cf5d4f8fea5d986b0 Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Mon, 18 Feb 2019 10:07:40 +0100 Subject: add demo-mode functionality for 'Austria eID' --- .../builder/attributes/BPKAttributeBuilder.java | 71 ++++++++++++++++------ .../builder/attributes/EIDIdentityLinkBuilder.java | 2 +- .../impl/idp/builder/attributes/EIDSourcePIN.java | 1 + .../idp/builder/attributes/EIDSourcePINType.java | 1 + 4 files changed, 56 insertions(+), 19 deletions(-) (limited to 'eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/builder') diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/builder/attributes/BPKAttributeBuilder.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/builder/attributes/BPKAttributeBuilder.java index 261fd211..a5c1e7d4 100644 --- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/builder/attributes/BPKAttributeBuilder.java +++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/builder/attributes/BPKAttributeBuilder.java @@ -41,7 +41,8 @@ import at.gv.egiz.eaaf.core.exceptions.UnavailableAttributeException; @PVPMETADATA public class BPKAttributeBuilder implements IPVPAttributeBuilder { - private static final Logger log = LoggerFactory.getLogger(BPKAttributeBuilder.class); + private static final Logger log = LoggerFactory.getLogger(BPKAttributeBuilder.class); + protected static final String DELIMITER_BPKTYPE_BPK = ":"; public String getName() { return BPK_NAME; @@ -49,32 +50,66 @@ public class BPKAttributeBuilder implements IPVPAttributeBuilder { public ATT build(ISPConfiguration oaParam, IAuthData authData, IAttributeGenerator g) throws AttributeBuilderException { - String bpk = authData.getBPK(); - String type = authData.getBPKType(); + String result = getBpkForSP(authData); + log.trace("Authenticate user with bPK/wbPK: " + result); + return g.buildStringAttribute(BPK_FRIENDLY_NAME, BPK_NAME, result); + + } + + public ATT buildEmpty(IAttributeGenerator g) { + return g.buildEmptyAttribute(BPK_FRIENDLY_NAME, BPK_NAME); + } + + /** + * Generate the bPK String for this specific SP + * + * @param authData + * @return + * @throws UnavailableAttributeException + */ + protected String getBpkForSP(IAuthData authData) throws UnavailableAttributeException { + String bpk = attrMaxSize(authData.getBPK()); + String type = removeBpkTypePrefix(authData.getBPKType()); if (StringUtils.isEmpty(bpk)) throw new UnavailableAttributeException(BPK_NAME); - + + return type + DELIMITER_BPKTYPE_BPK + bpk; + + } + + /** + * Limit the attribute value to maximum size + * + * @param attr + * @return + */ + protected String attrMaxSize(String attr) { + if (attr != null && attr.length() > BPK_MAX_LENGTH) { + attr = attr.substring(0, BPK_MAX_LENGTH); + } + return attr; + + } + + /** + * Remove bPKType prefix if available + * + * @param type + * @return + */ + protected String removeBpkTypePrefix(String type) { if (type.startsWith(EAAFConstants.URN_PREFIX_WBPK)) - type = type.substring((EAAFConstants.URN_PREFIX_WBPK).length()); + return type.substring((EAAFConstants.URN_PREFIX_WBPK).length()); else if (type.startsWith(EAAFConstants.URN_PREFIX_CDID)) - type = type.substring((EAAFConstants.URN_PREFIX_CDID).length()); + return type.substring((EAAFConstants.URN_PREFIX_CDID).length()); else if (type.startsWith(EAAFConstants.URN_PREFIX_EIDAS)) - type = type.substring((EAAFConstants.URN_PREFIX_EIDAS).length()); - - if (bpk.length() > BPK_MAX_LENGTH) { - bpk = bpk.substring(0, BPK_MAX_LENGTH); - } + return type.substring((EAAFConstants.URN_PREFIX_EIDAS).length()); - log.trace("Authenticate user with bPK/wbPK " + bpk + " and Type=" + type); + else + return type; - return g.buildStringAttribute(BPK_FRIENDLY_NAME, BPK_NAME, type + ":" + bpk); } - - public ATT buildEmpty(IAttributeGenerator g) { - return g.buildEmptyAttribute(BPK_FRIENDLY_NAME, BPK_NAME); - } - } diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/builder/attributes/EIDIdentityLinkBuilder.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/builder/attributes/EIDIdentityLinkBuilder.java index a3e22ea3..8a2cabbc 100644 --- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/builder/attributes/EIDIdentityLinkBuilder.java +++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/builder/attributes/EIDIdentityLinkBuilder.java @@ -39,7 +39,7 @@ import at.gv.egiz.eaaf.core.api.idp.ISPConfiguration; import at.gv.egiz.eaaf.core.exceptions.AttributeBuilderException; import at.gv.egiz.eaaf.core.exceptions.UnavailableAttributeException; - +@Deprecated @PVPMETADATA public class EIDIdentityLinkBuilder implements IPVPAttributeBuilder { private static final Logger log = LoggerFactory.getLogger(EIDIdentityLinkBuilder.class); diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/builder/attributes/EIDSourcePIN.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/builder/attributes/EIDSourcePIN.java index 4e5f8505..0db3f1fe 100644 --- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/builder/attributes/EIDSourcePIN.java +++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/builder/attributes/EIDSourcePIN.java @@ -36,6 +36,7 @@ import at.gv.egiz.eaaf.core.exceptions.AttributeBuilderException; import at.gv.egiz.eaaf.core.exceptions.AttributePolicyException; import at.gv.egiz.eaaf.core.exceptions.UnavailableAttributeException; +@Deprecated @PVPMETADATA public class EIDSourcePIN implements IPVPAttributeBuilder { diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/builder/attributes/EIDSourcePINType.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/builder/attributes/EIDSourcePINType.java index f55f5fb4..42e47a42 100644 --- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/builder/attributes/EIDSourcePINType.java +++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/builder/attributes/EIDSourcePINType.java @@ -33,6 +33,7 @@ import at.gv.egiz.eaaf.core.api.idp.ISPConfiguration; import at.gv.egiz.eaaf.core.exceptions.AttributeBuilderException; import at.gv.egiz.eaaf.core.exceptions.UnavailableAttributeException; +@Deprecated @PVPMETADATA public class EIDSourcePINType implements IPVPAttributeBuilder { -- cgit v1.2.3