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.

64 lines
1.8 KiB

  1. // AContHelp.h -- Helpers with abstract containers
  2. // (c) Copyright Schlumberger Technology Corp., unpublished work, created
  3. // 1999. This computer program includes Confidential, Proprietary
  4. // Information and is a Trade Secret of Schlumberger Technology Corp. All
  5. // use, disclosure, and/or reproduction is prohibited unless authorized
  6. // in writing. All Rights Reserved.
  7. #if !defined(SLBCCI_ACONTHELP_H)
  8. #define SLBCCI_ACONTHELP_H
  9. // Note: This file should only be included by the CCI, not directly
  10. // by the client.
  11. #include <functional>
  12. #include "cciKeyPair.h"
  13. #include "MethodHelp.h"
  14. namespace cci
  15. {
  16. // Functor to erase an item (cert, pub/pri key) from both key
  17. // pairs of a container
  18. template<class T, class C>
  19. class EraseFromContainer
  20. : std::unary_function<CContainer &, void>
  21. {
  22. public:
  23. EraseFromContainer(T const &rItem,
  24. typename AccessorMethod<T, C>::AccessorPtr Accessor,
  25. typename ModifierMethod<T, C>::ModifierPtr Modifier)
  26. : m_Item(rItem),
  27. m_matAccess(Accessor),
  28. m_mmtModify(Modifier)
  29. {}
  30. result_type
  31. operator()(argument_type rhcont)
  32. {
  33. EraseFromKeyPair(rhcont->SignatureKeyPair());
  34. EraseFromKeyPair(rhcont->ExchangeKeyPair());
  35. }
  36. private:
  37. void
  38. EraseFromKeyPair(CKeyPair &rhkp)
  39. {
  40. if (rhkp)
  41. {
  42. T TmpItem(m_matAccess(*rhkp));
  43. if (TmpItem && (m_Item == TmpItem))
  44. m_mmtModify(*rhkp, T());
  45. }
  46. }
  47. T const m_Item;
  48. MemberAccessorType<T, C> m_matAccess;
  49. MemberModifierType<T, C> m_mmtModify;
  50. };
  51. } // namespace cci
  52. #endif // SLBCCI_ACONTHELP_H