Open-Transactions  0.93.0-ge03d287
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
opentxs::OTSignedFile Class Reference

#include <OTSignedFile.hpp>

Inheritance diagram for opentxs::OTSignedFile:
Collaboration diagram for opentxs::OTSignedFile:

Public Member Functions

EXPORT OTSignedFile ()
 
 OTSignedFile (const OTString &LOCAL_SUBDIR, const OTString &FILE_NAME)
 
 OTSignedFile (const char *LOCAL_SUBDIR, const OTString &FILE_NAME)
 
EXPORT OTSignedFile (const char *LOCAL_SUBDIR, const char *FILE_NAME)
 
EXPORT bool LoadFile ()
 
EXPORT bool SaveFile ()
 
bool VerifyFile ()
 
void SetFilename (const OTString &LOCAL_SUBDIR, const OTString &FILE_NAME)
 
EXPORT OTStringGetFilePayload ()
 
EXPORT void SetFilePayload (const OTString &strArg)
 
EXPORT OTStringGetSignerNymID ()
 
EXPORT void SetSignerNymID (const OTString &strArg)
 
virtual EXPORT ~OTSignedFile ()
 
virtual void Release ()
 
void Release_SignedFile ()
 
virtual void UpdateContents ()
 
virtual bool SaveContractWallet (std::ofstream &ofs) const
 
- Public Member Functions inherited from opentxs::OTContract
const char * GetHashType () const
 
void SetIdentifier (const OTIdentifier &theID)
 
EXPORT OTContract ()
 
EXPORT OTContract (const OTString &name, const OTString &foldername, const OTString &filename, const OTString &strID)
 
EXPORT OTContract (const OTString &strID)
 
EXPORT OTContract (const OTIdentifier &theID)
 
void Initialize ()
 
virtual EXPORT ~OTContract ()
 
EXPORT void Release_Contract ()
 
EXPORT void ReleaseSignatures ()
 
virtual EXPORT bool CreateContract (const OTString &strContract, const OTPseudonym &theSigner)
 
EXPORT bool InsertNym (const OTString &strKeyName, const OTString &strKeyValue)
 
EXPORT void GetName (OTString &strName) const
 
EXPORT void SetName (const OTString &strName)
 
virtual EXPORT bool VerifyContract ()
 
virtual EXPORT void GetIdentifier (OTIdentifier &theIdentifier) const
 
virtual EXPORT void GetIdentifier (OTString &theIdentifier) const
 
EXPORT void GetFilename (OTString &strFilename) const
 
EXPORT void GetFoldername (OTString &strFoldername) const
 
virtual EXPORT bool LoadContract ()
 
EXPORT bool LoadContract (const char *szFoldername, const char *szFilename)
 
EXPORT bool LoadContractFromString (const OTString &theStr)
 
bool LoadContractRawFile ()
 
EXPORT bool ParseRawFile ()
 
EXPORT bool SaveToContractFolder ()
 
EXPORT bool SaveContractRaw (OTString &strOutput) const
 
EXPORT bool RewriteContract (OTString &strOutput) const
 
EXPORT bool SaveContract ()
 
EXPORT bool SaveContract (const char *szFoldername, const char *szFilename)
 
virtual EXPORT void CreateContents ()
 
EXPORT void CreateInnerContents ()
 
virtual EXPORT bool SaveContents (std::ofstream &ofs) const
 
virtual EXPORT bool SaveContractWallet (OTString &strContents) const
 
virtual EXPORT bool DisplayStatistics (OTString &strContents) const
 
virtual EXPORT bool SaveContents (OTString &strContents) const
 
virtual EXPORT bool SignContract (const OTPseudonym &theNym, const OTPasswordData *pPWData=nullptr)
 
EXPORT bool SignContractAuthent (const OTPseudonym &theNym, const OTPasswordData *pPWData=nullptr)
 
EXPORT bool SignWithKey (const OTAsymmetricKey &theKey, const OTPasswordData *pPWData=nullptr)
 
EXPORT bool SignContract (const OTPseudonym &theNym, OTSignature &theSignature, const OTPasswordData *pPWData=nullptr)
 
EXPORT bool SignContractAuthent (const OTPseudonym &theNym, OTSignature &theSignature, const OTPasswordData *pPWData=nullptr)
 
EXPORT bool SignContract (const OTAsymmetricKey &theKey, OTSignature &theSignature, const OTString &strHashType, const OTPasswordData *pPWData=nullptr)
 
EXPORT bool SignContract (const char *szFoldername, const char *szFilename, OTSignature &theSignature, const OTPasswordData *pPWData=nullptr)
 
virtual EXPORT bool VerifyContractID () const
 
virtual EXPORT void CalculateContractID (OTIdentifier &newID) const
 
virtual EXPORT bool VerifySignature (const OTPseudonym &theNym, const OTPasswordData *pPWData=nullptr) const
 
virtual EXPORT bool VerifySigAuthent (const OTPseudonym &theNym, const OTPasswordData *pPWData=nullptr) const
 
EXPORT bool VerifyWithKey (const OTAsymmetricKey &theKey, const OTPasswordData *pPWData=nullptr) const
 
EXPORT bool VerifySignature (const OTPseudonym &theNym, const OTSignature &theSignature, const OTPasswordData *pPWData=nullptr) const
 
EXPORT bool VerifySigAuthent (const OTPseudonym &theNym, const OTSignature &theSignature, const OTPasswordData *pPWData=nullptr) const
 
EXPORT bool VerifySignature (const OTAsymmetricKey &theKey, const OTSignature &theSignature, const OTString &strHashType, const OTPasswordData *pPWData=nullptr) const
 
EXPORT bool VerifySignature (const char *szFoldername, const char *szFilename, const OTSignature &theSignature, const OTPasswordData *pPWData=nullptr) const
 
EXPORT const OTAsymmetricKeyGetContractPublicKey () const
 
EXPORT const OTPseudonymGetContractPublicNym () const
 

Protected Member Functions

virtual int32_t ProcessXMLNode (irr::io::IrrXMLReader *&xml)
 
- Protected Member Functions inherited from opentxs::OTContract
bool LoadContractXML ()
 

Protected Attributes

OTString m_strSignedFilePayload
 
OTString m_strLocalDir
 
OTString m_strSignedFilename
 
OTString m_strPurportedLocalDir
 
OTString m_strPurportedFilename
 
OTString m_strSignerNymID
 
- Protected Attributes inherited from opentxs::OTContract
OTString m_strName
 
OTString m_strFoldername
 
OTString m_strFilename
 
OTIdentifier m_ID
 
OTStringXML m_xmlUnsigned
 
OTString m_strRawFile
 
OTString m_strSigHashType
 
OTString m_strContractType
 
mapOfNyms m_mapNyms
 
listOfSignatures m_listSignatures
 
OTString m_strVersion
 
OTString m_strEntityShortName
 
OTString m_strEntityLongName
 
OTString m_strEntityEmail
 
OTString::Map m_mapConditions
 

Additional Inherited Members

- Static Public Member Functions inherited from opentxs::OTContract
static EXPORT bool DearmorAndTrim (const OTString &strInput, OTString &strOutput, OTString &strFirstLine)
 
static bool AddBookendsAroundContent (OTString &strOutput, const OTString &strContents, const OTString &strContractType, const OTString &strHashType, const listOfSignatures &listSignatures)
 
static EXPORT bool LoadEncodedTextField (irr::io::IrrXMLReader *&xml, OTASCIIArmor &ascOutput)
 
static EXPORT bool LoadEncodedTextField (irr::io::IrrXMLReader *&xml, OTString &strOutput)
 
static bool LoadEncodedTextFieldByName (irr::io::IrrXMLReader *&xml, OTASCIIArmor &ascOutput, const char *&szName, OTString::Map *pmapExtraVars=nullptr)
 
static bool LoadEncodedTextFieldByName (irr::io::IrrXMLReader *&xml, OTString &strOutput, const char *&szName, OTString::Map *pmapExtraVars=nullptr)
 
static bool SkipToElement (irr::io::IrrXMLReader *&xml)
 
static bool SkipToTextField (irr::io::IrrXMLReader *&xml)
 
static bool SkipAfterLoadingField (irr::io::IrrXMLReader *&xml)
 
static EXPORT bool SignFlatText (OTString &strFlatText, const OTString &strContractType, const OTPseudonym &theSigner, OTString &strOutput)
 

Detailed Description

Definition at line 141 of file OTSignedFile.hpp.

Constructor & Destructor Documentation

opentxs::OTSignedFile::OTSignedFile ( )

Definition at line 345 of file OTSignedFile.cpp.

346  : ot_super()
347 {
348  m_strContractType.Set("FILE");
349 }
EXPORT void Set(const char *data, uint32_t enforcedMaxLength=0)
Definition: OTString.cpp:1055
OTString m_strContractType
Definition: OTContract.hpp:178
opentxs::OTSignedFile::OTSignedFile ( const OTString LOCAL_SUBDIR,
const OTString FILE_NAME 
)

Definition at line 257 of file OTSignedFile.cpp.

259  : ot_super()
260 {
261  m_strContractType.Set("FILE");
262 
263  SetFilename(LOCAL_SUBDIR, FILE_NAME);
264 }
EXPORT void Set(const char *data, uint32_t enforcedMaxLength=0)
Definition: OTString.cpp:1055
OTString m_strContractType
Definition: OTContract.hpp:178
void SetFilename(const OTString &LOCAL_SUBDIR, const OTString &FILE_NAME)
opentxs::OTSignedFile::OTSignedFile ( const char *  LOCAL_SUBDIR,
const OTString FILE_NAME 
)

Definition at line 266 of file OTSignedFile.cpp.

267  : ot_super()
268 {
269  m_strContractType.Set("FILE");
270 
271  OTString strLocalSubdir(LOCAL_SUBDIR);
272 
273  SetFilename(strLocalSubdir, FILE_NAME);
274 }
EXPORT void Set(const char *data, uint32_t enforcedMaxLength=0)
Definition: OTString.cpp:1055
OTString m_strContractType
Definition: OTContract.hpp:178
void SetFilename(const OTString &LOCAL_SUBDIR, const OTString &FILE_NAME)
opentxs::OTSignedFile::OTSignedFile ( const char *  LOCAL_SUBDIR,
const char *  FILE_NAME 
)

Definition at line 276 of file OTSignedFile.cpp.

277  : ot_super()
278 {
279  m_strContractType.Set("FILE");
280 
281  OTString strLocalSubdir(LOCAL_SUBDIR), strFile_Name(FILE_NAME);
282 
283  SetFilename(strLocalSubdir, strFile_Name);
284 }
EXPORT void Set(const char *data, uint32_t enforcedMaxLength=0)
Definition: OTString.cpp:1055
OTString m_strContractType
Definition: OTContract.hpp:178
void SetFilename(const OTString &LOCAL_SUBDIR, const OTString &FILE_NAME)
opentxs::OTSignedFile::~OTSignedFile ( )
virtual

Definition at line 351 of file OTSignedFile.cpp.

352 {
354 }

Member Function Documentation

OTString & opentxs::OTSignedFile::GetFilePayload ( )

Definition at line 146 of file OTSignedFile.cpp.

147 {
148  return m_strSignedFilePayload;
149 }
OTString & opentxs::OTSignedFile::GetSignerNymID ( )

Definition at line 156 of file OTSignedFile.cpp.

157 {
158  return m_strSignerNymID;
159 }
bool opentxs::OTSignedFile::LoadFile ( )

Definition at line 310 of file OTSignedFile.cpp.

311 {
312  // otOut << "DEBUG LoadFile (Signed) folder: %s file: %s \n",
313  // m_strFoldername.Get(), m_strFilename.Get());
314 
316  return LoadContract();
317 
318  return false;
319 }
virtual EXPORT bool LoadContract()
EXPORT const char * Get() const
Definition: OTString.cpp:1045
EXPORT bool Exists(std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
Definition: OTStorage.cpp:584
OTString m_strFoldername
Definition: OTContract.hpp:169
int32_t opentxs::OTSignedFile::ProcessXMLNode ( irr::io::IrrXMLReader *&  xml)
protectedvirtual

Reimplemented from opentxs::OTContract.

Definition at line 195 of file OTSignedFile.cpp.

196 {
197  int32_t nReturnVal = 0;
198 
199  // Here we call the parent class first.
200  // If the node is found there, or there is some error,
201  // then we just return either way. But if it comes back
202  // as '0', then nothing happened, and we'll continue executing.
203  //
204  // -- Note you can choose not to call the parent if
205  // you don't want to use any of those xml tags.
206  // As I do below, in the case of OTAccount.
207  // if (nReturnVal = ot_super::ProcessXMLNode(xml))
208  // return nReturnVal;
209 
210  if (!strcmp("signedFile", xml->getNodeName())) {
211  m_strVersion = xml->getAttributeValue("version");
212 
213  m_strPurportedLocalDir = xml->getAttributeValue("localDir");
214  m_strPurportedFilename = xml->getAttributeValue("filename");
215  m_strSignerNymID = xml->getAttributeValue("signer");
216 
217  nReturnVal = 1;
218  }
219  else if (!strcmp("filePayload", xml->getNodeName())) {
220  if (false ==
222  otErr << "Error in OTSignedFile::ProcessXMLNode: filePayload field "
223  "without value.\n";
224  return (-1); // error condition
225  }
226 
227  return 1;
228  }
229 
230  return nReturnVal;
231 }
static EXPORT bool LoadEncodedTextField(irr::io::IrrXMLReader *&xml, OTASCIIArmor &ascOutput)
OTLOG_IMPORT OTLogStream otErr
void opentxs::OTSignedFile::Release ( )
virtual

Reimplemented from opentxs::OTContract.

Definition at line 375 of file OTSignedFile.cpp.

376 {
378 
380 
381  m_strContractType.Set("FILE");
382 }
EXPORT void Set(const char *data, uint32_t enforcedMaxLength=0)
Definition: OTString.cpp:1055
OTString m_strContractType
Definition: OTContract.hpp:178
virtual EXPORT void Release()
Definition: OTContract.cpp:277
void opentxs::OTSignedFile::Release_SignedFile ( )

Definition at line 356 of file OTSignedFile.cpp.

357 {
358  m_strSignedFilePayload.Release(); // This is the file contents we were
359  // wrapping.
360  // We can release this now.
361 
362  // m_strLocalDir.Release(); // We KEEP these, *not* release,
363  // because LoadContract()
364  // m_strSignedFilename.Release(); // calls Release(), and these
365  // are our core values. We don't
366  // want to lose them when the file is loaded.
367 
368  // Note: Additionally, neither does OTContract release m_strFilename here,
369  // for the SAME reason.
370 
373 }
virtual EXPORT void Release()
Definition: OTString.cpp:765
bool opentxs::OTSignedFile::SaveContractWallet ( std::ofstream &  ofs) const
virtual

Implements opentxs::OTContract.

Definition at line 384 of file OTSignedFile.cpp.

385 {
386  return true;
387 }
bool opentxs::OTSignedFile::SaveFile ( )

Definition at line 291 of file OTSignedFile.cpp.

292 {
293  const OTString strTheFileName(m_strFilename);
294  const OTString strTheFolderName(m_strFoldername);
295 
296  // OTContract doesn't natively make it easy to save a contract to its own
297  // filename.
298  // Funny, I know, but OTContract is designed to save either to a specific
299  // filename,
300  // or to a string parameter, or to the internal rawfile member. It doesn't
301  // normally
302  // save to its own filename that was used to load it. But OTSignedFile is
303  // different...
304 
305  // This saves to a file, the name passed in as a char *.
306  return SaveContract(strTheFolderName.Get(), strTheFileName.Get());
307 }
EXPORT bool SaveContract()
OTString m_strFoldername
Definition: OTContract.hpp:169
void opentxs::OTSignedFile::SetFilename ( const OTString LOCAL_SUBDIR,
const OTString FILE_NAME 
)

Definition at line 321 of file OTSignedFile.cpp.

323 {
324  // OTSignedFile specific variables.
325  m_strLocalDir = LOCAL_SUBDIR;
326  m_strSignedFilename = FILE_NAME;
327 
328  // OTContract variables.
331 
332  /*
333  m_strFilename.Format("%s%s" // data_folder/
334  "%s%s" // nyms/
335  "%s", // 5bf9a88c.nym
336  OTLog::Path(), OTLog::PathSeparator(),
337  m_strLocalDir.Get(), OTLog::PathSeparator(),
338  m_strSignedFilename.Get());
339  */
340  // Software Path + Local Sub-directory + Filename
341  //
342  // Finished Product: "transaction/nyms/5bf9a88c.nym"
343 }
OTString m_strFoldername
Definition: OTContract.hpp:169
void opentxs::OTSignedFile::SetFilePayload ( const OTString strArg)

Definition at line 151 of file OTSignedFile.cpp.

152 {
153  m_strSignedFilePayload = strArg;
154 }
void opentxs::OTSignedFile::SetSignerNymID ( const OTString strArg)

Definition at line 161 of file OTSignedFile.cpp.

162 {
163  m_strSignerNymID = strArg;
164 }
void opentxs::OTSignedFile::UpdateContents ( )
virtual

Reimplemented from opentxs::OTContract.

Definition at line 166 of file OTSignedFile.cpp.

167 {
168 
169  OTString strSignerNym("");
170  if (m_strSignerNymID.Exists()) {
171  strSignerNym.Format("\n signer=\"%s\"", m_strSignerNymID.Get());
172  }
173 
174  // I release this because I'm about to repopulate it.
176 
177  m_xmlUnsigned.Concatenate("<?xml version=\"%s\"?>\n\n", "1.0");
178 
179  m_xmlUnsigned.Concatenate("<signedFile\n version=\"%s\"\n"
180  " localDir=\"%s\"\n"
181  " filename=\"%s\"%s"
182  " >\n\n",
184  m_strSignedFilename.Get(), strSignerNym.Get());
185 
187  OTASCIIArmor ascPayload(m_strSignedFilePayload);
188  m_xmlUnsigned.Concatenate("<filePayload>\n%s</filePayload>\n\n",
189  ascPayload.Get());
190  }
191 
192  m_xmlUnsigned.Concatenate("</signedFile>\n");
193 }
EXPORT void Concatenate(const char *arg,...)
Definition: OTString.cpp:1334
EXPORT bool Exists() const
Definition: OTString.cpp:1035
OTStringXML m_xmlUnsigned
Definition: OTContract.hpp:174
EXPORT const char * Get() const
Definition: OTString.cpp:1045
virtual EXPORT void Release()
Definition: OTString.cpp:765
bool opentxs::OTSignedFile::VerifyFile ( )

Definition at line 242 of file OTSignedFile.cpp.

243 {
246  return true;
247 
248  otErr << __FUNCTION__ << ": Failed verifying signed file:\n"
249  "Expected directory: " << m_strLocalDir
250  << " Found: " << m_strPurportedLocalDir
251  << "\n"
252  "Expected filename: " << m_strSignedFilename
253  << " Found: " << m_strPurportedFilename << "\n";
254  return false;
255 }
EXPORT bool Compare(const char *compare) const
Definition: OTString.cpp:1102
OTLOG_IMPORT OTLogStream otErr

Member Data Documentation

OTString opentxs::OTSignedFile::m_strLocalDir
protected

Definition at line 151 of file OTSignedFile.hpp.

OTString opentxs::OTSignedFile::m_strPurportedFilename
protected

Definition at line 160 of file OTSignedFile.hpp.

OTString opentxs::OTSignedFile::m_strPurportedLocalDir
protected

Definition at line 158 of file OTSignedFile.hpp.

OTString opentxs::OTSignedFile::m_strSignedFilename
protected

Definition at line 153 of file OTSignedFile.hpp.

OTString opentxs::OTSignedFile::m_strSignedFilePayload
protected

Definition at line 147 of file OTSignedFile.hpp.

OTString opentxs::OTSignedFile::m_strSignerNymID
protected

Definition at line 163 of file OTSignedFile.hpp.


The documentation for this class was generated from the following files: