Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2218 sbetterm 1
//## begin module%1.7%.codegen_version preserve=yes
2
//   Read the documentation to learn more about C++ code generator
3
//   versioning.
4
//## end module%1.7%.codegen_version
5
 
6
//## begin module%4212D05100DB.cm preserve=no
7
//## end module%4212D05100DB.cm
8
 
9
//## begin module%4212D05100DB.cp preserve=no
10
//	C O P Y R I G H T   N O T I C E
11
//	This material is confidential to ERG and may not be disclosed in whole
12
//	or in part to any third party nor used in any manner whatsoever other
13
//	than for the purposes expressly consented to by ERG in writing.
14
//
15
//	This material is also copyright and may not be reproduced, stored in a
16
//	retrieval system or transmitted in any form or by any means in whole or
17
//	in part without the express written consent of ERG.
18
//## end module%4212D05100DB.cp
19
 
20
//## Module: MacCallback%4212D05100DB; Pseudo Package body
21
//## Subsystem: MASS::Dev::Tools::TxnTestManager::src%41F5A79001E4
22
//## Source file: Z:\MASS_Dev\Tools\TxnTestManager\src\MacCallback.cpp
23
 
24
//## begin module%4212D05100DB.additionalIncludes preserve=no
25
//## end module%4212D05100DB.additionalIncludes
26
 
27
//## begin module%4212D05100DB.includes preserve=yes
28
#pragma warn -com
29
#include <LoggingMacros.h>
30
#pragma warn +com
31
//## end module%4212D05100DB.includes
32
 
33
// IXmlSchemaWrapperFactory
34
#include "IXmlSchemaWrapperFactory.h"
35
// IXmlSchemaWrapperString
36
#include "IXmlSchemaWrapperString.h"
37
// TransactionSpecification
38
#include "TransactionSpecification.h"
39
// IXmlSchemaWrapperByteArray
40
#include "IXmlSchemaWrapperByteArray.h"
41
// IXmlSchemaWrapperElement
42
#include "IXmlSchemaWrapperElement.h"
43
// IMessageDigest
44
#include "IMessageDigest.h"
45
// MacCallback
46
#include "MacCallback.h"
47
// EvaluationContext
48
#include "EvaluationContext.h"
49
// TransactionStructure
50
#include "TransactionStructure.h"
51
// Iteration
52
#include "Iteration.h"
53
// TestScenario
54
#include "TestScenario.h"
55
//## begin module%4212D05100DB.additionalDeclarations preserve=yes
56
#include <sstream>
57
//## end module%4212D05100DB.additionalDeclarations
58
 
59
 
60
// Class MacCallback 
61
 
62
//## begin MacCallback::isInMac%4212F476023C.attr preserve=no  private: static AnsiString {VAC} "true"
63
const AnsiString MacCallback::g_isInMac = "true";
64
//## end MacCallback::isInMac%4212F476023C.attr
65
 
66
//## Operation: MacCallback%4212D08F0291
67
MacCallback::MacCallback (EvaluationContext& evaluationContext, XMLSchema::IXmlSchemaWrapperByteArray &value)
68
  //## begin MacCallback::MacCallback%4212D08F0291.hasinit preserve=no
69
      : m_digest(0),
70
        m_value(0),
71
        m_string(0),
72
        m_evaluationContext(0)
73
  //## end MacCallback::MacCallback%4212D08F0291.hasinit
74
  //## begin MacCallback::MacCallback%4212D08F0291.initialization preserve=yes
75
  //## end MacCallback::MacCallback%4212D08F0291.initialization
76
{
77
  //## begin MacCallback::MacCallback%4212D08F0291.body preserve=yes
78
 
79
	m_evaluationContext	= &evaluationContext;
80
	m_digest			= &evaluationContext.getMessageDigest();
81
	m_value				= &value;
82
 
83
	m_string = &evaluationContext.
84
		getTransaction().
85
			getScenario().
86
				getIteration().
87
					getSchemaWrapperFactory().
88
						createString();
89
 
90
  //## end MacCallback::MacCallback%4212D08F0291.body
91
}
92
 
93
 
94
MacCallback::~MacCallback()
95
{
96
  //## begin MacCallback::~MacCallback%4212D05100DB_dest.body preserve=yes
97
 
98
	if ( m_string )
99
	{
100
		m_evaluationContext->
101
			getTransaction().
102
				getScenario().
103
					getIteration().
104
						getSchemaWrapperFactory().
105
							destroyString( *m_string );
106
		m_string = 0;
107
	}
108
 
109
	m_value				= 0;	// We don't own this.
110
	m_digest			= 0;	// We don't own this.
111
	m_evaluationContext = 0;	// We don't own this.
112
 
113
  //## end MacCallback::~MacCallback%4212D05100DB_dest.body
114
}
115
 
116
 
117
 
118
//## Other Operations (implementation)
119
//## Operation: traverseElement%4212D08F02CF
120
const bool XSW_STDCALL MacCallback::traverseElement (XMLSchema::IXmlSchemaWrapperElement& element)
121
{
122
  //## begin MacCallback::traverseElement%4212D08F02CF.body preserve=yes
123
 
124
	/**
125
	 *	Only consider elements that have the inMac property.  For those that
126
	 *	do, if they are in a MAC then update the MAC with its value.  When
127
	 *	that field has no value, evaluate to false.
128
	 */
129
	if ( element.getAttributeValue( "inMac", *m_string ) )
130
	{
131
		if ( g_isInMac.AnsiCompareIC( m_string->c_str() ) == 0 )
132
		{
133
			if ( element.getByteArray( *m_value ) )
134
			{
135
				return ( m_digest->updateByteArray(
136
							m_value->data(),
137
							m_value->length() ) );
138
			}
139
			else
140
			{
141
				std::string xpath;
142
				if ( element.getAttributeValue( "xpath", *m_string ) )
143
				{
144
					xpath = m_string->c_str();
145
				}
146
 
147
				std::stringstream message;
148
				message
149
					<< "Cannot compute MAC for field \""
150
					<< '/'
151
					<< m_evaluationContext->getTransaction().
152
						getCurrentStructure().getName()
153
					<< xpath
154
					<< "\" because no value has been assigned to that field.";
155
				MERROR( message.str() );
156
				message << "  Ignore the field in the MAC computation and continue?";
157
 
158
				return ( MessageDlg(
159
							message.str().c_str(),
160
							mtConfirmation,
161
							TMsgDlgButtons() << mbYes << mbNo,
162
 
163
			}
164
		}
165
	}
166
 
167
	return ( true );
168
 
169
  //## end MacCallback::traverseElement%4212D08F02CF.body
170
}
171
 
172
// Additional Declarations
173
  //## begin MacCallback%4212D05100DB.declarations preserve=yes
174
  //## end MacCallback%4212D05100DB.declarations
175
 
176
//## begin module%4212D05100DB.epilog preserve=yes
177
//## end module%4212D05100DB.epilog