kodi
PasswordManager.h
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "threads/CriticalSection.h"
12 
13 #include <map>
14 #include <stdint.h>
15 #include <string>
16 
17 class CURL;
18 
28 {
29 public:
34  static CPasswordManager &GetInstance();
35 
44  bool AuthenticateURL(CURL &url);
45 
58  bool PromptToAuthenticateURL(CURL &url);
59 
70  void SaveAuthenticatedURL(const CURL &url, bool saveToProfile = true);
71 
81  bool IsURLSupported(const CURL &url);
82 
86  void Clear();
87 
88 private:
89  // private construction, and no assignments; use the provided singleton methods
91  CPasswordManager(const CPasswordManager&) = delete;
92  CPasswordManager& operator=(CPasswordManager const&) = delete;
93  ~CPasswordManager() = default;
94 
95  void Load();
96  void Save() const;
97  std::string GetLookupPath(const CURL &url) const;
98  std::string GetServerLookup(const std::string &path) const;
99 
100  std::map<std::string, std::string> m_temporaryCache;
101  std::map<std::string, std::string> m_permanentCache;
102  bool m_loaded;
103 
104  CCriticalSection m_critSection;
105 };
Password Manager class for saving authentication details.
Definition: PasswordManager.h:27
bool IsURLSupported(const CURL &url)
Is an URL is supported (by the manager)
Definition: PasswordManager.cpp:121
static CPasswordManager & GetInstance()
The only way through which the global instance of the CPasswordManager should be accessed.
Definition: PasswordManager.cpp:25
bool AuthenticateURL(CURL &url)
Authenticate a URL by looking the URL up in the temporary and permanent caches First looks up based o...
Definition: PasswordManager.cpp:36
Definition: URL.h:21
bool PromptToAuthenticateURL(CURL &url)
Prompt for a username and password for the particular URL.
Definition: PasswordManager.cpp:59
void SaveAuthenticatedURL(const CURL &url, bool saveToProfile=true)
Save an authenticated URL.
Definition: PasswordManager.cpp:96
void Clear()
Clear any previously cached passwords.
Definition: PasswordManager.cpp:134