3 * Copyright (C) 2005-2008 Team XBMC
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with XBMC; see the file COPYING. If not, write to
18 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
19 * http://www.gnu.org/copyleft/gpl.html
23 #include "StdString.h"
30 \brief Password Manager class for saving authentication details
32 Handles access to previously saved passwords for paths, translating normal URLs
33 into authenticated URLs if the user has details about the username and password
34 for a path previously saved. Should be accessed via CPasswordManager::GetInstance()
36 class CPasswordManager
40 \brief The only way through which the global instance of the CPasswordManager should be accessed.
41 \return the global instance.
43 static CPasswordManager
&GetInstance();
46 \brief Authenticate a URL by looking the URL up in the temporary and permanent caches
47 First looks up based on host and share name. If that fails, it will try a match purely
48 on the host name (eg different shares on the same host with the same credentials)
49 \param url a CURL to authenticate
50 \return true if we have details in the cache, false otherwise.
53 bool AuthenticateURL(CURL
&url
);
56 \brief Prompt for a username and password for the particular URL.
58 This routine pops up a dialog, requesting the user enter a username and password
59 to access the given URL. The user may optionally save these details. If saved
60 we write the details into the users profile. If not saved, the details are temporarily
61 stored so that further access no longer requires prompting for authentication.
63 \param url the URL to authenticate.
64 \return true if the user entered details, false if the user cancelled the dialog.
67 bool PromptToAuthenticateURL(CURL
&url
);
70 \brief Clear any previously cached passwords
75 // private construction, and no assignements; use the provided singleton methods
77 CPasswordManager(const CPasswordManager
&);
78 CPasswordManager
const & operator=(CPasswordManager
const&);
79 ~CPasswordManager() {};
83 CStdString
GetLookupPath(const CURL
&url
) const;
84 CStdString
GetServerLookup(const CStdString
&path
) const;
86 std::map
<CStdString
, CStdString
> m_temporaryCache
;
87 std::map
<CStdString
, CStdString
> m_permanentCache
;