package at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes; import org.opensaml.saml2.core.Attribute; import at.gv.egovernment.moa.id.auth.data.AuthenticationSession; import at.gv.egovernment.moa.id.config.auth.OAAuthParameter; import at.gv.egovernment.moa.id.data.AuthenticationData; import at.gv.egovernment.moa.logging.Logger; import at.gv.egovernment.moa.util.Constants; public class BPKAttributeBuilder extends BaseAttributeBuilder { public String getName() { return BPK_NAME; } public Attribute build(AuthenticationSession authSession, OAAuthParameter oaParam, AuthenticationData authData) { String bpk = authData.getBPK(); String type = authData.getBPKType(); if (type.startsWith(Constants.URN_PREFIX_WBPK)) type = type.substring((Constants.URN_PREFIX_WBPK+"+").length()); else if (type.startsWith(Constants.URN_PREFIX_CDID)) type = type.substring((Constants.URN_PREFIX_CDID+"+").length()); if(bpk.length() > BPK_MAX_LENGTH) { bpk = bpk.substring(0, BPK_MAX_LENGTH); } Logger.trace("Authenticate user with bPK/wbPK " + bpk + " and Type=" + type); return buildStringAttribute(BPK_FRIENDLY_NAME, BPK_NAME, type + ":" + bpk); } public Attribute buildEmpty() { return buildemptyAttribute(BPK_FRIENDLY_NAME, BPK_NAME); } }