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.

82 lines
2.9 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 2000-2002.
  5. //
  6. // File: PolicyOID.cpp
  7. //
  8. // Contents: CPolicyOID
  9. //
  10. //----------------------------------------------------------------------------
  11. #include "stdafx.h"
  12. #include "PolicyOID.h"
  13. CPolicyOID::CPolicyOID (const CString& szOID, const CString& szDisplayName, ADS_INTEGER flags, bool bCanRename)
  14. : m_szOIDW (szOID),
  15. m_szDisplayName (szDisplayName),
  16. m_pszOIDA (0),
  17. m_flags (flags),
  18. m_bCanRename (bCanRename)
  19. {
  20. // security review 2/21/2002 BryanWal ok
  21. int nLen = WideCharToMultiByte(
  22. CP_ACP, // code page
  23. 0, // performance and mapping flags
  24. (PCWSTR) m_szOIDW, // wide-character string
  25. -1, // -1 - calculate length of null-terminated string automatically
  26. 0, // buffer for new string
  27. 0, // size of buffer - 0 causes API to return len inc. null term.
  28. 0, // default for unmappable chars
  29. 0); // set when default char used
  30. if ( nLen > 0 )
  31. {
  32. m_pszOIDA = new char[nLen];
  33. if ( m_pszOIDA )
  34. {
  35. // security review 2/21/2002 BryanWal ok
  36. ZeroMemory (m_pszOIDA, nLen);
  37. // security review 2/21/2002 BryanWal ok
  38. nLen = WideCharToMultiByte(
  39. CP_ACP, // code page
  40. 0, // performance and mapping flags
  41. (PCWSTR) m_szOIDW, // wide-character string
  42. -1, // -1 - calculate length of null-terminated string automatically
  43. m_pszOIDA, // buffer for new string
  44. nLen, // size of buffer
  45. 0, // default for unmappable chars
  46. 0); // set when default char used
  47. if ( !nLen )
  48. {
  49. _TRACE (0, L"WideCharToMultiByte (%s) failed: 0x%x\n",
  50. (PCWSTR) m_szOIDW, GetLastError ());
  51. }
  52. }
  53. }
  54. else
  55. {
  56. _TRACE (0, L"WideCharToMultiByte (%s) failed: 0x%x\n",
  57. (PCWSTR) m_szOIDW, GetLastError ());
  58. }
  59. }
  60. CPolicyOID::~CPolicyOID ()
  61. {
  62. if ( m_pszOIDA )
  63. delete [] m_pszOIDA;
  64. }
  65. bool CPolicyOID::IsIssuanceOID() const
  66. {
  67. return (m_flags == CERT_OID_TYPE_ISSUER_POLICY) ? true : false;
  68. }
  69. bool CPolicyOID::IsApplicationOID() const
  70. {
  71. return (m_flags == CERT_OID_TYPE_APPLICATION_POLICY) ? true : false;
  72. }
  73. void CPolicyOID::SetDisplayName(const CString &szDisplayName)
  74. {
  75. m_szDisplayName = szDisplayName;
  76. }