Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(350)

Side by Side Diff: components/os_crypt/kwallet_dbus.h

Issue 2150543002: OSCrypt supports encryption with KWallet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: feedback Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_OS_CRYPT_KWALLET_DBUS_H_ 5 #ifndef COMPONENTS_OS_CRYPT_KWALLET_DBUS_H_
6 #define COMPONENTS_OS_CRYPT_KWALLET_DBUS_H_ 6 #define COMPONENTS_OS_CRYPT_KWALLET_DBUS_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/nix/xdg_util.h" 13 #include "base/nix/xdg_util.h"
14 14
15 namespace dbus { 15 namespace dbus {
16 class Bus; 16 class Bus;
17 class ObjectProxy; 17 class ObjectProxy;
18 } 18 }
19 19
20 // Contains wrappers for dbus invocations related to KWallet. 20 // Contains wrappers for dbus invocations related to KWallet.
21 class KWalletDBus { 21 class KWalletDBus {
22 public: 22 public:
23 // Error code for dbus calls to kwallet. 23 // Error code for dbus calls to kwallet.
24 enum Error { SUCCESS = 0, CANNOT_CONTACT, CANNOT_READ }; 24 enum Error { SUCCESS = 0, CANNOT_CONTACT, CANNOT_READ };
25 25
26 explicit KWalletDBus(base::nix::DesktopEnvironment desktop_env); 26 explicit KWalletDBus(base::nix::DesktopEnvironment desktop_env);
27 ~KWalletDBus(); 27 virtual ~KWalletDBus();
28 28
29 // Set the bus that we will use. Required before any other operation. 29 // Set the bus that we will use. Required before any other operation.
30 // The owner of KWalletDBus is responsible for killing the bus. 30 // The owner of KWalletDBus is responsible for killing the bus.
31 void SetSessionBus(scoped_refptr<dbus::Bus> session_bus); 31 virtual void SetSessionBus(scoped_refptr<dbus::Bus> session_bus);
32 32
33 // Expose the bus so that shutdown can be scheduled asynchronously. 33 // Expose the bus so that shutdown can be scheduled asynchronously.
34 dbus::Bus* GetSessionBus(); 34 virtual dbus::Bus* GetSessionBus();
35 35
36 // Use KLauncher to start the KWallet service. Returns true if successful. 36 // Use KLauncher to start the KWallet service. Returns true if successful.
37 bool StartKWalletd() WARN_UNUSED_RESULT; 37 virtual bool StartKWalletd() WARN_UNUSED_RESULT;
38 38
39 // The functions below are wrappers for calling the eponymous KWallet dbus 39 // The functions below are wrappers for calling the eponymous KWallet dbus
40 // methods. They take pointers to locations where the return values will be 40 // methods. They take pointers to locations where the return values will be
41 // written. More KWallet documentation at 41 // written. More KWallet documentation at
42 // https://api.kde.org/4.12-api/kdelibs-apidocs/kdeui/html/classKWallet_1_1Wal let.html 42 // https://api.kde.org/4.12-api/kdelibs-apidocs/kdeui/html/classKWallet_1_1Wal let.html
43 43
44 // Determine if the KDE wallet is enabled. 44 // Determine if the KDE wallet is enabled.
45 Error IsEnabled(bool* enabled) WARN_UNUSED_RESULT; 45 virtual Error IsEnabled(bool* enabled) WARN_UNUSED_RESULT;
46 46
47 // Get the name of the wallet used to store network passwords. 47 // Get the name of the wallet used to store network passwords.
48 Error NetworkWallet(std::string* wallet_name_ptr) WARN_UNUSED_RESULT; 48 virtual Error NetworkWallet(std::string* wallet_name_ptr) WARN_UNUSED_RESULT;
49 49
50 // Open the |wallet_name| wallet for use. 50 // Open the |wallet_name| wallet for use.
51 Error Open(const std::string& wallet_name, 51 virtual Error Open(const std::string& wallet_name,
52 const std::string& app_name, 52 const std::string& app_name,
53 int* handle_ptr) WARN_UNUSED_RESULT; 53 int* handle_ptr) WARN_UNUSED_RESULT;
54 54
55 // Determine if the current folder has they entry key. 55 // Determine if the current folder has they entry key.
56 Error HasEntry(int wallet_handle, 56 virtual Error HasEntry(int wallet_handle,
57 const std::string& folder_name, 57 const std::string& folder_name,
58 const std::string& signon_realm, 58 const std::string& signon_realm,
59 const std::string& app_name, 59 const std::string& app_name,
60 bool* has_entry_ptr) WARN_UNUSED_RESULT; 60 bool* has_entry_ptr) WARN_UNUSED_RESULT;
61 61
62 // Read the entry key from the current folder. 62 // Read the entry key from the current folder.
63 Error ReadEntry(int wallet_handle, 63 virtual Error ReadEntry(int wallet_handle,
64 const std::string& folder_name, 64 const std::string& folder_name,
65 const std::string& signon_realm, 65 const std::string& signon_realm,
66 const std::string& app_name, 66 const std::string& app_name,
67 std::vector<uint8_t>* bytes_ptr) WARN_UNUSED_RESULT; 67 std::vector<uint8_t>* bytes_ptr) WARN_UNUSED_RESULT;
68 68
69 // Return the list of keys of all entries in this folder. 69 // Return the list of keys of all entries in this folder.
70 Error EntryList(int wallet_handle, 70 virtual Error EntryList(int wallet_handle,
71 const std::string& folder_name, 71 const std::string& folder_name,
72 const std::string& app_name, 72 const std::string& app_name,
73 std::vector<std::string>* entry_list_ptr) WARN_UNUSED_RESULT; 73 std::vector<std::string>* entry_list_ptr)
74 WARN_UNUSED_RESULT;
74 75
75 // Remove the entry key from the current folder. 76 // Remove the entry key from the current folder.
76 // |*return_code_ptr| is 0 on success. 77 // |*return_code_ptr| is 0 on success.
77 Error RemoveEntry(int wallet_handle, 78 virtual Error RemoveEntry(int wallet_handle,
78 const std::string& folder_name, 79 const std::string& folder_name,
79 const std::string& signon_realm, 80 const std::string& signon_realm,
80 const std::string& app_name, 81 const std::string& app_name,
81 int* return_code_ptr) WARN_UNUSED_RESULT; 82 int* return_code_ptr) WARN_UNUSED_RESULT;
82 83
83 // Write a binary entry to the current folder. 84 // Write a binary entry to the current folder.
84 // |*return_code_ptr| is 0 on success. 85 // |*return_code_ptr| is 0 on success.
85 Error WriteEntry(int wallet_handle, 86 virtual Error WriteEntry(int wallet_handle,
86 const std::string& folder_name, 87 const std::string& folder_name,
87 const std::string& signon_realm, 88 const std::string& signon_realm,
88 const std::string& app_name, 89 const std::string& app_name,
89 const uint8_t* data, 90 const uint8_t* data,
90 size_t length, 91 size_t length,
91 int* return_code_ptr) WARN_UNUSED_RESULT; 92 int* return_code_ptr) WARN_UNUSED_RESULT;
92 93
93 // Determine if the folder |folder_name| exists in the wallet. 94 // Determine if the folder |folder_name| exists in the wallet.
94 Error HasFolder(int handle, 95 virtual Error HasFolder(int handle,
95 const std::string& folder_name, 96 const std::string& folder_name,
96 const std::string& app_name, 97 const std::string& app_name,
97 bool* has_folder_ptr) WARN_UNUSED_RESULT; 98 bool* has_folder_ptr) WARN_UNUSED_RESULT;
98 99
99 // Created the folder |folder_name|. 100 // Create the folder |folder_name|.
100 Error CreateFolder(int handle, 101 virtual Error CreateFolder(int handle,
101 const std::string& folder_name, 102 const std::string& folder_name,
102 const std::string& app_name, 103 const std::string& app_name,
103 bool* success_ptr) WARN_UNUSED_RESULT; 104 bool* success_ptr) WARN_UNUSED_RESULT;
105
106 // Write a password to the current folder.
107 virtual Error WritePassword(int handle,
108 const std::string& folder_name,
109 const std::string& key,
110 const std::string& password,
111 const std::string& app_name,
112 bool* write_success_ptr) WARN_UNUSED_RESULT;
113
114 // Read the password for |key| from |folder_name|.
115 // Clear |password_ptr| if no such password exists.
116 virtual Error ReadPassword(int handle,
117 const std::string& folder_name,
118 const std::string& key,
119 const std::string& app_name,
120 std::string* password_ptr) WARN_UNUSED_RESULT;
121
122 // Close the wallet. The wallet will only be closed if it is open but not in
123 // use (rare), or if it is forced closed.
124 virtual Error Close(int handle,
125 bool force,
126 const std::string& app_name,
127 bool* success_ptr) WARN_UNUSED_RESULT;
104 128
105 private: 129 private:
106 // DBus handle for communication with klauncher and kwalletd. 130 // DBus handle for communication with klauncher and kwalletd.
107 scoped_refptr<dbus::Bus> session_bus_; 131 scoped_refptr<dbus::Bus> session_bus_;
108 // Object proxy for kwalletd. We do not own this. 132 // Object proxy for kwalletd. We do not own this.
109 dbus::ObjectProxy* kwallet_proxy_; 133 dbus::ObjectProxy* kwallet_proxy_;
110 134
111 // KWallet DBus name. 135 // KWallet DBus name.
112 std::string dbus_service_name_; 136 std::string dbus_service_name_;
113 // DBus path to KWallet interfaces. 137 // DBus path to KWallet interfaces.
114 std::string dbus_path_; 138 std::string dbus_path_;
115 // The name used for logging and by klauncher when starting KWallet. 139 // The name used for logging and by klauncher when starting KWallet.
116 std::string kwalletd_name_; 140 std::string kwalletd_name_;
117 141
118 DISALLOW_COPY_AND_ASSIGN(KWalletDBus); 142 DISALLOW_COPY_AND_ASSIGN(KWalletDBus);
119 }; 143 };
120 144
121 #endif // COMPONENTS_OS_CRYPT_KWALLET_DBUS_H_ 145 #endif // COMPONENTS_OS_CRYPT_KWALLET_DBUS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698