Mailinglist Archive: zypp-commit (325 mails)

< Previous Next >
[zypp-commit] r7093 - /trunk/zypper/src/zypper-media-callbacks.h
  • From: jkupec@xxxxxxxxxxxxxxxx
  • Date: Mon, 03 Sep 2007 15:08:47 -0000
  • Message-id: <20070903150847.2595925072@xxxxxxxxxxxxxxxx>
Author: jkupec
Date: Mon Sep  3 17:08:46 2007
New Revision: 7093

URL: http://svn.opensuse.org/viewcvs/zypp?rev=7093&view=rev
Log:
- authentication prompt implemented (190609)

Modified:
    trunk/zypper/src/zypper-media-callbacks.h

Modified: trunk/zypper/src/zypper-media-callbacks.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-media-callbacks.h?rev=7093&r1=7092&r2=7093&view=diff
==============================================================================
--- trunk/zypper/src/zypper-media-callbacks.h (original)
+++ trunk/zypper/src/zypper-media-callbacks.h Mon Sep  3 17:08:46 2007
@@ -22,6 +22,7 @@
 #include <zypp/Repository.h>
 #include <zypp/Digest.h>
 #include <zypp/Url.h>
+#include <zypp/media/MediaUserAuth.h>
 
 #include "zypper.h"
 #include "zypper-callbacks.h"
@@ -106,6 +107,50 @@
     }
   };
 
+  struct AuthenticationReportReceiver : public zypp::callback::ReceiveReport<zypp::media::AuthenticationReport>
+  {
+    virtual bool prompt(const zypp::Url & url,
+                        const std::string & description,
+                        zypp::media::AuthData & auth_data)
+    {
+      if (gSettings.non_interactive)
+      {
+        MIL << "Non-interactive mode: aborting" << std::endl;
+        cout_vv << description << std::endl;
+        cout_vv << "Non-interactive mode: aborting" << std::endl;
+        return false;
+      }
+
+      cout << description << std::endl;
+
+      // curl authentication
+      zypp::media::CurlAuthData * auth_data_ptr =
+        dynamic_cast<zypp::media::CurlAuthData*> (&auth_data);
+      if (auth_data_ptr)
+      {
+        cout_vv << "available auth types: "
+          << auth_data_ptr->authTypeAsString() << std::endl;
+
+        cout << "User Name: ";
+        string username;
+        std::cin >> username;
+        auth_data_ptr->setUserName(username);
+
+        cout << "Password: ";
+        string password;
+        std::cin >> password;
+        if (password.empty()) return false;
+        auth_data_ptr->setPassword(password);
+
+        auth_data_ptr->setAuthType("basic,digest");
+
+        return true;
+      }
+
+      return false;
+    }
+  };
+
     ///////////////////////////////////////////////////////////////////
 }; // namespace ZmartRecipients
 ///////////////////////////////////////////////////////////////////
@@ -115,18 +160,21 @@
   private:
     ZmartRecipients::MediaChangeReportReceiver _mediaChangeReport;
     ZmartRecipients::DownloadProgressReportReceiver _mediaDownloadReport;
+    ZmartRecipients::AuthenticationReportReceiver _mediaAuthenticationReport;
   public:
     MediaCallbacks()
     {
       MIL << "Set media callbacks.." << endl;
       _mediaChangeReport.connect();
       _mediaDownloadReport.connect();
+      _mediaAuthenticationReport.connect();
     }
 
     ~MediaCallbacks()
     {
       _mediaChangeReport.disconnect();
       _mediaDownloadReport.disconnect();
+      _mediaAuthenticationReport.disconnect();
     }
 };
 

--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages