package at.gv.egovernment.moa.id.auth.builder; import java.util.List; import org.w3c.dom.Element; import at.gv.egovernment.moa.id.auth.data.AuthenticationSession; import at.gv.egovernment.moa.id.auth.data.IdentityLink; import at.gv.egovernment.moa.id.auth.data.InfoboxValidatorParams; import at.gv.egovernment.moa.id.auth.data.InfoboxValidatorParamsImpl; import at.gv.egovernment.moa.id.auth.parser.IdentityLinkAssertionParser; import at.gv.egovernment.moa.id.config.auth.VerifyInfoboxParameter; import at.gv.egovernment.moa.util.XPathUtils; /** * This class provides one method for building parameters needed for * validating an infobox token. * * @author Harald Bratko */ public class InfoboxValidatorParamsBuilder { // hide the default constructor private InfoboxValidatorParamsBuilder() { } /** * Builds the parameters passed to the validator class for validating an infobox token. * * @param session The actual Authentication session. * @param verifyInfoboxParameter The configuration parameters for the infobox. * @param infoboxTokenList Contains the infobox token to be validated. * @param hideStammzahl Indicates whether source pins (Stammzahlen) * should be hidden in any SAML attributes returned by * an infobox validator. * * @return Parameters for validating an infobox token. */ public static InfoboxValidatorParams buildInfoboxValidatorParams( AuthenticationSession session, VerifyInfoboxParameter verifyInfoboxParameter, List infoboxTokenList, boolean hideStammzahl) { InfoboxValidatorParamsImpl infoboxValidatorParams = new InfoboxValidatorParamsImpl(); IdentityLink identityLink = session.getIdentityLink(); // the infobox token to validate infoboxValidatorParams.setInfoboxTokenList(infoboxTokenList); // configuration parameters infoboxValidatorParams.setTrustProfileID(verifyInfoboxParameter.getTrustProfileID()); infoboxValidatorParams.setSchemaLocations(verifyInfoboxParameter.getSchemaLocations()); infoboxValidatorParams.setApplicationSpecificParams(verifyInfoboxParameter.getApplicationSpecificParams()); // authentication session parameters infoboxValidatorParams.setBkuURL(session.getBkuURL()); infoboxValidatorParams.setTarget(session.getTarget()); infoboxValidatorParams.setBusinessApplication(session.getBusinessService()); // parameters from the identity link infoboxValidatorParams.setFamilyName(identityLink.getFamilyName()); infoboxValidatorParams.setGivenName(identityLink.getGivenName()); infoboxValidatorParams.setDateOfBirth(identityLink.getDateOfBirth()); if (verifyInfoboxParameter.getProvideStammzahl()) { infoboxValidatorParams.setIdentificationValue(identityLink.getIdentificationValue()); } infoboxValidatorParams.setIdentificationType(identityLink.getIdentificationType()); infoboxValidatorParams.setPublicKeys(identityLink.getPublicKey()); if (verifyInfoboxParameter.getProvideIdentityLink()) { Element identityLinkElem = (Element)identityLink.getSamlAssertion().cloneNode(true); if (!verifyInfoboxParameter.getProvideStammzahl()) { Element identificationValueElem = (Element)XPathUtils.selectSingleNode(identityLinkElem, IdentityLinkAssertionParser.PERSON_IDENT_VALUE_XPATH); if (identificationValueElem != null) { identificationValueElem.getFirstChild().setNodeValue(""); } } infoboxValidatorParams.setIdentityLink(identityLinkElem); } infoboxValidatorParams.setHideStammzahl(hideStammzahl); return infoboxValidatorParams; } }