commit 95b716e003d173fd90946d6a0f6e7ea116a42632
Author: Ján Kupec
Date: Tue Jan 27 12:43:23 2009 +0100
Ignore URL's username, password, and query string in AuthData comparator.
---
zypp/media/CredentialManager.cc | 38 +++++++++++++++++++++++++++++------
zypp/media/CredentialManager.h | 41 +++++++++++++++++---------------------
2 files changed, 49 insertions(+), 30 deletions(-)
diff --git a/zypp/media/CredentialManager.cc b/zypp/media/CredentialManager.cc
index 339094f..5e8ea09 100644
--- a/zypp/media/CredentialManager.cc
+++ b/zypp/media/CredentialManager.cc
@@ -27,16 +27,40 @@
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
//
//////////////////////////////////////////////////////////////////////
@@ -52,7 +76,7 @@ namespace zypp
//////////////////////////////////////////////////////////////////////
//
- // CLASS NAME : CredentialManager::Impl
+ // CLASS NAME : CredentialManager::Impl
//
struct CredentialManager::Impl
{
@@ -60,7 +84,7 @@ namespace zypp
~Impl()
{}
-
+
void init_globalCredentials();
void init_userCredentials();
@@ -86,7 +110,7 @@ namespace zypp
//////////////////////////////////////////////////////////////////////
//
- // CLASS NAME : CredentialManager::Impl
+ // CLASS NAME : CredentialManager::Impl
//
//////////////////////////////////////////////////////////////////////
@@ -204,7 +228,7 @@ namespace zypp
AuthData_Ptr CredentialManager::Impl::getCredFromFile(const Pathname & file)
{
AuthData_Ptr result;
-
+
Pathname credfile;
if (file.absolute())
// get from that file
@@ -262,7 +286,7 @@ namespace zypp
//////////////////////////////////////////////////////////////////////
//
- // CLASS NAME : CredentialManager
+ // CLASS NAME : CredentialManager
//
//////////////////////////////////////////////////////////////////////
diff --git a/zypp/media/CredentialManager.h b/zypp/media/CredentialManager.h
index 969f3ad..5ebcf76 100644
--- a/zypp/media/CredentialManager.h
+++ b/zypp/media/CredentialManager.h
@@ -14,13 +14,15 @@
#include <set>
-#include "zypp/Url.h"
#include "zypp/Pathname.h"
#include "zypp/media/MediaUserAuth.h"
//////////////////////////////////////////////////////////////////////
-namespace zypp
+namespace zypp
{ ////////////////////////////////////////////////////////////////////
+
+ class Url;
+
//////////////////////////////////////////////////////////////////////
namespace media
{ ////////////////////////////////////////////////////////////////////
@@ -28,10 +30,10 @@ namespace zypp
//////////////////////////////////////////////////////////////////////
//
- // CLASS NAME : CredManagerOptions
+ // CLASS NAME : CredManagerOptions
//
/**
- * \todo configurable cred file locations
+ * \todo configurable cred file locations
*/
struct CredManagerOptions
{
@@ -46,15 +48,8 @@ namespace zypp
// 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);
};
//////////////////////////////////////////////////////////////////////
@@ -81,10 +76,10 @@ namespace zypp
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.
@@ -101,7 +96,7 @@ namespace zypp
* Add new global credentials.
*/
void addGlobalCred(const AuthData & cred);
-
+
/**
* Add new user credentials.
*/
@@ -109,13 +104,13 @@ namespace zypp
/**
* 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
@@ -131,7 +126,7 @@ namespace zypp
/**
* 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()
@@ -139,8 +134,8 @@ namespace zypp
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()
@@ -149,7 +144,7 @@ namespace zypp
/**
* 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
@@ -159,7 +154,7 @@ namespace zypp
/**
* Remove all global or user credentials from memory and disk.
- *
+ *
* \param global Whether to remove global or user credentials.
*/
void clearAll(bool global = false);
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org