using namespace std;
//////////////////////////////////////////////////////////////////////
-namespace zypp
+namespace zypp
{ ////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
namespace media
{ ////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : AuthDataComparator
+ //
+ //////////////////////////////////////////////////////////////////////
+
+ const url::ViewOption AuthDataComparator::vopt =
+ url::ViewOption::DEFAULTS
+ - url::ViewOption::WITH_USERNAME
+ - url::ViewOption::WITH_PASSWORD
+ - url::ViewOption::WITH_QUERY_STR;
+
+ inline bool
+ AuthDataComparator::operator()(
+ const AuthData_Ptr & lhs, const AuthData_Ptr & rhs)
+ {
+ if (lhs->username() != rhs->username())
+ return true;
+
+ if (lhs->url().asString(vopt) != rhs->url().asString(vopt))
+ return true;
+
+ return false;
+ }
//////////////////////////////////////////////////////////////////////
//
- // CLASS NAME : CredManagerOptions
+ // CLASS NAME : CredManagerOptions
//
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//
- // CLASS NAME : CredentialManager::Impl
+ // CLASS NAME : CredentialManager::Impl
//
struct CredentialManager::Impl
{
~Impl()
{}
-
+
void init_globalCredentials();
void init_userCredentials();
//////////////////////////////////////////////////////////////////////
//
- // CLASS NAME : CredentialManager::Impl
+ // CLASS NAME : CredentialManager::Impl
//
//////////////////////////////////////////////////////////////////////
AuthData_Ptr CredentialManager::Impl::getCredFromFile(const Pathname & file)
{
AuthData_Ptr result;
-
+
Pathname credfile;
if (file.absolute())
// get from that file
//////////////////////////////////////////////////////////////////////
//
- // CLASS NAME : CredentialManager
+ // CLASS NAME : CredentialManager
//
//////////////////////////////////////////////////////////////////////
#include <set>
-#include "zypp/Url.h"
#include "zypp/Pathname.h"
#include "zypp/media/MediaUserAuth.h"
//////////////////////////////////////////////////////////////////////
-namespace zypp
+namespace zypp
{ ////////////////////////////////////////////////////////////////////
+
+ class Url;
+
//////////////////////////////////////////////////////////////////////
namespace media
{ ////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//
- // CLASS NAME : CredManagerOptions
+ // CLASS NAME : CredManagerOptions
//
/**
- * \todo configurable cred file locations
+ * \todo configurable cred file locations
*/
struct CredManagerOptions
{
// comparator for CredentialSet
struct AuthDataComparator
{
- public: bool operator()(const AuthData_Ptr & lhs,
- const AuthData_Ptr & rhs)
- {
- if (lhs->username() < rhs->username())
- return true;
- if (lhs->url() != rhs->url())
- return true;
- return false;
- }
+ static const url::ViewOption vopt;
+ bool operator()(const AuthData_Ptr & lhs, const AuthData_Ptr & rhs);
};
//////////////////////////////////////////////////////////////////////
public:
/**
* Get credentials for the specified \a url.
- *
+ *
* If the URL contains also username, it will be used to find the match
* for this user (in case mutliple are available).
- *
+ *
* \param url URL to find credentials for.
* \return Pointer to retrieved authentication data on success or an empty
* AuthData_Ptr otherwise.
* Add new global credentials.
*/
void addGlobalCred(const AuthData & cred);
-
+
/**
* Add new user credentials.
*/
/**
* Add new credentials with user callbacks.
- *
+ *
* If the cred->url() contains 'credentials' query parameter, the
* credentials will be automatically saved to the specified file using the
* \ref saveInFile() method.
*
* Otherwise a callback will be called asking whether to save to custom
- * file, or to global or user's credentials catalog.
+ * file, or to global or user's credentials catalog.
*
* \todo Currently no callback is called, credentials are automatically
* saved to user's credentials.cat if no 'credentials' parameter
/**
* Saves given \a cred to global credentials file.
- *
+ *
* \note Use this method to add just one piece of credentials. To add
* multiple items at once, use addGlobalCred() followed
* by save()
void saveInGlobal(const AuthData & cred);
/**
- * Saves given \a cred to user's credentials file.
- *
+ * Saves given \a cred to user's credentials file.
+ *
* \note Use this method to add just one piece of credentials. To add
* multiple items at once, use addUserCred() followed
* by save()
/**
* Saves given \a cred to user specified credentials file.
- *
+ *
* If the credFile path is absolute, it will be saved at that precise
* location. If \a credFile is just a filename, it will be saved
* in \ref CredManagerOptions::customCredFileDir. Otherwise the current
/**
* Remove all global or user credentials from memory and disk.
- *
+ *
* \param global Whether to remove global or user credentials.
*/
void clearAll(bool global = false);