From 514747e925abddcb320a8433908dbae32dc5049b Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Fri, 28 Jun 2019 09:25:09 +0200 Subject: some small updates --- .../auth/builder/AbstractAuthenticationDataBuilder.java | 12 ++++++------ .../impl/idp/builder/attributes/BPKAttributeBuilder.java | 16 ++++++++++++---- 2 files changed, 18 insertions(+), 10 deletions(-) (limited to 'eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp') diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/AbstractAuthenticationDataBuilder.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/AbstractAuthenticationDataBuilder.java index 47b1ecf9..558a9a33 100644 --- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/AbstractAuthenticationDataBuilder.java +++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/AbstractAuthenticationDataBuilder.java @@ -97,7 +97,9 @@ public abstract class AbstractAuthenticationDataBuilder implements IAuthenticati Assert.notNull(authData, "AuthData is null"); } - + + } catch ( EAAFAuthenticationException e) { + throw e; } catch (XPathException | DOMException | EAAFException e) { log.warn("Can not build authentication data from auth. process information"); @@ -461,10 +463,8 @@ public abstract class AbstractAuthenticationDataBuilder implements IAuthenticati authData.setBPKType(result.getSecond()); } else { - log.warn("Can not build authData, because moaSession include no valid bPK, encrypted bPK or baseID"); - throw new EAAFBuilderException("builder.08", new Object[]{"No valid " + PVPAttributeDefinitions.BPK_FRIENDLY_NAME - + " or " + PVPAttributeDefinitions.EID_SOURCE_PIN_FRIENDLY_NAME - + " or " + PVPAttributeDefinitions.ENC_BPK_LIST_FRIENDLY_NAME}, + log.warn("Can not build authData, because moaSession include no valid bPK, encrypted bPK or sourceID"); + throw new EAAFBuilderException("builder.13", new Object[]{pendingReq.getServiceProviderConfiguration().getAreaSpecificTargetIdentifier()}, "No valid " + PVPAttributeDefinitions.BPK_FRIENDLY_NAME + " or " + PVPAttributeDefinitions.EID_SOURCE_PIN_FRIENDLY_NAME + " or " + PVPAttributeDefinitions.ENC_BPK_LIST_FRIENDLY_NAME); @@ -550,7 +550,7 @@ public abstract class AbstractAuthenticationDataBuilder implements IAuthenticati * @return true, if bPK-Type matchs to Service-Provider configuration, otherwise false */ @Deprecated - private boolean matchsReceivedbPKToOnlineApplication(ISPConfiguration oaParam, String bPKType) { + protected boolean matchsReceivedbPKToOnlineApplication(ISPConfiguration oaParam, String bPKType) { return oaParam.getAreaSpecificTargetIdentifier().equals(bPKType); } 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 7005c930..714ffc9d 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 @@ -26,9 +26,12 @@ *******************************************************************************/ 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 org.springframework.util.Assert; import at.gv.egiz.eaaf.core.api.data.EAAFConstants; import at.gv.egiz.eaaf.core.api.idp.IAttributeGenerator; @@ -44,18 +47,21 @@ public class BPKAttributeBuilder implements IPVPAttributeBuilder { private static final Logger log = LoggerFactory.getLogger(BPKAttributeBuilder.class); public static final String DELIMITER_BPKTYPE_BPK = ":"; + @Override public String getName() { return BPK_NAME; } + @Override public ATT build(ISPConfiguration oaParam, IAuthData authData, IAttributeGenerator g) throws AttributeBuilderException { - String result = getBpkForSP(authData); + final String result = getBpkForSP(authData); log.trace("Authenticate user with bPK/wbPK: " + result); return g.buildStringAttribute(BPK_FRIENDLY_NAME, BPK_NAME, result); } + @Override public ATT buildEmpty(IAttributeGenerator g) { return g.buildEmptyAttribute(BPK_FRIENDLY_NAME, BPK_NAME); } @@ -68,8 +74,8 @@ public class BPKAttributeBuilder implements IPVPAttributeBuilder { * @throws UnavailableAttributeException */ protected String getBpkForSP(IAuthData authData) throws UnavailableAttributeException { - String bpk = attrMaxSize(authData.getBPK()); - String type = removeBpkTypePrefix(authData.getBPKType()); + final String bpk = attrMaxSize(authData.getBPK()); + final String type = removeBpkTypePrefix(authData.getBPKType()); if (StringUtils.isEmpty(bpk)) throw new UnavailableAttributeException(BPK_NAME); @@ -98,7 +104,9 @@ public class BPKAttributeBuilder implements IPVPAttributeBuilder { * @param type * @return */ - protected String removeBpkTypePrefix(String type) { + @Nonnull + protected String removeBpkTypePrefix(@Nonnull String type) { + Assert.isTrue(type != null, "bPKType is 'NULL'"); if (type.startsWith(EAAFConstants.URN_PREFIX_WBPK)) return type.substring((EAAFConstants.URN_PREFIX_WBPK).length()); -- cgit v1.2.3