Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

254 lines
6.5 KiB

  1. // CV2Cert.cpp: implementation of the CV2Certificate class.
  2. //
  3. // (c) Copyright Schlumberger Technology Corp., unpublished work, created
  4. // 1999. This computer program includes Confidential, Proprietary
  5. // Information and is a Trade Secret of Schlumberger Technology Corp. All
  6. // use, disclosure, and/or reproduction is prohibited unless authorized
  7. // in writing. All Rights Reserved.
  8. //////////////////////////////////////////////////////////////////////
  9. #include <scuCast.h>
  10. #include "cciCard.h"
  11. #include "TransactionWrap.h"
  12. #include "V2Cert.h"
  13. #include "CertificateInfoRecord.h"
  14. using namespace std;
  15. using namespace cci;
  16. /////////////////////////// LOCAL/HELPER /////////////////////////////////
  17. /////////////////////////// PUBLIC /////////////////////////////////
  18. // Types
  19. // C'tors/D'tors
  20. CV2Certificate::CV2Certificate(CV2Card const &rv2card,
  21. ObjectAccess oa)
  22. : CAbstractCertificate(rv2card, oa),
  23. m_sidHandle(0),
  24. m_apcir()
  25. {
  26. m_sidHandle =
  27. rv2card.ObjectInfoFile(oa).AddObject(otCertificateObject,
  28. CertInfoRecordSize);
  29. Setup(rv2card);
  30. // write new certificate object into info file
  31. m_apcir->Write();
  32. }
  33. CV2Certificate::CV2Certificate(CV2Card const &rv2card,
  34. SymbolID sidHandle,
  35. ObjectAccess oa)
  36. : CAbstractCertificate(rv2card, oa),
  37. m_sidHandle(sidHandle),
  38. m_apcir()
  39. {
  40. Setup(rv2card);
  41. }
  42. CV2Certificate::~CV2Certificate() throw()
  43. {}
  44. // Operators
  45. // Operations
  46. void
  47. CV2Certificate::CredentialID(string const &rstrCredID)
  48. {
  49. m_apcir->Symbol(&m_apcir->m_bCredentialID, rstrCredID);
  50. }
  51. void
  52. CV2Certificate::ID(string const &rstrId)
  53. {
  54. m_apcir->Symbol(&m_apcir->m_bID, rstrId);
  55. }
  56. void
  57. CV2Certificate::Issuer(string const &rstrIssuer)
  58. {
  59. m_apcir->Symbol(&m_apcir->m_bIssuer, rstrIssuer);
  60. }
  61. void
  62. CV2Certificate::Label(string const &rstrLabel)
  63. {
  64. m_apcir->Symbol(&m_apcir->m_bLabel, rstrLabel);
  65. }
  66. CV2Certificate *
  67. CV2Certificate::Make(CV2Card const &rv2card,
  68. SymbolID sidHandle,
  69. ObjectAccess oa)
  70. {
  71. return new CV2Certificate(rv2card, sidHandle, oa);
  72. }
  73. void
  74. CV2Certificate::Subject(string const &rstrSubject)
  75. {
  76. m_apcir->Symbol(&m_apcir->m_bSubject, rstrSubject);
  77. }
  78. void
  79. CV2Certificate::Modifiable(bool flag)
  80. {
  81. m_apcir->Flag(CertModifiableFlag, flag);
  82. }
  83. void
  84. CV2Certificate::Serial(string const &rstrSerialNumber)
  85. {
  86. m_apcir->Symbol(&m_apcir->m_bSerialNumber, rstrSerialNumber);
  87. }
  88. // Access
  89. string
  90. CV2Certificate::CredentialID()
  91. {
  92. return m_apcir->Symbol(&m_apcir->m_bCredentialID);
  93. }
  94. SymbolID
  95. CV2Certificate::Handle() const
  96. {
  97. return m_sidHandle;
  98. }
  99. string
  100. CV2Certificate::ID()
  101. {
  102. return m_apcir->Symbol(&m_apcir->m_bID);
  103. }
  104. string
  105. CV2Certificate::Issuer()
  106. {
  107. return m_apcir->Symbol(&m_apcir->m_bIssuer);
  108. }
  109. string
  110. CV2Certificate::Label()
  111. {
  112. return m_apcir->Symbol(&m_apcir->m_bLabel);
  113. }
  114. bool
  115. CV2Certificate::Modifiable()
  116. {
  117. return m_apcir->Flag(CertModifiableFlag);
  118. }
  119. bool
  120. CV2Certificate::Private()
  121. {
  122. return m_apcir->Private();
  123. }
  124. string
  125. CV2Certificate::Serial()
  126. {
  127. return m_apcir->Symbol(&m_apcir->m_bSerialNumber);
  128. }
  129. string
  130. CV2Certificate::Subject()
  131. {
  132. return m_apcir->Symbol(&m_apcir->m_bSubject);
  133. }
  134. // Predicates
  135. // Static Variables
  136. /////////////////////////// PROTECTED /////////////////////////////////
  137. // C'tors/D'tors
  138. // Operators
  139. // Operations
  140. void
  141. CV2Certificate::DoDelete()
  142. {
  143. m_apcir->Read();
  144. CV2Card &rv2card = scu::DownCast<CV2Card &, CAbstractCard &>(*m_hcard);
  145. CObjectInfoFile &roif = rv2card.ObjectInfoFile(m_oa);
  146. if (m_apcir->m_bValue)
  147. roif.RemoveSymbol(m_apcir->m_bValue);
  148. if (m_apcir->m_bLabel)
  149. roif.RemoveSymbol(m_apcir->m_bLabel);
  150. if (m_apcir->m_bID)
  151. roif.RemoveSymbol(m_apcir->m_bID);
  152. if (m_apcir->m_bCredentialID)
  153. roif.RemoveSymbol(m_apcir->m_bCredentialID);
  154. if (m_apcir->m_bSubject)
  155. roif.RemoveSymbol(m_apcir->m_bSubject);
  156. if (m_apcir->m_bIssuer)
  157. roif.RemoveSymbol(m_apcir->m_bIssuer);
  158. if (m_apcir->m_bSerialNumber)
  159. roif.RemoveSymbol(m_apcir->m_bSerialNumber);
  160. roif.RemoveObject(otCertificateObject,m_sidHandle);
  161. }
  162. void
  163. CV2Certificate::DoValue(ZipCapsule const &rzc)
  164. {
  165. m_apcir->Read();
  166. m_apcir->m_bCompressAlg = rzc.IsCompressed();
  167. m_apcir->Symbol(&m_apcir->m_bValue, rzc.Data());
  168. m_apcir->Write();
  169. }
  170. // Access
  171. CV2Certificate::ZipCapsule
  172. CV2Certificate::DoValue()
  173. {
  174. m_apcir->Read();
  175. return ZipCapsule(m_apcir->Symbol(&m_apcir->m_bValue),
  176. (1 == m_apcir->m_bCompressAlg));
  177. }
  178. // Predicates
  179. bool
  180. CV2Certificate::DoEquals(CAbstractCertificate const &rhs) const
  181. {
  182. CV2Certificate const &rv2rhs =
  183. scu::DownCast<CV2Certificate const &, CAbstractCertificate const &>(rhs);
  184. return rv2rhs.m_sidHandle == m_sidHandle;
  185. }
  186. // Static Variables
  187. /////////////////////////// PRIVATE /////////////////////////////////
  188. // C'tors/D'tors
  189. // Operators
  190. // Operations
  191. void
  192. CV2Certificate::Setup(CV2Card const &rv2card)
  193. {
  194. m_apcir =
  195. auto_ptr<CCertificateInfoRecord>(new CCertificateInfoRecord(rv2card,
  196. m_sidHandle,
  197. m_oa));
  198. }
  199. // Access
  200. // Predicates
  201. // Static Variables