From 663667a6a7df13305674636b169bd7a295472e2e Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Wed, 12 Jul 2023 10:12:18 +0200 Subject: feat(core): add static method into PVP bPK attribute-builder to build attribute-values according to specification --- .../builder/attributes/BpkAttributeBuilder.java | 27 +++++++++++++++------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'eaaf_core/src') 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 5cbfec01..a9bbebfc 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 @@ -19,9 +19,9 @@ package at.gv.egiz.eaaf.core.impl.idp.builder.attributes; +import javax.annotation.Nonnull; + import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import at.gv.egiz.eaaf.core.api.idp.IAttributeGenerator; import at.gv.egiz.eaaf.core.api.idp.IAuthData; @@ -30,12 +30,12 @@ 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; import at.gv.egiz.eaaf.core.impl.builder.BpkBuilder; +import lombok.extern.slf4j.Slf4j; +@Slf4j @PvpMetadata public class BpkAttributeBuilder implements IPvpAttributeBuilder { - private static final Logger log = LoggerFactory.getLogger(BpkAttributeBuilder.class); - @Override public String getName() { return BPK_NAME; @@ -55,16 +55,27 @@ public class BpkAttributeBuilder implements IPvpAttributeBuilder { return g.buildEmptyAttribute(BPK_FRIENDLY_NAME, BPK_NAME); } + /** + * Build a bPK attribute-value according to PVP specification. + * + * @param bpk bPK + * @param bpkType Type of the bPK + * @return PVP attribute-value for bPK + */ + public static String buildFromBpkAndType(@Nonnull String bpk, @Nonnull String bpkType) { + return BpkBuilder.removeBpkTypePrefix(bpkType) + DELIMITER_BPKTYPE_BPK + bpk; + + } + protected String getBpkForSP(final IAuthData authData) throws UnavailableAttributeException { if (StringUtils.isEmpty(authData.getBpk()) || StringUtils.isEmpty(authData.getBpkType())) { throw new UnavailableAttributeException(BPK_NAME); } - final String bpk = attrMaxSize(authData.getBpk()); - final String type = BpkBuilder.removeBpkTypePrefix(authData.getBpkType()); - - return type + DELIMITER_BPKTYPE_BPK + bpk; + return buildFromBpkAndType( + attrMaxSize(authData.getBpk()), + BpkBuilder.removeBpkTypePrefix(authData.getBpkType())); } -- cgit v1.2.3