diff options
author | Vitaly Buka <vitalybuka@google.com> | 2016-02-23 18:50:42 -0800 |
---|---|---|
committer | Vitaly Buka <vitalybuka@google.com> | 2016-02-24 18:13:14 +0000 |
commit | ebde3c1e1e87202d6c81a7351921468703be7b6f (patch) | |
tree | 335435626c63af0194fd9a00d4e525aa6b2ae32a /src/access_revocation_manager.h | |
parent | efbd66b690afb9c91ea95f91e216667901191746 (diff) | |
download | libweave-ebde3c1e1e87202d6c81a7351921468703be7b6f.tar.gz |
Rename *BlackList* into *Revocation*
This name matches better new trait and semantic.
BUG: 27313743
Change-Id: I0cbc7b40cf14b17cfbffb7f58572a7ea6d81c542
Reviewed-on: https://weave-review.googlesource.com/2730
Reviewed-by: Alex Vakulenko <avakulenko@google.com>
Diffstat (limited to 'src/access_revocation_manager.h')
-rw-r--r-- | src/access_revocation_manager.h | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/access_revocation_manager.h b/src/access_revocation_manager.h new file mode 100644 index 0000000..6d5bf7b --- /dev/null +++ b/src/access_revocation_manager.h @@ -0,0 +1,66 @@ +// Copyright 2016 The Weave Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef LIBWEAVE_SRC_ACCESS_REVOCATION_MANAGER_H_ +#define LIBWEAVE_SRC_ACCESS_REVOCATION_MANAGER_H_ + +#include <vector> + +#include <base/time/time.h> + +namespace weave { + +class AccessRevocationManager { + public: + struct Entry { + Entry() = default; + + Entry(const std::vector<uint8_t>& user, + const std::vector<uint8_t>& app, + base::Time revocation_ts, + base::Time expiration_ts) + : user_id{user}, + app_id{app}, + revocation{revocation_ts}, + expiration{expiration_ts} {} + // user_id is empty, app_id is empty: block everything. + // user_id is not empty, app_id is empty: block if user_id matches. + // user_id is empty, app_id is not empty: block if app_id matches. + // user_id is not empty, app_id is not empty: block if both match. + std::vector<uint8_t> user_id; + std::vector<uint8_t> app_id; + + // Revoke matching entries if |revocation| is not less than + // delegation timestamp. + base::Time revocation; + + // Time after which to discard the rule. + base::Time expiration; + }; + virtual ~AccessRevocationManager() = default; + + virtual void AddEntryAddedCallback(const base::Closure& callback) = 0; + virtual void Block(const Entry& entry, const DoneCallback& callback) = 0; + virtual bool IsBlocked(const std::vector<uint8_t>& user_id, + const std::vector<uint8_t>& app_id, + base::Time timestamp) const = 0; + virtual std::vector<Entry> GetEntries() const = 0; + virtual size_t GetSize() const = 0; + virtual size_t GetCapacity() const = 0; +}; + +inline bool operator==(const AccessRevocationManager::Entry& l, + const AccessRevocationManager::Entry& r) { + return l.revocation == r.revocation && l.expiration == r.expiration && + l.user_id == r.user_id && l.app_id == r.app_id; +} + +inline bool operator!=(const AccessRevocationManager::Entry& l, + const AccessRevocationManager::Entry& r) { + return !(l == r); +} + +} // namespace weave + +#endif // LIBWEAVE_SRC_ACCESS_REVOCATION_MANAGER_H_ |