diff options
Diffstat (limited to 'spss.server/src/at/gv/egovernment/moa/spss/api')
134 files changed, 8195 insertions, 0 deletions
diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/Configurator.java b/spss.server/src/at/gv/egovernment/moa/spss/api/Configurator.java new file mode 100644 index 000000000..a0efa8924 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/Configurator.java @@ -0,0 +1,60 @@ +package at.gv.egovernment.moa.spss.api; + +import org.apache.commons.discovery.tools.DiscoverClass; + +import at.gv.egovernment.moa.spss.MOAException; + +/** + * Configures the SP/SS API. + * + * Also handles dynamic configuration updates. + * + * @author Patrick Peck + * @version $Id$ + */ +public abstract class Configurator { + + /** The default implementation class. */ + private static final String DEFAULT_IMPLEMENTATION = + "at.gv.egovernment.moa.spss.server.init.ConfiguratorImpl"; + + /** The single instance of this class. */ + private static Configurator instance = null; + + public static synchronized Configurator getInstance() { + if (instance == null) { + try { + DiscoverClass discover = new DiscoverClass(); + instance = + (Configurator) discover.newInstance( + Configurator.class, + DEFAULT_IMPLEMENTATION); + } catch (Exception e) { + // this can not happen since we provide a valid default + // implementation + } + } + return instance; + } + + /** + * Initialize the SP/SS configuration. + * + * Only a single call to this method will have an effect. Use + * <code>update()</code> for reflecting changes in the configuration instead. + * + * @throws MOAException An error occurred updating the SP/SS configuration. + */ + public abstract void init() throws MOAException; + + /** + * Update the SP/SS configuration. + * + * This will only have an effect after the system has been initialized once + * using <code>init()</code>. + * + * @throws MOAException An error occurred updating the SP/SS configuration. + */ + public abstract void update() throws MOAException; + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/SPSSFactory.java b/spss.server/src/at/gv/egovernment/moa/spss/api/SPSSFactory.java new file mode 100644 index 000000000..178a45273 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/SPSSFactory.java @@ -0,0 +1,993 @@ +package at.gv.egovernment.moa.spss.api; + +import java.io.InputStream; +import java.math.BigInteger; +import java.security.cert.X509Certificate; +import java.util.Date; +import java.util.List; +import java.util.Map; + +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; + +import org.apache.commons.discovery.tools.DiscoverClass; + +import at.gv.egovernment.moa.spss.api.cmsverify.CMSContent; +import at.gv.egovernment.moa.spss.api.cmsverify.CMSDataObject; +import at.gv.egovernment.moa.spss.api.cmsverify.VerifyCMSSignatureRequest; +import at.gv.egovernment.moa.spss.api.cmsverify.VerifyCMSSignatureResponse; +import at.gv.egovernment.moa.spss.api.cmsverify.VerifyCMSSignatureResponseElement; +import at.gv.egovernment.moa.spss.api.common.CheckResult; +import at.gv.egovernment.moa.spss.api.common.Content; +import at.gv.egovernment.moa.spss.api.common.MetaInfo; +import at.gv.egovernment.moa.spss.api.common.SignerInfo; +import at.gv.egovernment.moa.spss.api.common.Transform; +import at.gv.egovernment.moa.spss.api.common.X509IssuerSerial; +import at.gv.egovernment.moa.spss.api.common.XMLDataObjectAssociation; +import at.gv.egovernment.moa.spss.api.common.XPathFilter; +import at.gv.egovernment.moa.spss.api.xmlsign.CreateSignatureEnvironmentProfile; +import at.gv.egovernment.moa.spss.api.xmlsign.CreateSignatureInfo; +import at.gv.egovernment.moa.spss.api.xmlsign.CreateSignatureLocation; +import at.gv.egovernment.moa.spss.api.xmlsign.CreateTransformsInfo; +import at.gv.egovernment.moa.spss.api.xmlsign.CreateTransformsInfoProfile; +import at.gv.egovernment.moa.spss.api.xmlsign.CreateXMLSignatureRequest; +import at.gv.egovernment.moa.spss.api.xmlsign.CreateXMLSignatureResponse; +import at.gv.egovernment.moa.spss.api.xmlsign.DataObjectInfo; +import at.gv.egovernment.moa.spss.api.xmlsign.ErrorResponse; +import at.gv.egovernment.moa.spss.api.xmlsign.SignatureEnvironmentResponse; +import at.gv.egovernment.moa.spss.api.xmlsign.SingleSignatureInfo; +import at.gv.egovernment.moa.spss.api.xmlverify.ManifestRefsCheckResult; +import at.gv.egovernment.moa.spss.api.xmlverify.ManifestRefsCheckResultInfo; +import at.gv.egovernment.moa.spss.api.xmlverify.ReferenceInfo; +import at.gv.egovernment.moa.spss.api.xmlverify.ReferencesCheckResult; +import at.gv.egovernment.moa.spss.api.xmlverify.ReferencesCheckResultInfo; +import at.gv.egovernment.moa.spss.api.xmlverify.SignatureManifestCheckParams; +import at.gv.egovernment.moa.spss.api.xmlverify.SupplementProfile; +import at.gv.egovernment.moa.spss.api.xmlverify.TransformParameter; +import at.gv.egovernment.moa.spss.api.xmlverify.VerifySignatureInfo; +import at.gv.egovernment.moa.spss.api.xmlverify.VerifySignatureLocation; +import at.gv.egovernment.moa.spss.api.xmlverify.VerifyTransformsInfoProfile; +import at.gv.egovernment.moa.spss.api.xmlverify.VerifyXMLSignatureRequest; +import at.gv.egovernment.moa.spss.api.xmlverify.VerifyXMLSignatureResponse; + +/** + * An abstract factory for creating MOA SP/SS API objects. + * + * Use <code>getInstance()</code> to get a concrete factory instance. Using + * this instance, concrete MOA SP/SS API object can be created. + * + * @author Patrick Peck + * @version $Id$ + */ +public abstract class SPSSFactory { + + /** The default implementation of this class. */ + private static final String DEFAULT_IMPLEMENTATION = + "at.gv.egovernment.moa.spss.api.impl.SPSSFactoryImpl"; + + /** The single instance of this class. */ + private static SPSSFactory instance = null; + + /** + * Returns the single instance of this class. + * + * @return The single instance of this class. + */ + public static synchronized SPSSFactory getInstance() { + if (instance == null) { + try { + DiscoverClass discover = new DiscoverClass(); + instance = + (SPSSFactory) discover.newInstance( + SPSSFactory.class, + DEFAULT_IMPLEMENTATION); + } catch (Exception e) { + // this can not happen since we provide a valid default + // implementation + } + } + return instance; + } + + // + // Factory methods for creating XML signatures + // + + /** + * Create a new <code>CreateXMLSignatureRequest</code> object. + * + * @param keyIdentifier The identifier for the key group to use for signing. + * @param singleSignatureInfos A <code>List</code> of + * <code>SingleSignatureInfo</code> objects containing information about a + * single signature to be created. + * @return The <code>CreateXMLSignatureRequest</code> containing the above + * data. + * + * @pre keyIdentifier != null && keyIdentifier.length() > 0 + * @pre singleSignatureInfos != null + * @pre forall Object o in singleSignatureInfos | + * o instanceof at.gv.egovernment.moa.spss.api.common.SingleSignatureInfo + * @post return != null + */ + public abstract CreateXMLSignatureRequest createCreateXMLSignatureRequest( + String keyIdentifier, + List singleSignatureInfos); + + /** + * Create a new <code>SingleSignatureInfo</code> object. + * + * @param dataObjectInfos The data objects that will be signed (including + * transformations). + * @param createSignatureInfo Information about the signature environment. May + * be <code>null</code>. + * @param securityLayerConform If <code>true</code>, a Security Layer conform + * signature manifest is created, otherwise not. + * @return The <code>SingleSignatureInfo</code> containing the above data. + * + * @pre dataObjectInfos != null && dataObjectInfos.size() > 0 + * @pre forall Object o in dataObjectInfos | + * o instanceof at.gv.egovernment.moa.spss.api.xmlsign.DataObjectInfo + * @post return != null + */ + public abstract SingleSignatureInfo createSingleSignatureInfo( + List dataObjectInfos, + CreateSignatureInfo createSignatureInfo, boolean securityLayerConform); + + /** + * Create a new <code>DataObjectInfo</code> object. + * + * @param structure The type of signature to create. + * @param childOfManifest If <code>true</code>, references will be returned + * as children of an XMLDsig manifest. Otherwise, they will be returned as + * children of the signature itself. + * @param dataObject The data object that will be signed. + * @param createTransformsInfoProfile Additional transformations to apply + * to the data object. + * @return The <code>DataObjectInfo</code> containing the above data. + * + * @pre DataObjectInfo.STRUCTURE_DETACHED.equals(structure) || + * DataObjectInfo.STRUCTURE_ENVELOPING.equals(structure) + * @pre dataObject != null + * @pre createTransformsInfoProfile != null + * @post return != null + */ + public abstract DataObjectInfo createDataObjectInfo( + String structure, + boolean childOfManifest, + Content dataObject, + CreateTransformsInfoProfile createTransformsInfoProfile); + + /** + * Create a new <code>CreateTransformsInfoProfile</code> object containing a + * reference to a locally stored profile. + * + * @param profileID The profile ID to resolve during signature creation. + * @return The <code>CreateTransformsInfoProfile</code> containing the given + * profile ID. + * + * @pre profileID != null && profileID.length() > 0 + * @post return != null + */ + public abstract CreateTransformsInfoProfile createCreateTransformsInfoProfile(String profileID); + + /** + * Create a new <code>CreateTransformsInfoProfile</code> object by providing + * the profile data explicitly. + * + * @param transformsInfo The transformations to apply to the associated + * data object. + * @param supplements Supplemental information for the transformation. May be + * <code>null</code>. + * @return The <code>CreateTransformsInfoProfile</code> containing the above + * data. + * + * @pre transformsInfo != null + * @pre supplements != null implies + * forall Object o in supplements | + * o instanceof at.gv.egovernment.moa.spss.api.common.XMLDataObjectAssociation + * @post return != null + */ + public abstract CreateTransformsInfoProfile createCreateTransformsInfoProfile( + CreateTransformsInfo transformsInfo, + List supplements); + + /** + * Create a new <code>CreateTransformsInfo</code> object. + * + * @param transforms The <code>Transform</code>s to apply to the associated + * data object. May be <code>null</code>. + * @param finalDataMetaInfo Information about the type of the transformed + * data. + * @return The <code>CreateTransformsInfo</code> containing the above data. + * + * @pre transforms != null implies transforms.size > 0 + * @pre transforms != null implies + * forall Object o in transforms | + * o instanceof at.gv.egovernment.moa.spss.api.common.Transform + * @pre finalDataMetaInfo != null + * @post return != null + */ + public abstract CreateTransformsInfo createCreateTransformsInfo( + List transforms, + MetaInfo finalDataMetaInfo); + + /** + * Create a new <code>CreateSignatureInfo</code> object. + * + * @param createSignatureEnvironment The signature environment that will + * contain the signature. + * @param createSignatureEnvironmentProfile Additional information about + * the signture environment. + * @return The <code>CreateSignatureInfo</code> containing the above data. + * + * @pre createSignatureEnvironment != null + * @pre createSignatureEnvironmentProfile != null + * @post return != null + */ + public abstract CreateSignatureInfo createCreateSignatureInfo( + Content createSignatureEnvironment, + CreateSignatureEnvironmentProfile createSignatureEnvironmentProfile); + + /** + * Create a new <code>CreateSignatureEnvironmentProfile</code> object + * containing a reference to a locally stored profile. + * + * @param profileID The profile ID to resolve during signature creation. + * @return The <code>CreateSignatureEnvironmentProfile</code> containing + * the given profile ID. + * + * @pre profileID != null && profileID.length() > 0 + * @post return != null + */ + public abstract CreateSignatureEnvironmentProfile createCreateSignatureEnvironmentProfile(String profileID); + + /** + * Create a new <code>CreateSignatureEnvironmentProfile</code> object by + * providing the profile data explicitly. + * + * @param createSignatureLocation The location where the signature will be + * inserted. + * @param supplements Additional information about the signature environment. + * @return The <code>CreateSignatureEnvironmentProfile</code> containing the + * above data. + * + * @pre createSignatureLocation != null + * @pre supplements != null + * @pre forall Object o in supplements | + * o instanceof at.gv.egovernment.moa.spss.api.common.XMLDataObjectAssociation + * @post return != null + */ + public abstract CreateSignatureEnvironmentProfile createCreateSignatureEnvironmentProfile( + CreateSignatureLocation createSignatureLocation, + List supplements); + + /** + * Create a new <code>CreateSignatureLocation</code> object. + * + * @param xPathExpression The XPath expression to select the signature + * parent element within the signature environment. + * @param index The index of the node, after which the signature will be + * inserted. + * @param namespaceDeclarations The namespace prefix to URI mapping to apply + * while evaluating the XPath expression. + * @return The <code>CreateSignatureLocation</code> containing the above data. + * + * @pre xPathExpression != null + * @pre index >= 0 + * @pre namespaceDeclarations != null + */ + public abstract CreateSignatureLocation createCreateSignatureLocation( + String xPathExpression, + int index, + Map namespaceDeclarations); + + /** + * Create a new <code>CreateXMLSignatureResponse</code> object. + * + * @param responseElements The elements of the response, either + * <code>SignatureEnvironmentResponse</code> objects, or + * <code>ErrorResponse</code> objects. + * @return The new <code>CreateXMLSignatureResponse</code> containing the + * above data. + * + * @pre responseElements != null && responseElements.size() > 0 + * @pre forall Object o in responseElements | + * o instanceof at.gv.egovernment.moa.spss.api.xmlsign.CreateSignatureResponseElement + * @post return != null + */ + public abstract CreateXMLSignatureResponse createCreateXMLSignatureResponse(List responseElements); + + /** + * Create a new <code>SignatureEnvironmentResponse</code> object. + * + * @param signatureEnvironment The signature environment containing the + * signature. + * @return The <code>SignatureEnvironmentResponse</code> containing the + * <code>signatureEnvironment</code>. + * + * @pre signatureEnvironment != null + * @post return != null + */ + public abstract SignatureEnvironmentResponse createSignatureEnvironmentResponse(Element signatureEnvironment); + + /** + * Create a new <code>ErrorResponse</code> object. + * + * @param code The numerical error code. + * @param info Verbose error information. + * @return The new <code>ErrorResponse</code> containing the above data. + * + * @pre code > 0 + * @pre info != null + * @post return != null + */ + public abstract ErrorResponse createErrorResponse(int code, String info); + + // + // Factory methods for verifying CMS signatures + // + + /** + * Create a new <code>VerifyCMSSignatureRequest</code> object. + * + * @param signatories The indexes of the signatories whose signature is to + * be verified. + * @param dateTime The date for which the verification is to be performed. + * May be <code>null</code>. + * @param cmsSignature The CMS signature. + * @param dataObject The signed data. May be <code>null</code>. + * @param trustProfileID The ID of the trust profile containing the trusted + * root certificates. + * @return The <code>VerifyCMSSignatureRequest</code> containing the above + * data. + * + * @pre signatories != null && signatories.length > 0 + * @pre signaturies != VerifyCMSSignatureRequest.ALL_SIGNATORIES implies + * for (int i = 0; i < signatories.length; i++) + * signatories[i] >= 1 + * @pre cmsSignature != null + * @pre trustProfileID != null && trustProfileID.length() > 0 + * @post return != null + */ + public abstract VerifyCMSSignatureRequest createVerifyCMSSignatureRequest( + int[] signatories, + Date dateTime, + InputStream cmsSignature, + CMSDataObject dataObject, + String trustProfileID); + + /** + * Create a new <code>CMSDataObject</code> object from data at a given URI. + * + * @param metaInfo Type information about the <code>CMSDataObject</code>. + * May be <code>null</code>. + * @param content The CMS content containing the data. + * @return The new <code>CMSDataObject</code> containing the data. + * + * @pre referenceURI != null + * @pre content != null + * @post return != null + */ + public abstract CMSDataObject createCMSDataObject( + MetaInfo metaInfo, + CMSContent content); + + /** + * Create a new <code>CMSContent</code> object from the data contained at the + * given URI. + * + * @param referenceURI The URI identifying the data. Must be resolvable. + * @return The <code>CMSContent</code> containing a reference to the signed + * data. + * + * @pre referenceURI != null + * @post return != null + */ + public abstract CMSContent createCMSContent(String referenceURI); + + /** + * Create a new <code>CMSContent</code> object from a byte stream. + * + * @param binaryContent The byte stream containing the signed data. + * @return The new <code>CMSContent</code> containing the data from the + * byte stream. + * + * @pre binaryContent != null + * @post return != null + */ + public abstract CMSContent createCMSContent(InputStream binaryContent); + + /** + * Create a new <code>VerifyCMSSignatureResponse</code> object. + * + * @param responseElements Verification information about each signature. + * @return The new <code>VerifyCMSSignatureResponse</code> containing the + * status of signature verification for each signature contained in the + * request. + * + * @pre responseElements != null && responseElements.size() > 0 + * @pre forall Object o in responseElements | + * o instanceof at.gv.egovernment.moa.spss.api.cmssign.VerifyCMSSignatureResponseElement + * @post return != null + */ + public abstract VerifyCMSSignatureResponse createVerifyCMSSignatureResponse(List responseElements); + + /** + * Create a new <code>VerifyCMSSignatureResponseElement</code> object. + * + * @param signerInfo Information about the signer certificate. + * @param signatureCheck Result of the singature value check. + * @param certificateCheck Result of the certificate status check. + * @return The new <code>VerifyCMSSignatureResponseElement</code> containing + * the above data. + * + * @pre signerInfo != null && signatureCheck != null && + * certificateCheck != null + * @post return != null + */ + public abstract VerifyCMSSignatureResponseElement createVerifyCMSSignatureResponseElement( + SignerInfo signerInfo, + CheckResult signatureCheck, + CheckResult certificateCheck); + + // + // Factory methods for verifying XML signatures + // + + /** + * Create a new <code>VerifyXMLSignatureRequest</code> object. + * + * @param dateTime The date for which the verification is to be performed. + * May be <code>null</code>. + * @param verifySignatureInfo Information about the signature environment and + * the location of the signature. + * @param supplementProfiles Supplemental information for the signature + * environment. May be <code>null</code>. + * @param signatureManifestParams Additional information for checking the + * signature manifest. May be <code>null</code>. + * @param returnHashInputData If <code>true</code>, hash input data will + * be returned in the response, otherwise not. + * @param trustProfileID The ID of the trust profile containing the trusted + * root certificates. + * @return The new <code>VerifyXMLSignatureRequest</code> containing the + * above data. + * + * @pre verifySignatureInfo != null + * @pre supplementProfiles != null implies + * forall Object o in supplementProfiles | + * o instanceof at.gv.egovernment.moa.spss.api.xmlverify.SupplementProfile + * @pre trustProfileID != null && trustProfileID.length() > 0 + * @post return != null + */ + public abstract VerifyXMLSignatureRequest createVerifyXMLSignatureRequest( + Date dateTime, + VerifySignatureInfo verifySignatureInfo, + List supplementProfiles, + SignatureManifestCheckParams signatureManifestParams, + boolean returnHashInputData, + String trustProfileID); + + /** + * Create a new <code>VerifySignatureInfo</code> object. + * + * @param verifySignatureEnvironment The signature environment containing + * the signature to be verified. + * @param verifySignatureLocation The location of the signature within the + * signature environment. + * @return The new <code>VerifySignatureInfo</code> containing the above data. + * + * @pre verifySignatureEnvironment != null + * @pre verifySignatureLocation != null + * @post return != null + */ + public abstract VerifySignatureInfo createVerifySignatureInfo( + Content verifySignatureEnvironment, + VerifySignatureLocation verifySignatureLocation); + + /** + * Create a new <code>VerifySignatureLocation</code> object. + * + * @param xPathExpression The XPath expression to select the signature + * element within the signature environment. + * @param namespaceDeclarations The namespace prefix to URI mapping to apply + * while evaluating the XPath expression. + * @return The new <code>VerifySignatureLocation</code> containing the above + * data. + * + * @pre xPathExpression != null + * @pre namespaceDeclarations != null + * @post return != null + */ + public abstract VerifySignatureLocation createVerifySignatureLocation( + String xPathExpression, + Map namespaceDeclarations); + + /** + * Create a new <code>SupplementProfile</code> object containing a reference + * to a locally stored profile. + * + * @param profileID The profile ID to resolve during signature verification. + * @return The <code>SupplementProfile</code> containing the profile ID. + * + * @pre profileID != null && profileID.length() > 0 + * @post return != null + */ + public abstract SupplementProfile createSupplementProfile(String profileID); + + /** + * Create a new <code>SupplementProfile</code> object by providing the profile + * data explicitly. + * + * @param supplementProfile The profile data. + * @return The <code>SupplementProfile</code> containing the profile data. + */ + public abstract SupplementProfile createSupplementProfile(XMLDataObjectAssociation supplementProfile); + + /** + * Create a new <code>SignatureManifestCheckParams</code> object. + * + * @param referenceInfos Information for checking the validity of a + * a reference. + * @param returnReferenceInputData If <code>true</code>, the input data to + * the calculation of reference digest values will be returned in the + * response, otherwise not. + * @return The <code>SignatureManifestCheckParams</code> containing the + * above data. + * + * @pre referenceInfos != null && referenceInfos.size() > 0 + * @pre forall Object o in referenceInfos | + * o instanceof at.gv.egovernment.moa.spss.api.xmlverify.ReferenceInfo + * @post return != null + */ + public abstract SignatureManifestCheckParams createSignatureManifestCheckParams( + List referenceInfos, + boolean returnReferenceInputData); + + /** + * Create a new <code>ReferenceInfo</code> object. + * + * @param verifyTransformsInfoProfiles The transformation profiles valid for + * the associated reference. + * @return The <code>ReferenceInfo</code> containing the transformation + * profiles. + * + * @pre verifyTransformsInfoProfiles != null && + * verifyTransformsInfoProfiles.size() > 0 + * @pre forall Object o in verifyTransformsInfoProfiles | + * o instanceof at.gv.egovernment.moa.spss.api.xmlverify.VerifyTransformsInfoProfile + * @post return != null + */ + public abstract ReferenceInfo createReferenceInfo(List verifyTransformsInfoProfiles); + + /** + * Create a new <code>VerifyTransformsInfoProfile</code> object containing + * a reference to a locally stored profile. + * + * @param profileID The profile ID to resolve during signature verification. + * @return The <code>VerifyTransformsInfoProfile</code> containing the + * given profile ID. + * + * @pre profileID != null && profileID.length() > 0 + * @post return != null + */ + public abstract VerifyTransformsInfoProfile createVerifyTransformsInfoProfile(String profileID); + + /** + * Create a new <code>VerifyTransformsInfoProfile</code> object by providing + * the profile data explicitly. + * + * @param transforms A valid chain of transformations for the reference. + * May be <code>null</code>. + * @param transformParameters Additional transformation information. + * @return The <code>VerifyTransformsInfoProfile</code> containing the above + * data. + * + * @pre transforms != null implies + * (transforms.size() > 0 && + * forall Object o in transforms | o instanceof Transform) + * @pre transformParameters != null implies + * forall Object o in transformParameters | + * o instanceof at.gv.egovernment.moa.spss.api.xmlverify.TransformParameter + * @post return != null + */ + public abstract VerifyTransformsInfoProfile createVerifyTransformsInfoProfile( + List transforms, + List transformParameters); + + /** + * Create a new <code>TransformParameter</code> object with the data + * contained at the given URI. + * + * @param URI The URI identifying the data. The URI will be resolved during + * signature verification. + * @return The <code>TransformParameter</code> containing the URI of the + * data. + * + * @pre URI != null + * @post return != null + */ + public abstract TransformParameter createTransformParameter(String URI); + + /** + * Creata a new <code>TransformParameter</code> object containing the + * binary data. + * + * @param URI The URI identifying the data. + * @param binaryData The binary data. + * @return The <code>TransformParameter</code> containig the binary data. + * + * @pre URI != null + * @pre binary != null + * @post return != null + */ + public abstract TransformParameter createTransformParameter( + String URI, + InputStream binaryData); + + /** + * Create a new <code>TransformParameter</code> object containing the hash + * value of the transformation data. + * + * @param URI The URI identifying the data. It will be resolved during + * signature verification. + * @param digestMethod The digest method used for calculating the digest + * value. + * @param digestValue The hash value of the transformation data. + * @return The <code>TransformParameter</code> containing the above data. + * + * @pre URI != null + * @pre digestMethod != null + * @pre digestValue != null + */ + public abstract TransformParameter createTransformParameter( + String URI, + String digestMethod, + byte[] digestValue); + + /** + * Create a new <code>VerifyXMLSignatureResponse</code> object. + * + * @param signerInfo Information about the signer certificate. + * @param hashInputDatas The signed data objects. May be <code>null</code>. + * @param referenceInputDatas The reference input data objects. + * May be <code>null</code>. + * @param signatureCheck Status information about the signature check. + * @param signatureManifestCheck Status information about the signature + * manifest check. + * @param xmlDsigManifestChecks Status information about each XMLDsig manifest + * check. + * @param certificateCheck Status information about the signer certificate + * check. + * @return The <code>VerifyXMLSignatureResponse</code> containing the above + * data. + * + * @pre signerInfo != null + * @pre hashInputDatas != null implies + * forall Object o in hashInputDatas | + * o instanceof at.gv.egovernment.moa.spss.api.common.Content + * @pre referenceInputDatas != null implies + * forall Object o in referenceInputDatas | + * o instanceof at.gv.egovernment.moa.spss.api.common.Content + * @pre signatureCheck != null + * @pre xmlDsigManifestChecks != null implies + * forall Object o in xmlDsigManifestChecks | + * o instanceof at.gv.egovernment.moa.spss.api.xmlverifyManifestRefsCheckResult + * @pre certificateCheck != null + * @post return != null + */ + public abstract VerifyXMLSignatureResponse createVerifyXMLSignatureResponse( + SignerInfo signerInfo, + List hashInputDatas, + List referenceInputDatas, + ReferencesCheckResult signatureCheck, + ReferencesCheckResult signatureManifestCheck, + List xmlDsigManifestChecks, + CheckResult certificateCheck); + + /** + * Create a new <code>ReferencesCheckResult</code> object. + * + * @param code The status code. + * @param info Additional information about the reference check. + * @return The <code>ReferencesCheckResult</code> containing the above data. + * + * @pre code >= 0 + * @post return != null + */ + public abstract ReferencesCheckResult createReferencesCheckResult( + int code, + ReferencesCheckResultInfo info); + + /** + * Create a new <code>ReferencesCheckResultInfo</code> object. + * + * @param anyOtherInfo Arbitrary XML content describing the check result. + * May be <code>null</code>. + * @param failedReferences The indexes of the failed references. May be + * <code>null</code>. + * @return The <code>ReferencesCheckResultInfo</code> containing the above + * data. + * + * @post return != null + */ + public abstract ReferencesCheckResultInfo createReferencesCheckResultInfo( + NodeList anyOtherInfo, + int[] failedReferences); + + /** + * Create a new <code>ManifestRefsCheckResult</code> object. + * + * @param code The status code. + * @param info Additional information about the manifest check. May be + * <code>null</code>. + * @return The <code>ManifestRefsCheckResult</code> containing the above + * data. + * + * @pre code >= 0 + * @post return != null + */ + public abstract ManifestRefsCheckResult createManifestRefsCheckResult( + int code, + ManifestRefsCheckResultInfo info); + + /** + * Create a new <code>ManifestRefsCheckResultInfo</code> object. + * + * @param anyOtherInfo Arbitrary XML content describing the check result. + * May be <code>null</code>. + * @param failedReferences The indexes of the failed references. May be + * <code>null</code>. + * @param referringSigReference The index of the reference in the signature. + * @return The <code>ManifestRefsCheckResultInfo</code> containing the + * above data. + * + * @pre referringSigReference > 0 + * @post return != null + */ + public abstract ManifestRefsCheckResultInfo createManifestRefsCheckResultInfo( + NodeList anyOtherInfo, + int[] failedReferences, + int referringSigReference); + + // + // Factory methods for common objects + // + + /** + * Create a new <code>Content</code> object referencing data via a URI. + * + * @param referenceURI The URI pointing to the content. + * @return The <code>Content</code> object containing the reference. + * + * @pre referenceURI != null && referenceURI.length() > 0 + * @post return != null + */ + public abstract Content createContent(String referenceURI); + + /** + * Create a new <code>Content</code> object containing binary data. + * + * @param binaryData An <code>InputStream</code> containing the binary data. + * @param referenceURI An URI identifying the data. May be <code>null</code>. + * @return The <code>Content</code> object containing the data. + * + * @pre binaryData != null + * @post return != null + */ + public abstract Content createContent( + InputStream binaryData, + String referenceURI); + + /** + * Create a new <code>Content</code> object containing XML data. + * + * @param xmlData The XML data contained in the new <code>Content</code>. + * @param referenceURI An URI identifying the data. May be <code>null</code>. + * @return The <code>Content</code> object containing the data. + * + * @pre xmlData != null + * @post return != null + */ + public abstract Content createContent(NodeList xmlData, String referenceURI); + + /** + * Create a new <code>XMLDataObjectAssociation</code> object. + * + * @param metaInfo Information about the content type. May be + * <code>null</code>. + * @param content The <code>Content</code> object containing the data. + * @return The <code>XMLDataObjectAssociation</code> containing the above + * data. + * + * @pre content != null + * @pre content.getContentType() == Content.CONTENT_XML || + * content.getContentType() == Contetn.CONTENT_BINARY + * @pre content.getReference() != null + * @post return != null + */ + public abstract XMLDataObjectAssociation createXMLDataObjectAssociation( + MetaInfo metaInfo, + Content content); + + /** + * Create a new <code>MetaInfo</code> object. + * + * @param mimeType The MIME type part of the meta information. + * @param description Descriptive meta information. May be <code>null</code>. + * @param otherInfo XML meta information. May be <code>null</code>. + * @return The <code>MetaInfo</code> object containing the above data. + * + * @pre mimeType != null && mimeType.length() > 0 + * @pre otherInfo != null implies + * forall Node n in otherInfo | n.getNodeType() == Node.ELEMENT + */ + public abstract MetaInfo createMetaInfo( + String mimeType, + String description, + NodeList otherInfo); + + /** + * Create a <code>CanonicalizationTransform</code> type of <code>Transform</code>. + * + * @param algorithmURI The algorithm URI of the canonicalization. + * @return The created <code>CanonicalizationTransform</code> object. + * + * @pre CanonicalizationTransform.CANONICAL_XML.equals(algorithmURI) || + * CanonicalizationTransform.CANONICAL_XML_WITH_COMMENTS.equals(algorithmURI) + * @post return != null + */ + public abstract Transform createCanonicalizationTransform(String algorithmURI); + + /** + * Create an <code>ExclusiveCanonicalizationTransform</code> type of + * <code>Transform</code>. + * + * @param algorithmURI The algorithm URI of the exclusive canonicalization. + * @param inclusiveNamespacePrefixes The prefixes of the namespaces to + * treat according to canonical XML. + * @return The new <code>ExclusiveCanonicalizationTransform</code> + * + * @pre ExclusiveCanonicalizationTransform.EXCLUSIVE_CANONICAL_XML.equals(algorithmURI) || + * ExclusiveCanonicalizationTransform.EXCLUSIVE_CANONICAL_XML_WITH_COMMENTS.equals(algorithmURI) + * @pre inclusiveNamespacePrefixes != null + * @pre forall Object o in inclusiveNamespacePrefixes | o instanceof String + * @post return != null + */ + public abstract Transform createExclusiveCanonicalizationTransform( + String algorithmURI, + List inclusiveNamespacePrefixes); + + /** + * Create a <code>Base64Transform</code> type of <code>Transform</code>. + * + * @return A <code>Transform</code> denoting a Base64 decoding. + * + * @post return != null + */ + public abstract Transform createBase64Transform(); + + /** + * Create a <code>EnvelopedSignatureTransform</code> type of + * <code>Transform</code>. + * + * @return A <code>Transform</code> denoting an enveloped signature. + * + * @post return != null + */ + public abstract Transform createEnvelopedSignatureTransform(); + + /** + * Create an <code>XSLTTransform</code> type of <code>Transform</code>. + * + * @param styleSheet The XSLT stylesheet contained in the + * <code>Transform</code>. + * @return A <code>Transform</code> containing the XSLT stylesheet. + * + * @post return != null + */ + public abstract Transform createXSLTTransform(Element styleSheet); + + /** + * Create an <code>XPathTransform</code> type of <code>Transform</code>. + * + * @param xPathExpression The XPath expression to use in the created + * <code>Transform</code>. + * @param namespaceDeclarations The namespace prefix to URI mapping to + * apply on evaluation of the XPath expression. + * @return The <code>XPathTransform</code> containing the above data. + * + * @pre xPathExpression != null + * @pre namespaceDeclarations != null + * @post return != null + */ + public abstract Transform createXPathTransform( + String xPathExpression, + Map namespaceDeclarations); + + /** + * Create a new <code>XPathFilter2Transform</code> type of + * <code>Transform</code>. + * + * @param xPathFilters The filters contained in the newly created + * <code>XPathFilter2Transform</code>. + * @return The <code>XPathFilter2Transform</code> containing the given + * filters. + * + * @pre xPathFilters != null && + * forall Object o in xPathFilters | + * o instanceof at.gv.egovernment.moa.spss.api.common.XPathFilter + * @post return != null + */ + public abstract Transform createXPathFilter2Transform(List xPathFilters); + + /** + * Create a new <code>XPathFilter</code> object. + * + * @param filterType The type of filter. + * @param xPathExpression The XPath expression contained in this filter. + * @param namespaceDeclarations The namespace prefix to URI mapping to apply + * on evaluation of the XPath expression. + * @return The <code>XPathFilter</code> containing the above data. + * + * @pre XPathFilter.SUBTRACT_TYPE.equals(filterType) || + * XPathFilter.INTERSECT_TYPE.equals(filterType) || + * XPathFilter.UNION_TYPE.equals(filterType) + * @pre xPathExpression != null + * @pre namespaceDeclarations != null + * @post return != null + */ + public abstract XPathFilter createXPathFilter( + String filterType, + String xPathExpression, + Map namespaceDeclarations); + + /** + * Create a new <code>CheckResult</code> object. + * + * @param code The check code. + * @param info Verbose information about the check. May be <code>null</code>. + * @return The <code>CheckResult</code> containing the above data. + * + * @pre code >= 0 + * @post return != null + */ + public abstract CheckResult createCheckResult(int code, NodeList info); + + /** + * Create a new <code>SignerInfo</code> object. + * + * @param signerCertificate The signer certificate in binary form. + * @param qualifiedCertificate <code>true</code>, if the signer certificate is + * a qualified certificate, otherwise <code>false</code>. + * @param publicAuthority <code>true</code>, if the signer certificate is a + * public authority certificate, otherwise <code>false</code>. + * @param publicAuthorityID The identification of the public authority + * (if <code>publicAuthority</code> is <code>true</code>). May be + * <code>null</code>. + * @return The <code>SignerInfo</code> containing the above data. + * + * @pre signerCertSubjectName != null + * @pre signerCertIssuerSerial != null + * @pre signerCertificate != null + */ + public abstract SignerInfo createSignerInfo( + X509Certificate signerCertificate, + boolean qualifiedCertificate, + boolean publicAuthority, + String publicAuthorityID); + + /** + * Create a new <code>X509IssuerSerial</code> object. + * + * @param issuerName The distinguished name of the issuer. + * @param issuerSerial The certificate serial number. + * @return The <code>X509IssuerSerial</code> containing the above data. + * + * @pre issuerName != null + * @pre issuerSerial != null + */ + public abstract X509IssuerSerial createX509IssuerSerial( + String issuerName, + BigInteger issuerSerial); + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/SignatureCreationService.java b/spss.server/src/at/gv/egovernment/moa/spss/api/SignatureCreationService.java new file mode 100644 index 000000000..a84ca2a83 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/SignatureCreationService.java @@ -0,0 +1,57 @@ +package at.gv.egovernment.moa.spss.api; + +import at.gv.egovernment.moa.spss.MOAException; + +import org.apache.commons.discovery.tools.DiscoverClass; + + +import at.gv.egovernment.moa.spss.api.xmlsign.CreateXMLSignatureRequest; +import at.gv.egovernment.moa.spss.api.xmlsign.CreateXMLSignatureResponse; + +/** + * Interface providing functions for signature creation. + * + * @author Patrick Peck + * @version $Id$ + */ +public abstract class SignatureCreationService { + + /** The default implementation class. */ + private static final String DEFAULT_IMPLEMENTATION = + "at.gv.egovernment.moa.spss.server.invoke.SignatureCreationServiceImpl"; + + /** The single instance of this class. */ + private static SignatureCreationService instance = null; + + /** + * Get an instance of the <code>SignatureCreationService</code>. + * + * @return A concrete instance of the <code>SignatureCreationService</code>. + */ + public static synchronized SignatureCreationService getInstance() { + if (instance == null) { + try { + DiscoverClass discover = new DiscoverClass(); + instance = + (SignatureCreationService) discover.newInstance( + SignatureCreationService.class, + DEFAULT_IMPLEMENTATION); + } catch (Exception e) { + // this can not happen since we provide a valid default + // implementation + } + } + return instance; + } + + /** + * Create an XML signature. + * + * @param request Information on how to create the signature. + * @return A <code>CreateXMLSignatureResponse</code> containing the + * signature. + * @throws MOAException Error in server side MOA module. + */ + public abstract CreateXMLSignatureResponse createXMLSignature(CreateXMLSignatureRequest request) + throws MOAException; +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/SignatureVerificationService.java b/spss.server/src/at/gv/egovernment/moa/spss/api/SignatureVerificationService.java new file mode 100644 index 000000000..d0fcb029a --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/SignatureVerificationService.java @@ -0,0 +1,69 @@ +package at.gv.egovernment.moa.spss.api; + +import org.apache.commons.discovery.tools.DiscoverClass; + +import at.gv.egovernment.moa.spss.MOAException; +import at.gv.egovernment.moa.spss.api.cmsverify.VerifyCMSSignatureRequest; +import at.gv.egovernment.moa.spss.api.cmsverify.VerifyCMSSignatureResponse; +import at.gv.egovernment.moa.spss.api.xmlverify.VerifyXMLSignatureRequest; +import at.gv.egovernment.moa.spss.api.xmlverify.VerifyXMLSignatureResponse; + +/** + * Interface providing functions for verifying signatures. + * + * @author Patrick Peck + * @version $Id$ + */ +public abstract class SignatureVerificationService { + + /** The default implementation class. */ + private static final String DEFAULT_IMPLEMENTATION = + "at.gv.egovernment.moa.spss.server.invoke.SignatureVerificationServiceImpl"; + + /** The single instance of this class. */ + private static SignatureVerificationService instance = null; + + /** + * Get an instance of the <code>SignatureVerificationService</code>. + * + * @return A concrete instance of the + * <code>SignatureVerificationService</code>. + */ + public static synchronized SignatureVerificationService getInstance() { + if (instance == null) { + try { + DiscoverClass discover = new DiscoverClass(); + instance = + (SignatureVerificationService) discover.newInstance( + SignatureVerificationService.class, + DEFAULT_IMPLEMENTATION); + } catch (Exception e) { + // this can not happen since we provide a valid default + // implementation + } + } + return instance; + } + + /** + * Verify a CMS signature. + * + * @param request Detailed information on the verification that should be + * performed. + * @return A <code>VerifyCMSSignatureResponse</code> object that contains + * information about the performed verification. + * @throws MOAException Error in server side MOA module. + */ + public abstract VerifyCMSSignatureResponse verifyCMSSignature(VerifyCMSSignatureRequest request) + throws MOAException; + /** + * Verfiy an XML Signature. + * + * @param request information on the verification that should be performed. + * @return A <code>VerifyXMLSignatureResponse</code> object that contains + * information about the performed verification. + * @throws MOAException Error in server side MOA module. + */ + public abstract VerifyXMLSignatureResponse verifyXMLSignature(VerifyXMLSignatureRequest request) + throws MOAException; +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/cmsverify/CMSContent.java b/spss.server/src/at/gv/egovernment/moa/spss/api/cmsverify/CMSContent.java new file mode 100644 index 000000000..b4ecb3937 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/cmsverify/CMSContent.java @@ -0,0 +1,28 @@ +package at.gv.egovernment.moa.spss.api.cmsverify; + +/** + * Base class for objects containing CMS content. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface CMSContent { + /** + * Indicates that this object contains a reference to the CMS content. + */ + public static final int REFERENCE_CONTENT = 0; + /** + * Indicates that this object contains the CMS content explicitly. + */ + public static final int EXPLICIT_CONTENT = 1; + + /** + * Gets the type of the contained content. + * + * @return The type of content, either <code>REFERENCE_CONTENT</code> or + * <code>EXPLICIT_CONTENT</code>. + */ + public int getContentType(); + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/cmsverify/CMSContentExcplicit.java b/spss.server/src/at/gv/egovernment/moa/spss/api/cmsverify/CMSContentExcplicit.java new file mode 100644 index 000000000..58c2b0259 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/cmsverify/CMSContentExcplicit.java @@ -0,0 +1,19 @@ +package at.gv.egovernment.moa.spss.api.cmsverify; + +import java.io.InputStream; + +/** + * Encapsulates binary CMS content. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface CMSContentExcplicit extends CMSContent { + /** + * Gets the content as a stream. + * + * @return A stream containing the binary content. + */ + public InputStream getBinaryContent(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/cmsverify/CMSContentReference.java b/spss.server/src/at/gv/egovernment/moa/spss/api/cmsverify/CMSContentReference.java new file mode 100644 index 000000000..7c4e6d913 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/cmsverify/CMSContentReference.java @@ -0,0 +1,17 @@ +package at.gv.egovernment.moa.spss.api.cmsverify; + +/** + * Encapsulates CMS content that is referenced by an URI. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface CMSContentReference extends CMSContent { + /** + * Gets the reference URI from wher the content can be retrieved. + * + * @return The reference URI. + */ + public String getReference(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/cmsverify/CMSDataObject.java b/spss.server/src/at/gv/egovernment/moa/spss/api/cmsverify/CMSDataObject.java new file mode 100644 index 000000000..37f6fd396 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/cmsverify/CMSDataObject.java @@ -0,0 +1,25 @@ +package at.gv.egovernment.moa.spss.api.cmsverify; + +import at.gv.egovernment.moa.spss.api.common.MetaInfo; + +/** + * A data object used for verification of CMS signatures. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface CMSDataObject { + /** + * Gets the meta information of the content. + * + * @return An object containig the meta information. + */ + public MetaInfo getMetaInfo(); + /** + * Gets the actual content of the data object. + * + * @return The actual content. + */ + public CMSContent getContent(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/cmsverify/VerifyCMSSignatureRequest.java b/spss.server/src/at/gv/egovernment/moa/spss/api/cmsverify/VerifyCMSSignatureRequest.java new file mode 100644 index 000000000..6d1f389af --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/cmsverify/VerifyCMSSignatureRequest.java @@ -0,0 +1,52 @@ +package at.gv.egovernment.moa.spss.api.cmsverify; + +import java.io.InputStream; +import java.util.Date; + +/** + * Object that encapsulates a request to verify a CMS signature. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface VerifyCMSSignatureRequest { + /** + * Indicates, that signature checks for all signatories must be returned. + */ + public static int[] ALL_SIGNATORIES = new int[] { -1 }; + /** + * Gets the positions of signatories whose signature must be verified. + * + * @return The positions of signatories. + */ + public int[] getSignatories(); + /** + * Gets the date and time for which the signature verification has to + * be performed. + * + * @return Date and time for which the signature verification has + * to be performed. + */ + public Date getDateTime(); + /** + * Gets the binary CMS signature. + * + * @return An <code>InputStream</code> from which the binary CMS signature + * can be read. + */ + public InputStream getCMSSignature(); + /** + * Gets the data object necessary for the verification. + * + * @return The data object necessary for verification. + */ + public CMSDataObject getDataObject(); + /** + * Gets the profile ID of trusted certificates to be used for signature + * verification. + * + * @return The profile ID of trusted certificates. + */ + public String getTrustProfileId(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/cmsverify/VerifyCMSSignatureResponse.java b/spss.server/src/at/gv/egovernment/moa/spss/api/cmsverify/VerifyCMSSignatureResponse.java new file mode 100644 index 000000000..5f2e6d255 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/cmsverify/VerifyCMSSignatureResponse.java @@ -0,0 +1,21 @@ +package at.gv.egovernment.moa.spss.api.cmsverify; + +import java.util.List; + + +/** + * Object that encapsulates the response on a request to verify a CMS + * signature. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface VerifyCMSSignatureResponse { + /** + * Gets the response elements. + * + * @return The response elements. + */ + public List getResponseElements(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/cmsverify/VerifyCMSSignatureResponseElement.java b/spss.server/src/at/gv/egovernment/moa/spss/api/cmsverify/VerifyCMSSignatureResponseElement.java new file mode 100644 index 000000000..49ddb9419 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/cmsverify/VerifyCMSSignatureResponseElement.java @@ -0,0 +1,32 @@ +package at.gv.egovernment.moa.spss.api.cmsverify; + +import at.gv.egovernment.moa.spss.api.common.CheckResult; +import at.gv.egovernment.moa.spss.api.common.SignerInfo; + +/** + * Contains detailed information about the verification of a signature. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface VerifyCMSSignatureResponseElement { + /** + * Gets a SignerInfo element according to CMS. + * + * @return The SignerInfo element according to CMS. + */ + public SignerInfo getSignerInfo(); + /** + * Gets the result of the signature verification. + * + * @return The result of the signature verification. + */ + public CheckResult getSignatureCheck(); + /** + * Gets the result of the certificate verification. + * + * @return The result of the certificate verification. + */ + public CheckResult getCertificateCheck(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/common/Base64Transform.java b/spss.server/src/at/gv/egovernment/moa/spss/api/common/Base64Transform.java new file mode 100644 index 000000000..94785727d --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/common/Base64Transform.java @@ -0,0 +1,13 @@ +package at.gv.egovernment.moa.spss.api.common; + +/** + * A <code>Transform</code> performing a Base64 decoding. + * + * @author Patrick Peck + * @version $Id$ + */ +public interface Base64Transform extends Transform { + /** Algorithm URI of the Base64 <code>Transform</code> type. */ + public static final String BASE64_DECODING = + "http://www.w3.org/2000/09/xmldsig#base64"; +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/common/CanonicalizationTransform.java b/spss.server/src/at/gv/egovernment/moa/spss/api/common/CanonicalizationTransform.java new file mode 100644 index 000000000..352461e52 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/common/CanonicalizationTransform.java @@ -0,0 +1,17 @@ +package at.gv.egovernment.moa.spss.api.common; + +import at.gv.egovernment.moa.util.Constants; + +/** + * A canonicalization type of <code>Transform</code>. + * + * @author Patrick Peck + * @version $Id$ + */ +public interface CanonicalizationTransform extends Transform { + /** Algorithm URI of canonical XML. */ + public static final String CANONICAL_XML = Constants.C14N_URI; + /** Algorithm URI of canonical XML with comments. */ + public static final String CANONICAL_XML_WITH_COMMENTS = + Constants.C14N_WITH_COMMENTS_URI; +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/common/CheckResult.java b/spss.server/src/at/gv/egovernment/moa/spss/api/common/CheckResult.java new file mode 100644 index 000000000..974483d82 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/common/CheckResult.java @@ -0,0 +1,25 @@ +package at.gv.egovernment.moa.spss.api.common; + +import org.w3c.dom.NodeList; + +/** + * Object encapsulating the result of a signature verification. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface CheckResult { + /** + * Gets the result code. + * + * @return The result code. + */ + public int getCode(); + /** + * Gets descriptive information. + * + * @return Descriptive information. + */ + public NodeList getInfo(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/common/Content.java b/spss.server/src/at/gv/egovernment/moa/spss/api/common/Content.java new file mode 100644 index 000000000..173e9d395 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/common/Content.java @@ -0,0 +1,37 @@ +package at.gv.egovernment.moa.spss.api.common; + +/** + * Encapsulates content data. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface Content { + /** + * Indicates that this object contains a URI reference to some content. + */ + public static final int REFERENCE_CONTENT = 0; + /** + * Indicates that this object contains binary content. + */ + public static final int BINARY_CONTENT = 1; + /** + * Indicates that this object contains XML content. + */ + public static final int XML_CONTENT = 2; + + /** + * Gets the type of content contained in this object. + * + * @return The type of content, either <code>BINARY_CONTENT</code> or + * <code>XML_CONTENT</code> + */ + public int getContentType(); + /** + * Gets the reference to the content data (a URI). + * + * @return The reference to the content data. + */ + public String getReference(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/common/ContentBinary.java b/spss.server/src/at/gv/egovernment/moa/spss/api/common/ContentBinary.java new file mode 100644 index 000000000..664afa406 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/common/ContentBinary.java @@ -0,0 +1,21 @@ +package at.gv.egovernment.moa.spss.api.common; + +import java.io.InputStream; + +/** + * Encapsulates binary content. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface ContentBinary extends Content { + /** + * Get the binary content. + * + * @return An <code>InputStream</code> from which the binary content can + * be read. + */ + public InputStream getBinaryContent(); + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/common/ContentReference.java b/spss.server/src/at/gv/egovernment/moa/spss/api/common/ContentReference.java new file mode 100644 index 000000000..c10f0c2f8 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/common/ContentReference.java @@ -0,0 +1,11 @@ +package at.gv.egovernment.moa.spss.api.common; + +/** + * Content containing a reference to content data. + * + * @author Patrick Peck + * @version $Id$ + */ +public interface ContentReference extends Content { + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/common/ContentXML.java b/spss.server/src/at/gv/egovernment/moa/spss/api/common/ContentXML.java new file mode 100644 index 000000000..ad5930452 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/common/ContentXML.java @@ -0,0 +1,19 @@ +package at.gv.egovernment.moa.spss.api.common; + +import org.w3c.dom.NodeList; + +/** + * Encapsulates arbitrary XML content. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface ContentXML extends Content { + /** + * Gets the XML content stored in this object. + * + * @return The XML content. + */ + public NodeList getXMLContent(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/common/ElementSelector.java b/spss.server/src/at/gv/egovernment/moa/spss/api/common/ElementSelector.java new file mode 100644 index 000000000..862cb84da --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/common/ElementSelector.java @@ -0,0 +1,28 @@ +package at.gv.egovernment.moa.spss.api.common; + +import java.util.Map; + +/** + * A class containing data for selecting single elements using an XPath + * expression. + * + * Derived classes are used to point to the <code>CreateSignatureLocation</code> + * and the <code>VerifySignatureLocation</code>. + * + * @author Patrick Peck + * @version $Id$ + */ +public interface ElementSelector { + /** + * Gets the XPath expression pointing to a single element. + * + * @return The XPath expression to select the signature parent element. + */ + public String getXPathExpression(); + /** + * Gets the namespace prefix to URI mapping to use when evaluating the XPath. + * + * @return The namespace prefix to URI mapping. + */ + public Map getNamespaceDeclarations(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/common/EnvelopedSignatureTransform.java b/spss.server/src/at/gv/egovernment/moa/spss/api/common/EnvelopedSignatureTransform.java new file mode 100644 index 000000000..f951e35c0 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/common/EnvelopedSignatureTransform.java @@ -0,0 +1,15 @@ +package at.gv.egovernment.moa.spss.api.common; + +/** + * An enveloped signature type of <code>Transform</code>. + * + * @author Patrick Peck + * @version $Id$ + */ +public interface EnvelopedSignatureTransform extends Transform { + /** + * Algorithm URI of the enveloped signature type of <code>Transform</code>. + */ + public static final String ENVELOPED_SIGNATURE = + "http://www.w3.org/2000/09/xmldsig#enveloped-signature"; +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/common/ExclusiveCanonicalizationTransform.java b/spss.server/src/at/gv/egovernment/moa/spss/api/common/ExclusiveCanonicalizationTransform.java new file mode 100644 index 000000000..369270259 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/common/ExclusiveCanonicalizationTransform.java @@ -0,0 +1,27 @@ +package at.gv.egovernment.moa.spss.api.common; + +import java.util.List; + +import at.gv.egovernment.moa.util.Constants; + +/** + * An exclusive canonicalization type of <code>Transform</code>. + * + * @author Patrick Peck + * @version $Id$ + */ +public interface ExclusiveCanonicalizationTransform extends Transform { + /** Algorithm URI of exclusive canonical XML. */ + public static final String EXCLUSIVE_CANONICAL_XML = Constants.EXC_C14N_URI; + /** Algorithm URI of exclusive canonical XML with comments. */ + public static final String EXCLUSIVE_CANONICAL_XML_WITH_COMMENTS = + Constants.EXC_C14N_WITH_COMMENTS_URI; + + /** + * Sets the namespace prefixes that are handled in the same manner as in + * canonical XML. + * + * @return The inclusive namespace prefixes. + */ + public List getInclusiveNamespacePrefixes(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/common/MetaInfo.java b/spss.server/src/at/gv/egovernment/moa/spss/api/common/MetaInfo.java new file mode 100644 index 000000000..fea0a1b42 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/common/MetaInfo.java @@ -0,0 +1,31 @@ +package at.gv.egovernment.moa.spss.api.common; + +import org.w3c.dom.NodeList; + +/** + * Object encapsulating descriptive meta information. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface MetaInfo { + /** + * Gets the mime type of the associated object. + * + * @return The mimetype of the associated object. + */ + public String getMimeType(); + /** + * Gets the descriptive information (URI). + * + * @return URI referencing the descriptive information. + */ + public String getDescription(); + /** + * Gets the elemental informations. + * + * @return The elemental informations. + */ + public NodeList getAnyElements(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/common/SignerInfo.java b/spss.server/src/at/gv/egovernment/moa/spss/api/common/SignerInfo.java new file mode 100644 index 000000000..c3b4aaadc --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/common/SignerInfo.java @@ -0,0 +1,43 @@ +package at.gv.egovernment.moa.spss.api.common; + +import java.security.cert.X509Certificate; + + +/** + * Contains information about the signer. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface SignerInfo { + /** + * Gets the signer certificate. + * + * @return The signer certificate. + */ + public X509Certificate getSignerCertificate(); + /** + * Checks, whether the certificate contained in this object is qualified. + * + * @return <code>true</code>, if the certificate is qualified, otherwise + * <code>false</code>. + */ + public boolean isQualifiedCertificate(); + /** + * Checks, whether the certificate contained in this object is a + * public authority certificate. + * + * @return <code>true</code>, if the certificate is a public authority + * certificate, otherwise <code>false</code>. + */ + public boolean isPublicAuthority(); + /** + * Gets the public authority ID, if the certificate contained in this + * object is from a public authority. + * + * @return The public authority ID. + */ + public String getPublicAuhtorityID(); + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/common/Transform.java b/spss.server/src/at/gv/egovernment/moa/spss/api/common/Transform.java new file mode 100644 index 000000000..49a4e7c35 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/common/Transform.java @@ -0,0 +1,16 @@ +package at.gv.egovernment.moa.spss.api.common; + +/** + * Base class for XMLDsig <code>Transform</code> elements. + * + * @author Patrick Peck + * @version $Id$ + */ +public interface Transform { + /** + * Gets the algorithm URI of this <code>Transform</code>. + * + * @return The algorithm URI of this <code>Transform</code>. + */ + public String getAlgorithmURI(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/common/X509IssuerSerial.java b/spss.server/src/at/gv/egovernment/moa/spss/api/common/X509IssuerSerial.java new file mode 100644 index 000000000..d2ea88968 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/common/X509IssuerSerial.java @@ -0,0 +1,25 @@ +package at.gv.egovernment.moa.spss.api.common; + +import java.math.BigInteger; + +/** + * Contains an X.509 issuer distinguished name/serial number pair. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface X509IssuerSerial { + /** + * Gets the issuer distinguished name. + * + * @return The issuer distinguished name. + */ + public String getX509IssuerName(); + /** + * Gets the issuer serial number. + * + * @return The issuer serial number. + */ + public BigInteger getX509SerialNumber(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/common/XMLDataObjectAssociation.java b/spss.server/src/at/gv/egovernment/moa/spss/api/common/XMLDataObjectAssociation.java new file mode 100644 index 000000000..e1e034222 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/common/XMLDataObjectAssociation.java @@ -0,0 +1,25 @@ +package at.gv.egovernment.moa.spss.api.common; + + +/** + * Object encapsulating arbitrary content and optional descriptive meta + * information. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface XMLDataObjectAssociation { + /** + * Gets descriptive meta information. + * + * @return The descriptive meta information. + */ + public MetaInfo getMetaInfo(); + /** + * Gets the actual content. + * + * @return The content of this association. + */ + public Content getContent(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/common/XPathFilter.java b/spss.server/src/at/gv/egovernment/moa/spss/api/common/XPathFilter.java new file mode 100644 index 000000000..247776ce0 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/common/XPathFilter.java @@ -0,0 +1,38 @@ +package at.gv.egovernment.moa.spss.api.common; + +import java.util.Map; + +/** + * An XPath expression set operation. + * + * @author Patrick Peck + * @version $Id$ + */ +public interface XPathFilter { + /** Subtract this filter's node set from the resulting node set. */ + public static final String SUBTRACT_TYPE = "subtract"; + /** Intersect this filter's node set with the resulting node set. */ + public static final String INTERSECT_TYPE = "intersect"; + /** Compute the union of this filter's node set and the resulting node set. */ + public static final String UNION_TYPE = "union"; + + /** + * Gets the type of this <code>XPathFilter</code>. + * + * @return The type of this <code>XPathFilter</code>. + */ + public String getFilterType(); + /** + * Gets the XPath expression for selecting the nodes. + * + * @return The XPath expression for selecting the nodes. + */ + public String getXPathExpression(); + /** + * Gets The namespace prefix to URI mapping used during evaluation of the + * XPath expression. + * + * @return The namespace prefix to URI mapping. + */ + public Map getNamespaceDeclarations(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/common/XPathFilter2Transform.java b/spss.server/src/at/gv/egovernment/moa/spss/api/common/XPathFilter2Transform.java new file mode 100644 index 000000000..335d37dbf --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/common/XPathFilter2Transform.java @@ -0,0 +1,25 @@ +package at.gv.egovernment.moa.spss.api.common; + +import java.util.List; + +/** + * An XPath type of <code>Transform</code> containing multiple filters for + * performing set operations on XPath selections. + * + * @author Patrick Peck + * @version $Id$ + */ +public interface XPathFilter2Transform extends Transform { + /** Algorithm URI for the XPath Filter2 <code>Transform</code>. */ + public static final String XPATH_FILTER2 = + "http://www.w3.org/2002/06/xmldsig-filter2"; + + /** + * Gets the <code>XPathFilter</code>s contained in this + * <code>XPathFilter2Transform</code>. + * + * @return The <code>XPathFilter</code>s. + */ + public List getFilters(); + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/common/XPathTransform.java b/spss.server/src/at/gv/egovernment/moa/spss/api/common/XPathTransform.java new file mode 100644 index 000000000..f1cc1a2bc --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/common/XPathTransform.java @@ -0,0 +1,30 @@ +package at.gv.egovernment.moa.spss.api.common; + +import java.util.Map; + +/** + * A <code>Transform</code> performing an XPath selection. + * + * @author Patrick Peck + * @version $Id$ + */ +public interface XPathTransform extends Transform { + /** Algorithm URI of the XPath <code>Transform</code>. */ + public static final String XPATH = + "http://www.w3.org/TR/1999/REC-xpath-19991116"; + + /** + * Gets the XPath expression used for selection. + * + * @return The XPath expression used for selection. + */ + public String getXPathExpression(); + /** + * Gets The namespace prefix to URI mapping used during evaluation of the + * XPath expression. + * + * @return The namespace prefix to URI mapping. + */ + public Map getNamespaceDeclarations(); + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/common/XSLTTransform.java b/spss.server/src/at/gv/egovernment/moa/spss/api/common/XSLTTransform.java new file mode 100644 index 000000000..7f44bb060 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/common/XSLTTransform.java @@ -0,0 +1,23 @@ +package at.gv.egovernment.moa.spss.api.common; + +import org.w3c.dom.Element; + +/** + * A <code>Transform</code> containing an XSLT stylesheet. + * + * @author Patrick Peck + * @version $Id$ + */ +public interface XSLTTransform extends Transform { + /** Algorithm URI for the XSLT type of <code>Transform</code>. */ + public static final String XSLT = + "http://www.w3.org/TR/1999/REC-xslt-19991116"; + + /** + * Gets the XSLT stylesheet element used for the transformation. + * + * @return The XSLT stylesheet element used for the transformation. + */ + public Element getStylesheet(); + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/Base64TransformImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/Base64TransformImpl.java new file mode 100644 index 000000000..4af075da2 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/Base64TransformImpl.java @@ -0,0 +1,22 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import at.gv.egovernment.moa.spss.api.common.Base64Transform; + +/** + * Default implementation of <code>Base64Transform</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class Base64TransformImpl + extends TransformImpl + implements Base64Transform { + + /** + * Create a new <code>Base64TransformImpl</code> object. + */ + public Base64TransformImpl() { + setAlgorithmURI(BASE64_DECODING); + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CMSContentExplicitImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CMSContentExplicitImpl.java new file mode 100644 index 000000000..dd700cf21 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CMSContentExplicitImpl.java @@ -0,0 +1,40 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import java.io.InputStream; + +import at.gv.egovernment.moa.spss.api.cmsverify.CMSContentExcplicit; + +/** + * Default implementation of <code>CMSContentExplicit</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class CMSContentExplicitImpl implements CMSContentExcplicit { + + /** The binary content, as a stream. */ + private InputStream binaryContent; + + /** + * Sets the binary content as a stream. + * + * @param content The binary content as a stream. + */ + public void setBinaryContent(InputStream content) { + this.binaryContent = content; + } + + public InputStream getBinaryContent() { + return binaryContent; + } + + /** + * Gets the type of content. + * + * @return EXPLICIT_CONTENT + */ + public int getContentType() { + return EXPLICIT_CONTENT; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CMSContentReferenceImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CMSContentReferenceImpl.java new file mode 100644 index 000000000..f9c080a0d --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CMSContentReferenceImpl.java @@ -0,0 +1,38 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import at.gv.egovernment.moa.spss.api.cmsverify.CMSContentReference; + +/** + * Default implementation of <code>CMSContentReference</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class CMSContentReferenceImpl implements CMSContentReference { + + /** The reference pointing to the actual data. */ + private String reference; + + /** + * Sets the reference URI. + * + * @param referenceURI The URI pointing to the content data. + */ + public void setReference(String referenceURI) { + this.reference = referenceURI; + } + + public String getReference() { + return reference; + } + + /** + * Gets the content type. + * + * @return REFERENCE_CONTENT + */ + public int getContentType() { + return REFERENCE_CONTENT; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CMSDataObjectImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CMSDataObjectImpl.java new file mode 100644 index 000000000..6eec4e847 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CMSDataObjectImpl.java @@ -0,0 +1,46 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import at.gv.egovernment.moa.spss.api.cmsverify.CMSContent; +import at.gv.egovernment.moa.spss.api.cmsverify.CMSDataObject; +import at.gv.egovernment.moa.spss.api.common.MetaInfo; + +/** + * Default implementation of <code>CMLSDataObject</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class CMSDataObjectImpl implements CMSDataObject { + + /** The <code>MetaInfo</code> associated with the CMS data object. */ + private MetaInfo metaInfo; + /** The <code>CMSContent</code> contained in this data object. */ + private CMSContent cmsContent; + + /** + * Sets the meta information associated with the CMS data object. + * + * @param metaInfo The meta information. + */ + public void setMetaInfo(MetaInfo metaInfo) { + this.metaInfo = metaInfo; + } + + public MetaInfo getMetaInfo() { + return metaInfo; + } + + /** + * Sets the data of this <code>CMSDataObject</code>. + * + * @param cmsContent The actual data of this <code>CMSDataObject</code>. + */ + public void setContent(CMSContent cmsContent) { + this.cmsContent = cmsContent; + } + + public CMSContent getContent() { + return cmsContent; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CanonicalizationTransformImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CanonicalizationTransformImpl.java new file mode 100644 index 000000000..cf446d1b4 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CanonicalizationTransformImpl.java @@ -0,0 +1,25 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import at.gv.egovernment.moa.spss.api.common.CanonicalizationTransform; + +/** + * Default implementation of <code>CanonicalizationTransform</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class CanonicalizationTransformImpl + extends TransformImpl + implements CanonicalizationTransform { + + /** + * Create a new <code>CanonicalizationTransformImpl</code> object. + * + * @param algorithmURI Algorithm URI of the canonicalization + * <code>Transform</code> type. + */ + public CanonicalizationTransformImpl(String algorithmURI) { + setAlgorithmURI(algorithmURI); + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CheckResultImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CheckResultImpl.java new file mode 100644 index 000000000..2acb12e51 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CheckResultImpl.java @@ -0,0 +1,52 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import org.w3c.dom.NodeList; + +import at.gv.egovernment.moa.spss.api.common.CheckResult; + +/** + * Default implementation of <code>CheckResult</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class CheckResultImpl implements CheckResult { + /** The result code. */ + private int code; + + /** Additional information. */ + private NodeList info; + + /** + * Sets a result code. + * + * @param code The result code. + */ + public void setCode(int code) { + this.code = code; + } + + /** + * @see at.gv.egovernment.moa.spss.api.CheckResult#getCode() + */ + public int getCode() { + return code; + } + + /** + * Sets a descriptive information. + * + * @param info The descriptive information. + */ + public void setInfo(NodeList info) { + this.info = info; + } + + /** + * @see at.gv.egovernment.moa.spss.api.CheckResult#getInfo() + */ + public NodeList getInfo() { + return info; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ContentBinaryImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ContentBinaryImpl.java new file mode 100644 index 000000000..bbed6bf8b --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ContentBinaryImpl.java @@ -0,0 +1,40 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import java.io.InputStream; + +import at.gv.egovernment.moa.spss.api.common.ContentBinary; + +/** + * Default implementation of <code>ContentBinary</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class ContentBinaryImpl extends ContentImpl implements ContentBinary { + + /** The binary content as a stream. */ + private InputStream binaryContent; + + /** + * Sets the binary content as a stream. + * + * @param binaryContent The binary content as a stream. + */ + public void setBinaryContent(InputStream binaryContent) { + this.binaryContent = binaryContent; + } + + public InputStream getBinaryContent() { + return binaryContent; + } + + /** + * Gets the type of content. + * + * @return BINARY_CONTENT + */ + public int getContentType() { + return BINARY_CONTENT; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ContentImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ContentImpl.java new file mode 100644 index 000000000..7f331d2cd --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ContentImpl.java @@ -0,0 +1,28 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import at.gv.egovernment.moa.spss.api.common.Content; + +/** + * Default base class for <code>Content</code> implementations. + * + * @author Patrick Peck + * @version $Id$ + */ +public abstract class ContentImpl implements Content { + /** The reference pointing to the content data. */ + private String reference; + + /** + * Sets the reference pointing to the content data. + * + * @param referenceURI The URI of the content data. + */ + public void setReference(String referenceURI) { + this.reference = referenceURI; + } + + public String getReference() { + return reference; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ContentReferenceImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ContentReferenceImpl.java new file mode 100644 index 000000000..50609aa0e --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ContentReferenceImpl.java @@ -0,0 +1,24 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import at.gv.egovernment.moa.spss.api.common.ContentReference; + +/** + * Default implementation of <code>ContentReference</code>. + * + * @author Patrick Peck + * @version $Id$ + */ +public class ContentReferenceImpl + extends ContentImpl + implements ContentReference { + + /** + * Gets the type of content. + * + * @return REFERENCE_CONTENT + */ + public int getContentType() { + return REFERENCE_CONTENT; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ContentXMLImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ContentXMLImpl.java new file mode 100644 index 000000000..c03f5edde --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ContentXMLImpl.java @@ -0,0 +1,40 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import org.w3c.dom.NodeList; + +import at.gv.egovernment.moa.spss.api.common.ContentXML; + +/** + * Default implementation of <code>ContentXML</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class ContentXMLImpl extends ContentImpl implements ContentXML { + + /** The nodes making up the XML content. */ + private NodeList xmlContent; + + /** + * Sets the nodes making up the XML content. + * + * @param xmlContent The XML content. + */ + public void setXMLContent(NodeList xmlContent) { + this.xmlContent = xmlContent; + } + + public NodeList getXMLContent() { + return xmlContent; + } + + /** + * Gets the type of content. + * + * @return XML_CONTENT + */ + public int getContentType() { + return XML_CONTENT; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CreateSignatureEnvironmentProfileExplicitImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CreateSignatureEnvironmentProfileExplicitImpl.java new file mode 100644 index 000000000..22e4cd61d --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CreateSignatureEnvironmentProfileExplicitImpl.java @@ -0,0 +1,66 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import at.gv.egovernment.moa.spss.api.xmlsign.CreateSignatureEnvironmentProfileExplicit; +import at.gv.egovernment.moa.spss.api.xmlsign.CreateSignatureLocation; + +/** + * Default implementation of + * <codeCreateSignatureEnvironmentProfileExplicit</code>. + * + * @author Patrick Peck + * @version $Id$ + */ +public class CreateSignatureEnvironmentProfileExplicitImpl + implements CreateSignatureEnvironmentProfileExplicit { + + /** The insertion location of the signature to be created. */ + private CreateSignatureLocation createSignatureLocation; + + /** Supplemental information for evaluating the signature environment. */ + private List supplements; + + /** + * Sets the insertion location of the signature to be created. + * + * @param createSignatureLocation The insertion location of the signature to + * be created. + */ + public void setCreateSignatureLocation(CreateSignatureLocation createSignatureLocation) { + this.createSignatureLocation = createSignatureLocation; + } + + public CreateSignatureLocation getCreateSignatureLocation() { + return createSignatureLocation; + } + + /** + * Sets the supplemental information for evaluating the signature + * environment. + * + * @param supplements The supplemental information. + */ + public void setSupplements(List supplements) { + this.supplements = + supplements != null + ? Collections.unmodifiableList(new ArrayList(supplements)) + : null; + } + + public List getSupplements() { + return supplements; + } + + /** + * Gets the type of profile. + * + * @return EXPLICIT_CREATESIGNATUREENVIRONMENTPROFILE + */ + public int getCreateSignatureEnvironmentProfileType() { + return EXPLICIT_CREATESIGNATUREENVIRONMENTPROFILE; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CreateSignatureEnvironmentProfileIDImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CreateSignatureEnvironmentProfileIDImpl.java new file mode 100644 index 000000000..1c7dc6439 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CreateSignatureEnvironmentProfileIDImpl.java @@ -0,0 +1,39 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import at.gv.egovernment.moa.spss.api.xmlsign.CreateSignatureEnvironmentProfileID; + +/** + * Default implementation of <code>CreateSignatureEnvironmentProfileID</code>. + * + * @author Patrick Peck + * @version $Id$ + */ +public class CreateSignatureEnvironmentProfileIDImpl + implements CreateSignatureEnvironmentProfileID { + + /** The profile ID. */ + private String createSignatureEnvironmentProfileID; + + /** + * Sets the profile ID. + * + * @param profileID The profile ID. + */ + public void setCreateSignatureEnvironmentProfileID(String profileID) { + this.createSignatureEnvironmentProfileID = profileID; + } + + public String getCreateSignatureEnvironmentProfileID() { + return createSignatureEnvironmentProfileID; + } + + /** + * Gets the type of profile. + * + * @return ID_CREATESIGNATUREENVIRONMENTPROFILE + */ + public int getCreateSignatureEnvironmentProfileType() { + return ID_CREATESIGNATUREENVIRONMENTPROFILE; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CreateSignatureInfoImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CreateSignatureInfoImpl.java new file mode 100644 index 000000000..097af7fff --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CreateSignatureInfoImpl.java @@ -0,0 +1,50 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import at.gv.egovernment.moa.spss.api.common.Content; +import at.gv.egovernment.moa.spss.api.xmlsign.CreateSignatureEnvironmentProfile; +import at.gv.egovernment.moa.spss.api.xmlsign.CreateSignatureInfo; + +/** + * Default implementation of <code>CreateSignatureInfo</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class CreateSignatureInfoImpl implements CreateSignatureInfo { + + /** The signature environment that will contain the newly created + * signature. */ + private Content createSignatureEnvironment; + + /** Additional information about the signature environment. */ + private CreateSignatureEnvironmentProfile createSignatureEnvironmentProfile; + + /** + * Sets the signature environment that will contain the newly created + * signature. + * + * @param createSignatureEnvironment The signature environment. + */ + public void setCreateSignatureEnvironment(Content createSignatureEnvironment) { + this.createSignatureEnvironment = createSignatureEnvironment; + } + + public Content getCreateSignatureEnvironment() { + return createSignatureEnvironment; + } + + /** + * Sets the signature environment profile containing additional information + * about the signature environment. + * + * @param profile The signature environment profile. + */ + public void setCreateSignatureEnvironmentProfile(CreateSignatureEnvironmentProfile profile) { + this.createSignatureEnvironmentProfile = profile; + } + + public CreateSignatureEnvironmentProfile getCreateSignatureEnvironmentProfile() { + return createSignatureEnvironmentProfile; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CreateSignatureLocationImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CreateSignatureLocationImpl.java new file mode 100644 index 000000000..c0b36f505 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CreateSignatureLocationImpl.java @@ -0,0 +1,31 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import at.gv.egovernment.moa.spss.api.xmlsign.CreateSignatureLocation; + +/** + * Default implementation of <code>CreateSignatureLocation</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class CreateSignatureLocationImpl + extends ElementSelectorImpl + implements CreateSignatureLocation { + + /** The index of the newly created signature. */ + private int index; + + /** + * Sets the index of the newly created signature. + * + * @param index The index of the newly created signature. + */ + public void setIndex(int index) { + this.index = index; + } + + public int getIndex() { + return index; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CreateTransformsInfoImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CreateTransformsInfoImpl.java new file mode 100644 index 000000000..ff4108248 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CreateTransformsInfoImpl.java @@ -0,0 +1,51 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import at.gv.egovernment.moa.spss.api.common.MetaInfo; +import at.gv.egovernment.moa.spss.api.xmlsign.CreateTransformsInfo; + +/** + * Default implementation of <code>CreateTransformsInfo</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class CreateTransformsInfoImpl implements CreateTransformsInfo { + /** The dsig:Transforms. */ + private List transforms; + /** Meta information about the data resulting from the transforms. */ + private MetaInfo finalDataMetaInfo; + + /** + * Sets the transforms. + * + * @param transforms The transforms. + */ + public void setTransforms(List transforms) { + this.transforms = + transforms != null + ? Collections.unmodifiableList(new ArrayList(transforms)) + : null; + } + + public List getTransforms() { + return transforms; + } + + /** + * Sets the meta information about the data resulting from the transforms. + * + * @param finalDataMetaInfo The meta information. + */ + public void setFinalDataMetaInfo(MetaInfo finalDataMetaInfo) { + this.finalDataMetaInfo = finalDataMetaInfo; + } + + public MetaInfo getFinalDataMetaInfo() { + return finalDataMetaInfo; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CreateTransformsInfoProfileExplicitImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CreateTransformsInfoProfileExplicitImpl.java new file mode 100644 index 000000000..508b6c083 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CreateTransformsInfoProfileExplicitImpl.java @@ -0,0 +1,62 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import at.gv.egovernment.moa.spss.api.xmlsign.CreateTransformsInfo; +import at.gv.egovernment.moa.spss.api.xmlsign.CreateTransformsInfoProfileExplicit; + +/** + * Default implementation of <code>CreateTransformsInfoProfileExplicit</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class CreateTransformsInfoProfileExplicitImpl + implements CreateTransformsInfoProfileExplicit { + + /** Transformation information. */ + private CreateTransformsInfo transformsInfo; + /** Additional data for the transformations. */ + private List supplements = new ArrayList(); + + /** + * Sets the transformation information. + * + * @param transformsInfo The transformation information. + */ + public void setCreateTransformsInfo(CreateTransformsInfo transformsInfo) { + this.transformsInfo = transformsInfo; + } + + public CreateTransformsInfo getCreateTransformsInfo() { + return transformsInfo; + } + + /** + * Sets the additional data for the transformations. + * + * @param supplements The additional data. + */ + public void setSupplements(List supplements) { + this.supplements = + supplements != null + ? Collections.unmodifiableList(new ArrayList(supplements)) + : null; + } + + public List getSupplements() { + return supplements; + } + + /** + * Gets the type of profile. + * + * @return EXPLICIT_CREATETRANSFORMSINFOPROFILE + */ + public int getCreateTransformsInfoProfileType() { + return EXPLICIT_CREATETRANSFORMSINFOPROFILE; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CreateTransformsInfoProfileIDImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CreateTransformsInfoProfileIDImpl.java new file mode 100644 index 000000000..5cd1fcc48 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CreateTransformsInfoProfileIDImpl.java @@ -0,0 +1,38 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import at.gv.egovernment.moa.spss.api.xmlsign.CreateTransformsInfoProfileID; + +/** + * Default implementation of <code>CreateTransformsInfoProfileID</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class CreateTransformsInfoProfileIDImpl + implements CreateTransformsInfoProfileID { + + /** The profile ID. */ + private String createTransformsID; + + /** + * Sets the profile ID. + * @param createTransformsID The profile ID. + */ + public void setCreateTransformsInfoProfileID(String createTransformsID) { + this.createTransformsID = createTransformsID; + } + + public String getCreateTransformsInfoProfileID() { + return createTransformsID; + } + + /** + * Gets the type of profile. + * + * @return ID_CREATETRANSFORMSINFOPROFILE + */ + public int getCreateTransformsInfoProfileType() { + return ID_CREATETRANSFORMSINFOPROFILE; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CreateXMLSignatureRequestImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CreateXMLSignatureRequestImpl.java new file mode 100644 index 000000000..08f94cc31 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CreateXMLSignatureRequestImpl.java @@ -0,0 +1,53 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import at.gv.egovernment.moa.spss.api.xmlsign.CreateXMLSignatureRequest; + +/** + * Default implementation of <code>CreateXMLSignatureRequest</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class CreateXMLSignatureRequestImpl + implements CreateXMLSignatureRequest { + + /** The identifier for selecting the private keys for creating the signature.*/ + private String keyIdentifier; + /** Information for creating a single signature. */ + private List singleSignatureInfos = new ArrayList(); + + /** + * Sets the identifier for selecting the private keys for creating the + * signature. + * + * @param keyIdentifier The identifier for selecting the private keys. + */ + public void setKeyIdentifier(String keyIdentifier) { + this.keyIdentifier = keyIdentifier; + } + + public String getKeyIdentifier() { + return keyIdentifier; + } + + /** + * Sets the information for creating single signatures. + * + * @param singleSignaureInfos The information for creating single signatures. + */ + public void setSingleSignatureInfos(List singleSignaureInfos) { + this.singleSignatureInfos = + singleSignaureInfos != null + ? Collections.unmodifiableList(new ArrayList(singleSignaureInfos)) + : null; + } + + public List getSingleSignatureInfos() { + return singleSignatureInfos; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CreateXMLSignatureResponseImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CreateXMLSignatureResponseImpl.java new file mode 100644 index 000000000..590258e30 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/CreateXMLSignatureResponseImpl.java @@ -0,0 +1,37 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import at.gv.egovernment.moa.spss.api.xmlsign.CreateXMLSignatureResponse; + +/** + * Default implementation of <code>CreateXMLSignatureResponse</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class CreateXMLSignatureResponseImpl + implements CreateXMLSignatureResponse { + + /** The elements contained in the response. */ + private List responseElements = new ArrayList(); + + /** + * Sets the elements contained in the response. + * + * @param responseElements The response elements. + */ + public void setResponseElements(List responseElements) { + this.responseElements = + responseElements != null + ? Collections.unmodifiableList(new ArrayList(responseElements)) + : null; + } + + public List getResponseElements() { + return responseElements; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/DataObjectInfoImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/DataObjectInfoImpl.java new file mode 100644 index 000000000..8ab2241de --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/DataObjectInfoImpl.java @@ -0,0 +1,79 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import at.gv.egovernment.moa.spss.api.common.Content; +import at.gv.egovernment.moa.spss.api.xmlsign.CreateTransformsInfoProfile; +import at.gv.egovernment.moa.spss.api.xmlsign.DataObjectInfo; + +/** + * Default implementation of <code>DataObjectInfo</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class DataObjectInfoImpl implements DataObjectInfo { + /** The signature structure type. */ + private String stucture; + /** Whether a reference will be placed in the signature itself or in the + * manifest */ + private boolean childOfManifest; + /** The data object to be signed. */ + private Content dataObject; + /** The profile containing additional information for the transformations. */ + private CreateTransformsInfoProfile createTransformsInfoProfile; + + /** + * Sets the signature structure type. + * + * @param structure The signature structure type. + */ + public void setStructure(String structure) { + this.stucture = structure; + } + + public String getStructure() { + return stucture; + } + + /** + * Sets whether a reference will be placed in the signature itself or in the + * manifest. + * + * @param childOfManifest Whether to put the reference in the signature of + * in the manifest. + */ + public void setChildOfManifest(boolean childOfManifest) { + this.childOfManifest = childOfManifest; + } + + public boolean isChildOfManifest() { + return childOfManifest; + } + + /** + * Sets the data object to be signed. + * + * @param dataObject The data object to be signed. + */ + public void setDataObject(Content dataObject) { + this.dataObject = dataObject; + } + + public Content getDataObject() { + return dataObject; + } + + /** + * Sets additional information for the transformations. + * + * @param profile The profile containing additional information for the + * transformations. + */ + public void setCreateTransformsInfoProfile(CreateTransformsInfoProfile profile) { + this.createTransformsInfoProfile = profile; + } + + public CreateTransformsInfoProfile getCreateTransformsInfoProfile() { + return createTransformsInfoProfile; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ElementSelectorImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ElementSelectorImpl.java new file mode 100644 index 000000000..e460bd584 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ElementSelectorImpl.java @@ -0,0 +1,47 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import java.util.HashMap; +import java.util.Map; + +import at.gv.egovernment.moa.spss.api.common.ElementSelector; + +/** + * Default implementation of <code>ElementSelector</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class ElementSelectorImpl implements ElementSelector { + /** The XPath expression pointing to the element. */ + private String xPathExpression; + /** The namespace declarations to apply for evaluating the XPath */ + private Map namespaceDeclarations = new HashMap(); + + /** + * Sets the XPath expression pointing to the element. + * + * @param xPathExpression XPath expression pointing to the element. + */ + public void setXPathExpression(String xPathExpression) { + this.xPathExpression = xPathExpression; + } + + public String getXPathExpression() { + return xPathExpression; + } + + /** + * Sets namespace declarations to apply for evaluating the XPath. + * + * @param namespaceDeclarations The namespace declarations to apply for + * evaluating the XPath. + */ + public void setNamespaceDeclarations(Map namespaceDeclarations) { + this.namespaceDeclarations = namespaceDeclarations; + } + + public Map getNamespaceDeclarations() { + return namespaceDeclarations; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/EnvelopedSignatureTransformImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/EnvelopedSignatureTransformImpl.java new file mode 100644 index 000000000..a1be3d86a --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/EnvelopedSignatureTransformImpl.java @@ -0,0 +1,22 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import at.gv.egovernment.moa.spss.api.common.EnvelopedSignatureTransform; + +/** + * Default implementation of <code>EnvelopedSignatureTransform</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class EnvelopedSignatureTransformImpl + extends TransformImpl + implements EnvelopedSignatureTransform { + + /** + * Create a <code>EnvelopedSignatureTransformImpl</code>. + */ + public EnvelopedSignatureTransformImpl() { + setAlgorithmURI(ENVELOPED_SIGNATURE); + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ErrorResponseImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ErrorResponseImpl.java new file mode 100644 index 000000000..d7047ab44 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ErrorResponseImpl.java @@ -0,0 +1,52 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import at.gv.egovernment.moa.spss.api.xmlsign.ErrorResponse; + +/** + * Default implementation of <code>ErrorResponse</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class ErrorResponseImpl implements ErrorResponse { + /** The error code. */ + private int code; + /** Verbose error message. */ + private String info; + + /** + * Sets the error code. + * + * @param code The error code. + */ + public void setErrorCode(int code) { + this.code = code; + } + + public int getErrorCode() { + return code; + } + + /** + * Sets the verbose error information. + * + * @param info The verbose error information. + */ + public void setInfo(String info) { + this.info = info; + } + + public String getInfo() { + return info; + } + + /** + * Gets the response type. + * + * @return ERROR_RESPONSE + */ + public int getResponseType() { + return ERROR_RESPONSE; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ExclusiveCanonicalizationTransformImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ExclusiveCanonicalizationTransformImpl.java new file mode 100644 index 000000000..bf21c8634 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ExclusiveCanonicalizationTransformImpl.java @@ -0,0 +1,48 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import at.gv.egovernment.moa.spss.api.common.ExclusiveCanonicalizationTransform; + +/** + * Default implementation of <code>ExclusiveCanonicalizationTransform</code>. + * + * @author Patrick Peck + * @version $Id$ + */ +public class ExclusiveCanonicalizationTransformImpl + extends TransformImpl + implements ExclusiveCanonicalizationTransform { + + /** The namespaces to treat according to canonical XML. */ + private List inclusiveNamespacePrefixes; + + /** + * Create a <code>ExclusiveCanonicalizationTransformImpl</code> object. + * + * @param algorithmURI The algorithm URI identifying the transformation + * algorithm. + */ + public ExclusiveCanonicalizationTransformImpl(String algorithmURI) { + setAlgorithmURI(algorithmURI); + } + + /** + * Sets the namespaces to treat according to canonical XML. + * @param inclusiveNamespacePrefixes The namespaces to treat according to + * canonical XML. + */ + public void setInclusiveNamespacePrefixes(List inclusiveNamespacePrefixes) { + this.inclusiveNamespacePrefixes = + inclusiveNamespacePrefixes != null + ? Collections.unmodifiableList(new ArrayList(inclusiveNamespacePrefixes)) + : null; + } + + public List getInclusiveNamespacePrefixes() { + return inclusiveNamespacePrefixes; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ManifestRefsCheckResultImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ManifestRefsCheckResultImpl.java new file mode 100644 index 000000000..9174e3a46 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ManifestRefsCheckResultImpl.java @@ -0,0 +1,44 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import at.gv.egovernment.moa.spss.api.xmlverify.ManifestRefsCheckResult; +import at.gv.egovernment.moa.spss.api.xmlverify.ManifestRefsCheckResultInfo; + +/** + * Default implementation of <code>ManifestRefsCheckResult</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class ManifestRefsCheckResultImpl implements ManifestRefsCheckResult { + /** The numerical check code. */ + private int code; + /** Additional information about the check. */ + private ManifestRefsCheckResultInfo info; + + /** + * Sets the check code. + * + * @param code A numerical representation of the result of the manifest check. + */ + public void setCode(int code) { + this.code = code; + } + + public int getCode() { + return code; + } + + /** + * Sets a reference to the manifest. + * + * @param info The reference to the manifest. + */ + public void setInfo(ManifestRefsCheckResultInfo info) { + this.info = info; + } + + public ManifestRefsCheckResultInfo getInfo() { + return info; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ManifestRefsCheckResultInfoImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ManifestRefsCheckResultInfoImpl.java new file mode 100644 index 000000000..0071a14f3 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ManifestRefsCheckResultInfoImpl.java @@ -0,0 +1,32 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import at.gv.egovernment.moa.spss.api.xmlverify.ManifestRefsCheckResultInfo; + +/** + * Default implementation of <code>ManifestRefsCheckResultInfo</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class ManifestRefsCheckResultInfoImpl + extends ReferencesCheckResultInfoImpl + implements ManifestRefsCheckResultInfo { + + /** The position of the signature reference containing the reference to the + * manifest being described by this object.*/ + private int referringSignatureReference; + + /** + * Sets the position of the signature reference containing the reference to + * the manifest being described by this object. + * @param referringSignatureReference The position of the signature reference. + */ + public void setReferringSignatureReference(int referringSignatureReference) { + this.referringSignatureReference = referringSignatureReference; + } + + public int getReferringSignatureReference() { + return referringSignatureReference; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/MetaInfoImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/MetaInfoImpl.java new file mode 100644 index 000000000..c435dd8fd --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/MetaInfoImpl.java @@ -0,0 +1,59 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import org.w3c.dom.NodeList; + +import at.gv.egovernment.moa.spss.api.common.MetaInfo; + +/** + * Default implementation of <code>MetaInfo</code>. + * @author Fatemeh Philippi + * @version $Id$ + */ +public class MetaInfoImpl implements MetaInfo { + /** Information about the MIME type. */ + private String mimeType; + /** URI pointing to a description of the content. */ + private String description; + /** Descriptive XML content. */ + private NodeList anyElements; + + /** + * Sets the MIME type. + * + * @param mimeType The MIME type to set. + */ + public void setMimeType(String mimeType) { + this.mimeType = mimeType; + } + + public String getMimeType() { + return mimeType; + } + + /** + * Sets the URI pointing to a description of the content. + * + * @param description The URI pointing to a description of the content. + */ + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return description; + } + + /** + * Sets descriptive XML content. + * + * @param anyElements The elements to set. + */ + public void setAnyElements(NodeList anyElements) { + this.anyElements = anyElements; + } + + public NodeList getAnyElements() { + return anyElements; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ReferenceInfoImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ReferenceInfoImpl.java new file mode 100644 index 000000000..923a4bce1 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ReferenceInfoImpl.java @@ -0,0 +1,38 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import at.gv.egovernment.moa.spss.api.xmlverify.ReferenceInfo; + +/** + * Default implementation of <code>ReferenceInfo</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class ReferenceInfoImpl implements ReferenceInfo { + /** Profile containing the transforms allowed in the signature. */ + private List verifyTransformsInfoProfiles; + + /** + * Sets the transforms profile used for verifying the transforms contained + * in the signature. + * + * @param verifyTransformsInfoProfiles The profiles containing the transforms + * allowed in the signature. + */ + public void setVerifyTransformsInfoProfiles(List verifyTransformsInfoProfiles) { + this.verifyTransformsInfoProfiles = + verifyTransformsInfoProfiles != null + ? Collections.unmodifiableList( + new ArrayList(verifyTransformsInfoProfiles)) + : null; + } + + public List getVerifyTransformsInfoProfiles() { + return verifyTransformsInfoProfiles; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ReferencesCheckResultImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ReferencesCheckResultImpl.java new file mode 100644 index 000000000..6bb4d30ac --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ReferencesCheckResultImpl.java @@ -0,0 +1,46 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import at.gv.egovernment.moa.spss.api.xmlverify.ReferencesCheckResult; +import at.gv.egovernment.moa.spss.api.xmlverify.ReferencesCheckResultInfo; + +/** + * Default implementation of <code>ReferencesCheckResult</code>. + * + * @author Patrick Peck + * @version $Id$ + */ +public class ReferencesCheckResultImpl implements ReferencesCheckResult { + /** The check code. */ + private int code; + /** Additional information about the reference check. */ + private ReferencesCheckResultInfo info; + + /** + * Sets the check code. + * + * @param code A numerical representation of the result of the reference + * check. + */ + public void setCode(int code) { + this.code = code; + } + + public int getCode() { + return code; + } + + /** + * Sets additional information about the reference check. + * + * @param manifestRefsCheckResultInfo Additional information about the + * reference check. + */ + public void setInfo(ReferencesCheckResultInfo manifestRefsCheckResultInfo) { + this.info = manifestRefsCheckResultInfo; + } + + public ReferencesCheckResultInfo getInfo() { + return info; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ReferencesCheckResultInfoImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ReferencesCheckResultInfoImpl.java new file mode 100644 index 000000000..a21b417ae --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ReferencesCheckResultInfoImpl.java @@ -0,0 +1,46 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import org.w3c.dom.NodeList; + +import at.gv.egovernment.moa.spss.api.xmlverify.ReferencesCheckResultInfo; + +/** + * Default implementation of <code>ReferencesCheckResultInfo</code>. + * + * @author Patrick Peck + * @version $Id$ + */ +public class ReferencesCheckResultInfoImpl + implements ReferencesCheckResultInfo { + + /** Additional information about the references check. */ + private NodeList anyOtherInfo; + /** The indexes of the failed references. */ + private int[] failedReferences = new int[0]; + + /** + * Sets additional information about the references check. + * @param anyOtherInfo Additional information about the references check. + */ + public void setAnyOtherInfo(NodeList anyOtherInfo) { + this.anyOtherInfo = anyOtherInfo; + } + + public NodeList getAnyOtherInfo() { + return anyOtherInfo; + } + + /** + * Sets the indexes of the failed references. + * + * @param failedReferences The indexes of the failed references. + */ + public void setFailedReferences(int[] failedReferences) { + this.failedReferences = failedReferences; + } + + public int[] getFailedReferences() { + return failedReferences; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/SPSSFactoryImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/SPSSFactoryImpl.java new file mode 100644 index 000000000..ab6240f79 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/SPSSFactoryImpl.java @@ -0,0 +1,559 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import java.io.InputStream; +import java.math.BigInteger; +import java.security.cert.X509Certificate; +import java.util.Date; +import java.util.List; +import java.util.Map; + +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; + +import at.gv.egovernment.moa.spss.api.SPSSFactory; +import at.gv.egovernment.moa.spss.api.cmsverify.CMSContent; +import at.gv.egovernment.moa.spss.api.cmsverify.CMSDataObject; +import at.gv.egovernment.moa.spss.api.cmsverify.VerifyCMSSignatureRequest; +import at.gv.egovernment.moa.spss.api.cmsverify.VerifyCMSSignatureResponse; +import at.gv.egovernment.moa.spss.api.cmsverify.VerifyCMSSignatureResponseElement; +import at.gv.egovernment.moa.spss.api.common.CheckResult; +import at.gv.egovernment.moa.spss.api.common.Content; +import at.gv.egovernment.moa.spss.api.common.MetaInfo; +import at.gv.egovernment.moa.spss.api.common.SignerInfo; +import at.gv.egovernment.moa.spss.api.common.Transform; +import at.gv.egovernment.moa.spss.api.common.X509IssuerSerial; +import at.gv.egovernment.moa.spss.api.common.XMLDataObjectAssociation; +import at.gv.egovernment.moa.spss.api.common.XPathFilter; +import at.gv.egovernment.moa.spss.api.xmlsign.CreateSignatureEnvironmentProfile; +import at.gv.egovernment.moa.spss.api.xmlsign.CreateSignatureInfo; +import at.gv.egovernment.moa.spss.api.xmlsign.CreateSignatureLocation; +import at.gv.egovernment.moa.spss.api.xmlsign.CreateTransformsInfo; +import at.gv.egovernment.moa.spss.api.xmlsign.CreateTransformsInfoProfile; +import at.gv.egovernment.moa.spss.api.xmlsign.CreateXMLSignatureRequest; +import at.gv.egovernment.moa.spss.api.xmlsign.CreateXMLSignatureResponse; +import at.gv.egovernment.moa.spss.api.xmlsign.DataObjectInfo; +import at.gv.egovernment.moa.spss.api.xmlsign.ErrorResponse; +import at.gv.egovernment.moa.spss.api.xmlsign.SignatureEnvironmentResponse; +import at.gv.egovernment.moa.spss.api.xmlsign.SingleSignatureInfo; +import at.gv.egovernment.moa.spss.api.xmlverify.ManifestRefsCheckResult; +import at.gv.egovernment.moa.spss.api.xmlverify.ManifestRefsCheckResultInfo; +import at.gv.egovernment.moa.spss.api.xmlverify.ReferenceInfo; +import at.gv.egovernment.moa.spss.api.xmlverify.ReferencesCheckResult; +import at.gv.egovernment.moa.spss.api.xmlverify.ReferencesCheckResultInfo; +import at.gv.egovernment.moa.spss.api.xmlverify.SignatureManifestCheckParams; +import at.gv.egovernment.moa.spss.api.xmlverify.SupplementProfile; +import at.gv.egovernment.moa.spss.api.xmlverify.TransformParameter; +import at.gv.egovernment.moa.spss.api.xmlverify.VerifySignatureInfo; +import at.gv.egovernment.moa.spss.api.xmlverify.VerifySignatureLocation; +import at.gv.egovernment.moa.spss.api.xmlverify.VerifyTransformsInfoProfile; +import at.gv.egovernment.moa.spss.api.xmlverify.VerifyXMLSignatureRequest; +import at.gv.egovernment.moa.spss.api.xmlverify.VerifyXMLSignatureResponse; + +/** + * Default implementation of <code>SPSSFactory</code>. + * + * @author Patrick Peck + * @version $Id$ + */ +public class SPSSFactoryImpl extends SPSSFactory { + + public CreateXMLSignatureRequest createCreateXMLSignatureRequest( + String keyIdentifier, + List singleSignatureInfos) { + CreateXMLSignatureRequestImpl createXMLSignatureRequest = + new CreateXMLSignatureRequestImpl(); + createXMLSignatureRequest.setKeyIdentifier(keyIdentifier); + createXMLSignatureRequest.setSingleSignatureInfos(singleSignatureInfos); + return createXMLSignatureRequest; + } + + public SingleSignatureInfo createSingleSignatureInfo( + List dataObjectInfos, + CreateSignatureInfo createSignatureInfo, + boolean securityLayerConform) { + SingleSignatureInfoImpl singleSignatureInfo = new SingleSignatureInfoImpl(); + singleSignatureInfo.setDataObjectInfos(dataObjectInfos); + singleSignatureInfo.setCreateSignatureInfo(createSignatureInfo); + singleSignatureInfo.setSecurityLayerConform(securityLayerConform); + return singleSignatureInfo; + } + public DataObjectInfo createDataObjectInfo( + String structure, + boolean childOfManifest, + Content dataObject, + CreateTransformsInfoProfile createTransformsInfoProfile) { + DataObjectInfoImpl dataObjectInfo = new DataObjectInfoImpl(); + dataObjectInfo.setStructure(structure); + dataObjectInfo.setChildOfManifest(childOfManifest); + dataObjectInfo.setDataObject(dataObject); + dataObjectInfo.setCreateTransformsInfoProfile(createTransformsInfoProfile); + return dataObjectInfo; + } + + public CreateTransformsInfoProfile createCreateTransformsInfoProfile(String profileID) { + + CreateTransformsInfoProfileIDImpl createTransformsInfoProfile = + new CreateTransformsInfoProfileIDImpl(); + createTransformsInfoProfile.setCreateTransformsInfoProfileID(profileID); + return createTransformsInfoProfile; + } + + public CreateTransformsInfoProfile createCreateTransformsInfoProfile( + CreateTransformsInfo transformsInfo, + List supplements) { + CreateTransformsInfoProfileExplicitImpl createTransformsInfoProfile = + new CreateTransformsInfoProfileExplicitImpl(); + createTransformsInfoProfile.setCreateTransformsInfo(transformsInfo); + createTransformsInfoProfile.setSupplements(supplements); + return createTransformsInfoProfile; + } + + public CreateTransformsInfo createCreateTransformsInfo( + List transforms, + MetaInfo finalDataMetaInfo) { + CreateTransformsInfoImpl createTransformsInfo = + new CreateTransformsInfoImpl(); + + createTransformsInfo.setTransforms(transforms); + createTransformsInfo.setFinalDataMetaInfo(finalDataMetaInfo); + return createTransformsInfo; + } + + public CreateSignatureInfo createCreateSignatureInfo( + Content createSignatureEnvironment, + CreateSignatureEnvironmentProfile createSignatureEnvironmentProfile) { + CreateSignatureInfoImpl createSignatureInfo = new CreateSignatureInfoImpl(); + createSignatureInfo.setCreateSignatureEnvironment( + createSignatureEnvironment); + createSignatureInfo.setCreateSignatureEnvironmentProfile( + createSignatureEnvironmentProfile); + return createSignatureInfo; + } + + public CreateSignatureEnvironmentProfile createCreateSignatureEnvironmentProfile( + CreateSignatureLocation createSignatureLocation, + List supplements) { + CreateSignatureEnvironmentProfileExplicitImpl createSignatureEnvironmentProfile = + new CreateSignatureEnvironmentProfileExplicitImpl(); + createSignatureEnvironmentProfile.setCreateSignatureLocation( + createSignatureLocation); + createSignatureEnvironmentProfile.setSupplements(supplements); + return createSignatureEnvironmentProfile; + } + + public CreateSignatureLocation createCreateSignatureLocation( + String signatureLocationXPath, + int signatureLocationIndex, + Map namespaceDeclarations) { + CreateSignatureLocationImpl createSignatureLocation = + new CreateSignatureLocationImpl(); + createSignatureLocation.setIndex(signatureLocationIndex); + createSignatureLocation.setNamespaceDeclarations(namespaceDeclarations); + createSignatureLocation.setXPathExpression(signatureLocationXPath); + return createSignatureLocation; + } + + public CreateSignatureEnvironmentProfile createCreateSignatureEnvironmentProfile(String profileID) { + CreateSignatureEnvironmentProfileIDImpl createSignatureEnvironmentProfile = + new CreateSignatureEnvironmentProfileIDImpl(); + createSignatureEnvironmentProfile.setCreateSignatureEnvironmentProfileID( + profileID); + return createSignatureEnvironmentProfile; + } + + public CreateXMLSignatureResponse createCreateXMLSignatureResponse(List responseElements) { + CreateXMLSignatureResponseImpl createXMLSignatureResponse = + new CreateXMLSignatureResponseImpl(); + createXMLSignatureResponse.setResponseElements(responseElements); + return createXMLSignatureResponse; + } + + public SignatureEnvironmentResponse createSignatureEnvironmentResponse(Element signatureEnvironment) { + SignatureEnvironmentResponseImpl signatureEnvironmentResponse = + new SignatureEnvironmentResponseImpl(); + signatureEnvironmentResponse.setSignatureEnvironment(signatureEnvironment); + return signatureEnvironmentResponse; + } + + public ErrorResponse createErrorResponse(int code, String info) { + ErrorResponseImpl errorResponse = new ErrorResponseImpl(); + errorResponse.setErrorCode(code); + errorResponse.setInfo(info); + return errorResponse; + } + + public VerifyCMSSignatureRequest createVerifyCMSSignatureRequest( + int[] signatories, + Date dateTime, + InputStream cmsSignature, + CMSDataObject dataObject, + String trustProfileID) { + VerifyCMSSignatureRequestImpl verifyCMSSignatureRequest = + new VerifyCMSSignatureRequestImpl(); + verifyCMSSignatureRequest.setDateTime(dateTime); + verifyCMSSignatureRequest.setCMSSignature(cmsSignature); + verifyCMSSignatureRequest.setDataObject(dataObject); + verifyCMSSignatureRequest.setTrustProfileId(trustProfileID); + verifyCMSSignatureRequest.setSignatories(signatories); + return verifyCMSSignatureRequest; + } + + public CMSDataObject createCMSDataObject( + MetaInfo metaInfo, + CMSContent content) { + + CMSDataObjectImpl cmsDataObject = new CMSDataObjectImpl(); + cmsDataObject.setMetaInfo(metaInfo); + cmsDataObject.setContent(content); + + return cmsDataObject; + } + + public CMSContent createCMSContent(InputStream binaryContent) { + CMSContentExplicitImpl cmsContent = new CMSContentExplicitImpl(); + + cmsContent.setBinaryContent(binaryContent); + return cmsContent; + } + + public CMSContent createCMSContent(String referenceURI) { + CMSContentReferenceImpl cmsContent = new CMSContentReferenceImpl(); + + cmsContent.setReference(referenceURI); + return cmsContent; + } + + + public CMSDataObject createCMSDataObject( + MetaInfo metaInfo, + String referenceURI) { + CMSDataObjectImpl cmsDataObject = new CMSDataObjectImpl(); + CMSContentReferenceImpl cmsContent = new CMSContentReferenceImpl(); + cmsDataObject.setMetaInfo(metaInfo); + cmsContent.setReference(referenceURI); + return cmsDataObject; + } + + public VerifyCMSSignatureResponse createVerifyCMSSignatureResponse(List responseElements) { + VerifyCMSSinatureResponseImpl verifyCMSSignatureResponse = + new VerifyCMSSinatureResponseImpl(); + verifyCMSSignatureResponse.setResponseElements(responseElements); + return verifyCMSSignatureResponse; + } + + public VerifyCMSSignatureResponseElement createVerifyCMSSignatureResponseElement( + SignerInfo signerInfo, + CheckResult signatureCheck, + CheckResult certificateCheck) { + VerifyCMSSignatureResponseElementImpl verifyCMSSignatureResponseElement = + new VerifyCMSSignatureResponseElementImpl(); + verifyCMSSignatureResponseElement.setSignerInfo(signerInfo); + verifyCMSSignatureResponseElement.setSignatureCheck(signatureCheck); + verifyCMSSignatureResponseElement.setCertificateCheck(certificateCheck); + return verifyCMSSignatureResponseElement; + } + + public VerifyXMLSignatureRequest createVerifyXMLSignatureRequest( + Date dateTime, + VerifySignatureInfo verifySignatureInfo, + List supplementProfiles, + SignatureManifestCheckParams signatureManifestParams, + boolean returnHashInputData, + String trustProfileID) { + VerifyXMLSignatureRequestImpl verifyXMLSignatureRequest = + new VerifyXMLSignatureRequestImpl(); + verifyXMLSignatureRequest.setDateTime(dateTime); + verifyXMLSignatureRequest.setSignatureInfo(verifySignatureInfo); + verifyXMLSignatureRequest.setSupplementProfiles(supplementProfiles); + verifyXMLSignatureRequest.setSignatureManifestCheckParams( + signatureManifestParams); + verifyXMLSignatureRequest.setReturnHashInputData(returnHashInputData); + verifyXMLSignatureRequest.setTrustProfileId(trustProfileID); + return verifyXMLSignatureRequest; + } + + public VerifySignatureInfo createVerifySignatureInfo( + Content verifySignatureEnvironment, + VerifySignatureLocation verifySignatureLocation) { + VerifySignatureInfoImpl verifySignatureInfo = new VerifySignatureInfoImpl(); + verifySignatureInfo.setVerifySignatureEnvironment( + verifySignatureEnvironment); + verifySignatureInfo.setVerifySignatureLocation(verifySignatureLocation); + return verifySignatureInfo; + } + + public VerifySignatureLocation createVerifySignatureLocation( + String xPathExpression, + Map namespaceDeclarations) { + VerifySignatureLocationImpl verifySignatureLocation = + new VerifySignatureLocationImpl(); + verifySignatureLocation.setXPathExpression(xPathExpression); + verifySignatureLocation.setNamespaceDeclarations(namespaceDeclarations); + return verifySignatureLocation; + } + + public SupplementProfile createSupplementProfile(String profileID) { + SupplementProfileIDImpl supplementProfileID = new SupplementProfileIDImpl(); + supplementProfileID.setSupplementProfileID(profileID); + return supplementProfileID; + } + + public SupplementProfile createSupplementProfile(XMLDataObjectAssociation supplementProfile) { + SupplementProfileExplicitImpl supplementProfileExplicit = + new SupplementProfileExplicitImpl(); + supplementProfileExplicit.setSupplementProfile(supplementProfile); + return supplementProfileExplicit; + } + + public SignatureManifestCheckParams createSignatureManifestCheckParams( + List referenceInfos, + boolean returnReferenceInputData) { + SignatureManifestCheckParamsImpl signatureManifestCheckParams = + new SignatureManifestCheckParamsImpl(); + signatureManifestCheckParams.setReferenceInfos(referenceInfos); + signatureManifestCheckParams.setReturnReferenceInputData( + returnReferenceInputData); + return signatureManifestCheckParams; + } + + public ReferenceInfo createReferenceInfo(List verifyTransformsInfoProfiles) { + ReferenceInfoImpl referenceInfo = new ReferenceInfoImpl(); + referenceInfo.setVerifyTransformsInfoProfiles(verifyTransformsInfoProfiles); + return referenceInfo; + } + + public VerifyTransformsInfoProfile createVerifyTransformsInfoProfile( + List transforms, + List transformParameters) { + VerifyTransformsInfoProfileExplicitImpl verifyTransformsInfoProfile = + new VerifyTransformsInfoProfileExplicitImpl(); + + verifyTransformsInfoProfile.setTransforms(transforms); + verifyTransformsInfoProfile.setTransformParameters(transformParameters); + + return verifyTransformsInfoProfile; + } + + public VerifyTransformsInfoProfile createVerifyTransformsInfoProfile(String profileID) { + VerifyTransformsInfoProfileIDImpl verifyTransformsInfoProfile = + new VerifyTransformsInfoProfileIDImpl(); + verifyTransformsInfoProfile.setVerifyTransformsInfoProfileID(profileID); + return verifyTransformsInfoProfile; + } + + + public TransformParameter createTransformParameter(String URI, String digestMethod, byte[] digestValue) { + TransformPatameterHashImpl transformParameter = + new TransformPatameterHashImpl(); + transformParameter.setURI(URI); + transformParameter.setDigestMethod(digestMethod); + transformParameter.setDigestValue(digestValue); + return transformParameter; + } + + public TransformParameter createTransformParameter( + String URI, + InputStream binaryData) { + TransformParameterBinaryImpl transformParameter = + new TransformParameterBinaryImpl(); + transformParameter.setURI(URI); + transformParameter.setBinaryContent(binaryData); + return transformParameter; + } + + public TransformParameter createTransformParameter(String URI) { + TransformParameterURIImpl transformParameter = + new TransformParameterURIImpl(); + transformParameter.setURI(URI); + return transformParameter; + } + + public VerifyXMLSignatureResponse createVerifyXMLSignatureResponse( + SignerInfo signerInfo, + List hashInputDatas, + List referenceInputDatas, + ReferencesCheckResult signatureCheck, + ReferencesCheckResult signatureManifestCheck, + List xmlDsigManifestChecks, + CheckResult certificateCheck) { + VerifyXMLSignatureResponseImpl verifyXMLSignatureResponse = + new VerifyXMLSignatureResponseImpl(); + verifyXMLSignatureResponse.setSignerInfo(signerInfo); + verifyXMLSignatureResponse.setHashInputDatas(hashInputDatas); + verifyXMLSignatureResponse.setReferenceInputDatas(referenceInputDatas); + verifyXMLSignatureResponse.setSignatureCheck(signatureCheck); + verifyXMLSignatureResponse.setSignatureManifestCheck( + signatureManifestCheck); + verifyXMLSignatureResponse.setXMLDsigManifestChecks(xmlDsigManifestChecks); + verifyXMLSignatureResponse.setCertificateCheck(certificateCheck); + return verifyXMLSignatureResponse; + } + + public ReferencesCheckResult createReferencesCheckResult( + int code, + ReferencesCheckResultInfo info) { + ReferencesCheckResultImpl referencesCheckResult = + new ReferencesCheckResultImpl(); + referencesCheckResult.setCode(code); + referencesCheckResult.setInfo(info); + return referencesCheckResult; + } + + public ReferencesCheckResultInfo createReferencesCheckResultInfo( + NodeList anyOtherInfo, + int[] failedReferences) { + ReferencesCheckResultInfoImpl referencesCheckResultInfo = + new ReferencesCheckResultInfoImpl(); + referencesCheckResultInfo.setAnyOtherInfo(anyOtherInfo); + referencesCheckResultInfo.setFailedReferences(failedReferences); + return referencesCheckResultInfo; + } + + public ManifestRefsCheckResult createManifestRefsCheckResult( + int code, + ManifestRefsCheckResultInfo info) { + ManifestRefsCheckResultImpl manifestRefsCheckResult = + new ManifestRefsCheckResultImpl(); + manifestRefsCheckResult.setCode(code); + manifestRefsCheckResult.setInfo(info); + return manifestRefsCheckResult; + } + + public ManifestRefsCheckResultInfo createManifestRefsCheckResultInfo( + NodeList anyOtherInfo, + int[] failedReferences, + int referringSigReference) { + ManifestRefsCheckResultInfoImpl manifestRefsCheckResultInfo = + new ManifestRefsCheckResultInfoImpl(); + manifestRefsCheckResultInfo.setAnyOtherInfo(anyOtherInfo); + manifestRefsCheckResultInfo.setReferringSignatureReference( + referringSigReference); + manifestRefsCheckResultInfo.setFailedReferences(failedReferences); + return manifestRefsCheckResultInfo; + } + + public Content createContent(InputStream binaryData, String referenceURI) { + ContentBinaryImpl content = new ContentBinaryImpl(); + content.setBinaryContent(binaryData); + content.setReference(referenceURI); + return content; + } + + public Content createContent(String referenceURI) { + ContentReferenceImpl content = new ContentReferenceImpl(); + content.setReference(referenceURI); + return content; + } + + public Content createContent(NodeList xmlData, String referenceURI) { + ContentXMLImpl content = new ContentXMLImpl(); + content.setXMLContent(xmlData); + content.setReference(referenceURI); + return content; + } + + public XMLDataObjectAssociation createXMLDataObjectAssociation( + MetaInfo metaInfo, + Content xmlContent) { + XMLDataObjectAssociationImpl xmlDataObjectAssociation = + new XMLDataObjectAssociationImpl(); + xmlDataObjectAssociation.setMetaInfo(metaInfo); + xmlDataObjectAssociation.setContent(xmlContent); + return xmlDataObjectAssociation; + } + + public MetaInfo createMetaInfo( + String mimeType, + String description, + NodeList otherInfo) { + MetaInfoImpl metaInfo = new MetaInfoImpl(); + metaInfo.setMimeType(mimeType); + metaInfo.setDescription(description); + metaInfo.setAnyElements(otherInfo); + return metaInfo; + } + + public Transform createCanonicalizationTransform(String algorithmURI) { + CanonicalizationTransformImpl transform = new CanonicalizationTransformImpl(algorithmURI); + return transform; + } + + public Transform createExclusiveCanonicalizationTransform(String algorithmURI, List inclusiveNamespacePrefixes) { + ExclusiveCanonicalizationTransformImpl transform = new ExclusiveCanonicalizationTransformImpl(algorithmURI); + transform.setInclusiveNamespacePrefixes(inclusiveNamespacePrefixes); + return transform; + } + + public Transform createBase64Transform() { + Base64TransformImpl transform = new Base64TransformImpl(); + return transform; + } + + public Transform createEnvelopedSignatureTransform() { + EnvelopedSignatureTransformImpl transform = + new EnvelopedSignatureTransformImpl(); + return transform; + } + + public Transform createXSLTTransform(Element styleSheet) { + XSLTransformImpl transform = new XSLTransformImpl(); + transform.setStylesheet(styleSheet); + return transform; + } + + public Transform createXPathTransform( + String xPathExpression, + Map namespaceDeclarations) { + XPathTransformImpl transform = new XPathTransformImpl(); + transform.setXPathExpression(xPathExpression); + transform.setNamespaceDelcarations(namespaceDeclarations); + return transform; + } + + public Transform createXPathFilter2Transform(List xPathFilters) { + XPathFilter2TransformImpl transform = new XPathFilter2TransformImpl(); + transform.setFilters(xPathFilters); + return transform; + } + + public XPathFilter createXPathFilter( + String filterType, + String xPathExpression, + Map namespaceDeclarations) { + XPathFilterImpl xPathFilter = new XPathFilterImpl(); + xPathFilter.setFilterType(filterType); + xPathFilter.setXPathExpression(xPathExpression); + xPathFilter.setNamespaceDelcarations(namespaceDeclarations); + return xPathFilter; + } + + public CheckResult createCheckResult(int code, NodeList info) { + CheckResultImpl checkResult = new CheckResultImpl(); + checkResult.setCode(code); + checkResult.setInfo(info); + return checkResult; + } + + public SignerInfo createSignerInfo( + X509Certificate signerCertificate, + boolean qualifiedCertificate, + boolean publicAuthority, + String publicAuthorityID) { + SignerInfoImpl signerInfo = new SignerInfoImpl(); + signerInfo.setSignerCertificate(signerCertificate); + signerInfo.setQualifiedCertificate(qualifiedCertificate); + signerInfo.setPublicAuthority(publicAuthority); + signerInfo.setPublicAuhtorityID(publicAuthorityID); + return signerInfo; + } + + public X509IssuerSerial createX509IssuerSerial( + String issuerName, + BigInteger serialNumber) { + X509IssuerSerialImpl x509IssuerSerial = new X509IssuerSerialImpl(); + x509IssuerSerial.setX509IssuerName(issuerName); + x509IssuerSerial.setX509SerialNumber(serialNumber); + return x509IssuerSerial; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/SignatureEnvironmentResponseImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/SignatureEnvironmentResponseImpl.java new file mode 100644 index 000000000..57d30ad3b --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/SignatureEnvironmentResponseImpl.java @@ -0,0 +1,41 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import org.w3c.dom.Element; + +import at.gv.egovernment.moa.spss.api.xmlsign.SignatureEnvironmentResponse; + +/** + * Default implementation of <code>SignatureEnvironmentResponse</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class SignatureEnvironmentResponseImpl + implements SignatureEnvironmentResponse { + + /** The signature environment containing the XML signature. */ + private Element signatureEnvironment; + + /** + * Sets the XML structure which contains the signature. + * + * @param signatureEnvironment A general XML structure containing the signature. + */ + public void setSignatureEnvironment(Element signatureEnvironment) { + this.signatureEnvironment = signatureEnvironment; + } + + public Element getSignatureEnvironment() { + return signatureEnvironment; + } + + /** + * Gets the type of <code>CreateXMLSignatureResponseElement</code>. + * + * @return SIGNATURE_ENVIRONMENT_RESPONSE + */ + public int getResponseType() { + return SIGNATURE_ENVIRONMENT_RESPONSE; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/SignatureManifestCheckParamsImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/SignatureManifestCheckParamsImpl.java new file mode 100644 index 000000000..5924f8447 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/SignatureManifestCheckParamsImpl.java @@ -0,0 +1,52 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import at.gv.egovernment.moa.spss.api.xmlverify.SignatureManifestCheckParams; + +/** + * Default implementation of <code>SignatureManifestCheckParams</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class SignatureManifestCheckParamsImpl + implements SignatureManifestCheckParams { + + /** Referential information. */ + private List referenceInfos; + /** Whether to return the signature source data. */ + private boolean returnReferenceInputData = true; + + /** + * Sets the referantial information. + * + * @param referenceInfos The referential information. + */ + public void setReferenceInfos(List referenceInfos) { + this.referenceInfos = + referenceInfos != null + ? Collections.unmodifiableList(new ArrayList(referenceInfos)) + : null; + } + + public List getReferenceInfos() { + return referenceInfos; + } + + /** + * Sets whether to return signature source data. + * + * @param returnReferenceInputData Whether to return signature source data. + */ + public void setReturnReferenceInputData(boolean returnReferenceInputData) { + this.returnReferenceInputData = returnReferenceInputData; + } + + public boolean getReturnReferenceInputData() { + return returnReferenceInputData; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/SignerInfoImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/SignerInfoImpl.java new file mode 100644 index 000000000..277f1a008 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/SignerInfoImpl.java @@ -0,0 +1,81 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import java.security.cert.X509Certificate; + +import at.gv.egovernment.moa.spss.api.common.SignerInfo; + +/** + * Default implementation of <code>SignerInfo</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class SignerInfoImpl implements SignerInfo { + + /** The signer certificate. */ + private X509Certificate signerCertificate; + /** Determines, whether <code>signerCertificate</code> is a qualified + * certificate. */ + private boolean qualifiedCertificate; + /** Determines, whether <code>signerCertificate</code> is from a public + * authority. */ + private boolean publicAuthority; + /** The public authority ID of the <code>signerCertificate</code>. */ + private String publicAuthorityID; + + /** + * Sets the signer certificate. + * + * @param signerCertificate The signer certificate. + */ + public void setSignerCertificate(X509Certificate signerCertificate) { + this.signerCertificate = signerCertificate; + } + + public X509Certificate getSignerCertificate() { + return signerCertificate; + } + + /** + * Sets, whether the certificate contained in this object is qualified or not. + * + * @param qualifiedCertificate Is <code>true</code>, if the certificate is + * qualified, otherwise <code>false</code>. + */ + public void setQualifiedCertificate(boolean qualifiedCertificate) { + this.qualifiedCertificate = qualifiedCertificate; + } + + public boolean isQualifiedCertificate() { + return qualifiedCertificate; + } + + /** + * Sets, whether the certificate contained in this object is an + * e-government certificate or not. + * + * @param publicAuthority Is <code>true</code>, if the certificate is + * public authority certificate, otherwise <code>false</code>. + */ + public void setPublicAuthority(boolean publicAuthority) { + this.publicAuthority = publicAuthority; + } + + public boolean isPublicAuthority() { + return publicAuthority; + } + + /** + * Sets the public authority ID of the signer certificate. + * + * @param publicAuhtorityID The public authority ID of the signer certificate. + */ + public void setPublicAuhtorityID(String publicAuhtorityID) { + this.publicAuthorityID = publicAuhtorityID; + } + + public String getPublicAuhtorityID() { + return publicAuthorityID; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/SingleSignatureInfoImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/SingleSignatureInfoImpl.java new file mode 100644 index 000000000..b50a65c68 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/SingleSignatureInfoImpl.java @@ -0,0 +1,49 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import at.gv.egovernment.moa.spss.api.xmlsign.CreateSignatureInfo; +import at.gv.egovernment.moa.spss.api.xmlsign.SingleSignatureInfo; + +/** + * @author Fatemeh Philippi + * @version $Id$ + */ +public class SingleSignatureInfoImpl implements SingleSignatureInfo { + + private List dataObjectInfos = new ArrayList(); + + private CreateSignatureInfo createSignatureInfo; + + private boolean securityLayerConform = true; + + public void setDataObjectInfos(List dataObjectInfos) { + this.dataObjectInfos = + dataObjectInfos != null + ? Collections.unmodifiableList(new ArrayList(dataObjectInfos)) + : null; + } + + public List getDataObjectInfos() { + return dataObjectInfos; + } + + public void setCreateSignatureInfo(CreateSignatureInfo createSignatureInfo) { + this.createSignatureInfo = createSignatureInfo; + } + + public CreateSignatureInfo getCreateSignatureInfo() { + return createSignatureInfo; + } + + public void setSecurityLayerConform(boolean securityLayerConform) { + this.securityLayerConform = securityLayerConform; + } + + public boolean isSecurityLayerConform() { + return securityLayerConform; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/SupplementProfileExplicitImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/SupplementProfileExplicitImpl.java new file mode 100644 index 000000000..78723fec2 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/SupplementProfileExplicitImpl.java @@ -0,0 +1,39 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import at.gv.egovernment.moa.spss.api.common.XMLDataObjectAssociation; +import at.gv.egovernment.moa.spss.api.xmlverify.SupplementProfileExplicit; + +/** + * Default implementation of <code>SupplementProfileExplicit</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class SupplementProfileExplicitImpl implements SupplementProfileExplicit { + + /** Supplemental information for verifying a signature. */ + private XMLDataObjectAssociation supplement; + + /** + * Sets the supplemental information for verifying a signature. + * + * @param supplement The supplemental information for verifying a signature. + */ + public void setSupplementProfile(XMLDataObjectAssociation supplement) { + this.supplement = supplement; + } + + public XMLDataObjectAssociation getSupplementProfile() { + return supplement; + } + + /** + * Gets the type of <code>SupplementProfile</code>. + * + * @return EXPLICIT_SUPPLEMENTPROFILE + */ + public int getSupplementProfileType() { + return EXPLICIT_SUPPLEMENTPROFILE; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/SupplementProfileIDImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/SupplementProfileIDImpl.java new file mode 100644 index 000000000..320827fad --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/SupplementProfileIDImpl.java @@ -0,0 +1,37 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import at.gv.egovernment.moa.spss.api.xmlverify.SupplementProfileID; + +/** + * Default implementation of <code>SupplementProfileID</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class SupplementProfileIDImpl implements SupplementProfileID { + /** The profile ID. */ + private String profileID; + + /** + * Sets the <code>SupplementProfile</code> profile ID. + * + * @param profileID The profile ID. + */ + public void setSupplementProfileID(String profileID) { + this.profileID = profileID; + } + + public String getSupplementProfileID() { + return profileID; + } + + /** + * Gets the type of <code>SupplementProfile</code>. + * + * @return ID_SUPPLEMENTPROFILE + */ + public int getSupplementProfileType() { + return ID_SUPPLEMENTPROFILE; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/TransformImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/TransformImpl.java new file mode 100644 index 000000000..51c7a543f --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/TransformImpl.java @@ -0,0 +1,26 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import at.gv.egovernment.moa.spss.api.common.Transform; + +/** + * @author Fatemeh Philippi + * @version $Id$ + */ +public class TransformImpl implements Transform { + /** The URI identifying the transformation algorithm. */ + private String algorithmURI; + + /** + * Sets the URI identifying the transformation algorithm. + * + * @param algorithmURI The URI identifying the transformation algorithm. + */ + public void setAlgorithmURI(String algorithmURI) { + this.algorithmURI = algorithmURI; + } + + public String getAlgorithmURI() { + return algorithmURI; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/TransformParameterBinaryImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/TransformParameterBinaryImpl.java new file mode 100644 index 000000000..2901fb1bb --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/TransformParameterBinaryImpl.java @@ -0,0 +1,42 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import java.io.InputStream; + +import at.gv.egovernment.moa.spss.api.xmlverify.TransformParameterBinary; + +/** + * Default implementation of <code>TransformParameterBinary</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class TransformParameterBinaryImpl + extends TransformParameterImpl + implements TransformParameterBinary { + + /** The binary content as a stream. */ + private InputStream binaryContent; + + /** + * Sets the binary content as a stream. + * + * @param binaryContent The binary content as a stream. + */ + public void setBinaryContent(InputStream binaryContent) { + this.binaryContent = binaryContent; + } + + public InputStream getBinaryContent() { + return binaryContent; + } + + /** + * Gets the <code>TransformParameter</code> type. + * + * @return BINARY_TRANSFORMPARAMETER + */ + public int getTransformParameterType() { + return BINARY_TRANSFORMPARAMETER; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/TransformParameterImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/TransformParameterImpl.java new file mode 100644 index 000000000..9fe60638e --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/TransformParameterImpl.java @@ -0,0 +1,25 @@ +package at.gv.egovernment.moa.spss.api.impl; + +/** + * Default base implementation of <code>TransformParameter</code>. + * + * @author Patrick Peck + * @version $Id$ + */ +public abstract class TransformParameterImpl { + /** An URI identifying the <code>TransformParameter</code>. */ + private String uri; + + /** + * Sets the URI identifying the <code>TransformParameter</code>. + * @param uri The URI identifying the <code>TransformParameter</code>. + */ + public void setURI(String uri) { + this.uri = uri; + } + + public String getURI() { + return uri; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/TransformParameterURIImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/TransformParameterURIImpl.java new file mode 100644 index 000000000..25449504c --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/TransformParameterURIImpl.java @@ -0,0 +1,24 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import at.gv.egovernment.moa.spss.api.xmlverify.TransformParameterURI; + +/** + * Default implementation of <code>TransformParameterURI</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class TransformParameterURIImpl + extends TransformParameterImpl + implements TransformParameterURI { + + /** + * Gets the type of <code>TransformParameter</code>. + * + * @return URI_TRANSFORMPARAMETER + */ + public int getTransformParameterType() { + return URI_TRANSFORMPARAMETER; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/TransformPatameterHashImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/TransformPatameterHashImpl.java new file mode 100644 index 000000000..a7843e68c --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/TransformPatameterHashImpl.java @@ -0,0 +1,54 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import at.gv.egovernment.moa.spss.api.xmlverify.TransformParameterHash; + +/** + * Default implementation of <code>TransformParameterHash</code> + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class TransformPatameterHashImpl + extends TransformParameterImpl + implements TransformParameterHash { + + /** The method used to calculate the digest value. */ + private String digestMethod; + /** The digest value. */ + private byte[] digestValue; + + /** + * Sets method used to calculate the digest value. + * @param digestMethod The method used to calculate the digest value. + */ + public void setDigestMethod(String digestMethod) { + this.digestMethod = digestMethod; + } + + public String getDigestMethod() { + return digestMethod; + } + + /** + * Sets the digest value. + * + * @param digestValue The digest value. + */ + public void setDigestValue(byte[] digestValue) { + this.digestValue = digestValue; + } + + public byte[] getDigestValue() { + return digestValue; + } + + /** + * Gets the type of <code>TransformParameter</code>. + * + * @return HASH_TRANSFORMPARAMETER + */ + public int getTransformParameterType() { + return HASH_TRANSFORMPARAMETER; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/VerifyCMSSignatureRequestImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/VerifyCMSSignatureRequestImpl.java new file mode 100644 index 000000000..a3c37aaef --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/VerifyCMSSignatureRequestImpl.java @@ -0,0 +1,93 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import java.io.InputStream; +import java.util.Date; + +import at.gv.egovernment.moa.spss.api.cmsverify.CMSDataObject; +import at.gv.egovernment.moa.spss.api.cmsverify.VerifyCMSSignatureRequest; + +/** + * Default implementation of <code>VerifyCMSSignatureRequest</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class VerifyCMSSignatureRequestImpl + implements VerifyCMSSignatureRequest { + + /** The indexes of the signatories whose signature should be verified. */ + private int[] signatories; + /** The profile ID of trusted certificates. */ + private String trustProfileId; + /** The data object necessary for signature verification. */ + private CMSDataObject dataObject; + /** The CMS signature to verify. */ + private InputStream cmsSignature; + /** The date for which to verify the signature. */ + private Date dateTime; + + /** + * Sets the indexes of the signatories whose signature should be verified. + * + * @param signatories The indexes of the signatories whose signature should be + * verified. + */ + public void setSignatories(int[] signatories) { + this.signatories = signatories; + } + + public int[] getSignatories() { + return signatories; + } + + /** + * Sets the date for which to verify the signature. + * + * @param dateTime The date for which to verify the signature. + */ + public void setDateTime(Date dateTime) { + this.dateTime = dateTime; + } + + public Date getDateTime() { + return dateTime; + } + + /** + * Sets the CMS signature to verify. + * @param signature The CMS signature to verify. + */ + public void setCMSSignature(InputStream signature) { + this.cmsSignature = signature; + + } + + public InputStream getCMSSignature() { + return cmsSignature; + } + + /** + * Sets the data object necessary for signature verification. + * @param dataObject The data object necessary for signature verification. + */ + public void setDataObject(CMSDataObject dataObject) { + this.dataObject = dataObject; + } + + public CMSDataObject getDataObject() { + return dataObject; + } + + /** + * Sets the profile ID of trusted certificates. + * @param trustProfileId The profile ID of trusted certificates. + */ + public void setTrustProfileId(String trustProfileId) { + this.trustProfileId = trustProfileId; + } + + public String getTrustProfileId() { + return trustProfileId; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/VerifyCMSSignatureResponseElementImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/VerifyCMSSignatureResponseElementImpl.java new file mode 100644 index 000000000..40dc04683 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/VerifyCMSSignatureResponseElementImpl.java @@ -0,0 +1,62 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import at.gv.egovernment.moa.spss.api.cmsverify.VerifyCMSSignatureResponseElement; +import at.gv.egovernment.moa.spss.api.common.CheckResult; +import at.gv.egovernment.moa.spss.api.common.SignerInfo; + +/** + * Default implementation of <code>VerifyCMSSignatureResponseElement</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class VerifyCMSSignatureResponseElementImpl + implements VerifyCMSSignatureResponseElement { + + /** Information about the signer certificate. */ + private SignerInfo signerInfo; + /** Information about the signature check. */ + private CheckResult signatureCheck; + /** Information about the certificate check. */ + private CheckResult certificateCheck; + + /** + * Sets a SignerInfo element according to CMS. + * + * @param signerInfo The SignerInfo element according to CMS. + */ + public void setSignerInfo(SignerInfo signerInfo) { + this.signerInfo = signerInfo; + } + + public SignerInfo getSignerInfo() { + return signerInfo; + } + + /** + * Sets a result of the signature verification. + * + * @param signatureCheck The result of the signature verification. + */ + public void setSignatureCheck(CheckResult signatureCheck) { + this.signatureCheck = signatureCheck; + } + + public CheckResult getSignatureCheck() { + return signatureCheck; + } + + /** + * Sets a result of the certificate verification. + * + * @param certificateCheck The result of the certificate verification. + */ + public void setCertificateCheck(CheckResult certificateCheck) { + this.certificateCheck = certificateCheck; + } + + public CheckResult getCertificateCheck() { + return certificateCheck; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/VerifyCMSSinatureResponseImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/VerifyCMSSinatureResponseImpl.java new file mode 100644 index 000000000..f258380e0 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/VerifyCMSSinatureResponseImpl.java @@ -0,0 +1,37 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import at.gv.egovernment.moa.spss.api.cmsverify.VerifyCMSSignatureResponse; + +/** + * Default implementation of <code>VerifyCMSSignatureResponse</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class VerifyCMSSinatureResponseImpl + implements VerifyCMSSignatureResponse { + + /** The elements contained in the response. */ + private List responseElements; + + /** + * Sets the elements contained in the response. + * + * @param responseElements The elements contained in the response. + */ + public void setResponseElements(List responseElements) { + this.responseElements = + responseElements != null + ? Collections.unmodifiableList(new ArrayList(responseElements)) + : null; + } + + public List getResponseElements() { + return responseElements; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/VerifySignatureInfoImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/VerifySignatureInfoImpl.java new file mode 100644 index 000000000..2653e2fd2 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/VerifySignatureInfoImpl.java @@ -0,0 +1,47 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import at.gv.egovernment.moa.spss.api.common.Content; +import at.gv.egovernment.moa.spss.api.xmlverify.VerifySignatureInfo; +import at.gv.egovernment.moa.spss.api.xmlverify.VerifySignatureLocation; + +/** + * Default implementation of <code>VerifySignatureInfo</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class VerifySignatureInfoImpl implements VerifySignatureInfo { + /** The location of the signature to be verified. */ + private VerifySignatureLocation verifySignatureLocation; + /** The environment containing the signature to be verified. */ + private Content verifySignatureEnvironment; + + /** + * Sets the location of the signature to be verified. + * + * @param verifySignatureLocation The location of the signature to be + * verified. + */ + public void setVerifySignatureLocation(VerifySignatureLocation verifySignatureLocation) { + this.verifySignatureLocation = verifySignatureLocation; + } + + public VerifySignatureLocation getVerifySignatureLocation() { + return verifySignatureLocation; + } + + /** + * Sets the signature environment containing the signature to be verified. + * + * @param verifySignatureEnvironment The signature environment containing the + * signature to be verified. + */ + public void setVerifySignatureEnvironment(Content verifySignatureEnvironment) { + this.verifySignatureEnvironment = verifySignatureEnvironment; + } + + public Content getVerifySignatureEnvironment() { + return verifySignatureEnvironment; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/VerifySignatureLocationImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/VerifySignatureLocationImpl.java new file mode 100644 index 000000000..933e42987 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/VerifySignatureLocationImpl.java @@ -0,0 +1,15 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import at.gv.egovernment.moa.spss.api.xmlverify.VerifySignatureLocation; + +/** + * Default implementation of <code>VerifySignatureLocation</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class VerifySignatureLocationImpl + extends ElementSelectorImpl + implements VerifySignatureLocation { + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/VerifyTransformsDataImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/VerifyTransformsDataImpl.java new file mode 100644 index 000000000..594f9c246 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/VerifyTransformsDataImpl.java @@ -0,0 +1,36 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import at.gv.egovernment.moa.spss.api.xmlverify.ReferenceInfo; + +/** + * Default implementation of <codeReferenceInfo</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class VerifyTransformsDataImpl implements ReferenceInfo { + /** Information about the transformations contained in the signature. */ + private List verifyTransformsInfoProfiles; + + /** + * Sets the information about the transformations contained in the signature. + * + * @param verifyTransformsInfoProfiles The profiles containing transformation + * information. + */ + public void setVerifyTransformsInfoProfiles(List verifyTransformsInfoProfiles) { + this.verifyTransformsInfoProfiles = + verifyTransformsInfoProfiles != null + ? Collections.unmodifiableList( + new ArrayList(verifyTransformsInfoProfiles)) + : null; + } + + public List getVerifyTransformsInfoProfiles() { + return verifyTransformsInfoProfiles; + } +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/VerifyTransformsInfoProfileExplicitImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/VerifyTransformsInfoProfileExplicitImpl.java new file mode 100644 index 000000000..d9a864499 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/VerifyTransformsInfoProfileExplicitImpl.java @@ -0,0 +1,61 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import at.gv.egovernment.moa.spss.api.xmlverify.VerifyTransformsInfoProfileExplicit; + +/** + * Default implementation of <code>VerifyTransformsInfoProfileExplicit</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class VerifyTransformsInfoProfileExplicitImpl + implements VerifyTransformsInfoProfileExplicit { + + /** The transforms contained in this profile. */ + private List transforms; + /** Additional information for the transforms. */ + private List transformParameters = new ArrayList(); + + /** + * Sets the transforms contained in this profile. + * + * @param transforms The transforms contained in this profile. + */ + public void setTransforms(List transforms) { + this.transforms = + transforms != null + ? Collections.unmodifiableList(new ArrayList(transforms)) + : null; + } + + public List getTransforms() { + return transforms; + } + + /** + * Sets additional information for the transforms. + * + * @param transformParameters Additional information for the transforms. + */ + public void setTransformParameters(List transformParameters) { + this.transformParameters = new ArrayList(transformParameters); + } + + public List getTransformParameters() { + return transformParameters; + } + + /** + * Gets the type of <code>VerifyTransformsInfoProfile</code>. + * + * @return EXPLICIT_VERIFYTRANSFORMSINFOPROFILE + */ + public int getVerifyTransformsInfoProfileType() { + return EXPLICIT_VERIFYTRANSFORMSINFOPROFILE; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/VerifyTransformsInfoProfileIDImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/VerifyTransformsInfoProfileIDImpl.java new file mode 100644 index 000000000..fb1f10cea --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/VerifyTransformsInfoProfileIDImpl.java @@ -0,0 +1,38 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import at.gv.egovernment.moa.spss.api.xmlverify.VerifyTransformsInfoProfileID; + +/** + * Default implementation of <code>VerifyTransformsInfoProfileID</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class VerifyTransformsInfoProfileIDImpl implements VerifyTransformsInfoProfileID { + + /** The profile ID. */ + private String verifyTransformsInfoProfileID; + + /** + * Sets the profile ID. + * + * @param profileID The profile ID. + */ + public void setVerifyTransformsInfoProfileID(String profileID) { + this.verifyTransformsInfoProfileID = profileID; + } + + public String getVerifyTransformsInfoProfileID() { + return verifyTransformsInfoProfileID; + } + + /** + * Gets the type of <code>VerifyTransformsInfoProfile</code>. + * + * @return ID_VERIFYTRANSFORMSINFOPROFILE + */ + public int getVerifyTransformsInfoProfileType() { + return ID_VERIFYTRANSFORMSINFOPROFILE; + } + +}
\ No newline at end of file diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/VerifyXMLSignatureRequestImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/VerifyXMLSignatureRequestImpl.java new file mode 100644 index 000000000..26d7def4c --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/VerifyXMLSignatureRequestImpl.java @@ -0,0 +1,113 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.List; + +import at.gv.egovernment.moa.spss.api.xmlverify.SignatureManifestCheckParams; +import at.gv.egovernment.moa.spss.api.xmlverify.VerifySignatureInfo; +import at.gv.egovernment.moa.spss.api.xmlverify.VerifyXMLSignatureRequest; + +/** + * Default implementation of <code>VerifyXMLSignatureRequest</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class VerifyXMLSignatureRequestImpl + implements VerifyXMLSignatureRequest { + /** Date and time for signature verification. */ + private Date dateTime; + /** The signature to be verified. */ + private VerifySignatureInfo verifySignatureInfo; + /** Supplemental information about the singature. */ + private List supplementProfiles; + /** Additional parameters for checking the signature manifest. */ + private SignatureManifestCheckParams signatureManifestCheckParams; + /** Whether to return the hash input data. */ + private boolean returnHashInputData; + /** The profile ID of the trust profile containing the trusted certificates. + */ + private String trustProfileId; + + /** + * Sets the date and time for signature verification. + * + * @param dateTime The date and time for signature verification. + */ + public void setDateTime(Date dateTime) { + this.dateTime = dateTime; + } + + public Date getDateTime() { + return dateTime; + } + + /** + * Sets the signature to be verified. + * + * @param signatureInfo The signature to be verified. + */ + public void setSignatureInfo(VerifySignatureInfo signatureInfo) { + this.verifySignatureInfo = signatureInfo; + } + + public VerifySignatureInfo getSignatureInfo() { + return verifySignatureInfo; + } + + /** + * Sets supplemental information about the singature. + * @param supplementProfiles + */ + public void setSupplementProfiles(List supplementProfiles) { + this.supplementProfiles = + supplementProfiles != null + ? Collections.unmodifiableList(new ArrayList(supplementProfiles)) + : null; + } + + public List getSupplementProfiles() { + return supplementProfiles; + } + + /** + * Sets supplemental information about the singature. + * @param params Supplemental information about the singature. + */ + public void setSignatureManifestCheckParams(SignatureManifestCheckParams params) { + this.signatureManifestCheckParams = params; + } + + public SignatureManifestCheckParams getSignatureManifestCheckParams() { + return signatureManifestCheckParams; + } + + /** + * Sets whether to return hash input data. + * + * @param returnSignedData Whether to return hash input data. + */ + public void setReturnHashInputData(boolean returnSignedData) { + this.returnHashInputData = returnSignedData; + } + + public boolean getReturnHashInputData() { + return returnHashInputData; + } + + /** + * Sets the profile ID of trusted certificates. + * + * @param trustProfileId The profile ID of trusted certificates. + */ + public void setTrustProfileId(String trustProfileId) { + this.trustProfileId = trustProfileId; + } + + public String getTrustProfileId() { + return trustProfileId; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/VerifyXMLSignatureResponseImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/VerifyXMLSignatureResponseImpl.java new file mode 100644 index 000000000..f163013c1 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/VerifyXMLSignatureResponseImpl.java @@ -0,0 +1,134 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import at.gv.egovernment.moa.spss.api.common.CheckResult; +import at.gv.egovernment.moa.spss.api.common.SignerInfo; +import at.gv.egovernment.moa.spss.api.xmlverify.ReferencesCheckResult; +import at.gv.egovernment.moa.spss.api.xmlverify.VerifyXMLSignatureResponse; + +/** + * @author Fatemeh Philippi + * @version $Id$ + */ +public class VerifyXMLSignatureResponseImpl + implements VerifyXMLSignatureResponse { + + /** Information about the signer certificate. */ + private SignerInfo signerInfo; + /** The hash input data objects. */ + private List hashInputDatas = new ArrayList(); + /** The reference input data objects. */ + private List referenceInputDatas = new ArrayList(); + /** Information about the signature check. */ + private ReferencesCheckResult signatureCheck; + /** Information about the signature manifest check. */ + private ReferencesCheckResult signatureManifestCheck; + /** Information about the XMLDsig manifest check. */ + private List xmlDsigManifestChecks = new ArrayList(); + /** Information about the certificate check. */ + private CheckResult certificateCheck; + + /** + * Sets information about the signer certificate. + * + * @param signerInfo Information about the signer certificate. + */ + public void setSignerInfo(SignerInfo signerInfo) { + this.signerInfo = signerInfo; + } + + public SignerInfo getSignerInfo() { + return signerInfo; + } + + /** + * Sets data signed by the signatory. + * + * @param hashInputDatas The signed datas. + */ + public void setHashInputDatas(List hashInputDatas) { + this.hashInputDatas = + hashInputDatas != null + ? Collections.unmodifiableList(new ArrayList(hashInputDatas)) + : null; + } + + public List getHashInputDatas() { + return hashInputDatas; + } + + /** + * Sets the source data elements. + * + * @param referenceInputDatas The source data elements. + */ + public void setReferenceInputDatas(List referenceInputDatas) { + this.referenceInputDatas = + referenceInputDatas != null + ? Collections.unmodifiableList(new ArrayList(referenceInputDatas)) + : null; + } + + public List getReferenceInputDatas() { + return referenceInputDatas; + } + + /** + * Sets the result of the signature verification. + * + * @param signatureCheck The result of the signature verification. + */ + public void setSignatureCheck(ReferencesCheckResult signatureCheck) { + this.signatureCheck = signatureCheck; + } + + public ReferencesCheckResult getSignatureCheck() { + return signatureCheck; + } + + /** + * Sets the result of the signature manifest verification. + * + * @param signatureManifestCheck The result of the signature manifest verification. + */ + public void setSignatureManifestCheck(ReferencesCheckResult signatureManifestCheck) { + this.signatureManifestCheck = signatureManifestCheck; + } + + public ReferencesCheckResult getSignatureManifestCheck() { + return signatureManifestCheck; + } + + /** + * Sets the result of the certification verification. + * + * @param certificateCheck The result of the certificate verification. + */ + public void setCertificateCheck(CheckResult certificateCheck) { + this.certificateCheck = certificateCheck; + } + + public CheckResult getCertificateCheck() { + return certificateCheck; + } + + /** + * Sets the XMLDSigManifestChecks. + * + * @param xmlDsigManifestChecks The XMLDSigManifestChecks. + */ + public void setXMLDsigManifestChecks(List xmlDsigManifestChecks) { + this.xmlDsigManifestChecks = + xmlDsigManifestChecks != null + ? Collections.unmodifiableList(new ArrayList(xmlDsigManifestChecks)) + : null; + } + + public List getXMLDsigManifestChecks() { + return xmlDsigManifestChecks; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/X509IssuerSerialImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/X509IssuerSerialImpl.java new file mode 100644 index 000000000..e6d644fd9 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/X509IssuerSerialImpl.java @@ -0,0 +1,45 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import java.math.BigInteger; + +import at.gv.egovernment.moa.spss.api.common.X509IssuerSerial; + +/** + * Default implementation of <code>X509IssuerSerial</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class X509IssuerSerialImpl implements X509IssuerSerial { + /** The certificate serial number. */ + private BigInteger x509SerialNumber; + /** The certificate issuer DN. */ + private String x509IssuerName; + + /** + * Sets the issuer distinguished name. + * + * @param x509IssuerName The issuer distinguished name. + */ + public void setX509IssuerName(String x509IssuerName) { + this.x509IssuerName = x509IssuerName; + } + + public String getX509IssuerName() { + return x509IssuerName; + } + + /** + * Sets the certificate serial number. + * + * @param x509SerialNumber The issuer serial number. + */ + public void setX509SerialNumber(BigInteger x509SerialNumber) { + this.x509SerialNumber = x509SerialNumber; + } + + public BigInteger getX509SerialNumber() { + return x509SerialNumber; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/XMLDataObjectAssociationImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/XMLDataObjectAssociationImpl.java new file mode 100644 index 000000000..b603c3367 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/XMLDataObjectAssociationImpl.java @@ -0,0 +1,45 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import at.gv.egovernment.moa.spss.api.common.Content; +import at.gv.egovernment.moa.spss.api.common.MetaInfo; +import at.gv.egovernment.moa.spss.api.common.XMLDataObjectAssociation; + +/** + * Default implementation of <code>XMLDataObjectAssociation</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class XMLDataObjectAssociationImpl implements XMLDataObjectAssociation { + + /** Meta information about the <code>Content</code> object. */ + private MetaInfo metaInfo; + /** The actual data contained in this object. */ + private Content content; + + /** + * Sets meta information about the <code>Content</code> object. + * @param metaInfo Meta information about the <code>Content</code> object. + */ + public void setMetaInfo(MetaInfo metaInfo) { + this.metaInfo = metaInfo; + } + + public MetaInfo getMetaInfo() { + return metaInfo; + } + + /** + * Sets the actual data contained in this object. + * + * @param content The actual data contained in this object. + */ + public void setContent(Content content) { + this.content = content; + } + + public Content getContent() { + return content; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/XPathFilter2TransformImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/XPathFilter2TransformImpl.java new file mode 100644 index 000000000..a96a8f161 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/XPathFilter2TransformImpl.java @@ -0,0 +1,43 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import java.util.ArrayList; +import java.util.List; + +import at.gv.egovernment.moa.spss.api.common.XPathFilter2Transform; + +/** + * Default implementation of <code>XPathFilter2Transform</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class XPathFilter2TransformImpl + extends TransformImpl + implements XPathFilter2Transform { + + /** The XPath filters. */ + private List filters; + + /** + * Create a new <code>XPathFilter2TransformImpl</code> object. + */ + public XPathFilter2TransformImpl() { + setAlgorithmURI(XPATH_FILTER2); + } + + /** + * Sets the XPath filters contained in this + * <code>XPathFilter2Transform</code>. + * + * @param filters The XPath filters contained in this + * <code>XPathFilter2Transform</code>. + */ + public void setFilters(List filters) { + this.filters = new ArrayList(filters); + } + + public List getFilters() { + return filters; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/XPathFilterImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/XPathFilterImpl.java new file mode 100644 index 000000000..72d91bc58 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/XPathFilterImpl.java @@ -0,0 +1,64 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import java.util.HashMap; +import java.util.Map; + +import at.gv.egovernment.moa.spss.api.common.XPathFilter; + +/** + * Default implementation of <code>XPathFilter</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class XPathFilterImpl implements XPathFilter { + /** The type of filter. */ + private String filterType; + /** The XPath expression of the filter. */ + private String xPathExpression; + /** The namespace prefix to URI mapping to while evaluating the XPath + * expression. */ + private Map namespaceDeclarations = new HashMap(); + + /** + * Sets the type of filter. + * + * @param filterType The type of filter. + */ + public void setFilterType(String filterType) { + this.filterType = filterType; + } + + public String getFilterType() { + return filterType; + } + + /** + * Sets the XPath expression of the filter. + * + * @param xPathExpression The XPath expression of the filter. + */ + public void setXPathExpression(String xPathExpression) { + this.xPathExpression = xPathExpression; + } + + public String getXPathExpression() { + return xPathExpression; + } + + /** + * Sets the namespace prefix to URI mapping to while evaluating the XPath + * expression. + * + * @param namespaceDeclarations The namespace prefix to URI mapping to while + * evaluating the XPath expression. + */ + public void setNamespaceDelcarations(Map namespaceDeclarations) { + this.namespaceDeclarations = namespaceDeclarations; + } + + public Map getNamespaceDeclarations() { + return namespaceDeclarations; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/XPathTransformImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/XPathTransformImpl.java new file mode 100644 index 000000000..1c9817ecc --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/XPathTransformImpl.java @@ -0,0 +1,59 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import java.util.HashMap; +import java.util.Map; + +import at.gv.egovernment.moa.spss.api.common.XPathTransform; + +/** + * Default implementation of <code>XPathTransform</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class XPathTransformImpl + extends TransformImpl + implements XPathTransform { + + /** The XPath expression to evaluate. */ + private String xPathExpression; + /** The namespace prefix to URI mapping to while evaluating the XPath + * expression. */ + private Map namespaceDeclarations = new HashMap(); + + /** + * Create a new <code>XPathTransformImpl</code> object. + */ + public XPathTransformImpl() { + setAlgorithmURI(XPATH); + } + + /** + * Sets the XPath expression to evaluate. + * + * @param xPathExpression The XPath expression to evaluate. + */ + public void setXPathExpression(String xPathExpression) { + this.xPathExpression = xPathExpression; + } + + public String getXPathExpression() { + return xPathExpression; + } + + /** + * Sets the namespace prefix to URI mapping to while evaluating the XPath + * expression. + * + * @param namespaceDeclarations The namespace prefix to URI mapping to while + * evaluating the XPath expression. + */ + public void setNamespaceDelcarations(Map namespaceDeclarations) { + this.namespaceDeclarations = namespaceDeclarations; + } + + public Map getNamespaceDeclarations() { + return namespaceDeclarations; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/XSLTransformImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/XSLTransformImpl.java new file mode 100644 index 000000000..c6ddc0fd6 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/XSLTransformImpl.java @@ -0,0 +1,37 @@ +package at.gv.egovernment.moa.spss.api.impl; + +import org.w3c.dom.Element; + +import at.gv.egovernment.moa.spss.api.common.XSLTTransform; + +/** + * Default implementation of <code>XSLTTransform</code>. + * + * @author Fatemeh Philippi + * @version $Id$ + */ +public class XSLTransformImpl extends TransformImpl implements XSLTTransform { + /** The XSLT stylesheet to apply. */ + private Element styleSheet; + + /** + * Create a new <code>XSLTransformImpl</code> object. + */ + public XSLTransformImpl() { + setAlgorithmURI(XSLT); + } + + /** + * Sets the XSLT stylesheet to apply. + * + * @param styleSheet The XSLT stylesheet to apply. + */ + public void setStylesheet(Element styleSheet) { + this.styleSheet = styleSheet; + } + + public Element getStylesheet() { + return styleSheet; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/CreateXMLSignatureRequestParser.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/CreateXMLSignatureRequestParser.java new file mode 100644 index 000000000..319d3ac9d --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/CreateXMLSignatureRequestParser.java @@ -0,0 +1,288 @@ +package at.gv.egovernment.moa.spss.api.xmlbind; + +import java.util.ArrayList; +import java.util.List; + +import org.w3c.dom.Element; +import org.w3c.dom.traversal.NodeIterator; + +import at.gv.egovernment.moa.util.BoolUtils; +import at.gv.egovernment.moa.util.Constants; +import at.gv.egovernment.moa.util.DOMUtils; +import at.gv.egovernment.moa.util.XPathUtils; + +import at.gv.egovernment.moa.spss.MOAApplicationException; +import at.gv.egovernment.moa.spss.api.SPSSFactory; +import at.gv.egovernment.moa.spss.api.common.Content; +import at.gv.egovernment.moa.spss.api.xmlsign.CreateSignatureEnvironmentProfile; +import at.gv.egovernment.moa.spss.api.xmlsign.CreateSignatureInfo; +import at.gv.egovernment.moa.spss.api.xmlsign.CreateTransformsInfoProfile; +import at.gv.egovernment.moa.spss.api.xmlsign.CreateXMLSignatureRequest; +import at.gv.egovernment.moa.spss.api.xmlsign.DataObjectInfo; +import at.gv.egovernment.moa.spss.api.xmlsign.SingleSignatureInfo; + +/** + * A parser to parse <code>CreateXMLSignatureRequest</code> DOM trees into + * <code>CreateXMLSignatureRequest</code> API objects. + * + * @author Patrick Peck + * @version $Id$ + */ +public class CreateXMLSignatureRequestParser { + + // + // XPath expresssions to select elements in the CreateXMLSignatureRequest + // + private static final String MOA = Constants.MOA_PREFIX + ":"; + private static final String KEY_IDENTIFIER_XPATH = + "/" + MOA + "CreateXMLSignatureRequest/" + MOA + "KeyIdentifier"; + private static final String SINGLE_SIGNATURE_INFO_XPATH = + "/" + MOA + "CreateXMLSignatureRequest/" + MOA + "SingleSignatureInfo"; + private static final String DATA_OBJECT_INFO_XPATH = MOA + "DataObjectInfo"; + private static final String DATA_OBJECT_XPATH = MOA + "DataObject"; + private static final String CREATE_SIGNATURE_INFO_XPATH = + MOA + "CreateSignatureInfo"; + private static final String CREATE_TRANSFORMS_INFO_PROFILE_XPATH = + (MOA + "CreateTransformsInfoProfile | ") + + (MOA + "CreateTransformsInfoProfileID"); + private static final String CREATE_SIGNATURE_ENVIRONMENT_XPATH = + MOA + "CreateSignatureEnvironment"; + private static final String CREATE_SIGNATURE_ENVIRONMENT_PROFILE_XPATH = + (MOA + "CreateSignatureEnvironmentProfile | ") + + (MOA + "CreateSignatureEnvironmentProfileID"); + private static final String SL_CONFORM_ATTR_NAME = "SecurityLayerConformity"; + + /** The factory to create API objects. */ + private SPSSFactory factory; + + /** + * Create a new <code>CreateXMLSignatureRequestParser</code>. + */ + public CreateXMLSignatureRequestParser() { + this.factory = SPSSFactory.getInstance(); + } + + /** + * Parse a <code>CreateXMLSignatureRequest</code> DOM element, as defined + * by the MOA schema. + * + * @param requestElem The <code>CreateXMLSignatureRequest</code> to parse. The + * request must have been successfully parsed against the schema for this + * method to succeed. + * @return A <code>CreateXMLSignatureRequest</code> API object containing + * the data from the DOM element. + * @throws MOAApplicationException An error occurred parsing the request. + */ + public CreateXMLSignatureRequest parse(Element requestElem) + throws MOAApplicationException { + + List singleSignatureInfos = parseSingleSignatureInfos(requestElem); + String keyIdentifier = + XPathUtils.getElementValue(requestElem, KEY_IDENTIFIER_XPATH, null); + + return factory.createCreateXMLSignatureRequest( + keyIdentifier, + singleSignatureInfos); + } + + /** + * Parse all <code>SingleSignatureInfo</code> elements of the + * <code>CreateXMLSignatureRequest</code>. + * + * @param requestElem The <code>CreateXMLSignatureRequest</code> to parse. + * @return A <code>List</code> of <code>SingleSignatureInfo</code> API + * objects. + * @throws MOAApplicationException An error occurred parsing on of the + * <code>SingleSignatureInfo</code> elements. + */ + private List parseSingleSignatureInfos(Element requestElem) + throws MOAApplicationException { + + List singleSignatureInfos = new ArrayList(); + NodeIterator sigInfoElems = + XPathUtils.selectNodeIterator(requestElem, SINGLE_SIGNATURE_INFO_XPATH); + Element sigInfoElem; + + while ((sigInfoElem = (Element) sigInfoElems.nextNode()) != null) { + singleSignatureInfos.add(parseSingleSignatureInfo(sigInfoElem)); + } + + return singleSignatureInfos; + } + + /** + * Parse a <code>SingleSignatureInfo</code> DOM element. + * + * @param sigInfoElem The <code>SingleSignatureInfo</code> DOM element to + * parse. + * @return A <code>SingleSignatureInfo</code> API object containing the + * information of <code>sigInfoElem</code>. + * @throws MOAApplicationException An error occurred parsing the + * <code>SingleSignatureInfo</code>. + */ + private SingleSignatureInfo parseSingleSignatureInfo(Element sigInfoElem) + throws MOAApplicationException { + + List dataObjectInfos = parseDataObjectInfos(sigInfoElem); + CreateSignatureInfo createSignatureInfo = + parseCreateSignatureInfo(sigInfoElem); + boolean securityLayerConform; + + if (sigInfoElem.hasAttribute(SL_CONFORM_ATTR_NAME)) { + securityLayerConform = + BoolUtils.valueOf(sigInfoElem.getAttribute(SL_CONFORM_ATTR_NAME)); + } else { + securityLayerConform = true; + } + + return factory.createSingleSignatureInfo( + dataObjectInfos, + createSignatureInfo, + securityLayerConform); + } + + /** + * Parse the <code>DataObjectInfo</code> DOM elements contained in the given + * <code>SingleSignatureInfo</code> DOM element. + * + * @param sigInfoElem The <code>SingleSignatureInfo</code> DOM element + * whose <code>DataObjectInfo</code>s to parse. + * @return A <code>List</code> of <code>DataObjectInfo</code> API objects + * containing the data from the <code>DataObjectInfo</code> DOM elements. + * @throws MOAApplicationException An error occurred parsing one of the + * <code>DataObjectInfo</code>s. + */ + private List parseDataObjectInfos(Element sigInfoElem) + throws MOAApplicationException { + + List dataObjectInfos = new ArrayList(); + NodeIterator dataObjInfoElems = + XPathUtils.selectNodeIterator(sigInfoElem, DATA_OBJECT_INFO_XPATH); + Element dataObjInfoElem; + + while ((dataObjInfoElem = (Element) dataObjInfoElems.nextNode()) != null) { + dataObjectInfos.add(parseDataObjectInfo(dataObjInfoElem)); + } + return dataObjectInfos; + } + + /** + * Parse a <code>DataObjectInfo</code> DOM element. + * + * @param dataObjInfoElem The <code>DataObjectInfo</code> DOM element to + * parse. + * @return A <code>DataObjectInfo</code> API element containing the data + * from <code>dataObjInfoElem</code>. + * @throws MOAApplicationException An error occurred parsing the + * <code>DataObjectInfo</code>. + */ + private DataObjectInfo parseDataObjectInfo(Element dataObjInfoElem) + throws MOAApplicationException { + + String structure = dataObjInfoElem.getAttribute("Structure"); + Element dataObjectElem = + (Element) XPathUtils.selectSingleNode(dataObjInfoElem, DATA_OBJECT_XPATH); + Content dataObject = RequestParserUtils.parseContent(dataObjectElem); + CreateTransformsInfoProfile createTransformsInfoProfile = + parseCreateTransformsInfoProfile(dataObjInfoElem); + boolean childOfManifest; + + if (dataObjInfoElem.hasAttribute("ChildOfManifest")) { + childOfManifest = + BoolUtils.valueOf(dataObjInfoElem.getAttribute("ChildOfManifest")); + } else { + childOfManifest = false; + } + + return factory.createDataObjectInfo( + structure, + childOfManifest, + dataObject, + createTransformsInfoProfile); + } + + /** + * Parse a <code>CreateTransformsInfoProfile</code> DOM element. + * + * @param dataObjInfoElem The <code>DataObjectInfo</code> DOM element + * containing the <code>CreateTransformsInfoProfile</code>. + * @return The <code>CreateTransformsInfoProfile</code> API object containing + * the profile found in <code>dataObjInfoElem</code>. + * @throws MOAApplicationException An error occurred parsing the + * <code>CreateTransformsInfoProfile</code>. + */ + private CreateTransformsInfoProfile parseCreateTransformsInfoProfile(Element dataObjInfoElem) + throws MOAApplicationException { + + Element profileElem = + (Element) XPathUtils.selectSingleNode( + dataObjInfoElem, + CREATE_TRANSFORMS_INFO_PROFILE_XPATH); + + if ("CreateTransformsInfoProfile".equals(profileElem.getLocalName())) { + ProfileParser profileParser = new ProfileParser(); + return profileParser.parseCreateTransformsInfoProfile(profileElem); + + } else { + String profileID = DOMUtils.getText(profileElem); + return factory.createCreateTransformsInfoProfile(profileID); + } + } + + /** + * Parse the <code>CreateSignatureInfo</code> DOM element contained in + * a <code>SingleSignatureInfo</code>. + * + * @param sigInfoElem The <code>SingleSignatureInfo</code> DOM element + * containing the <code>CreateSignatureInfo</code> to be parsed. + * @return A <code>CreateSignatureInfo</code> API object containing the + * data from the <code>CreateSignatureInfo</code> DOM element, or + * <code>null</code>, if none was found. + */ + private CreateSignatureInfo parseCreateSignatureInfo(Element sigInfoElem) { + Element createInfoElem = + (Element) XPathUtils.selectSingleNode( + sigInfoElem, + CREATE_SIGNATURE_INFO_XPATH); + + if (createInfoElem != null) { + Element environmentElem = + (Element) XPathUtils.selectSingleNode( + createInfoElem, + CREATE_SIGNATURE_ENVIRONMENT_XPATH); + Content environment = RequestParserUtils.parseContent(environmentElem); + CreateSignatureEnvironmentProfile environmentProfile = + parseCreateSignatureEnvironmentProfile(createInfoElem); + + return factory.createCreateSignatureInfo(environment, environmentProfile); + } else { + return null; + } + } + + /** + * Parse the <code>CreateSignatureEnvironmentProfile</code> contained in + * the given <code>CreateSignatureInfo</code> DOM element. + * + * @param createInfoElem <code>CreateSignatureInfo</code> DOM element to + * parse. + * @return The <code>CreateSignatureEnvironmentProfile</code> contained + * in the given <code>CreateSignatureInfo</code> DOM element.. + */ + private CreateSignatureEnvironmentProfile parseCreateSignatureEnvironmentProfile(Element createInfoElem) { + Element profileElem = + (Element) XPathUtils.selectSingleNode( + createInfoElem, + CREATE_SIGNATURE_ENVIRONMENT_PROFILE_XPATH); + + if ("CreateSignatureEnvironmentProfile" + .equals(profileElem.getLocalName())) { + ProfileParser profileParser = new ProfileParser(); + return profileParser.parseCreateSignatureEnvironmentProfile(profileElem); + } else { + String profileID = DOMUtils.getText(profileElem); + return factory.createCreateSignatureEnvironmentProfile(profileID); + } + } + +}
\ No newline at end of file diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/CreateXMLSignatureResponseBuilder.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/CreateXMLSignatureResponseBuilder.java new file mode 100644 index 000000000..eec9c4882 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/CreateXMLSignatureResponseBuilder.java @@ -0,0 +1,119 @@ +package at.gv.egovernment.moa.spss.api.xmlbind; + +import java.util.Iterator; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; + +import at.gv.egovernment.moa.util.Constants; + +import at.gv.egovernment.moa.spss.MOASystemException; +import at.gv.egovernment.moa.spss.api.xmlsign.CreateXMLSignatureResponse; +import at.gv.egovernment.moa.spss.api.xmlsign.CreateXMLSignatureResponseElement; +import at.gv.egovernment.moa.spss.api.xmlsign.ErrorResponse; +import at.gv.egovernment.moa.spss.api.xmlsign.SignatureEnvironmentResponse; + +/** + * Convert a <code>CreateXMLSignatureResponse</code> API object into its + * XML representation, according to the MOA XML schema. + * + * @author Patrick Peck + * @version $Id$ + */ +public class CreateXMLSignatureResponseBuilder { + private static final String MOA_NS_URI = Constants.MOA_NS_URI; + + /** The XML document containing the response element. */ + private Document responseDoc; + /** The response <code>CreateXMLSignatureResponse</code> DOM element. */ + private Element responseElem; + + /** + * Create a new <code>CreateXMLSignatureResponseBuilder</code>: + * + * @throws MOASystemException An error occurred setting up the resulting + * XML document. + */ + public CreateXMLSignatureResponseBuilder() throws MOASystemException { + responseDoc = + ResponseBuilderUtils.createResponse("CreateXMLSignatureResponse"); + responseElem = responseDoc.getDocumentElement(); + } + + /** + * Build a document containing a <code>CreateXMLSignatureResponse</code> + * DOM element being the XML representation of the given + * <code>CreateXMLSignatureResponse</code> API object. + * + * @param response The <code>CreateXMLSignatureResponse</code> to convert + * to XML. + * @return A document containing the <code>CreateXMLSignatureResponse</code> + * DOM element. + */ + public Document build(CreateXMLSignatureResponse response) { + Iterator iter; + + for (iter = response.getResponseElements().iterator(); iter.hasNext();) { + CreateXMLSignatureResponseElement responseElement = + (CreateXMLSignatureResponseElement) iter.next(); + + switch (responseElement.getResponseType()) { + case CreateXMLSignatureResponseElement.SIGNATURE_ENVIRONMENT_RESPONSE : + SignatureEnvironmentResponse envResponse = + (SignatureEnvironmentResponse) responseElement; + addSignatureEnvironment(envResponse); + break; + + case CreateXMLSignatureResponseElement.ERROR_RESPONSE : + ErrorResponse errorResponse = (ErrorResponse) responseElement; + addErrorResponse(errorResponse); + break; + } + + } + + return responseDoc; + } + + /** + * Add a <code>SignatureEnvironment</code> element to the response. + * + * @param envResponse The content to put under the + * <code>SignatureEnvironment</code> element. This should either be a + * <code>dsig:Signature</code> element (in case of a detached signature) or + * the signature environment containing the signature (in case of + * an enveloping signature). + */ + private void addSignatureEnvironment(SignatureEnvironmentResponse envResponse) { + Element content = envResponse.getSignatureEnvironment(); + Node importedSignature = responseDoc.importNode(content, true); + Element signatureEnvironment = + responseDoc.createElementNS(MOA_NS_URI, "SignatureEnvironment"); + signatureEnvironment.appendChild(importedSignature); + responseElem.appendChild(signatureEnvironment); + } + + /** + * Add a <code>ErrorResponse</code> element to the response. + * + * @param errorResponse The API object containing the information to put into + * the <code>ErrorResponse</code> DOM element. + */ + private void addErrorResponse(ErrorResponse errorResponse) { + Element errorElem = + responseDoc.createElementNS(MOA_NS_URI, "ErrorResponse"); + Element errorCodeElem = + responseDoc.createElementNS(MOA_NS_URI, "ErrorCode"); + Element infoElem = responseDoc.createElementNS(MOA_NS_URI, "Info"); + String errorCodeStr = Integer.toString(errorResponse.getErrorCode()); + + errorCodeElem.appendChild(responseDoc.createTextNode(errorCodeStr)); + errorElem.appendChild(errorCodeElem); + infoElem.appendChild(responseDoc.createTextNode(errorResponse.getInfo())); + errorElem.appendChild(errorCodeElem); + errorElem.appendChild(infoElem); + responseElem.appendChild(errorElem); + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/ProfileParser.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/ProfileParser.java new file mode 100644 index 000000000..66c08e0ab --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/ProfileParser.java @@ -0,0 +1,285 @@ +package at.gv.egovernment.moa.spss.api.xmlbind; + +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.w3c.dom.Element; +import org.w3c.dom.traversal.NodeIterator; + +import at.gv.egovernment.moa.util.Base64Utils; +import at.gv.egovernment.moa.util.Constants; +import at.gv.egovernment.moa.util.DOMUtils; +import at.gv.egovernment.moa.util.XPathUtils; + +import at.gv.egovernment.moa.spss.MOAApplicationException; +import at.gv.egovernment.moa.spss.api.SPSSFactory; +import at.gv.egovernment.moa.spss.api.common.MetaInfo; +import at.gv.egovernment.moa.spss.api.common.XMLDataObjectAssociation; +import at.gv.egovernment.moa.spss.api.xmlsign.CreateSignatureEnvironmentProfile; +import at.gv.egovernment.moa.spss.api.xmlsign.CreateSignatureLocation; +import at.gv.egovernment.moa.spss.api.xmlsign.CreateTransformsInfo; +import at.gv.egovernment.moa.spss.api.xmlsign.CreateTransformsInfoProfile; +import at.gv.egovernment.moa.spss.api.xmlverify.SupplementProfile; +import at.gv.egovernment.moa.spss.api.xmlverify.TransformParameter; +import at.gv.egovernment.moa.spss.api.xmlverify.VerifyTransformsInfoProfile; + +/** + * Parse the various profile elements contained in the MOA web service requests + * and given as separate files in the MOA configuration. + * + * The profiles parsed must be schema valid according to the MOA XML schema. + * + * @author Patrick Peck + * @version $Id$ + */ +public class ProfileParser { + + // + // XPath expressions to select parts of the profiles + // + private static final String MOA = Constants.MOA_PREFIX + ":"; + private static final String DSIG = Constants.DSIG_PREFIX + ":"; + private static final String CREATE_TRANSFORMS_XPATH = + MOA + "CreateTransformsInfo/" + DSIG + "Transforms"; + private static final String FINAL_DATA_META_INFO_XPATH = + MOA + "CreateTransformsInfo/" + MOA + "FinalDataMetaInfo"; + private static final String CREATE_SIGNATURE_LOCATION_XPATH = + MOA + "CreateSignatureLocation"; + private static final String SUPPLEMENT_XPATH = MOA + "Supplement"; + private static final String VERIFY_TRANSFORMS_XPATH = DSIG + "Transforms"; + private static final String TRANSFORM_PARAMETER_XPATH = + MOA + "TransformParameter"; + private static final String TRANSFORM_PARAMETER_CONTENT_XPATH = + MOA + "Base64Content | " + MOA + "Hash"; + private static final String DIGEST_METHOD_XPATH = DSIG + "DigestMethod"; + private static final String DIGEST_VALUE_XPATH = DSIG + "DigestValue"; + + /** The factory used to create API objects. */ + private SPSSFactory factory = SPSSFactory.getInstance(); + + /** + * Parse a <code>CreateTransformsInfoProfile</code> DOM element. + * + * @param profileElem The <code>CreateTransformsInfoProfile</code> element + * to parse. + * @return The <code>CreateTransformsInfoProfile</code> API object containing + * the data from the <code>profileElem</code>. + * @throws MOAApplicationException An error occurred parsing the DOM element. + */ + public CreateTransformsInfoProfile parseCreateTransformsInfoProfile(Element profileElem) + throws MOAApplicationException { + CreateTransformsInfo createTransformsInfo = + parseCreateTransformsInfo(profileElem); + List supplements = parseSupplements(profileElem); + + return factory.createCreateTransformsInfoProfile( + createTransformsInfo, + supplements); + } + + /** + * Parse the <code>CreateTransformsInfo</code> DOM element contained in a + * <code>CreateTransformsInfoProfile</code>. + * + * @param profileElem The <code>CreateTransformsInfoProfile</code> DOM + * element containing the <code>CreateTransformsInfo</code>. + * @return The <code>CreateTransformsInfo</code> API object containinig the + * data from the <code>CreateTransformsInfo</code> DOM element. + * @throws MOAApplicationException An error occurred parsing the + * <code>CreateTransformsInfo</code> DOM element. + */ + private CreateTransformsInfo parseCreateTransformsInfo(Element profileElem) + throws MOAApplicationException { + + Element transformsElem = + (Element) XPathUtils.selectSingleNode( + profileElem, + CREATE_TRANSFORMS_XPATH); + Element metaInfoElem = + (Element) XPathUtils.selectSingleNode( + profileElem, + FINAL_DATA_META_INFO_XPATH); + MetaInfo finalDataMetaInfo; + List transforms; + + // parse the dsig:Transforms + if (transformsElem != null) { + TransformParser transformsParser = new TransformParser(); + transforms = transformsParser.parseTransforms(transformsElem); + } else { + transforms = null; + } + + // parse the meta info + finalDataMetaInfo = RequestParserUtils.parseMetaInfo(metaInfoElem); + + return factory.createCreateTransformsInfo(transforms, finalDataMetaInfo); + } + + /** + * Parse a <code>CreateSignatureEnvironmentProfile</code> DOM element. + * + * @param profileElem The <code>CreateSignatureEnvironmentProfile</code> + * DOM element to parse. + * @return The <code>CreateSignatureEnvironmentProfile</code> API object + * containing the data from the <code>profileElem</code>. + */ + public CreateSignatureEnvironmentProfile parseCreateSignatureEnvironmentProfile(Element profileElem) { + CreateSignatureLocation createSignatureLocation = + parseCreateSignatureLocation(profileElem); + List supplements = parseSupplements(profileElem); + + return factory.createCreateSignatureEnvironmentProfile( + createSignatureLocation, + supplements); + } + + /** + * Parse a <code>CreateSignatureLocation</code> DOM element contained in + * a <code>CreateSignatureEnvironmentProfile</code>. + * + * @param profileElem The <code>CreateSignatureEnvironmentProfile</code> DOM + * element containing the <code>CreateSignatureLocation</code>. + * @return The <code>CreateSignatureLocation</code> API object containing + * the data from the <code>CreateSignatureLocation</code> DOM element. + */ + private CreateSignatureLocation parseCreateSignatureLocation(Element profileElem) { + Element locationElem = + (Element) XPathUtils.selectSingleNode( + profileElem, + CREATE_SIGNATURE_LOCATION_XPATH); + String xPathExpression = DOMUtils.getText(locationElem); + Map namespaceDeclarations = DOMUtils.getNamespaceDeclarations(locationElem); + String indexStr = locationElem.getAttribute("Index"); + int index = Integer.parseInt(indexStr); + + return factory.createCreateSignatureLocation( + xPathExpression, + index, + namespaceDeclarations); + } + + /** + * Parse all <code>Supplement</code> DOM elements contained in a given + * parent DOM element. + * + * @param supplementsParentElem The DOM element being the parent of the + * <code>Supplement</code>s. + * @return A <code>List</code> of <code>Supplement</code> API objects + * containing the data from the <code>Supplement</code> DOM elements. + */ + private List parseSupplements(Element supplementsParentElem) { + List supplements = new ArrayList(); + NodeIterator supplementElems = + XPathUtils.selectNodeIterator(supplementsParentElem, SUPPLEMENT_XPATH); + Element supplementElem; + + while ((supplementElem = (Element) supplementElems.nextNode()) != null) { + XMLDataObjectAssociation supplement = + RequestParserUtils.parseXMLDataObjectAssociation(supplementElem); + supplements.add(supplement); + } + return supplements; + } + + /** + * Parse a <code>SupplementProfile</code> DOM element. + * + * @param profileElem The <code>SupplementProfile</code> DOM element to parse. + * @return The <code>SupplementProfile</code> API object containing the + * data from the <code>SupplementProfile</code> DOM element. + */ + public SupplementProfile parseSupplementProfile(Element profileElem) { + XMLDataObjectAssociation supplementProfile = + RequestParserUtils.parseXMLDataObjectAssociation(profileElem); + + return factory.createSupplementProfile(supplementProfile); + } + + /** + * Parse a <code>VerifyTransformsInfoProfile</code> DOM element. + * + * @param profileElem The <code>VerifyTransformsInfoProfile</code> DOM + * element to parse. + * @return A <code>VerifyTransformsInfoProfile</code> API object containing + * the information from the <code>VerifyTransformsInfoProfile</code> DOM + * element. + * @throws MOAApplicationException An error occurred parsing the + * <code>VerifyTransformsInfoProfile</code>. + */ + public VerifyTransformsInfoProfile parseVerifyTransformsInfoProfile(Element profileElem) + throws MOAApplicationException { + Element transformsElem = + (Element) XPathUtils.selectSingleNode( + profileElem, + VERIFY_TRANSFORMS_XPATH); + List transforms = null; + NodeIterator paramElems = + XPathUtils.selectNodeIterator(profileElem, TRANSFORM_PARAMETER_XPATH); + Element paramElem; + List transformParameters = new ArrayList(); + + // parse the dsig:Transforms + if (transformsElem != null) { + TransformParser transformsParser = new TransformParser(); + transforms = transformsParser.parseTransforms(transformsElem); + } + + // parse the TransformParameter elements + while ((paramElem = (Element) paramElems.nextNode()) != null) { + transformParameters.add(parseTransformParameter(paramElem)); + } + + return factory.createVerifyTransformsInfoProfile( + transforms, + transformParameters); + } + + /** + * Parse a <code>TransformParameter</code> DOM element. + * + * @param paramElem The <code>TransformParameter</code> DOM element to + * parse. + * @return The <code>TransformParameter</code> API object containing the + * information from the <code>TransformParameter</code> DOM element. + * @throws MOAApplicationException An error occurred parsing the + * <code>TransformParameter</code> DOM element. + */ + private TransformParameter parseTransformParameter(Element paramElem) + throws MOAApplicationException { + String uri = paramElem.getAttribute("URI"); + Element contentElem = + (Element) XPathUtils.selectSingleNode( + paramElem, + TRANSFORM_PARAMETER_CONTENT_XPATH); + + if (contentElem == null) { + return factory.createTransformParameter(uri); + } else if ("Base64Content".equals(contentElem.getLocalName())) { + String base64Str = DOMUtils.getText(contentElem); + InputStream binaryContent = Base64Utils.decodeToStream(base64Str, true); + + return factory.createTransformParameter(uri, binaryContent); + } else { // "Hash".equals(contentElem.getLocalName()) + String digestMethodStr = + XPathUtils.getElementValue(contentElem, DIGEST_METHOD_XPATH, ""); + String digestValueStr = + XPathUtils.getElementValue(contentElem, DIGEST_VALUE_XPATH, ""); + byte[] digestValue = null; + + try { + digestValue = Base64Utils.decode(digestValueStr, true); + } catch (IOException e) { + throw new MOAApplicationException("2270", null); + } + return factory.createTransformParameter( + uri, + digestMethodStr, + digestValue); + } + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/RequestParserUtils.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/RequestParserUtils.java new file mode 100644 index 000000000..0fff949b1 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/RequestParserUtils.java @@ -0,0 +1,147 @@ +package at.gv.egovernment.moa.spss.api.xmlbind; + +import java.text.ParseException; +import java.util.Date; + +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; + +import at.gv.egovernment.moa.util.Base64Utils; +import at.gv.egovernment.moa.util.Constants; +import at.gv.egovernment.moa.util.DOMUtils; +import at.gv.egovernment.moa.util.DateTimeUtils; +import at.gv.egovernment.moa.util.XPathUtils; + +import at.gv.egovernment.moa.spss.MOAApplicationException; +import at.gv.egovernment.moa.spss.api.SPSSFactory; +import at.gv.egovernment.moa.spss.api.common.Content; +import at.gv.egovernment.moa.spss.api.common.MetaInfo; +import at.gv.egovernment.moa.spss.api.common.XMLDataObjectAssociation; + +/** + * Utility methods for parsing XML requests definied in the MOA XML schema. + * + * @author Patrick Peck + * @version $Id$ + */ +public class RequestParserUtils { + // + // XPath expressions for parsing parts of a request + // + private static final String MOA = Constants.MOA_PREFIX + ":"; + private static final String REFERENCE_ATTR_NAME = "Reference"; + private static final String MIME_TYPE_XPATH = MOA + "MimeType"; + private static final String DESCRIPTION_XPATH = MOA + "Description"; + private static final String XML_ASSOC_CONTENT_XPATH = MOA + "Content"; + private static final String CONTENT_XPATH = + MOA + "Base64Content | " + MOA + "XMLContent"; + private static final String ANY_OTHER_XPATH = + "*[namespace-uri() != \"" + Constants.MOA_NS_URI + "\"]"; + + /** + * Parse a <code>XMLDataObjectAssociationType</code> kind of DOM element. + * + * @param assocElem The <code>XMLDataObjectAssociationType</code> kind of + * DOM elmeent to parse. + * @return The <code>XMLDataObjectAssociation</code> API object containing + * the data from the <code>XMLDataObjectAssociationType</code> DOM element. + */ + public static XMLDataObjectAssociation parseXMLDataObjectAssociation(Element assocElem) { + SPSSFactory factory = SPSSFactory.getInstance(); + MetaInfo metaInfo = parseMetaInfo(assocElem); + Element contentElem = + (Element) XPathUtils.selectSingleNode(assocElem, XML_ASSOC_CONTENT_XPATH); + Content content = parseContent(contentElem); + + return factory.createXMLDataObjectAssociation(metaInfo, content); + } + + /** + * Parse a <code>MetaInfoType</code> kind of DOM element. + * + * @param metaInfoElem The <code>MetaInfoType</code> kind of DOM element. + * @return The <code>MetaInfo</code> API object containing the data from + * the <code>metaInfoElem</code>. + */ + public static MetaInfo parseMetaInfo(Element metaInfoElem) { + SPSSFactory factory = SPSSFactory.getInstance(); + String mimeType = + XPathUtils.getElementValue(metaInfoElem, MIME_TYPE_XPATH, null); + String description = + XPathUtils.getElementValue(metaInfoElem, DESCRIPTION_XPATH, null); + NodeList anyOther = + XPathUtils.selectNodeList(metaInfoElem, ANY_OTHER_XPATH); + + return factory.createMetaInfo(mimeType, description, anyOther); + } + + /** + * Parse a <code>ContentOptionalRefType</code> or + * <code>ContentRequiredRefType</code> kind of DOM element. + * @param contentParentElem The DOM element being the parent of the + * content element. + * @return The <code>Content</code> API object containing the data from + * the given DOM element. + */ + public static Content parseContent(Element contentParentElem) { + SPSSFactory factory = SPSSFactory.getInstance(); + String referenceURI = + contentParentElem.hasAttribute(REFERENCE_ATTR_NAME) + ? contentParentElem.getAttribute(REFERENCE_ATTR_NAME) + : null; + Element contentElem = + (Element) XPathUtils.selectSingleNode(contentParentElem, CONTENT_XPATH); + + if (contentElem == null) { + return factory.createContent(referenceURI); + } + + if ("Base64Content".equals(contentElem.getLocalName())) { + String base64String = DOMUtils.getText(contentElem); + return factory.createContent( + Base64Utils.decodeToStream(base64String, true), + referenceURI); + } else { // "XMLContent".equals(contentElem.getLocalName()) + return factory.createContent(contentElem.getChildNodes(), referenceURI); + } + } + + /** + * Get the signing time from a Verfiy(CMS|XML)SignatureRequest. + * + * @param requestElem A <code>Verify(CMS|XML)SignatureRequest</code> DOM + * element. + * @param dateTimeXPath The XPath to lookup the <code>DateTime</code> element + * within the request. + * @return Date The date and time corresponding to the <code>DateTime</code> + * element in the request. If no <code>DateTime</code> element exists in the + * request, <code>null</code> is returned. + * @throws MOAApplicationException An error occurred during a parsing the + * <code>DateTime</code> element or creating the return value. + */ + public static Date parseDateTime(Element requestElem, String dateTimeXPath) + throws MOAApplicationException { + + Element dateTimeElem; + String dateTimeText; + + // select the DateTime element + dateTimeElem = + (Element) XPathUtils.selectSingleNode(requestElem, dateTimeXPath); + + // parse a date from the element value + if (dateTimeElem != null) { + dateTimeText = DOMUtils.getText(dateTimeElem); + try { + return DateTimeUtils.parseDateTime(dateTimeText); + } catch (ParseException e) { + throw new MOAApplicationException( + "1104", + new Object[] { dateTimeText }); + } + } else { + return null; + } + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/ResponseBuilderUtils.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/ResponseBuilderUtils.java new file mode 100644 index 000000000..cc3e73e41 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/ResponseBuilderUtils.java @@ -0,0 +1,213 @@ +package at.gv.egovernment.moa.spss.api.xmlbind; + +import java.io.IOException; +import java.security.cert.CertificateEncodingException; +import java.security.cert.X509Certificate; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +import org.w3c.dom.DOMImplementation; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; + +import iaik.utils.RFC2253NameParser; +import iaik.utils.RFC2253NameParserException; + +import at.gv.egovernment.moa.util.Base64Utils; +import at.gv.egovernment.moa.util.Constants; + +import at.gv.egovernment.moa.spss.MOAApplicationException; +import at.gv.egovernment.moa.spss.MOASystemException; + +/** + * Utility methods used by the verious <code>ResponseBuilder</code> classes. + * + * @author Patrick Peck + * @version $Id$ + */ +class ResponseBuilderUtils { + // + // shortcuts to various XML namespace constants + // + private static final String MOA_NS_URI = Constants.MOA_NS_URI; + private static final String SL11 = Constants.SL11_PREFIX + ":"; + private static final String SL11_NS_URI = Constants.SL11_NS_URI; + private static final String DSIG = Constants.DSIG_PREFIX + ":"; + private static final String DSIG_NS_URI = Constants.DSIG_NS_URI; + private static final String XMLNS_NS_URI = Constants.XMLNS_NS_URI; + + /** + * Create a response element with all the namespaces set. + * + * @param responseName The name of the response root element. + * @return A DOM document containing the response root element and predefined + * MOA, DSIG and XML namespace declarations. + * @throws MOASystemException An error building the response document. + */ + public static Document createResponse(String responseName) + throws MOASystemException { + + try { + DocumentBuilder docBuilder = + DocumentBuilderFactory.newInstance().newDocumentBuilder(); + DOMImplementation impl = docBuilder.getDOMImplementation(); + Document response; + Element root; + String attrValue; + + response = impl.createDocument(MOA_NS_URI, responseName, null); + root = response.getDocumentElement(); + + // add namespace prefix declarations + root.setAttributeNS(XMLNS_NS_URI, "xmlns", MOA_NS_URI); + attrValue = "xmlns:" + Constants.DSIG_PREFIX; + root.setAttributeNS(XMLNS_NS_URI, attrValue, DSIG_NS_URI); + + return response; + } catch (ParserConfigurationException e) { + throw new MOASystemException("2200", null, e); + } + } + + /** + * Add a <code>SignerInfo</code> element to the response. + * + * @param response The response document, in order to create new elements in + * it. + * @param root The root element into which the <code>SignerInfo</code> element + * will be inserted. + * @param cert The signer certificate to add. + * @param isQualified Indicates, whether <code>cert</code> is a qualified + * certificate. + * @param isPublicAuthority Indicates, whether <code>cert</code> is + * certificate owned by a public authority. + * @param publicAuthorityID Information about the public authority owning + * <code>cert</code>. Must not be <code>null</code>, if + * <code>isPublicAuthority ! = null</code>. + * @throws MOAApplicationException An error occurred reading data from the + * certificate. + */ + public static void addSignerInfo( + Document response, + Element root, + X509Certificate cert, + boolean isQualified, + boolean isPublicAuthority, + String publicAuthorityID) + throws MOAApplicationException { + + Element signerInfoElem = response.createElementNS(MOA_NS_URI, "SignerInfo"); + Element x509DataElem = + response.createElementNS(DSIG_NS_URI, DSIG + "X509Data"); + Element x509IssuerSerialElem = + response.createElementNS(DSIG_NS_URI, DSIG + "X509IssuerSerial"); + Element x509IssuerElem = + response.createElementNS(DSIG_NS_URI, DSIG + "X509IssuerName"); + String issuer = cert.getIssuerDN().getName(); + Element x509SerialNumberElem = + response.createElementNS(DSIG_NS_URI, DSIG + "X509SerialNumber"); + String serialNumber = cert.getSerialNumber().toString(); + Element x509SubjectNameElem = + response.createElementNS(DSIG_NS_URI, DSIG + "X509SubjectName"); + Element x509CertificateElem = + response.createElementNS(DSIG_NS_URI, DSIG + "X509Certificate"); + Element qualifiedCertificateElem = + isQualified + ? response.createElementNS(SL11_NS_URI, SL11 + "QualifiedCertificate") + : null; + Element publicAuthorityElem = + isPublicAuthority + ? response.createElementNS(MOA_NS_URI, "PublicAuthority") + : null; + Element codeElem = + publicAuthorityID != null + ? response.createElementNS(MOA_NS_URI, "Code") + : null; + + // fill in text + x509IssuerElem.appendChild(response.createTextNode(issuer)); + x509SerialNumberElem.appendChild(response.createTextNode(serialNumber)); + try { + RFC2253NameParser parser = + new RFC2253NameParser(cert.getSubjectDN().getName()); + String subjectRfc2253 = parser.parse().getRFC2253String(); + x509SubjectNameElem.appendChild(response.createTextNode(subjectRfc2253)); + } catch (RFC2253NameParserException e) { + x509SubjectNameElem.appendChild( + response.createTextNode(cert.getSubjectDN().getName())); + } + try { + x509CertificateElem.appendChild( + response.createTextNode(Base64Utils.encode(cert.getEncoded()))); + } catch (CertificateEncodingException e) { + throw new MOAApplicationException("2245", null, e); + } catch (IOException e) { + throw new MOAApplicationException("2245", null, e); + } + + // build structure + x509DataElem.appendChild(x509SubjectNameElem); + x509IssuerSerialElem.appendChild(x509IssuerElem); + x509IssuerSerialElem.appendChild(x509SerialNumberElem); + x509DataElem.appendChild(x509IssuerSerialElem); + x509DataElem.appendChild(x509CertificateElem); + if (isQualified) { + String attrValue = "xmlns:" + Constants.SL11_PREFIX; + qualifiedCertificateElem.setAttributeNS( + XMLNS_NS_URI, + attrValue, + SL11_NS_URI); + x509DataElem.appendChild(qualifiedCertificateElem); + } + if (isPublicAuthority) { + x509DataElem.appendChild(publicAuthorityElem); + if (publicAuthorityID != null) { + codeElem.appendChild(response.createTextNode(publicAuthorityID)); + publicAuthorityElem.appendChild(codeElem); + } + } + signerInfoElem.appendChild(x509DataElem); + root.appendChild(signerInfoElem); + } + + /** + * Add an element containing <code>Code</code> and <code>Info</code> + * subelements. + * + * @param response The response document, in order to create new elements in + * it. + * @param root The root element into which to insert the newly created + * element. + * @param elementName The name of the newly created element. + * @param code The content of the <code>Code</code> subelement. + * @param info The content of the <code>Info</code> subelement. + */ + public static void addCodeInfoElement( + Document response, + Element root, + String elementName, + int code, + NodeList info) { + + Element codeInfoElem = response.createElementNS(MOA_NS_URI, elementName); + Element codeElem = response.createElementNS(MOA_NS_URI, "Code"); + Element infoElem; + int i; + + codeElem.appendChild(response.createTextNode(Integer.toString(code))); + codeInfoElem.appendChild(codeElem); + if (info != null) { + infoElem = response.createElementNS(MOA_NS_URI, "Info"); + + for (i = 0; i < info.getLength(); i++) { + infoElem.appendChild(info.item(i).cloneNode(true)); + } + codeInfoElem.appendChild(infoElem); + } + root.appendChild(codeInfoElem); + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/TransformParser.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/TransformParser.java new file mode 100644 index 000000000..84f377826 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/TransformParser.java @@ -0,0 +1,251 @@ +package at.gv.egovernment.moa.spss.api.xmlbind; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.StringTokenizer; + +import org.w3c.dom.Element; +import org.w3c.dom.traversal.NodeIterator; + +import at.gv.egovernment.moa.util.Constants; +import at.gv.egovernment.moa.util.DOMUtils; +import at.gv.egovernment.moa.util.XPathUtils; + +import at.gv.egovernment.moa.spss.MOAApplicationException; +import at.gv.egovernment.moa.spss.api.SPSSFactory; +import at.gv.egovernment.moa.spss.api.common.Base64Transform; +import at.gv.egovernment.moa.spss.api.common.CanonicalizationTransform; +import at.gv.egovernment.moa.spss.api.common.EnvelopedSignatureTransform; +import at.gv.egovernment.moa.spss.api.common.ExclusiveCanonicalizationTransform; +import at.gv.egovernment.moa.spss.api.common.Transform; +import at.gv.egovernment.moa.spss.api.common.XPathFilter; +import at.gv.egovernment.moa.spss.api.common.XPathFilter2Transform; +import at.gv.egovernment.moa.spss.api.common.XPathTransform; +import at.gv.egovernment.moa.spss.api.common.XSLTTransform; + +/** + * A parser to parse XMLDsig <code>Transform</code> DOM elements into their + * MOA SPSS API representation. + * + * @author Patrick Peck + * @version $Id$ + */ +public class TransformParser { + // + // XPath expressions for selecting information from the DOM tree + // + private static final String DSIG = Constants.DSIG_PREFIX + ":"; + private static final String DSIG_FILTER2 = + Constants.DSIG_FILTER2_PREFIX + ":"; + private static final String XSLT = Constants.XSLT_PREFIX + ":"; + private static final String EC = Constants.DSIG_EC_PREFIX + ":"; + private static final String TRANSFORM_XPATH = DSIG + "Transform"; + private static final String XPATH_XPATH = DSIG + "XPath"; + private static final String XSLT_ELEMENT_XPATH = XSLT + "stylesheet"; + private static final String XPATH2_XPATH = + (DSIG_FILTER2 + "XPath[@Filter=\"intersect\"] | ") + + (DSIG_FILTER2 + "XPath[@Filter=\"subtract\"] | ") + + (DSIG_FILTER2 + "XPath[@Filter=\"union\"]"); + private static final String INCLUSIVE_NAMESPACES_XPATH = + EC + "InclusiveNamespaces"; + + /** + * The <code>SPSSFactory</code> to use for creating new API objects. + */ + private SPSSFactory factory = SPSSFactory.getInstance(); + + /** + * Parse an XMLDsig <code>Transforms</code> DOM element. + * + * @param transformsElem The <code>Transforms</code> DOM element to parse. + * @return A <code>List</code> of <code>Transform</code> API objects + * containing the data from the individual <code>Transform</code> DOM + * elements. + * @throws MOAApplicationException An error occurred parsing the + * <code>Transforms</code> DOM element. + */ + public List parseTransforms(Element transformsElem) + throws MOAApplicationException { + List transforms = new ArrayList(); + NodeIterator transformElems = + XPathUtils.selectNodeIterator(transformsElem, TRANSFORM_XPATH); + Element transformElem; + Transform transform; + + while ((transformElem = (Element) transformElems.nextNode()) != null) { + transform = parseTransform(transformElem); + transforms.add(transform); + } + + return transforms; + } + + /** + * Parse an XMLDsig <code>Transform</code> DOM element. + * + * @param transformElem <code>Transform</code> DOM element to parse. + * @return The <code>Transform</code> API object containing the data + * from the <code>Transform</code> DOM element. + * @throws MOAApplicationException An error occurred parsing the + * <code>Transform</code> DOM element. + */ + public Transform parseTransform(Element transformElem) + throws MOAApplicationException { + + String algorithmUri = transformElem.getAttribute("Algorithm"); + + if (CanonicalizationTransform.CANONICAL_XML.equals(algorithmUri) + || CanonicalizationTransform.CANONICAL_XML_WITH_COMMENTS.equals( + algorithmUri)) { + return factory.createCanonicalizationTransform(algorithmUri); + } else if ( + ExclusiveCanonicalizationTransform.EXCLUSIVE_CANONICAL_XML.equals( + algorithmUri) + || ExclusiveCanonicalizationTransform + .EXCLUSIVE_CANONICAL_XML_WITH_COMMENTS + .equals( + algorithmUri)) { + return parseExclusiveC14nTransform(algorithmUri, transformElem); + } else if (Base64Transform.BASE64_DECODING.equals(algorithmUri)) { + return factory.createBase64Transform(); + } else if ( + EnvelopedSignatureTransform.ENVELOPED_SIGNATURE.equals(algorithmUri)) { + return factory.createEnvelopedSignatureTransform(); + } else if (XPathTransform.XPATH.equals(algorithmUri)) { + return parseXPathTransform(transformElem); + } else if (XPathFilter2Transform.XPATH_FILTER2.equals(algorithmUri)) { + return parseXPathFilter2Transform(transformElem); + } else if (XSLTTransform.XSLT.equals(algorithmUri)) { + return parseXSLTTransform(transformElem); + } else { + throw new MOAApplicationException("1108", new Object[] { algorithmUri }); + } + } + + /** + * Parse an exclusive canonicalization type of transform. + * + * @param algorithmUri The algorithm URI of the canonicalization algorithm. + * @param transformElem The <code>Transform</code> DOM element to parse. + * @return An <code>ExclusiveCanonicalizationTransform</code> API object + * containing the data from the <code>transformElem</code>. + * @throws MOAApplicationException An error occurred parsing the + * <code>transformElem</code>. + */ + private Transform parseExclusiveC14nTransform( + String algorithmUri, + Element transformElem) + throws MOAApplicationException { + + Element inclusiveNamespacesElem = + (Element) XPathUtils.selectSingleNode( + transformElem, + INCLUSIVE_NAMESPACES_XPATH); + + if (inclusiveNamespacesElem == null) { + throw new MOAApplicationException("2217", null); + } else { + StringTokenizer tokenizer = + new StringTokenizer(inclusiveNamespacesElem.getAttribute("PrefixList")); + List inclusiveNamespaces = new ArrayList(); + + while (tokenizer.hasMoreTokens()) { + inclusiveNamespaces.add(tokenizer.nextToken()); + } + + return factory.createExclusiveCanonicalizationTransform( + algorithmUri, + inclusiveNamespaces); + } + } + + /** + * Parse an <code>XPath</code> type of <code>Transform</code>. + * + * @param transformElem The <code>Transform</code> DOM element to parse. + * @return The <code>Transform</code> API object representation of the + * <code>Transform</code> DOM element. + * @throws MOAApplicationException An error occurred parsing the + * <code>Transform</code> DOM element. + */ + private Transform parseXPathTransform(Element transformElem) + throws MOAApplicationException { + Element xPathElem = + (Element) XPathUtils.selectSingleNode(transformElem, XPATH_XPATH); + Map nsDecls; + + if (xPathElem == null) { + throw new MOAApplicationException("2202", null); + } + + nsDecls = DOMUtils.getNamespaceDeclarations(xPathElem); + nsDecls.remove(""); + + return factory.createXPathTransform(DOMUtils.getText(xPathElem), nsDecls); + } + + /** + * Parse an <code>XPathFilter2</code> type of <code>Transform</code>. + * + * @param transformElem The <code>Transform</code> DOM element to parse. + * @return The <code>Transform</code> API object representation of the + * <code>Transform</code> DOM element. + * @throws MOAApplicationException An error occurred parsing the + * <code>Transform</code> DOM element. + */ + private Transform parseXPathFilter2Transform(Element transformElem) + throws MOAApplicationException { + List filters = new ArrayList(); + NodeIterator iter = + XPathUtils.selectNodeIterator(transformElem, XPATH2_XPATH); + Element filterElem; + + while ((filterElem = (Element) iter.nextNode()) != null) { + String filterAttr = filterElem.getAttribute("Filter"); + String filterType; + String expression; + Map nsDecls; + + if (filterAttr.equals("intersect")) { + filterType = XPathFilter.INTERSECT_TYPE; + } else if (filterAttr.equals("subtract")) { + filterType = XPathFilter.SUBTRACT_TYPE; + } else { + filterType = XPathFilter.UNION_TYPE; + } + + expression = DOMUtils.getText(filterElem); + nsDecls = DOMUtils.getNamespaceDeclarations(filterElem); + nsDecls.remove(""); + filters.add(factory.createXPathFilter(filterType, expression, nsDecls)); + } + if (filters.size() == 0) { + throw new MOAApplicationException("2216", null); + } + + return factory.createXPathFilter2Transform(filters); + } + + /** + * Parse an <code>XSLT</code> type of <code>Transform</code>. + * + * @param transformElem The <code>Transform</code> DOM element to parse. + * @return The <code>Transform</code> API object representation of the + * <code>Transform</code> DOM element. + * @throws MOAApplicationException An error occurred parsing the + * <code>Transform</code> DOM element. + */ + private Transform parseXSLTTransform(Element transformElem) + throws MOAApplicationException { + Element xsltElem = + (Element) XPathUtils.selectSingleNode(transformElem, XSLT_ELEMENT_XPATH); + + if (xsltElem == null) { + throw new MOAApplicationException("2215", null); + } + + return factory.createXSLTTransform(xsltElem); + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/VerifyCMSSignatureRequestParser.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/VerifyCMSSignatureRequestParser.java new file mode 100644 index 000000000..74d14b7cc --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/VerifyCMSSignatureRequestParser.java @@ -0,0 +1,169 @@ +package at.gv.egovernment.moa.spss.api.xmlbind; + +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.StringTokenizer; + +import org.w3c.dom.Element; + +import at.gv.egovernment.moa.util.Base64Utils; +import at.gv.egovernment.moa.util.CollectionUtils; +import at.gv.egovernment.moa.util.Constants; +import at.gv.egovernment.moa.util.DOMUtils; +import at.gv.egovernment.moa.util.XPathUtils; + +import at.gv.egovernment.moa.spss.MOAApplicationException; +import at.gv.egovernment.moa.spss.api.SPSSFactory; +import at.gv.egovernment.moa.spss.api.cmsverify.CMSContent; +import at.gv.egovernment.moa.spss.api.cmsverify.CMSDataObject; +import at.gv.egovernment.moa.spss.api.cmsverify.VerifyCMSSignatureRequest; +import at.gv.egovernment.moa.spss.api.common.MetaInfo; + +/** + * A parser to parse <code>VerifyCMSSignatureRequest</code> DOM trees into + * <code>VerifyCMSSignatureRequest</code> API objects. + * + * @author Patrick Peck + * @version $Id$ + */ +public class VerifyCMSSignatureRequestParser { + + // + // XPath expressions for selecting parts of the DOM message + // + private static final String MOA = Constants.MOA_PREFIX + ":"; + private static final String DATE_TIME_XPATH = MOA + "DateTime"; + private static final String CMS_SIGNATURE_XPATH = MOA + "CMSSignature"; + private static final String TRUST_PROFILE_ID_XPATH = MOA + "TrustProfileID"; + private static final String DATA_OBJECT_XPATH = MOA + "DataObject"; + private static final String META_INFO_XPATH = MOA + "MetaInfo"; + private static final String CONTENT_XPATH = MOA + "Content"; + private static final String BASE64_CONTENT_XPATH = MOA + "Base64Content"; + + /** The <code>SPSSFactory</code> for creating new API objects. */ + private SPSSFactory factory = SPSSFactory.getInstance(); + + /** + * Parse a <code>VerifyCMSSignatureRequest</code> DOM element, as defined + * by the MOA schema. + * + * @param requestElem The <code>VerifyCMSSignatureRequest</code> to parse. The + * request must have been successfully parsed against the schema for this + * method to succeed. + * @return A <code>VerifyCMSSignatureRequest</code> API objects containing + * the data from the DOM element. + * @throws MOAApplicationException An error occurred parsing the request. + */ + public VerifyCMSSignatureRequest parse(Element requestElem) + throws MOAApplicationException { + + int[] signatories = parseSignatories(requestElem); + Date dateTime = + RequestParserUtils.parseDateTime(requestElem, DATE_TIME_XPATH); + String cmsSignatureStr = + XPathUtils.getElementValue(requestElem, CMS_SIGNATURE_XPATH, ""); + CMSDataObject dataObject = parseDataObject(requestElem); + String trustProfileID = + XPathUtils.getElementValue(requestElem, TRUST_PROFILE_ID_XPATH, null); + InputStream cmsSignature = + Base64Utils.decodeToStream(cmsSignatureStr, true); + + return factory.createVerifyCMSSignatureRequest( + signatories, + dateTime, + cmsSignature, + dataObject, + trustProfileID); + } + + /** + * Parse the <code>Signatories</code> attribute contained in the + * <code>VerifyCMSSignatureRequest</code> DOM element. + * + * @param requestElem The <code>VerifyCMSSignatureRequest</code> DOM element. + * @return The signatories contained in the given + * <code>VerifyCMSSignatureRequest</code> DOM element. + */ + private int[] parseSignatories(Element requestElem) { + String signatoriesStr = requestElem.getAttribute("Signatories"); + + if ("all".equals(signatoriesStr)) { + return VerifyCMSSignatureRequest.ALL_SIGNATORIES; + } else { + StringTokenizer tokenizer = new StringTokenizer(signatoriesStr); + List signatoriesList = new ArrayList(); + int[] signatories; + + // put the signatories into a List + while (tokenizer.hasMoreTokens()) { + try { + signatoriesList.add(new Integer(tokenizer.nextToken())); + } catch (NumberFormatException e) { + // this cannot occur if the request has been validated + } + } + + // convert the List into an int array + signatories = CollectionUtils.toIntArray(signatoriesList); + + return signatories; + } + } + + /** + * Parse a the <code>DataObject</code> DOM element contained in a given + * <code>VerifyCMSSignatureRequest</code> DOM element. + * + * @param requestElem The <code>VerifyCMSSignatureRequest</code> DOM element + * to parse. + * @return The <code>CMSDataObject</code> API object containing the data + * from the <code>DataObject</code> DOM element. + */ + private CMSDataObject parseDataObject(Element requestElem) { + Element dataObjectElem = + (Element) XPathUtils.selectSingleNode(requestElem, DATA_OBJECT_XPATH); + + if (dataObjectElem != null) { + Element metaInfoElem = + (Element) XPathUtils.selectSingleNode(dataObjectElem, META_INFO_XPATH); + MetaInfo metaInfo = null; + Element contentElem = + (Element) XPathUtils.selectSingleNode(dataObjectElem, CONTENT_XPATH); + CMSContent content = parseContent(contentElem); + + if (metaInfoElem != null) { + metaInfo = RequestParserUtils.parseMetaInfo(metaInfoElem); + } + + return factory.createCMSDataObject(metaInfo, content); + } else { + return null; + } + + } + + /** + * Parse the content contained in a <code>CMSContentBaseType</code> kind of + * DOM element. + * + * @param contentElem The <code>CMSContentBaseType</code> kind of element to + * parse. + * @return A <code>CMSDataObject</code> API object containing the data + * from the given DOM element. + */ + private CMSContent parseContent(Element contentElem) { + Element base64ContentElem = + (Element) XPathUtils.selectSingleNode(contentElem, BASE64_CONTENT_XPATH); + + if (base64ContentElem != null) { + String base64Str = DOMUtils.getText(base64ContentElem); + InputStream binaryContent = Base64Utils.decodeToStream(base64Str, true); + return factory.createCMSContent(binaryContent); + } else { + return factory.createCMSContent( + contentElem.getAttribute("Reference")); + } + } +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/VerifyCMSSignatureResponseBuilder.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/VerifyCMSSignatureResponseBuilder.java new file mode 100644 index 000000000..3fc8f223d --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/VerifyCMSSignatureResponseBuilder.java @@ -0,0 +1,101 @@ +package at.gv.egovernment.moa.spss.api.xmlbind; + +import java.util.Iterator; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +import at.gv.egovernment.moa.spss.MOAApplicationException; +import at.gv.egovernment.moa.spss.MOASystemException; +import at.gv.egovernment.moa.spss.api.cmsverify.VerifyCMSSignatureResponse; +import at.gv.egovernment.moa.spss.api.cmsverify.VerifyCMSSignatureResponseElement; +import at.gv.egovernment.moa.spss.api.common.CheckResult; +import at.gv.egovernment.moa.spss.api.common.SignerInfo; + +/** + * Convert a <code>VerifyCMSSignatureResponse</code> API object into its + * XML representation, according to the MOA XML schema. + * + * @author Patrick Peck + * @version $Id$ + */ +public class VerifyCMSSignatureResponseBuilder { + /** The XML document containing the response element. */ + private Document responseDoc; + /** The response <code>VerifyCMSSignatureResponse</code> DOM element. */ + private Element responseElem; + + /** + * Create a new <code>VerifyCMSSignatureResponseBuilder</code>: + * + * @throws MOASystemException An error occurred setting up the resulting + * XML document. + */ + public VerifyCMSSignatureResponseBuilder() throws MOASystemException { + responseDoc = + ResponseBuilderUtils.createResponse("VerifyCMSSignatureResponse"); + responseElem = responseDoc.getDocumentElement(); + } + + /** + * Build a document containing a <code>VerifyCMSSignatureResponse</code> + * DOM element being the XML representation of the given + * <code>VerifyCMSSignatureResponse</code> API object. + * + * @param response The <code>VerifyCMSSignatureResponse</code> to convert + * to XML. + * @return A document containing the <code>VerifyCMSSignatureResponse</code> + * DOM element. + * @throws MOAApplicationException An error occurred building the response. + */ + public Document build(VerifyCMSSignatureResponse response) + throws MOAApplicationException { + + Iterator iter; + + for (iter = response.getResponseElements().iterator(); iter.hasNext();) { + VerifyCMSSignatureResponseElement responseElement = + (VerifyCMSSignatureResponseElement) iter.next(); + addResponseElement(responseElement); + } + + return responseDoc; + } + + /** + * Add an element to the response. + * + * @param responseElement The element to add to the response. + * @throws MOAApplicationException An error occurred adding the element. + */ + private void addResponseElement(VerifyCMSSignatureResponseElement responseElement) + throws MOAApplicationException { + + SignerInfo signerInfo = responseElement.getSignerInfo(); + CheckResult signatureCheck = responseElement.getSignatureCheck(); + CheckResult certCheck = responseElement.getCertificateCheck(); + + ResponseBuilderUtils.addSignerInfo( + responseDoc, + responseElem, + signerInfo.getSignerCertificate(), + signerInfo.isQualifiedCertificate(), + signerInfo.isPublicAuthority(), + signerInfo.getPublicAuhtorityID()); + + ResponseBuilderUtils.addCodeInfoElement( + responseDoc, + responseElem, + "SignatureCheck", + signatureCheck.getCode(), + signatureCheck.getInfo()); + + ResponseBuilderUtils.addCodeInfoElement( + responseDoc, + responseElem, + "CertificateCheck", + certCheck.getCode(), + certCheck.getInfo()); + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/VerifyXMLSignatureRequestParser.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/VerifyXMLSignatureRequestParser.java new file mode 100644 index 000000000..e736af522 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/VerifyXMLSignatureRequestParser.java @@ -0,0 +1,275 @@ +package at.gv.egovernment.moa.spss.api.xmlbind; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; + +import org.w3c.dom.Element; +import org.w3c.dom.traversal.NodeIterator; + +import at.gv.egovernment.moa.util.BoolUtils; +import at.gv.egovernment.moa.util.Constants; +import at.gv.egovernment.moa.util.DOMUtils; +import at.gv.egovernment.moa.util.XPathUtils; + +import at.gv.egovernment.moa.spss.MOAApplicationException; +import at.gv.egovernment.moa.spss.api.SPSSFactory; +import at.gv.egovernment.moa.spss.api.common.Content; +import at.gv.egovernment.moa.spss.api.xmlverify.ReferenceInfo; +import at.gv.egovernment.moa.spss.api.xmlverify.SignatureManifestCheckParams; +import at.gv.egovernment.moa.spss.api.xmlverify.SupplementProfile; +import at.gv.egovernment.moa.spss.api.xmlverify.VerifySignatureInfo; +import at.gv.egovernment.moa.spss.api.xmlverify.VerifySignatureLocation; +import at.gv.egovernment.moa.spss.api.xmlverify.VerifyXMLSignatureRequest; + +/** + * @author Patrick Peck + * @version $Id$ + */ +public class VerifyXMLSignatureRequestParser { + + // + // XPath expressions for parsing parts of the request + // + private static final String MOA = Constants.MOA_PREFIX + ":"; + private static final String DATE_TIME_XPATH = MOA + "DateTime"; + private static final String RETURN_HASH_INPUT_DATA_XPATH = + MOA + "ReturnHashInputData"; + private static final String TRUST_PROFILE_ID_XPATH = MOA + "TrustProfileID"; + private static final String VERIFY_SIGNATURE_ENVIRONMENT_XPATH = + MOA + "VerifySignatureInfo/" + MOA + "VerifySignatureEnvironment"; + private static final String VERIFY_SIGNATURE_LOCATION_XPATH = + MOA + "VerifySignatureInfo/" + MOA + "VerifySignatureLocation"; + private static final String SUPPLEMENT_PROFILE_XPATH = + MOA + "SupplementProfile | " + MOA + "SupplementProfileID"; + private static final String SIGNATURE_MANIFEST_CHECK_PARAMS_XPATH = + MOA + "SignatureManifestCheckParams"; + private static final String VERIFY_TRANSFORMS_INFO_PROFILE_XPATH = + (MOA + "VerifyTransformsInfoProfile | ") + + (MOA + "VerifyTransformsInfoProfileID"); + private static final String REFERENCE_INFO_XPATH = MOA + "ReferenceInfo"; + + /** The <code>SPSSFactory</code> for creating new API objects. */ + private SPSSFactory factory = SPSSFactory.getInstance(); + + + /** + * Parse a <code>VerifyXMLSignatureRequest</code> DOM element, as defined + * by the MOA schema. + * + * @param requestElem The <code>VerifyXMLSignatureRequest</code> to parse. The + * request must have been successfully parsed against the schema for this + * method to succeed. + * @return A <code>VerifyXMLSignatureRequest</code> API object containing + * the data from the DOM element. + * @throws MOAApplicationException An error occurred parsing the request. + */ + public VerifyXMLSignatureRequest parse(Element requestElem) + throws MOAApplicationException { + + Date dateTime = + RequestParserUtils.parseDateTime(requestElem, DATE_TIME_XPATH); + VerifySignatureInfo verifySignatureInfo = + parseVerifySignatureInfo(requestElem); + List supplementProfiles = parseSupplementProfiles(requestElem); + SignatureManifestCheckParams signatureManifestCheckParams = + parseSignatureManifestCheckParams(requestElem); + boolean returnHashInputData = + XPathUtils.selectSingleNode(requestElem, RETURN_HASH_INPUT_DATA_XPATH) + != null; + String trustProfileID = + XPathUtils.getElementValue(requestElem, TRUST_PROFILE_ID_XPATH, null); + + return factory.createVerifyXMLSignatureRequest( + dateTime, + verifySignatureInfo, + supplementProfiles, + signatureManifestCheckParams, + returnHashInputData, + trustProfileID); + } + + /** + * Parse the <code>VerifySignatureInfo</code> DOM element contained in + * the <code>VerifyXMLSignatureRequest</code> DOM element. + * + * @param requestElem The <code>VerifyXMLSignatureRequest</code> DOM element + * containing the <code>VerifySignatureInfo</code> DOM element. + * @return The <code>VerifySignatureInfo</code> API object containing the + * data from the DOM element. + */ + private VerifySignatureInfo parseVerifySignatureInfo(Element requestElem) { + Element verifySignatureEnvironmentElem = + (Element) XPathUtils.selectSingleNode( + requestElem, + VERIFY_SIGNATURE_ENVIRONMENT_XPATH); + Content verifySignatureEnvironment = + RequestParserUtils.parseContent(verifySignatureEnvironmentElem); + VerifySignatureLocation verifySignatureLocation = + parseVerifySignatureLocation(requestElem); + + return factory.createVerifySignatureInfo( + verifySignatureEnvironment, + verifySignatureLocation); + } + + /** + * Parse the <code>VerifySignatureLocation</code> DOM element contained + * in the given <code>VerifyXMLSignatureRequest</code> DOM element. + * + * @param requestElem The <code>VerifyXMLSignatureRequst</code> DOM element. + * @return The <code>VerifySignatureLocation</code> API object containing the + * data from the DOM element. + */ + private VerifySignatureLocation parseVerifySignatureLocation(Element requestElem) { + Element locationElem = + (Element) XPathUtils.selectSingleNode( + requestElem, + VERIFY_SIGNATURE_LOCATION_XPATH); + String xPathExpression = DOMUtils.getText(locationElem); + Map namespaceDeclarations = DOMUtils.getNamespaceDeclarations(locationElem); + + return factory.createVerifySignatureLocation( + xPathExpression, + namespaceDeclarations); + } + + /** + * Parse the supplement profiles contained in the given + * <code>VerifyXMLSignatureRequest</code> DOM element. + * + * @param requestElem The <code>VerifyXMLSignatureRequest</code> DOM element. + * @return A <code>List</code> of <code>SupplementProfile</code> API objects + * containing the data from the <code>SupplementProfile</code> DOM elements. + */ + private List parseSupplementProfiles(Element requestElem) { + List supplementProfiles = new ArrayList(); + NodeIterator profileElems = + XPathUtils.selectNodeIterator(requestElem, SUPPLEMENT_PROFILE_XPATH); + Element profileElem; + + while ((profileElem = (Element) profileElems.nextNode()) != null) { + SupplementProfile profile; + + if ("SupplementProfile".equals(profileElem.getLocalName())) { + ProfileParser profileParser = new ProfileParser(); + profile = profileParser.parseSupplementProfile(profileElem); + } else { + String profileID = DOMUtils.getText(profileElem); + profile = factory.createSupplementProfile(profileID); + } + supplementProfiles.add(profile); + } + return supplementProfiles; + } + + /** + * Parse the <code>SignatureManifestCheckParams</code> DOM element contained + * in the given <code>VerifyXMLSignatureRequest</code> DOM element. + * @param requestElem The <code>VerifyXMLSignatureRequest</code> DOM element. + * @return The <code>SignatureManifestCheckParams</code> API object containing + * the data from the <code>SignatureManifestCheckParams</code> DOM element. + * @throws MOAApplicationException An error occurred parsing the + * <code>SignatureManifestCheckParams</code> DOM element. + */ + private SignatureManifestCheckParams parseSignatureManifestCheckParams(Element requestElem) + throws MOAApplicationException { + Element paramsElem = + (Element) XPathUtils.selectSingleNode( + requestElem, + SIGNATURE_MANIFEST_CHECK_PARAMS_XPATH); + + if (paramsElem != null) { + String returnReferenceInputDataStr = + paramsElem.getAttribute("ReturnReferenceInputData"); + boolean returnReferencInputData = + BoolUtils.valueOf(returnReferenceInputDataStr); + List referenceInfos = parseReferenceInfos(paramsElem); + + return factory.createSignatureManifestCheckParams( + referenceInfos, + returnReferencInputData); + } else { + return null; + } + } + + /** + * Parse the <code>ReferenceInfo</code> DOM elements contained in a + * <code>SignatureManifestCheckParams</code> DOM element. + * + * @param paramsElem The <code>SignatureManifestCheckParams</code> DOM element + * containing the <code>ReferenceInfo</code> DOM elements. + * @return A <code>List</code> of <code>RefernceInfo</code> API objects + * containing the data from the <code>ReferenceInfo</code> DOM elements. + * @throws MOAApplicationException An error occurred parsing the + * <code>ReferenceInfo</code> DOM elements. + */ + private List parseReferenceInfos(Element paramsElem) + throws MOAApplicationException { + + List referenceInfos = new ArrayList(); + NodeIterator refInfoElems = + XPathUtils.selectNodeIterator(paramsElem, REFERENCE_INFO_XPATH); + Element refInfoElem; + + while ((refInfoElem = (Element) refInfoElems.nextNode()) != null) { + ReferenceInfo referenceInfo = parseReferenceInfo(refInfoElem); + + referenceInfos.add(referenceInfo); + } + + return referenceInfos; + } + + /** + * Parse a <code>ReferenceInfo</code> DOM element. + * + * @param refInfoElem The <code>ReferenceInfo</code> DOM element to parse. + * @return The <code>ReferenceInfo</code> API object containing the data + * from the given <code>ReferenceInfo</code> DOM element. + * @throws MOAApplicationException An error occurred parsing the + * <code>ReferenceInfo</code> DOM element. + */ + private ReferenceInfo parseReferenceInfo(Element refInfoElem) + throws MOAApplicationException { + List profiles = parseVerifyTransformsInfoProfiles(refInfoElem); + return factory.createReferenceInfo(profiles); + } + + /** + * Parse the <code>VerifyTransformsInfoProfile</code> DOM elements contained + * in a <code>ReferenceInfo</code> DOM element. + * + * @param refInfoElem <code>ReferenceInfo</code> DOM element containing + * the <code>VerifyTransformsInfoProfile</code> DOM elements. + * @return A <code>List</code> of <code>VerifyTransformsInfoProfile</code> + * API objects containing the profile data. + * @throws MOAApplicationException An error occurred building the + * <code>VerifyTransformsInfoProfile</code>s. + */ + private List parseVerifyTransformsInfoProfiles(Element refInfoElem) + throws MOAApplicationException { + + List profiles = new ArrayList(); + NodeIterator profileElems = + XPathUtils.selectNodeIterator( + refInfoElem, + VERIFY_TRANSFORMS_INFO_PROFILE_XPATH); + Element profileElem; + + while ((profileElem = (Element) profileElems.nextNode()) != null) { + if ("VerifyTransformsInfoProfile".equals(profileElem.getLocalName())) { + ProfileParser profileParser = new ProfileParser(); + profiles.add( + profileParser.parseVerifyTransformsInfoProfile(profileElem)); + } else { + String profileID = DOMUtils.getText(profileElem); + profiles.add(factory.createVerifyTransformsInfoProfile(profileID)); + } + } + return profiles; + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/VerifyXMLSignatureResponseBuilder.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/VerifyXMLSignatureResponseBuilder.java new file mode 100644 index 000000000..56bcf63fa --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/VerifyXMLSignatureResponseBuilder.java @@ -0,0 +1,300 @@ +package at.gv.egovernment.moa.spss.api.xmlbind; + +import java.io.IOException; +import java.util.Iterator; +import java.util.List; + +import org.w3c.dom.Document; +import org.w3c.dom.DocumentFragment; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; + +import at.gv.egovernment.moa.util.Base64Utils; +import at.gv.egovernment.moa.util.Constants; + +import at.gv.egovernment.moa.spss.MOAApplicationException; +import at.gv.egovernment.moa.spss.MOASystemException; +import at.gv.egovernment.moa.spss.api.common.Content; +import at.gv.egovernment.moa.spss.api.common.ContentBinary; +import at.gv.egovernment.moa.spss.api.common.ContentXML; +import at.gv.egovernment.moa.spss.api.xmlverify.ManifestRefsCheckResult; +import at.gv.egovernment.moa.spss.api.xmlverify.ReferencesCheckResult; +import at.gv.egovernment.moa.spss.api.xmlverify.VerifyXMLSignatureResponse; + +/** + * Convert a <code>VerifyXMLSignatureResponse</code> API object into its + * XML representation, according to the MOA XML schema. + * + * @author Patrick Peck + * @version $Id$ + */ +public class VerifyXMLSignatureResponseBuilder { + private static final String MOA_NS_URI = Constants.MOA_NS_URI; + + /** The XML document containing the response element. */ + private Document responseDoc; + /** The response <code>VerifyXMLSignatureResponse</code> DOM element. */ + private Element responseElem; + + /** + * Create a new <code>VerifyXMLSignatureResponseBuilder</code>: + * + * @throws MOASystemException An error occurred setting up the resulting + * XML document. + */ + public VerifyXMLSignatureResponseBuilder() throws MOASystemException { + responseDoc = + ResponseBuilderUtils.createResponse("VerifyXMLSignatureResponse"); + responseElem = responseDoc.getDocumentElement(); + } + + /** + * Build a document containing a <code>VerifyXMLSignatureResponse</code> + * DOM element being the XML representation of the given + * <code>VerifyXMLSignatureResponse</code> API object. + * + * @param response The <code>VerifyXMLSignatureResponse</code> to convert + * to XML. + * @return A document containing the <code>VerifyXMLSignatureResponse</code> + * DOM element. + * @throws MOAApplicationException An error occurred building the response. + */ + public Document build(VerifyXMLSignatureResponse response) + throws MOAApplicationException { + + Iterator iter; + List responseData; + + // add the SignerInfo + ResponseBuilderUtils.addSignerInfo( + responseDoc, + responseElem, + response.getSignerInfo().getSignerCertificate(), + response.getSignerInfo().isQualifiedCertificate(), + response.getSignerInfo().isPublicAuthority(), + response.getSignerInfo().getPublicAuhtorityID()); + + // add HashInputData elements + responseData = response.getHashInputDatas(); + if (responseData != null && !responseData.isEmpty()) { + for (iter = responseData.iterator(); iter.hasNext();) { + Content content = (Content) iter.next(); + addContent("HashInputData", content); + } + } + + // add ReferenceInputData elements + responseData = response.getReferenceInputDatas(); + if (responseData != null && !responseData.isEmpty()) { + for (iter = responseData.iterator(); iter.hasNext();) { + Content content = (Content) iter.next(); + addContent("ReferenceInputData", content); + } + } + + // add the SignatureCheck + addReferencesCheckResult("SignatureCheck", response.getSignatureCheck()); + + // add the SignatureManifestCheck + if (response.getSignatureManifestCheck() != null) { + addReferencesCheckResult( + "SignatureManifestCheck", + response.getSignatureManifestCheck()); + } + + // add the XMLDsigManifestChecks + responseData = response.getXMLDsigManifestChecks(); + if (responseData != null && !responseData.isEmpty()) { + for (iter = responseData.iterator(); iter.hasNext();) { + ManifestRefsCheckResult checkResult = + (ManifestRefsCheckResult) iter.next(); + addManifestRefsCheckResult("XMLDSIGManifestCheck", checkResult); + } + } + + // add the CertificateCheck + ResponseBuilderUtils.addCodeInfoElement( + responseDoc, + responseElem, + "CertificateCheck", + response.getCertificateCheck().getCode(), + response.getCertificateCheck().getInfo()); + + return responseDoc; + } + + /** + * Add an element of type <code>ContentBaseType</code> to the response. + * + * @param elementName The name of the element. + * @param content The <code>Content</code> to add. Based on the type of + * the <code>Content</code>, either a <code>Base64Content</code> element + * or a <code>XMLContent</code> subelement will be added. A + * <code>ContentBinary</code> of type <code>BinaryDataObject</code> will be + * added as a <code>Base64Content</code> child element. + * <code>ContentXML</code> will be added as <code>XMLContent</code> child + * element. + * @throws MOAApplicationException An error occurred adding the content. + */ + private void addContent(String elementName, Content content) + throws MOAApplicationException { + + Element contentElem = responseDoc.createElementNS(MOA_NS_URI, elementName); + + switch (content.getContentType()) { + case Content.XML_CONTENT : + ContentXML contentXml = (ContentXML) content; + NodeList nodes = contentXml.getXMLContent(); + Element xmlElem; + int i; + + xmlElem = responseDoc.createElementNS(MOA_NS_URI, "XMLContent"); + //xmlElem.setAttributeNS(XML_NS_URI, "xml:space", "preserve"); + xmlElem.setAttribute("xml:space", "preserve"); + + for (i = 0; i < nodes.getLength(); i++) { + xmlElem.appendChild(responseDoc.importNode(nodes.item(i), true)); + } + contentElem.appendChild(xmlElem); + responseElem.appendChild(contentElem); + break; + case Content.BINARY_CONTENT : + Element binaryElem = + responseDoc.createElementNS(MOA_NS_URI, "Base64Content"); + ContentBinary contentBinary = (ContentBinary) content; + String base64Str; + + try { + base64Str = Base64Utils.encode(contentBinary.getBinaryContent()); + } catch (IOException e) { + throw new MOAApplicationException("2200", null, e); + } + binaryElem.appendChild(responseDoc.createTextNode(base64Str)); + contentElem.appendChild(binaryElem); + responseElem.appendChild(contentElem); + break; + } + } + + /** + * Add a <code>ReferencesCheckResult</code> to the response. + * + * @param elementName The DOM element name to use. + * @param checkResult The <code>ReferencesCheckResult</code> to add. + */ + private void addReferencesCheckResult( + String elementName, + ReferencesCheckResult checkResult) { + + NodeList info = null; + + if (checkResult.getInfo() != null) { + DocumentFragment fragment = responseDoc.createDocumentFragment(); + NodeList anyOtherInfo = checkResult.getInfo().getAnyOtherInfo(); + int[] failedReferences = checkResult.getInfo().getFailedReferences(); + + if (anyOtherInfo != null) { + addAnyOtherInfo(fragment, checkResult.getInfo().getAnyOtherInfo()); + } + + if (failedReferences != null) { + addFailedReferences(fragment, failedReferences); + } + + info = fragment.getChildNodes(); + } + + ResponseBuilderUtils.addCodeInfoElement( + responseDoc, + responseElem, + elementName, + checkResult.getCode(), + info); + } + + + /** + * Add a <code>ManifestRefsCheckResult</code> to the response. + * + * @param elementName The DOM element name to use. + * @param checkResult The <code>ManifestRefsCheckResult</code> to add. + */ + private void addManifestRefsCheckResult( + String elementName, + ManifestRefsCheckResult checkResult) { + + DocumentFragment fragment = responseDoc.createDocumentFragment(); + NodeList anyOtherInfo = checkResult.getInfo().getAnyOtherInfo(); + int[] failedReferences = checkResult.getInfo().getFailedReferences(); + Element referringSigRefElem; + String referringSigRefStr; + + // add any other elements + if (anyOtherInfo != null) { + addAnyOtherInfo(fragment, checkResult.getInfo().getAnyOtherInfo()); + } + + // add the failed references + if (failedReferences != null) { + addFailedReferences(fragment, failedReferences); + } + + // add the ReferringSigReference + referringSigRefElem = + responseDoc.createElementNS(MOA_NS_URI, "ReferringSigReference"); + referringSigRefStr = + Integer.toString(checkResult.getInfo().getReferringSignatureReference()); + referringSigRefElem.appendChild( + responseDoc.createTextNode(referringSigRefStr)); + fragment.appendChild(referringSigRefElem); + + // add XMLDSIGManifestCheckResult to the response + ResponseBuilderUtils.addCodeInfoElement( + responseDoc, + responseElem, + elementName, + checkResult.getCode(), + fragment.getChildNodes()); + } + + /** + * Add arbitrary XML content to a DOM <code>DocumentFragment</code>. + * + * @param fragment The fragment to add the XML content to. + * @param anyOtherInfo The XML content to add. + */ + private void addAnyOtherInfo( + DocumentFragment fragment, + NodeList anyOtherInfo) { + + int i; + + for (i = 0; i < anyOtherInfo.getLength(); i++) { + fragment.appendChild(responseDoc.importNode(anyOtherInfo.item(i), true)); + } + } + + /** + * Add the failed references as <code>FailedReference</code> DOM elements to + * the fragment. + * + * @param fragment The DOM document fragment to add the + * <code>FailedReference</code> elements to. + * @param failedReferences The indexes of the failed references. + */ + private void addFailedReferences( + DocumentFragment fragment, + int[] failedReferences) { + Element failedReferenceElem; + int i; + + for (i = 0; i < failedReferences.length; i++) { + failedReferenceElem = + responseDoc.createElementNS(MOA_NS_URI, "FailedReference"); + failedReferenceElem.appendChild( + responseDoc.createTextNode(Integer.toString(failedReferences[i]))); + fragment.appendChild(failedReferenceElem); + } + } + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/CreateSignatureEnvironmentProfile.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/CreateSignatureEnvironmentProfile.java new file mode 100644 index 000000000..425c410ad --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/CreateSignatureEnvironmentProfile.java @@ -0,0 +1,30 @@ +package at.gv.egovernment.moa.spss.api.xmlsign; + +/** + * Base class for signature environment profile data used in XML signature + * creation. + * + * @author Patrick Peck + * @version $Id$ + */ +public interface CreateSignatureEnvironmentProfile { + /** + * Indicates that the profile data is given explicitly. + */ + public static int EXPLICIT_CREATESIGNATUREENVIRONMENTPROFILE = 0; + /** + * Indicates that the profile data is stored in the configuration and resolved + * using an ID. + */ + public static int ID_CREATESIGNATUREENVIRONMENTPROFILE = 1; + + /** + * Gets the type of this object. + * + * @return The type of <code>CreateSignatureEnvironmentProfile</code> denoted + * by this object. Either + * <code>EXPLICIT_CREATESIGNATUREENVIRONMENTPROFILE</code> or + * <code>ID_CREATESIGNATUREENVIRONMENTPROFILE</code>. + */ + public int getCreateSignatureEnvironmentProfileType(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/CreateSignatureEnvironmentProfileExplicit.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/CreateSignatureEnvironmentProfileExplicit.java new file mode 100644 index 000000000..6aebd102b --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/CreateSignatureEnvironmentProfileExplicit.java @@ -0,0 +1,30 @@ +package at.gv.egovernment.moa.spss.api.xmlsign; + +import java.util.List; + +/** + * A <code>CreateSignatureEnvironmentProfile</code> containing the profile + * data explicitly. + * + * @author Patrick Peck + * @version $Id$ + */ +public interface CreateSignatureEnvironmentProfileExplicit + extends CreateSignatureEnvironmentProfile { + + /** + * Gets the location and index of where to insert the signature into the + * signature environment. + * + * @return The location and index of the signature in the signature + * environment. + */ + public CreateSignatureLocation getCreateSignatureLocation(); + /** + * Gets the supplemental information. + * + * @return The supplemental information. + */ + public List getSupplements(); + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/CreateSignatureEnvironmentProfileID.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/CreateSignatureEnvironmentProfileID.java new file mode 100644 index 000000000..1c0d87adc --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/CreateSignatureEnvironmentProfileID.java @@ -0,0 +1,20 @@ +package at.gv.egovernment.moa.spss.api.xmlsign; + +/** + * A <code>CreateSignatureEnvironmentProfile</code> containing a profile ID + * pointing to locally stored profile data. + * + * @author Patrick Peck + * @version $Id$ + */ +public interface CreateSignatureEnvironmentProfileID + extends CreateSignatureEnvironmentProfile { + + /** + * Gets the profile ID. + * + * @return The profile ID. + */ + public String getCreateSignatureEnvironmentProfileID(); + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/CreateSignatureInfo.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/CreateSignatureInfo.java new file mode 100644 index 000000000..5ceae4d0a --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/CreateSignatureInfo.java @@ -0,0 +1,25 @@ +package at.gv.egovernment.moa.spss.api.xmlsign; + +import at.gv.egovernment.moa.spss.api.common.Content; + +/** + * Encapsulates a signature object used during signature creation. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface CreateSignatureInfo { + /** + * Gets the XML structure where the signature will be inserted. + * + * @return The XML structure where the signature will be inserted. + */ + public Content getCreateSignatureEnvironment(); + /** + * Gets the supplemental data for the signature environment. + * + * @return The supplemental data for the signature envoronment. + */ + public CreateSignatureEnvironmentProfile getCreateSignatureEnvironmentProfile(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/CreateSignatureLocation.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/CreateSignatureLocation.java new file mode 100644 index 000000000..81374ceaa --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/CreateSignatureLocation.java @@ -0,0 +1,23 @@ +package at.gv.egovernment.moa.spss.api.xmlsign; + +import at.gv.egovernment.moa.spss.api.common.ElementSelector; + +/** + * Specifies where to insert the newly created signature. + * + * An XPath expression is used to select the signature parent element. An + * additional index specifies the node index after which to insert the + * signature into the parent element. + * + * @author Patrick Peck + * @version $Id$ + */ +public interface CreateSignatureLocation extends ElementSelector { + /** + * Gets the node index, after which the signature will be inserted into the + * parent elemen. + * + * @return The index of the node after which the signature will be inserted. + */ + public int getIndex(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/CreateTransformsInfo.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/CreateTransformsInfo.java new file mode 100644 index 000000000..94152434e --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/CreateTransformsInfo.java @@ -0,0 +1,27 @@ +package at.gv.egovernment.moa.spss.api.xmlsign; + +import java.util.List; + +import at.gv.egovernment.moa.spss.api.common.MetaInfo; + +/** + * Encapsulates information used for the transformation of the data object. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface CreateTransformsInfo { + /** + * Gets the XMLDSig transforms. + * + * @return A <code>List</code> of <code>Transform</code> objects. + */ + public List getTransforms(); + /** + * Gets meta information about the data resulting from the transformation. + * + * @return Meta information about the resulting data. + */ + public MetaInfo getFinalDataMetaInfo(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/CreateTransformsInfoProfile.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/CreateTransformsInfoProfile.java new file mode 100644 index 000000000..40acfd317 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/CreateTransformsInfoProfile.java @@ -0,0 +1,28 @@ +package at.gv.egovernment.moa.spss.api.xmlsign; + +/** + * Base class for transformation informations used in signature creation. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface CreateTransformsInfoProfile { + /** + * Indicates transformation information given explicitly. + */ + public static final int EXPLICIT_CREATETRANSFORMSINFOPROFILE = 0; + /** + * Indicates transformation information given as an ID. + */ + public static final int ID_CREATETRANSFORMSINFOPROFILE = 1; + + /** + * Gets the type of profile information this object contains. + * + * @return The type of transformation information, either + * <code>EXPLICIT_CREATETRANSFORMSINFOPROFILE</code> or + * <code>ID_CREATETRANSFORMSINFOPROFILE</code>. + */ + public int getCreateTransformsInfoProfileType(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/CreateTransformsInfoProfileExplicit.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/CreateTransformsInfoProfileExplicit.java new file mode 100644 index 000000000..aeb74445f --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/CreateTransformsInfoProfileExplicit.java @@ -0,0 +1,26 @@ +package at.gv.egovernment.moa.spss.api.xmlsign; + +import java.util.List; + +/** + * Encapsulates explicit transformation informations. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface CreateTransformsInfoProfileExplicit + extends CreateTransformsInfoProfile { + /** + * Gets the transformation information of the data object. + * + * @return Transformation information of the data object. + */ + public CreateTransformsInfo getCreateTransformsInfo(); + /** + * Gets the supplemental information. + * + * @return The supplemental information. + */ + public List getSupplements(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/CreateTransformsInfoProfileID.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/CreateTransformsInfoProfileID.java new file mode 100644 index 000000000..3631ead29 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/CreateTransformsInfoProfileID.java @@ -0,0 +1,18 @@ +package at.gv.egovernment.moa.spss.api.xmlsign; + +/** + * Encapsulates transformation information given via an identifier. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface CreateTransformsInfoProfileID + extends CreateTransformsInfoProfile { + /** + * Gets the ID of the transformation. + * + * @return The transformation profile ID. + */ + public String getCreateTransformsInfoProfileID(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/CreateXMLSignatureRequest.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/CreateXMLSignatureRequest.java new file mode 100644 index 000000000..b8157fdfb --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/CreateXMLSignatureRequest.java @@ -0,0 +1,26 @@ +package at.gv.egovernment.moa.spss.api.xmlsign; + +import java.util.List; + + +/** + * Object that encapsulates a request to create an XML Signature. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface CreateXMLSignatureRequest { + /** + * Gets the identifier for the keys to be used for the signature. + * + * @return The identifier for the keys to be used. + */ + public String getKeyIdentifier(); + /** + * Gets the information of the singleSignatureInfo elements. + * + * @return The information of singleSignatureInfo elements. + */ + public List getSingleSignatureInfos(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/CreateXMLSignatureResponse.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/CreateXMLSignatureResponse.java new file mode 100644 index 000000000..6bf54e6a5 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/CreateXMLSignatureResponse.java @@ -0,0 +1,20 @@ +package at.gv.egovernment.moa.spss.api.xmlsign; + +import java.util.List; + +/** + * Object that encapsulates the response on to a + * <code>CreateXMLSignatureRequest</code> to create an XML signature. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface CreateXMLSignatureResponse { + /** + * Gets the response elements. + * + * @return The response elements. + */ + public List getResponseElements(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/CreateXMLSignatureResponseElement.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/CreateXMLSignatureResponseElement.java new file mode 100644 index 000000000..2162d82fd --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/CreateXMLSignatureResponseElement.java @@ -0,0 +1,29 @@ +package at.gv.egovernment.moa.spss.api.xmlsign; + +/** + * Base class for <code>SignatureEnvironmentResponse</code> and + * <code>ErrorResponse</code> elements in a + * <code>CreateXMLSignatureResponse</code>. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface CreateXMLSignatureResponseElement { + /** + * Indicates that this object contains a <code>SignatureEnvironment</code>. + */ + public static final int SIGNATURE_ENVIRONMENT_RESPONSE = 0; + /** + * Indicates that this objet contains an <code>ErrorResponse</code>. + */ + public static final int ERROR_RESPONSE = 1; + + /** + * Gets the type of response object. + * + * @return The type of response object, either + * <code>SIGNATURE_ENVIRONMENT_RESPONSE</code> or <code>ERROR_RESPONSE</code>. + */ + public int getResponseType(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/DataObjectInfo.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/DataObjectInfo.java new file mode 100644 index 000000000..43d49c587 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/DataObjectInfo.java @@ -0,0 +1,48 @@ +package at.gv.egovernment.moa.spss.api.xmlsign; + +import at.gv.egovernment.moa.spss.api.common.Content; + +/** + * Encapsulates information required to create a single signature. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface DataObjectInfo { + /** + * Indicates that a detached signature will be created. + */ + public static final String STRUCTURE_DETACHED = "detached"; + /** + * Indicates that an enveloping signature will be created. + */ + public static final String STRUCTURE_ENVELOPING = "enveloping"; + + /** + * Gets the structure of the signature. + * + * @return The structure of the signature. + */ + public String getStructure(); + /** + * Checks whether a refercence will be placed in the signature itself or + * in the manifest. + * + * @return <code>true</code> if a reference will be placed in the manifest, + * <code>false</code> if it will be placed in the signature. + */ + public boolean isChildOfManifest(); + /** + * Gets information related to a single data object. + * + * @return Information related to a single data object. + */ + public Content getDataObject(); + /** + * Gets information for the transformation of the data object. + * + * @return The transformation information. + */ + public CreateTransformsInfoProfile getCreateTransformsInfoProfile(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/ErrorResponse.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/ErrorResponse.java new file mode 100644 index 000000000..30fa4fb52 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/ErrorResponse.java @@ -0,0 +1,24 @@ +package at.gv.egovernment.moa.spss.api.xmlsign; + + +/** + * Object containing detailed error information. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface ErrorResponse extends CreateXMLSignatureResponseElement { + /** + * Gets the error code. + * + * @return The error code. + */ + public int getErrorCode(); + /** + * Gets verbose error information. + * + * @return Verbose error information. + */ + public String getInfo(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/SignatureEnvironmentResponse.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/SignatureEnvironmentResponse.java new file mode 100644 index 000000000..449349a68 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/SignatureEnvironmentResponse.java @@ -0,0 +1,20 @@ +package at.gv.egovernment.moa.spss.api.xmlsign; + +import org.w3c.dom.Element; + +/** + * Contains the signature if the signature creation was successful. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface SignatureEnvironmentResponse + extends CreateXMLSignatureResponseElement { + /** + * Gets the XML structure which contains the signature. + * + * @return A general XML structure containing the signature. + */ + public Element getSignatureEnvironment(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/SingleSignatureInfo.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/SingleSignatureInfo.java new file mode 100644 index 000000000..9c74c5157 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlsign/SingleSignatureInfo.java @@ -0,0 +1,32 @@ +package at.gv.egovernment.moa.spss.api.xmlsign; + +import java.util.List; + +/** + * Encapsulates data to create a single signature. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface SingleSignatureInfo { + /** + * Gets the dataObjectInfo information. + * + * @return The dataObjectInfo information. + */ + public List getDataObjectInfos(); + /** + * Gets the signature object. + * + * @return The signature object used during signature creation. + */ + public CreateSignatureInfo getCreateSignatureInfo(); + /** + * Check whether a Security Layer conform signature manifest will be created. + * + * @return <code>true</code>, if a Security Layer conform signature manifest + * will be created, <code>false</code> otherwise. + */ + public boolean isSecurityLayerConform(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/ManifestRefsCheckResult.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/ManifestRefsCheckResult.java new file mode 100644 index 000000000..1984ba349 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/ManifestRefsCheckResult.java @@ -0,0 +1,24 @@ +package at.gv.egovernment.moa.spss.api.xmlverify; + + +/** + * Contains the results of manifest checks according to XMLDsig. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface ManifestRefsCheckResult { + /** + * Gets the check code. + * + * @return A numerical representation of the result of the manifest check. + */ + public int getCode(); + /** + * Gets the reference to the manifest. + * + * @return The reference to the manifest. + */ + public ManifestRefsCheckResultInfo getInfo(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/ManifestRefsCheckResultInfo.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/ManifestRefsCheckResultInfo.java new file mode 100644 index 000000000..258840162 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/ManifestRefsCheckResultInfo.java @@ -0,0 +1,19 @@ +package at.gv.egovernment.moa.spss.api.xmlverify; + + +/** + * Encapsulates information referring to the manifest of the check. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface ManifestRefsCheckResultInfo extends ReferencesCheckResultInfo { + /** + * Gets the position of the signature reference containing the + * reference to the manifest being described by this object. + * + * @return The position of the signature reference. + */ + public int getReferringSignatureReference(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/ReferenceInfo.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/ReferenceInfo.java new file mode 100644 index 000000000..4c644583b --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/ReferenceInfo.java @@ -0,0 +1,19 @@ +package at.gv.egovernment.moa.spss.api.xmlverify; + +import java.util.List; + +/** + * Contains transformation parameters which are locally available. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface ReferenceInfo { + /** + * Gets the transformation info. + * + * @return The transformation info. + */ + public List getVerifyTransformsInfoProfiles(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/ReferencesCheckResult.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/ReferencesCheckResult.java new file mode 100644 index 000000000..7b5488613 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/ReferencesCheckResult.java @@ -0,0 +1,23 @@ +package at.gv.egovernment.moa.spss.api.xmlverify; + +/** + * Contains information about the verification status of references contained + * in the signature. + * + * @author Patrick Peck + * @version $Id$ + */ +public interface ReferencesCheckResult { + /** + * Gets the check code. + * + * @return A numerical representation of the result of the reference check. + */ + public int getCode(); + /** + * Gets the additional information about the result. + * + * @return Additional information about the result. + */ + public ReferencesCheckResultInfo getInfo(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/ReferencesCheckResultInfo.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/ReferencesCheckResultInfo.java new file mode 100644 index 000000000..be21b61c2 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/ReferencesCheckResultInfo.java @@ -0,0 +1,25 @@ +package at.gv.egovernment.moa.spss.api.xmlverify; + +import org.w3c.dom.NodeList; + +/** + * Additional information contained in a <code>ReferencesCheckResult</code>. + * + * @author Patrick Peck + * @version $Id$ + */ +public interface ReferencesCheckResultInfo { + /** + * Gets the additional info of the failed <code>dsig:reference</code> element. + * + * @return The info elements. + */ + public NodeList getAnyOtherInfo(); + /** + * Gets the positions of the failed signature references containing the + * references to the manifests being described by this object. + * + * @return The positions of the failed signature references. + */ + public int[] getFailedReferences(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/SignatureManifestCheckParams.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/SignatureManifestCheckParams.java new file mode 100644 index 000000000..8f0efacf3 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/SignatureManifestCheckParams.java @@ -0,0 +1,26 @@ +package at.gv.egovernment.moa.spss.api.xmlverify; + +import java.util.List; + +/** + * Contains parameters used to check the signature manifest. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface SignatureManifestCheckParams { + /** + * Gets the referential information. + * + * @return The referential information. + */ + public List getReferenceInfos(); + /** + * Gets information on whether signature source data should be returned. + * + * @return <code>true</code>, if signature source data should be returned, + * otherwise <code>false</code>. + */ + public boolean getReturnReferenceInputData(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/SupplementProfile.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/SupplementProfile.java new file mode 100644 index 000000000..569e691ca --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/SupplementProfile.java @@ -0,0 +1,28 @@ +package at.gv.egovernment.moa.spss.api.xmlverify; + +/** + * Base class for supplementary information. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface SupplementProfile { + /** + * Indicates that this object contains explicit supplementary information. + */ + public static final int EXPLICIT_SUPPLEMENTPROFILE = 0; + /** + * Indicates that this object contains a profile id where supplementary + * information can be found. + */ + public static final int ID_SUPPLEMENTPROFILE = 1; + + /** + * Gets the type of supplementary information contained in this object. + * + * @return The type of supplementary information contained in this object, + * either <code>EXPLICIT_SUPPLEMENT</code> or <code>ID_SUPPLEMENT</code>. + */ + public int getSupplementProfileType(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/SupplementProfileExplicit.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/SupplementProfileExplicit.java new file mode 100644 index 000000000..7dd37a2d1 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/SupplementProfileExplicit.java @@ -0,0 +1,19 @@ +package at.gv.egovernment.moa.spss.api.xmlverify; + +import at.gv.egovernment.moa.spss.api.common.XMLDataObjectAssociation; + +/** + * Encapsulates explicit supplementary information. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface SupplementProfileExplicit extends SupplementProfile { + /** + * Gets the supplemental object. + * + * @return The supplemental object. + */ + public XMLDataObjectAssociation getSupplementProfile(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/SupplementProfileID.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/SupplementProfileID.java new file mode 100644 index 000000000..5b5083be9 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/SupplementProfileID.java @@ -0,0 +1,18 @@ +package at.gv.egovernment.moa.spss.api.xmlverify; + +/** + * Encapsulates supplementary information stored in a profile. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface SupplementProfileID extends SupplementProfile { + /** + * Gets the id of the profile where the supplementary information can be + * found. + * + * @return The profile id. + */ + public String getSupplementProfileID(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/TransformParameter.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/TransformParameter.java new file mode 100644 index 000000000..3e173e0cd --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/TransformParameter.java @@ -0,0 +1,40 @@ +package at.gv.egovernment.moa.spss.api.xmlverify; + +/** + * Object encapsulating transform parameters either as a URI, binary or + * hashed. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface TransformParameter { + /** + * Indicates that this object contains a transform parameter given as + * a URI. + */ + public static final int URI_TRANSFORMPARAMETER = 0; + /** + * Indicates that this object contains binary transform parameter. + */ + public static final int BINARY_TRANSFORMPARAMETER = 1; + /** + * Indicatest that this object contains a binary hash of the transform + * parameter. + */ + public static final int HASH_TRANSFORMPARAMETER = 2; + + /** + * Gets the type of transform parameter contained in this object. + * + * @return The type of transform parameter, being one of + * <code>URI_TRANSFORMPARAMETER</code>, <code>BINARY_TRANSFORMPARAMETER</code> + * or <code>HASH_TRANSFORMPARAMETER</code>. + */ + public int getTransformParameterType(); + /** + * Gets the transform parameter URI. + * + * @return The transform parameter URI. + */ + public String getURI();} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/TransformParameterBinary.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/TransformParameterBinary.java new file mode 100644 index 000000000..600227dfd --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/TransformParameterBinary.java @@ -0,0 +1,21 @@ +package at.gv.egovernment.moa.spss.api.xmlverify; + +import java.io.InputStream; + +/** + * Encapsulates a binary transform parameter. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface TransformParameterBinary extends TransformParameter { + /** + * Gets the binary transform parameter. + * + * @return An <code>InputStream</code> from which the binary content can + * be read. + */ + public InputStream getBinaryContent(); + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/TransformParameterHash.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/TransformParameterHash.java new file mode 100644 index 000000000..ec45ea4f4 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/TransformParameterHash.java @@ -0,0 +1,26 @@ +package at.gv.egovernment.moa.spss.api.xmlverify; + + +/** + * Contains a hash of the transform parameter. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface TransformParameterHash extends TransformParameter { + /** + * Gets the method used for calculating the digest value. + * + * @return The digest method. + */ + public String getDigestMethod(); + /** + * Gets the binary hash of the transform parameter. + * + * @return A binary representation of the hash. + */ + public byte[] getDigestValue(); + + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/TransformParameterURI.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/TransformParameterURI.java new file mode 100644 index 000000000..4a6f0a58f --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/TransformParameterURI.java @@ -0,0 +1,12 @@ +package at.gv.egovernment.moa.spss.api.xmlverify; + +/** + * Encapsulates a transform parameter given as a URI. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface TransformParameterURI extends TransformParameter { + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/VerifySignatureInfo.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/VerifySignatureInfo.java new file mode 100644 index 000000000..386651c47 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/VerifySignatureInfo.java @@ -0,0 +1,27 @@ +package at.gv.egovernment.moa.spss.api.xmlverify; + +import at.gv.egovernment.moa.spss.api.common.Content; + +/** + * Encapsulates a signature. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface VerifySignatureInfo { + /** + * Gets the content of the <code>VerifySignatureEnvironment</code> element. + * + * @return A <code>MOAElement</code> containing the + * <code>VerifySignatureEnvironment</code> in a DOM-like structure. + */ + public Content getVerifySignatureEnvironment(); + /** + * Gets the location of the signature. + * + * @return The location of the signature within the signature environment. + */ + public VerifySignatureLocation getVerifySignatureLocation(); + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/VerifySignatureLocation.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/VerifySignatureLocation.java new file mode 100644 index 000000000..f05e3e889 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/VerifySignatureLocation.java @@ -0,0 +1,13 @@ +package at.gv.egovernment.moa.spss.api.xmlverify; + +import at.gv.egovernment.moa.spss.api.common.ElementSelector; + +/** + * Specifies where to find the signature to be verified. + * + * @author Patrick Peck + * @version $Id$ + */ +public interface VerifySignatureLocation extends ElementSelector { + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/VerifyTransformsInfoProfile.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/VerifyTransformsInfoProfile.java new file mode 100644 index 000000000..909fc58a2 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/VerifyTransformsInfoProfile.java @@ -0,0 +1,28 @@ +package at.gv.egovernment.moa.spss.api.xmlverify; + +/** + * Object for explicitly specifying a transformation path. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface VerifyTransformsInfoProfile { + /** + * Indicates that this object contains the transformation path explicitly. + */ + public static final int EXPLICIT_VERIFYTRANSFORMSINFOPROFILE = 0; + /** + * Indicatest that this object contains a transformation info id. + */ + public static final int ID_VERIFYTRANSFORMSINFOPROFILE = 1; + + /** + * Gets the type of transformation information contained in this object. + * + * @return The type of transformation information, either + * <code>EXPLICIT_VERIFYTRANSFORMSINFOPROFILE</code> or + * <code>ID_VERIFYTRANSFORMSINFOPROFILE</code>. + */ + public int getVerifyTransformsInfoProfileType(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/VerifyTransformsInfoProfileExplicit.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/VerifyTransformsInfoProfileExplicit.java new file mode 100644 index 000000000..ff19683da --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/VerifyTransformsInfoProfileExplicit.java @@ -0,0 +1,25 @@ +package at.gv.egovernment.moa.spss.api.xmlverify; + +import java.util.List; + +/** + * Encapsulates explicit transformation information. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface VerifyTransformsInfoProfileExplicit extends VerifyTransformsInfoProfile { + /** + * Gets the XMLDSig transforms element. + * + * @return The <code>List</code> of <code>Transform</code>s. + */ + public List getTransforms(); + /** + * Gets the transformation parameters. + * + * @return The transformation parameters. + */ + public List getTransformParameters(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/VerifyTransformsInfoProfileID.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/VerifyTransformsInfoProfileID.java new file mode 100644 index 000000000..0df3664da --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/VerifyTransformsInfoProfileID.java @@ -0,0 +1,18 @@ +package at.gv.egovernment.moa.spss.api.xmlverify; + +/** + * Encapsulates transformation info id for signature verification. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface VerifyTransformsInfoProfileID extends VerifyTransformsInfoProfile { + /** + * Gets the identifier referencing the transformation info. + * + * @return The identifier referencing the transformation info. + */ + public String getVerifyTransformsInfoProfileID(); + +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/VerifyXMLSignatureRequest.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/VerifyXMLSignatureRequest.java new file mode 100644 index 000000000..eb71f500b --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/VerifyXMLSignatureRequest.java @@ -0,0 +1,55 @@ +package at.gv.egovernment.moa.spss.api.xmlverify; + +import java.util.Date; +import java.util.List; + + +/** + * Object that encapsulates a request to verify an XML signature. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface VerifyXMLSignatureRequest { + /** + * Gets the date and time for which the signature verification has to + * be performed. + * + * @return Date and time for which the signature verification has + * to be performed. + */ + public Date getDateTime(); + /** + * Gets the signature to be verified. + * + * @return The signature to be verified. + */ + public VerifySignatureInfo getSignatureInfo(); + /** + * Gets the supplemental information. + * + * @return The supplemental information. + */ + public List getSupplementProfiles(); + /** + * Gets parameters for Security Layer signature verification. + * + * @return Parameters for Security Layer signature verification. + */ + public SignatureManifestCheckParams getSignatureManifestCheckParams(); + /** + * Checks, whether actually signed data shall be returned. + * + * @return <code>true</code>, if signed data will be returned, + * otherwise <code>false</code>. + */ + public boolean getReturnHashInputData(); + /** + * Gets the profile id of the set of trusted certificates to be used for + * signature verification. + * + * @return The id of the trusted certificates. + */ + public String getTrustProfileId(); +} diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/VerifyXMLSignatureResponse.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/VerifyXMLSignatureResponse.java new file mode 100644 index 000000000..14ac71e67 --- /dev/null +++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlverify/VerifyXMLSignatureResponse.java @@ -0,0 +1,60 @@ +package at.gv.egovernment.moa.spss.api.xmlverify; + +import java.util.List; + +import at.gv.egovernment.moa.spss.api.common.CheckResult; +import at.gv.egovernment.moa.spss.api.common.SignerInfo; + +/** + * Object that encapsulates the response on a request to verify an XML + * signature. + * + * @author Patrick Peck + * @author Stephan Grill + * @version $Id$ + */ +public interface VerifyXMLSignatureResponse { + /** + * Gets a <code>SignerInfo</code> element according to XMLDSig. + * + * @return A <code>SignerInfo</code> element according to XMLDSig. + */ + public SignerInfo getSignerInfo(); + /** + * Gets datas signed by the signatory. + * + * @return The signed datas. + */ + public List getHashInputDatas(); + /** + * Gets source datas elements. + * + * @return The source datas elements. + */ + public List getReferenceInputDatas(); + /** + * Gets the result of the signature verification. + * + * @return The result of the signature verification. + */ + public ReferencesCheckResult getSignatureCheck(); + /** + * Gets the result of the signature manifest verification. + * + * @return The result of the signature manifest verification. + */ + public ReferencesCheckResult getSignatureManifestCheck(); + /** + * Gets XMLDSigManifestCheck elements. + * + * @return The XMLDSigManifestCheck elements. + */ + public List getXMLDsigManifestChecks(); + /** + * Gets the result of the certification verification. + * + * @return The result of the certificate verification. + */ + public CheckResult getCertificateCheck(); + +} |