nss_profile_filter_chromeos.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Copyright 2013 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef NET_CERT_NSS_PROFILE_FILTER_CHROMEOS_H_
  5. #define NET_CERT_NSS_PROFILE_FILTER_CHROMEOS_H_
  6. #include "base/memory/ref_counted.h"
  7. #include "crypto/scoped_nss_types.h"
  8. #include "net/base/net_export.h"
  9. #include "net/cert/scoped_nss_types.h"
  10. namespace net {
  11. // On ChromeOS each user has separate NSS databases, which are loaded
  12. // simultaneously when multiple users are logged in at the same time. NSS
  13. // doesn't have built-in support to partition databases into separate groups, so
  14. // NSSProfileFilterChromeOS can be used to check if a given slot or certificate
  15. // should be used for a given user.
  16. //
  17. // Objects of this class are thread-safe except for the Init function, which if
  18. // called must not be called while other threads could access the object.
  19. class NET_EXPORT NSSProfileFilterChromeOS {
  20. public:
  21. // Create a filter. Until Init is called (or if Init is called with NULL
  22. // slot handles), the filter will allow only certs/slots from the read-only
  23. // slots and the root CA module.
  24. NSSProfileFilterChromeOS();
  25. NSSProfileFilterChromeOS(const NSSProfileFilterChromeOS& other);
  26. ~NSSProfileFilterChromeOS();
  27. NSSProfileFilterChromeOS& operator=(const NSSProfileFilterChromeOS& other);
  28. // Initialize the filter with the slot handles to allow. This method is not
  29. // thread-safe.
  30. void Init(crypto::ScopedPK11Slot public_slot,
  31. crypto::ScopedPK11Slot private_slot,
  32. crypto::ScopedPK11Slot system_slot);
  33. bool IsModuleAllowed(PK11SlotInfo* slot) const;
  34. bool IsCertAllowed(CERTCertificate* cert) const;
  35. private:
  36. crypto::ScopedPK11Slot public_slot_;
  37. crypto::ScopedPK11Slot private_slot_;
  38. crypto::ScopedPK11Slot system_slot_;
  39. };
  40. } // namespace net
  41. #endif // NET_CERT_NSS_PROFILE_FILTER_CHROMEOS_H_