Subversion Repositories DevTools

Rev

Blame | Last modification | View Log | RSS feed

//## begin module%1.7%.codegen_version preserve=yes
//   Read the documentation to learn more about C++ code generator
//   versioning.
//## end module%1.7%.codegen_version

//## begin module%4212D05100DB.cm preserve=no
//## end module%4212D05100DB.cm

//## begin module%4212D05100DB.cp preserve=no
//      C O P Y R I G H T   N O T I C E
//      This material is confidential to ERG and may not be disclosed in whole
//      or in part to any third party nor used in any manner whatsoever other
//      than for the purposes expressly consented to by ERG in writing.
//
//      This material is also copyright and may not be reproduced, stored in a
//      retrieval system or transmitted in any form or by any means in whole or
//      in part without the express written consent of ERG.
//## end module%4212D05100DB.cp

//## Module: MacCallback%4212D05100DB; Pseudo Package body
//## Subsystem: MASS::Dev::Tools::TxnTestManager::src%41F5A79001E4
//## Source file: Z:\MASS_Dev\Tools\TxnTestManager\src\MacCallback.cpp

//## begin module%4212D05100DB.additionalIncludes preserve=no
//## end module%4212D05100DB.additionalIncludes

//## begin module%4212D05100DB.includes preserve=yes
#pragma warn -com
#include <LoggingMacros.h>
#pragma warn +com
//## end module%4212D05100DB.includes

// IXmlSchemaWrapperFactory
#include "IXmlSchemaWrapperFactory.h"
// IXmlSchemaWrapperString
#include "IXmlSchemaWrapperString.h"
// TransactionSpecification
#include "TransactionSpecification.h"
// IXmlSchemaWrapperByteArray
#include "IXmlSchemaWrapperByteArray.h"
// IXmlSchemaWrapperElement
#include "IXmlSchemaWrapperElement.h"
// IMessageDigest
#include "IMessageDigest.h"
// MacCallback
#include "MacCallback.h"
// EvaluationContext
#include "EvaluationContext.h"
// TransactionStructure
#include "TransactionStructure.h"
// Iteration
#include "Iteration.h"
// TestScenario
#include "TestScenario.h"
//## begin module%4212D05100DB.additionalDeclarations preserve=yes
#include <sstream>
//## end module%4212D05100DB.additionalDeclarations


// Class MacCallback 

//## begin MacCallback::isInMac%4212F476023C.attr preserve=no  private: static AnsiString {VAC} "true"
const AnsiString MacCallback::g_isInMac = "true";
//## end MacCallback::isInMac%4212F476023C.attr

//## Operation: MacCallback%4212D08F0291
MacCallback::MacCallback (EvaluationContext& evaluationContext, XMLSchema::IXmlSchemaWrapperByteArray &value)
  //## begin MacCallback::MacCallback%4212D08F0291.hasinit preserve=no
      : m_digest(0),
        m_value(0),
        m_string(0),
        m_evaluationContext(0)
  //## end MacCallback::MacCallback%4212D08F0291.hasinit
  //## begin MacCallback::MacCallback%4212D08F0291.initialization preserve=yes
  //## end MacCallback::MacCallback%4212D08F0291.initialization
{
  //## begin MacCallback::MacCallback%4212D08F0291.body preserve=yes

        m_evaluationContext     = &evaluationContext;
        m_digest                        = &evaluationContext.getMessageDigest();
        m_value                         = &value;

        m_string = &evaluationContext.
                getTransaction().
                        getScenario().
                                getIteration().
                                        getSchemaWrapperFactory().
                                                createString();

  //## end MacCallback::MacCallback%4212D08F0291.body
}


MacCallback::~MacCallback()
{
  //## begin MacCallback::~MacCallback%4212D05100DB_dest.body preserve=yes

        if ( m_string )
        {
                m_evaluationContext->
                        getTransaction().
                                getScenario().
                                        getIteration().
                                                getSchemaWrapperFactory().
                                                        destroyString( *m_string );
                m_string = 0;
        }

        m_value                         = 0;    // We don't own this.
        m_digest                        = 0;    // We don't own this.
        m_evaluationContext = 0;        // We don't own this.
  
  //## end MacCallback::~MacCallback%4212D05100DB_dest.body
}



//## Other Operations (implementation)
//## Operation: traverseElement%4212D08F02CF
const bool XSW_STDCALL MacCallback::traverseElement (XMLSchema::IXmlSchemaWrapperElement& element)
{
  //## begin MacCallback::traverseElement%4212D08F02CF.body preserve=yes

        /**
         *      Only consider elements that have the inMac property.  For those that
         *      do, if they are in a MAC then update the MAC with its value.  When
         *      that field has no value, evaluate to false.
         */
        if ( element.getAttributeValue( "inMac", *m_string ) )
        {
                if ( g_isInMac.AnsiCompareIC( m_string->c_str() ) == 0 )
                {
                        if ( element.getByteArray( *m_value ) )
                        {
                                return ( m_digest->updateByteArray(
                                                        m_value->data(),
                                                        m_value->length() ) );
                        }
                        else
                        {
                                std::string xpath;
                                if ( element.getAttributeValue( "xpath", *m_string ) )
                                {
                                        xpath = m_string->c_str();
                                }

                                std::stringstream message;
                                message
                                        << "Cannot compute MAC for field \""
                                        << '/'
                                        << m_evaluationContext->getTransaction().
                                                getCurrentStructure().getName()
                                        << xpath
                                        << "\" because no value has been assigned to that field.";
                                MERROR( message.str() );
                                message << "  Ignore the field in the MAC computation and continue?";

                                return ( MessageDlg(
                                                        message.str().c_str(),
                                                        mtConfirmation,
                                                        TMsgDlgButtons() << mbYes << mbNo,
                                                        0 ) == mrYes );
                        }
                }
        }

        return ( true );

  //## end MacCallback::traverseElement%4212D08F02CF.body
}

// Additional Declarations
  //## begin MacCallback%4212D05100DB.declarations preserve=yes
  //## end MacCallback%4212D05100DB.declarations

//## begin module%4212D05100DB.epilog preserve=yes
//## end module%4212D05100DB.epilog