/////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance"). // All rights reserved. // // This software and its documentation and related materials are owned by // the Alliance. The software may only be incorporated into application // programs owned by members of the Alliance, subject to a signed // Membership Agreement and Supplemental Software License Agreement with the // Alliance. The structure and organization of this software are the valuable // trade secrets of the Alliance and its suppliers. The software is also // protected by copyright law and international treaty provisions. Application // programs incorporating this software must include the following statement // with their copyright notices: // // This application incorporates Open Design Alliance software pursuant to a license // agreement with Open Design Alliance. // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance. // All rights reserved. // // By use of this software, its documentation or related materials, you // acknowledge and accept the above terms. /////////////////////////////////////////////////////////////////////////////// #ifndef _DAI_SIGNATURE_H #define _DAI_SIGNATURE_H #include "OdaCommon.h" #include "daiBuildOptions.h" #include #include "OdAnsiString.h" #include "daiUtils/daiTextEncodeDecode.h" #include "OdCryptoServices/OdCryptoServices.h" #include "TD_PackPush.h" /** \details Implements the Data Access Interface (DAI) that provides functionality for manipulating data that is defined within the EXPRESS SCHEMA format. */ namespace OdDAI { /** \details The class that implements storing and handling of a digital signature for the file part before SIGNATURE tag of the section. */ class DAI_EXPORT SignatureSection { public: /** \details Creates a new signature section object with default or set parameters. \param position [in] position of the signature in the file. \param content [in] encoded content of the signature. \param asComment [in] a flag indicating that signature is represented as a comment in the file. \param externalCertificate [in] a flag indicating that certificate should be written after signature to the file. \param pCryptoServices [in] crypto services used to extract certificate. \remarks Signature section presence notifies writing filer to calculate digital signature and write it at the end of the file during model writing process. After setting signature content constructor will attempt to extract and set the certificate. If externalCertificate flag is set to true the public key of the digital certificate would be added after the signature. */ SignatureSection(OdUInt64 position = 0, OdAnsiString content = OdAnsiString(), bool asComment = false, bool externalCertificate = false, OdCryptoServicesPtr pCryptoServices = OdCryptoServicesPtr()); /** \details Creates a new signature section object with certificate. \param pCertificate [in] certificate object. \param asComment [in] a flag indicating that signature is represented as a comment in the file. \param externalCertificate [in] a flag indicating that certificate should be written after signature to the file. \param pCryptoServices [in] crypto services used to load certificate. \remarks Signature section presence notifies writing filer to calculate digital signature and write it at the end of the file during model writing process. If externalCertificate flag is set to true the public key of the digital certificate would be added after the signature. */ SignatureSection(OdCertificateObjectPtr pCertificate, bool asComment = false, bool externalCertificate = false, OdCryptoServicesPtr pCryptoServices = OdCryptoServicesPtr()); /** \details Sets new value for the starting position of a signature section instance. \param position [in] position value. */ void setPosition(OdUInt64 position); /** \details Retrieves the value of the starting postion. \returns returns an integer that contains position value */ OdUInt64 getPosition() const; /** \details Sets new value for the signature content of a signature section instance and updates the certificate. \param content [in] content value. \param pCryptoServices [in] crypto services value used to extract certificate. \returns returns true if signature content was set successfully and false otherwise \remarks After setting signature content function will attempt to extract and set the certificate. */ bool setContent(const OdAnsiString& content, OdCryptoServicesPtr pCryptoServices = OdCryptoServicesPtr()); /** \details Retrieves the value of the signature content. \returns returns an OdAnsiString that contains content value */ const OdAnsiString& getContent() const; /** \details Sets new value for the signature certificate of a signature section instance. \param pCertificate [in] certificate value. \param pCryptoServices [in] crypto services value used to load certificate. */ void setCertificate(OdCertificateObjectPtr pCertificate, OdCryptoServicesPtr pCryptoServices = OdCryptoServicesPtr()); /** \details Retrieves the value of the signature certificate. \returns returns an OdCertificateObjectPtr that contains certificate value */ const OdCertificateObjectPtr getCertificate() const; /** \details Retrieves the value of the asComment flag. \returns returns a boolean that contains asComment value \remarks asComment flag indicates that signature is represented as a comment in the file. */ bool getAsComment() const; /** \details Sets new value for the asComment flag of a signature section instance. \param asComment [in] asComment flag value. \remarks asComment flag indicates that signature is represented as a comment in the file. */ void setAsComment(bool asComment); /** \details Retrieves the value of the externalCertificate flag. \returns returns a boolean that contains externalCertificate value \remarks externalCertificate flag indicates that the public key of the certificate should be written after signature to the file. */ bool getExternalCertificate() const; /** \details Sets new value for the externalCertificate flag of a signature section instance. \param externalCertificate [in] externalCertificate flag value. \remarks externalCertificate flag indicates that the public key of the certificate should be written after signature to the file. */ void setExternalCertificate(bool externalCertificate); /** \details Retrieves the value of the isValid flag. \returns returns a boolean that contains isValid value \remarks isValid flag indicates whether the signature is valid. */ bool getIsValid() const; /** \details Sets new value for the isValid flag of a signature section instance. \param isValid [in] isValid flag value. \remarks isValid flag indicates whether the signature is valid. */ void setIsValid(bool isValid); protected: OdUInt64 m_position; OdAnsiString m_content; OdCertificateObjectPtr m_pCertificate; bool m_asComment; bool m_externalCertificate; bool m_isValid; }; /** \details A data type that represents a smart pointer to an object. */ using SignatureSectionPtr = OdSharedPtr; /** \details A data type that represents an array of objects. */ typedef OdArray SignatureSectionArray; } #include "TD_PackPop.h" #endif // _DAI_SIGNATURE_H