summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMili Verma <mili.verma@isode.com>2015-07-09 08:40:05 (GMT)
committerMili Verma <mili.verma@isode.com>2015-07-09 09:15:02 (GMT)
commit23481aa1306b7d77b18be3b1c8764cccdc80e32d (patch)
treee799049949f78d51f317f8e9771e7a2e986c1ebb /Swift/Controllers/MainController.cpp
parent58bb58557368c520e8a9368fcacff8d22466e759 (diff)
downloadswift-23481aa1306b7d77b18be3b1c8764cccdc80e32d.zip
swift-23481aa1306b7d77b18be3b1c8764cccdc80e32d.tar.bz2
Enable SSO
Add a hidden option to enable single sign on. When that is enabled, ensure that the user only enters the domain name and that the JID is constructed from the Windows log-on credentials. Test-information: Tested on Windows. Unit tests pass. Change-Id: Ia5592a3893f0807a3801b515c8fcddb580c9ef8d
Diffstat (limited to 'Swift/Controllers/MainController.cpp')
-rw-r--r--Swift/Controllers/MainController.cpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp
index 95094f2..a65a18a 100644
--- a/Swift/Controllers/MainController.cpp
+++ b/Swift/Controllers/MainController.cpp
@@ -40,6 +40,10 @@
40#include <Swiften/Client/ClientBlockListManager.h> 40#include <Swiften/Client/ClientBlockListManager.h>
41#include <Swiften/Crypto/CryptoProvider.h> 41#include <Swiften/Crypto/CryptoProvider.h>
42 42
43#ifdef SWIFTEN_PLATFORM_WIN32
44#include <Swiften/SASL/WindowsAuthentication.h>
45#endif
46
43#include <SwifTools/Dock/Dock.h> 47#include <SwifTools/Dock/Dock.h>
44#include <SwifTools/Notifier/TogglableNotifier.h> 48#include <SwifTools/Notifier/TogglableNotifier.h>
45#include <SwifTools/Idle/IdleDetector.h> 49#include <SwifTools/Idle/IdleDetector.h>
@@ -181,6 +185,11 @@ MainController::MainController(
181 std::string certificate = profileSettings.getStringSetting("certificate"); 185 std::string certificate = profileSettings.getStringSetting("certificate");
182 std::string jid = profileSettings.getStringSetting("jid"); 186 std::string jid = profileSettings.getStringSetting("jid");
183 ClientOptions clientOptions = parseClientOptions(profileSettings.getStringSetting("options")); 187 ClientOptions clientOptions = parseClientOptions(profileSettings.getStringSetting("options"));
188
189#ifdef SWIFTEN_PLATFORM_WIN32
190 clientOptions.singleSignOn = settings_->getSetting(SettingConstants::SINGLE_SIGN_ON);
191#endif
192
184 loginWindow_->addAvailableAccount(jid, password, certificate, clientOptions); 193 loginWindow_->addAvailableAccount(jid, password, certificate, clientOptions);
185 if (jid == selectedLoginJID) { 194 if (jid == selectedLoginJID) {
186 cachedPassword = password; 195 cachedPassword = password;
@@ -511,10 +520,32 @@ void MainController::handleShowCertificateRequest() {
511 520
512void MainController::handleLoginRequest(const std::string &username, const std::string &password, const std::string& certificatePath, CertificateWithKey::ref certificate, const ClientOptions& options, bool remember, bool loginAutomatically) { 521void MainController::handleLoginRequest(const std::string &username, const std::string &password, const std::string& certificatePath, CertificateWithKey::ref certificate, const ClientOptions& options, bool remember, bool loginAutomatically) {
513 jid_ = JID(username); 522 jid_ = JID(username);
514 if (!jid_.isValid() || jid_.getNode().empty()) { 523 if (options.singleSignOn && (!jid_.isValid() || !jid_.getNode().empty())) {
524 loginWindow_->setMessage(QT_TRANSLATE_NOOP("", "User address invalid. User address should be of the form 'wonderland.lit'"));
525 loginWindow_->setIsLoggingIn(false);
526 } else if (!options.singleSignOn && (!jid_.isValid() || jid_.getNode().empty())) {
515 loginWindow_->setMessage(QT_TRANSLATE_NOOP("", "User address invalid. User address should be of the form 'alice@wonderland.lit'")); 527 loginWindow_->setMessage(QT_TRANSLATE_NOOP("", "User address invalid. User address should be of the form 'alice@wonderland.lit'"));
516 loginWindow_->setIsLoggingIn(false); 528 loginWindow_->setIsLoggingIn(false);
517 } else { 529 } else {
530#ifdef SWIFTEN_PLATFORM_WIN32
531 if (options.singleSignOn) {
532 std::string userName;
533 std::string clientName;
534 std::string serverName;
535 boost::shared_ptr<boost::system::error_code> errorCode = getUserNameEx(userName, clientName, serverName);
536
537 if (!errorCode) {
538 /* Create JID using the Windows logon name and user provided domain name */
539 jid_ = JID(clientName, username);
540 }
541 else {
542 loginWindow_->setMessage(str(format(QT_TRANSLATE_NOOP("", "Error obtaining Windows user name (%1%)")) % errorCode->message()));
543 loginWindow_->setIsLoggingIn(false);
544 return;
545 }
546 }
547#endif
548
518 loginWindow_->setMessage(""); 549 loginWindow_->setMessage("");
519 loginWindow_->setIsLoggingIn(true); 550 loginWindow_->setIsLoggingIn(true);
520 profileSettings_ = new ProfileSettingsProvider(username, settings_); 551 profileSettings_ = new ProfileSettingsProvider(username, settings_);