package at.gv.egovernment.moa.id.config.auth; import java.io.IOException; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import javax.xml.transform.TransformerException; import org.w3c.dom.Element; import at.gv.egovernment.moa.id.auth.data.Schema; import at.gv.egovernment.moa.util.DOMUtils; import at.gv.egovernment.moa.util.StringUtils; /** * This class is a container for parameters that maybe needed for verifying an infobox. * * @author Harald Bratko */ public class VerifyInfoboxParameter { /** * The default package name (first part) of a infobox validator class. */ public static final String DEFAULT_PACKAGE_TRUNK = "at.gv.egovernment.moa.id.auth.validator."; /** * The identifier of the infobox to be verified. This identifier must exactly the * identifier of the infobox returned by BKU. */ private String identifier_; /** * The friendly name of the infobox. * This name is used within browser messages, thus it should be the german equivalent of * the {@link #identifier_ infobox identifier} (e.g. "Stellvertretungen" * for "Mandates" or "GDAToken" for * "EHSPToken". *
If not specified within the config file the {@link #identifier_ infobox identifier} * will be used. */ private String friendlyName_; /** * The Id of the TrustProfile to be used for validating certificates. */ private String trustProfileID_; /** * The full name of the class to be used for verifying the infobox. */ private String validatorClassName_; /** * Schema location URIs that may be needed by the * validator to parse infobox tokens. * Each entry in the list is a {@link at.gv.egovernment.moa.id.auth.data.Schema Schema} * specifying the location of an XML schema. */ private List schemaLocations_; /** * Application specific parameters that may be needed for verifying an infobox. */ private Element applicationSpecificParams_; /** * Specifies if the infobox is be required to be returned by the BKU. */ private boolean required_; /** * Specifies whether the Stammzahl should be passed to the verifying * application or not. */ private boolean provideStammzahl_; /** * Specifies whether the identity link should be passed to the verifying * application or not. */ private boolean provideIdentityLink_; /** * Initializes this VerifiyInfoboxParamater with the given identifier and a default * validator class name. * * @param identifier The identifier of the infobox to be verified. */ public VerifyInfoboxParameter(String identifier) { identifier_ = identifier; StringBuffer sb = new StringBuffer(DEFAULT_PACKAGE_TRUNK); sb.append(identifier.toLowerCase()); sb.append("."); sb.append(identifier.substring(0, 1).toUpperCase()); sb.append(identifier.substring(1)); sb.append("Validator"); validatorClassName_ = sb.toString(); } /** * Returns application specific parameters. * Each child element of this element contains a verifying application specific parameter. * * @see #applicationSpecificParams_ * * @return Application specific parameters. */ public Element getApplicationSpecificParams() { return applicationSpecificParams_; } /** * Sets the application specific parameters. * * @see #applicationSpecificParams_ * * @param applicationSpecificParams The application specific parameters to set. */ public void setApplicationSpecificParams(Element applicationSpecificParams) { applicationSpecificParams_ = applicationSpecificParams; } /** * Returns the friendly name. * * @see #friendlyName_ * * @return The friendly name. */ public String getFriendlyName() { return friendlyName_; } /** * Sets the friendly name. * * @param friendlyName The friendly name to set. */ public void setFriendlyName(String friendlyName) { friendlyName_ = friendlyName; } /** * Returns the infobox identifier. * * @see #identifier_ * * @return The infobox identifier. */ public String getIdentifier() { return identifier_; } /** * Sets the the infobox identifier. * * @see #identifier_ * * @param identifier The infobox identifier to set. */ public void setIdentifier(String identifier) { identifier_ = identifier; } /** * Specifies whether the identity link should be passed to the verifying application * or not. * * @return True if the identity link should be passed to the verifying * application, otherwise false. */ public boolean getProvideIdentityLink() { return provideIdentityLink_; } /** * Sets the {@link #provideIdentityLink_} parameter. * * @param provideIdentityLink True if the identity link should be passed to * the verifying application, otherwise false. */ public void setProvideIdentityLink(boolean provideIdentityLink) { provideIdentityLink_ = provideIdentityLink; } /** * Specifies whether the Stammzahl should be passed to the verifying * application or not. * * @return True if the Stammzahl should be passed to the * verifying application, otherwise false. */ public boolean getProvideStammzahl() { return provideStammzahl_; } /** * Sets the {@link provideStammzahl_} parameter. * * @param provideStammzahl True if the Stammzahl should be * passed to the verifying application, otherwise false. */ public void setProvideStammzahl(boolean provideStammzahl) { provideStammzahl_ = provideStammzahl; } /** * Specifies whether the infobox is required or not. * * @return True if the infobox is required to be returned by the BKU, * otherwise false. */ public boolean isRequired() { return required_; } /** * Sets the {@link required_} parameter. * * @param required True if the infobox is required to be returned by the * BKU, otherwise false. */ public void setRequired(boolean required) { required_ = required; } /** * Schema location URIs that may be needed by the * validator to parse infobox tokens. * Each entry in the list is a {@link at.gv.egovernment.moa.id.auth.data.Schema Schema} * specifying the location of an XML schema. * * @return A list of {@link at.gv.egovernment.moa.id.auth.data.Schema Schema} objects * each of them specifying the location of an XML schema. */ public List getSchemaLocations() { return schemaLocations_; } /** * Sets the schema locations. * * @see #schemaLocations_ * * @param schemaLocations The schema location list to be set. */ public void setSchemaLocations(List schemaLocations) { schemaLocations_ = schemaLocations; } /** * Returns the ID of the trust profile to be used for verifying certificates. * * @return The ID of the trust profile to be used for verifying certificates. * Maybe null. */ public String getTrustProfileID() { return trustProfileID_; } /** * Sets the ID of the trust profile to be used for verifying certificates. * * @param trustProfileID The ID of the trust profile to be used for verifying certificates. */ public void setTrustProfileID(String trustProfileID) { trustProfileID_ = trustProfileID; } /** * Returns the name of the class to be used for verifying this infobox. * * @return The name of the class to be used for verifying this infobox. */ public String getValidatorClassName() { return validatorClassName_; } /** * Sets the name of the class to be used for verifying this infobox. * * @param validatorClassName The name of the class to be used for verifying this infobox. */ public void setValidatorClassName(String validatorClassName) { validatorClassName_ = validatorClassName; } /** * Get a string representation of this object. * This method is for debugging purposes only. * * @return A string representation of this object. */ public String toString() { StringBuffer buffer = new StringBuffer(1024); buffer.append(" "); buffer.append("\n"); if (friendlyName_ != null) { buffer.append(" "); buffer.append(friendlyName_); buffer.append(""); buffer.append("\n"); } if (trustProfileID_ != null) { buffer.append(" "); buffer.append(trustProfileID_); buffer.append(""); buffer.append("\n"); } if (validatorClassName_ != null) { buffer.append(" "); buffer.append(validatorClassName_); buffer.append(""); buffer.append("\n"); } if (schemaLocations_ != null) { buffer.append(" "); buffer.append("\n"); Iterator it = schemaLocations_.iterator(); while (it.hasNext()) { buffer.append(" \n"); } buffer.append(" "); buffer.append("\n"); } if (applicationSpecificParams_ != null) { try { String applicationSpecificParams = DOMUtils.serializeNode(applicationSpecificParams_); buffer.append(" "); buffer.append(StringUtils.removeXMLDeclaration(applicationSpecificParams)); buffer.append("\n"); } catch (TransformerException e) { // do nothing } catch (IOException e) { // do nothing } } buffer.append(" "); return buffer.toString() ; } }