Source code of Windows XP (NT5)
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.

255 lines
5.5 KiB

  1. // CV1Cert.cpp: implementation of the CV1Certificate 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 "NoWarning.h"
  10. #include <scuCast.h>
  11. #include <iopPubBlob.h>
  12. #include "slbCci.h" // for KeySpec
  13. #include "cciExc.h"
  14. #include "cciCard.h"
  15. #include "TransactionWrap.h"
  16. #include "V1Cert.h"
  17. #include "V1ContRec.h"
  18. using namespace std;
  19. using namespace cci;
  20. using namespace iop;
  21. /////////////////////////// LOCAL/HELPER /////////////////////////////////
  22. /////////////////////////// PUBLIC /////////////////////////////////
  23. // Types
  24. // C'tors/D'tors
  25. CV1Certificate::CV1Certificate(CV1Card const &rv1card,
  26. KeySpec ks)
  27. : CAbstractCertificate(rv1card, oaPublicAccess, true),
  28. m_ks(ks),
  29. m_sCertToStore()
  30. {}
  31. CV1Certificate::~CV1Certificate() throw()
  32. {}
  33. // Operators
  34. // Operations
  35. void
  36. CV1Certificate::AssociateWith(KeySpec ks)
  37. {
  38. CTransactionWrap wrap(m_hcard);
  39. m_ks = ks;
  40. Store();
  41. }
  42. void
  43. CV1Certificate::CredentialID(string const &rstrCredID)
  44. {
  45. throw Exception(ccNotImplemented);
  46. }
  47. void
  48. CV1Certificate::ID(string const &rstrId)
  49. {
  50. throw Exception(ccNotImplemented);
  51. }
  52. void
  53. CV1Certificate::Issuer(string const &rstrIssuer)
  54. {
  55. throw Exception(ccNotImplemented);
  56. }
  57. void
  58. CV1Certificate::Label(string const &rstrLabel)
  59. {
  60. throw Exception(ccNotImplemented);
  61. }
  62. CV1Certificate *
  63. CV1Certificate::Make(CV1Card const &rv1card,
  64. KeySpec ks)
  65. {
  66. return new CV1Certificate(rv1card, ks);
  67. }
  68. void
  69. CV1Certificate::Subject(string const &rstrSubject)
  70. {
  71. throw Exception(ccNotImplemented);
  72. }
  73. void
  74. CV1Certificate::Modifiable(bool flag)
  75. {
  76. throw Exception(ccNotImplemented);
  77. }
  78. void
  79. CV1Certificate::Serial(string const &rstrSerialNumber)
  80. {
  81. throw Exception(ccNotImplemented);
  82. }
  83. // Access
  84. string
  85. CV1Certificate::CredentialID()
  86. {
  87. throw Exception(ccNotImplemented);
  88. return string();
  89. }
  90. string
  91. CV1Certificate::ID()
  92. {
  93. throw Exception(ccNotImplemented);
  94. return string();
  95. }
  96. string
  97. CV1Certificate::Issuer()
  98. {
  99. throw Exception(ccNotImplemented);
  100. return string();
  101. }
  102. string
  103. CV1Certificate::Label()
  104. {
  105. throw Exception(ccNotImplemented);
  106. return string();
  107. }
  108. bool
  109. CV1Certificate::Modifiable()
  110. {
  111. throw Exception(ccNotImplemented);
  112. return false;
  113. }
  114. bool
  115. CV1Certificate::Private()
  116. {
  117. return false;
  118. }
  119. string
  120. CV1Certificate::Serial()
  121. {
  122. throw Exception(ccNotImplemented);
  123. return string();
  124. }
  125. string
  126. CV1Certificate::Subject()
  127. {
  128. throw Exception(ccNotImplemented);
  129. return string();
  130. }
  131. // Predicates
  132. // Static Variables
  133. /////////////////////////// PROTECTED /////////////////////////////////
  134. // C'tors/D'tors
  135. // Operators
  136. // Operations
  137. void
  138. CV1Certificate::DoDelete()
  139. {
  140. if (ksNone != m_ks)
  141. {
  142. m_sCertToStore.erase();
  143. Store();
  144. }
  145. }
  146. void
  147. CV1Certificate::DoValue(ZipCapsule const &rzc)
  148. {
  149. m_sCertToStore = rzc.Data();
  150. if (ksNone != m_ks)
  151. Store();
  152. }
  153. // Access
  154. CV1Certificate::ZipCapsule
  155. CV1Certificate::DoValue()
  156. {
  157. CV1Card &rv1card = scu::DownCast<CV1Card &, CAbstractCard &>(*m_hcard);
  158. CV1ContainerRecord CertRec(rv1card,
  159. CV1ContainerRecord::CertName(),
  160. CV1ContainerRecord::cmConditionally);
  161. if (ksNone == m_ks)
  162. throw Exception(ccInvalidParameter);
  163. string sCompressedCert;
  164. CertRec.Read(m_ks, sCompressedCert);
  165. return ZipCapsule(sCompressedCert, true);
  166. }
  167. // Predicates
  168. bool
  169. CV1Certificate::DoEquals(CAbstractCertificate const &rhs) const
  170. {
  171. CV1Certificate const &rv1rhs =
  172. scu::DownCast<CV1Certificate const &, CAbstractCertificate const &>(rhs);
  173. return rv1rhs.m_ks == m_ks;
  174. }
  175. // Static Variables
  176. /////////////////////////// PRIVATE /////////////////////////////////
  177. // C'tors/D'tors
  178. // Operators
  179. // Operations
  180. void
  181. CV1Certificate::Store()
  182. {
  183. if (ksNone != m_ks)
  184. {
  185. CV1Card &rv1card =
  186. scu::DownCast<CV1Card &, CAbstractCard &>(*m_hcard);
  187. CV1ContainerRecord CertRec(rv1card,
  188. CV1ContainerRecord::CertName(),
  189. CV1ContainerRecord::cmConditionally);
  190. CertRec.Write(m_ks, m_sCertToStore);
  191. }
  192. else
  193. throw Exception(ccInvalidParameter);
  194. }
  195. // Access
  196. // Predicates
  197. // Static Variables