- save credentials after asking for them
authorJan Kupec <jkupec@suse.cz>
Fri, 26 Sep 2008 13:25:03 +0000 (13:25 +0000)
committerJan Kupec <jkupec@suse.cz>
Fri, 26 Sep 2008 13:25:03 +0000 (13:25 +0000)
- todo: ask user _where_ to store them. Automatically saving to user's
  credentials.cat for now

zypp/media/CredentialManager.cc
zypp/media/MediaCurl.cc

index 38c5489..2f2ff0e 100644 (file)
@@ -286,8 +286,12 @@ namespace zypp
 
   void CredentialManager::addCred(const AuthData & cred)
   {
-#warning addCred(const AuthData & cred) not implemented
-    // add with user callbacks
+    Pathname credfile = cred.url().getQueryParam("credentials");
+    if (credfile.empty())
+      //! \todo ask user where to store these creds. saving to user creds for now
+      addUserCred(cred);
+    else
+      saveInFile(cred, credfile);
   }
 
 
@@ -338,6 +342,7 @@ namespace zypp
   {
     AuthData_Ptr c_ptr;
     c_ptr.reset(new AuthData(cred)); // FIX for child classes if needed
+    c_ptr->setUrl(Url()); // don't save url in custom creds file
     CredentialManager::CredentialSet creds;
     creds.insert(c_ptr);
 
index 3bd4436..d0ca341 100644 (file)
@@ -1653,6 +1653,13 @@ bool MediaCurl::authenticate(const string & availAuthTypes, bool firstTry) const
       if ( ret != 0 ) ZYPP_THROW(MediaCurlSetOptException(_url, _curlError));
     }
 
+    if (!cmcred)
+    {
+      credentials->setUrl(_url);
+      cm.addCred(*credentials);
+      cm.save();
+    }
+
     return true;
   }