summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
Diffstat (limited to 'Swift')
-rw-r--r--Swift/Controllers/MainController.cpp33
-rw-r--r--Swift/Controllers/SettingConstants.cpp1
-rw-r--r--Swift/Controllers/SettingConstants.h9
3 files changed, 42 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
@@ -38,10 +38,14 @@
38#include <Swiften/Client/ClientXMLTracer.h> 38#include <Swiften/Client/ClientXMLTracer.h>
39#include <Swiften/Client/StanzaChannel.h> 39#include <Swiften/Client/StanzaChannel.h>
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>
46 50
47#include <Swift/Controllers/Intl.h> 51#include <Swift/Controllers/Intl.h>
@@ -179,10 +183,15 @@ MainController::MainController(
179 ProfileSettingsProvider profileSettings(profile, settings); 183 ProfileSettingsProvider profileSettings(profile, settings);
180 std::string password = profileSettings.getStringSetting("pass"); 184 std::string password = profileSettings.getStringSetting("pass");
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;
187 cachedCertificate = certificate; 196 cachedCertificate = certificate;
188 cachedOptions = clientOptions; 197 cachedOptions = clientOptions;
@@ -509,14 +518,36 @@ void MainController::handleShowCertificateRequest() {
509 rosterController_->getWindow()->openCertificateDialog(chain); 518 rosterController_->getWindow()->openCertificateDialog(chain);
510} 519}
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_);
521 if (!settings_->getSetting(SettingConstants::FORGET_PASSWORDS)) { 552 if (!settings_->getSetting(SettingConstants::FORGET_PASSWORDS)) {
522 profileSettings_->storeString("jid", username); 553 profileSettings_->storeString("jid", username);
diff --git a/Swift/Controllers/SettingConstants.cpp b/Swift/Controllers/SettingConstants.cpp
index d740686..9807abc 100644
--- a/Swift/Controllers/SettingConstants.cpp
+++ b/Swift/Controllers/SettingConstants.cpp
@@ -26,6 +26,7 @@ const SettingsProvider::Setting<std::string> SettingConstants::PERSONAL_DICT_PAT
26const SettingsProvider::Setting<std::string> SettingConstants::DICT_FILE("dictFile", "en_US.dic"); 26const SettingsProvider::Setting<std::string> SettingConstants::DICT_FILE("dictFile", "en_US.dic");
27const SettingsProvider::Setting<std::string> SettingConstants::INVITE_AUTO_ACCEPT_MODE("inviteAutoAcceptMode", "presence"); 27const SettingsProvider::Setting<std::string> SettingConstants::INVITE_AUTO_ACCEPT_MODE("inviteAutoAcceptMode", "presence");
28const SettingsProvider::Setting<std::string> SettingConstants::TRELLIS_GRID_SIZE("trellisGridSize", ""); 28const SettingsProvider::Setting<std::string> SettingConstants::TRELLIS_GRID_SIZE("trellisGridSize", "");
29const SettingsProvider::Setting<std::string> SettingConstants::TRELLIS_GRID_POSITIONS("trellisGridPositions", ""); 29const SettingsProvider::Setting<std::string> SettingConstants::TRELLIS_GRID_POSITIONS("trellisGridPositions", "");
30const SettingsProvider::Setting<bool> SettingConstants::DISCONNECT_ON_CARD_REMOVAL("disconnectOnCardRemoval", true); 30const SettingsProvider::Setting<bool> SettingConstants::DISCONNECT_ON_CARD_REMOVAL("disconnectOnCardRemoval", true);
31const SettingsProvider::Setting<bool> SettingConstants::SINGLE_SIGN_ON("singleSignOn", false);
31} 32}
diff --git a/Swift/Controllers/SettingConstants.h b/Swift/Controllers/SettingConstants.h
index eca3199..c4ac4ad 100644
--- a/Swift/Controllers/SettingConstants.h
+++ b/Swift/Controllers/SettingConstants.h
@@ -93,7 +93,16 @@ namespace Swift {
93 * 93 *
94 * If set true Swift will sign out the user when the 94 * If set true Swift will sign out the user when the
95 * smart card is removed; else not. 95 * smart card is removed; else not.
96 */ 96 */
97 static const SettingsProvider::Setting<bool> DISCONNECT_ON_CARD_REMOVAL; 97 static const SettingsProvider::Setting<bool> DISCONNECT_ON_CARD_REMOVAL;
98 /**
99 * The #SINGLE_SIGN_ON setting
100 * specifies whether to log in using Single Sign On.
101 * This is currently supported on Windows.
102 *
103 * If set true Swift will use GSSAPI authentication to
104 * log in the user; else not.
105 */
106 static const SettingsProvider::Setting<bool> SINGLE_SIGN_ON;
98 }; 107 };
99} 108}