Vitaly Buka | f08caeb | 2015-12-02 13:47:48 -0800 | [diff] [blame] | 1 | // Copyright 2015 The Weave 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 | |
| 5 | #ifndef LIBWEAVE_SRC_PRIVET_AUTH_MANAGER_H_ |
| 6 | #define LIBWEAVE_SRC_PRIVET_AUTH_MANAGER_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | #include <vector> |
| 10 | |
| 11 | #include <base/time/time.h> |
| 12 | #include <weave/error.h> |
| 13 | |
| 14 | #include "src/privet/privet_types.h" |
| 15 | |
| 16 | namespace weave { |
| 17 | namespace privet { |
| 18 | |
| 19 | class AuthManager { |
| 20 | public: |
| 21 | AuthManager(const std::vector<uint8_t>& secret, |
| 22 | const std::vector<uint8_t>& certificate_fingerprint); |
| 23 | ~AuthManager(); |
| 24 | |
| 25 | std::vector<uint8_t> CreateAccessToken(const UserInfo& user_info, |
| 26 | const base::Time& time); |
| 27 | UserInfo ParseAccessToken(const std::vector<uint8_t>& token, |
| 28 | base::Time* time) const; |
| 29 | |
| 30 | const std::vector<uint8_t>& GetSecret() const { return secret_; } |
| 31 | const std::vector<uint8_t>& GetCertificateFingerprint() const { |
| 32 | return certificate_fingerprint_; |
| 33 | } |
| 34 | |
| 35 | private: |
| 36 | std::vector<uint8_t> secret_; |
| 37 | std::vector<uint8_t> certificate_fingerprint_; |
| 38 | |
| 39 | DISALLOW_COPY_AND_ASSIGN(AuthManager); |
| 40 | }; |
| 41 | |
| 42 | } // namespace privet |
| 43 | } // namespace weave |
| 44 | |
| 45 | #endif // LIBWEAVE_SRC_PRIVET_AUTH_MANAGER_H_ |