/*
* Copyright 2003 Federal Chancellery Austria
* MOA-ID has been developed in a cooperation between BRZ, the Federal
* Chancellery Austria - ICT staff unit, and Graz University of Technology.
*
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
* the European Commission - subsequent versions of the EUPL (the "Licence");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
* http://www.osor.eu/eupl/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*
* This product combines work with different licenses. See the "NOTICE" text
* file for details on the various modules and licenses.
* The "NOTICE" text file is part of the distribution. Any derivative works
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
package at.gv.egovernment.moa.id.config.auth;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import javax.xml.transform.TransformerException;
import org.apache.xpath.XPathAPI;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import at.gv.egovernment.moa.id.auth.data.Schema;
import at.gv.egovernment.moa.util.Constants;
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.
*/
protected 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.
*/
protected String friendlyName_;
/**
* The Id of the TrustProfile to be used for validating certificates.
*/
protected String trustProfileID_;
/**
* The full name of the class to be used for verifying the infobox.
*/
protected 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.
*/
protected List schemaLocations_;
/**
* Application specific parameters that may be needed for verifying an infobox.
*/
protected Element applicationSpecificParams_;
/**
* Specifies if the infobox is be required to be returned by the BKU.
*/
protected boolean required_;
/**
* Specifies whether the Stammzahl
should be passed to the verifying
* application or not.
*/
protected boolean provideStammzahl_;
/**
* Specifies whether the identity link
should be passed to the verifying
* application or not.
*/
protected 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. {@link #applicationSpecificParams_}
*
* @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;
}
/**
* Appends special application specific parameters for party representation.
*
* @param applicationSpecificParams The application specific parameters for party representation to set.
*/
public void appendParepSpecificParams(Element applicationSpecificParams) {
try {
if (applicationSpecificParams_==null) {
applicationSpecificParams_ = applicationSpecificParams.getOwnerDocument().createElement("ApplicationSpecificParameters");
}
Element nameSpaceNode = applicationSpecificParams.getOwnerDocument().createElement("NameSpaceNode");
nameSpaceNode.setAttribute("xmlns:" + Constants.MOA_ID_CONFIG_PREFIX, Constants.MOA_ID_CONFIG_NS_URI);
NodeList nodeList = XPathAPI.selectNodeList(applicationSpecificParams, "*", nameSpaceNode);
if (null!=nodeList) {
for (int i=0; iTrue 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() ;
}
}