summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMili Verma <mili.verma@isode.com>2015-07-06 14:10:25 (GMT)
committerKevin Smith <kevin.smith@isode.com>2015-07-07 10:49:49 (GMT)
commitf10c9618f8ccd9e44c9a45a69179883b39a445f5 (patch)
treec22b7ddfaa5aaba08edb1ae62650a45dce6af9e7
parent88e392fd98a1d49d787860f4b504a01f082c6ae6 (diff)
downloadswift-f10c9618f8ccd9e44c9a45a69179883b39a445f5.zip
swift-f10c9618f8ccd9e44c9a45a69179883b39a445f5.tar.bz2
Add hidden option to prevent disconnect when smartcard removed
This patch adds an option 'disconnectOnCardRemoval' to system-settings.xml which when set to false allows the user's session to stay connected if the smartcard is removed. The default value of this option is true if it is not specified. Test-information: Tested on Windows using NIST smartcards. Tested true and false values set for this option in the file and also when option is not specified (true). Unit tests pass. Change-Id: I7e421b4153ff7d3000f41999add20d339076c96e
-rw-r--r--Swift/Controllers/SettingConstants.cpp3
-rw-r--r--Swift/Controllers/SettingConstants.h11
-rw-r--r--Swift/QtUI/QtSwift.cpp4
-rw-r--r--Swiften/TLS/OpenSSL/OpenSSLContextFactory.cpp10
-rw-r--r--Swiften/TLS/OpenSSL/OpenSSLContextFactory.h3
-rw-r--r--Swiften/TLS/Schannel/SchannelContext.cpp10
-rw-r--r--Swiften/TLS/Schannel/SchannelContext.h5
-rw-r--r--Swiften/TLS/Schannel/SchannelContextFactory.cpp6
-rw-r--r--Swiften/TLS/Schannel/SchannelContextFactory.h3
-rw-r--r--Swiften/TLS/TLSContextFactory.h1
10 files changed, 47 insertions, 9 deletions
diff --git a/Swift/Controllers/SettingConstants.cpp b/Swift/Controllers/SettingConstants.cpp
index 33ed17d..d740686 100644
--- a/Swift/Controllers/SettingConstants.cpp
+++ b/Swift/Controllers/SettingConstants.cpp
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2012 Isode Limited. 2 * Copyright (c) 2012-2015 Isode Limited.
3 * All rights reserved. 3 * All rights reserved.
4 * See the COPYING file for more information. 4 * See the COPYING file for more information.
5 */ 5 */
@@ -27,4 +27,5 @@ const SettingsProvider::Setting<std::string> SettingConstants::DICT_FILE("dictFi
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);
30} 31}
diff --git a/Swift/Controllers/SettingConstants.h b/Swift/Controllers/SettingConstants.h
index b441303..eca3199 100644
--- a/Swift/Controllers/SettingConstants.h
+++ b/Swift/Controllers/SettingConstants.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2012 Isode Limited. 2 * Copyright (c) 2012-2015 Isode Limited.
3 * All rights reserved. 3 * All rights reserved.
4 * See the COPYING file for more information. 4 * See the COPYING file for more information.
5 */ 5 */
@@ -86,5 +86,14 @@ namespace Swift {
86 * Its value is a Qt serialized representation. 86 * Its value is a Qt serialized representation.
87 */ 87 */
88 static const SettingsProvider::Setting<std::string> TRELLIS_GRID_POSITIONS; 88 static const SettingsProvider::Setting<std::string> TRELLIS_GRID_POSITIONS;
89 /**
90 * The #DISCONNECT_ON_CARD_REMOVAL setting
91 * specifies whether or not to sign out the user when
92 * the smartcard is removed.
93 *
94 * If set true Swift will sign out the user when the
95 * smart card is removed; else not.
96 */
97 static const SettingsProvider::Setting<bool> DISCONNECT_ON_CARD_REMOVAL;
89 }; 98 };
90} 99}
diff --git a/Swift/QtUI/QtSwift.cpp b/Swift/QtUI/QtSwift.cpp
index 20d7bc9..6d8ac7b 100644
--- a/Swift/QtUI/QtSwift.cpp
+++ b/Swift/QtUI/QtSwift.cpp
@@ -23,6 +23,7 @@
23#include <Swiften/Elements/Presence.h> 23#include <Swiften/Elements/Presence.h>
24#include <Swiften/Client/Client.h> 24#include <Swiften/Client/Client.h>
25#include <Swiften/Base/Paths.h> 25#include <Swiften/Base/Paths.h>
26#include <Swiften/TLS/TLSContextFactory.h>
26 27
27#include <SwifTools/Application/PlatformApplicationPathProvider.h> 28#include <SwifTools/Application/PlatformApplicationPathProvider.h>
28#include <SwifTools/AutoUpdater/AutoUpdater.h> 29#include <SwifTools/AutoUpdater/AutoUpdater.h>
@@ -32,6 +33,7 @@
32#include <Swift/Controllers/Storages/FileStoragesFactory.h> 33#include <Swift/Controllers/Storages/FileStoragesFactory.h>
33#include <Swift/Controllers/Settings/XMLSettingsProvider.h> 34#include <Swift/Controllers/Settings/XMLSettingsProvider.h>
34#include <Swift/Controllers/Settings/SettingsProviderHierachy.h> 35#include <Swift/Controllers/Settings/SettingsProviderHierachy.h>
36#include <Swift/Controllers/SettingConstants.h>
35#include <Swift/Controllers/MainController.h> 37#include <Swift/Controllers/MainController.h>
36#include <Swift/Controllers/ApplicationInfo.h> 38#include <Swift/Controllers/ApplicationInfo.h>
37#include <Swift/Controllers/BuildVersion.h> 39#include <Swift/Controllers/BuildVersion.h>
@@ -144,6 +146,8 @@ QtSwift::QtSwift(const po::variables_map& options) : networkFactories_(&clientMa
144 settingsHierachy_->addProviderToTopOfStack(xmlSettings_); 146 settingsHierachy_->addProviderToTopOfStack(xmlSettings_);
145 settingsHierachy_->addProviderToTopOfStack(qtSettings_); 147 settingsHierachy_->addProviderToTopOfStack(qtSettings_);
146 148
149 networkFactories_.getTLSContextFactory()->setDisconnectOnCardRemoval(settingsHierachy_->getSetting(SettingConstants::DISCONNECT_ON_CARD_REMOVAL));
150
147 std::map<std::string, std::string> emoticons; 151 std::map<std::string, std::string> emoticons;
148 loadEmoticonsFile(":/emoticons/emoticons.txt", emoticons); 152 loadEmoticonsFile(":/emoticons/emoticons.txt", emoticons);
149 loadEmoticonsFile(P2QSTRING(pathToString(Paths::getExecutablePath() / "emoticons.txt")), emoticons); 153 loadEmoticonsFile(P2QSTRING(pathToString(Paths::getExecutablePath() / "emoticons.txt")), emoticons);
diff --git a/Swiften/TLS/OpenSSL/OpenSSLContextFactory.cpp b/Swiften/TLS/OpenSSL/OpenSSLContextFactory.cpp
index 50f6731..4981170 100644
--- a/Swiften/TLS/OpenSSL/OpenSSLContextFactory.cpp
+++ b/Swiften/TLS/OpenSSL/OpenSSLContextFactory.cpp
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2010 Isode Limited. 2 * Copyright (c) 2010-2015 Isode Limited.
3 * All rights reserved. 3 * All rights reserved.
4 * See the COPYING file for more information. 4 * See the COPYING file for more information.
5 */ 5 */
@@ -20,8 +20,14 @@ TLSContext* OpenSSLContextFactory::createTLSContext(const TLSOptions&) {
20 20
21void OpenSSLContextFactory::setCheckCertificateRevocation(bool check) { 21void OpenSSLContextFactory::setCheckCertificateRevocation(bool check) {
22 if (check) { 22 if (check) {
23 assert(false);
24 SWIFT_LOG(warning) << "CRL Checking not supported for OpenSSL" << std::endl; 23 SWIFT_LOG(warning) << "CRL Checking not supported for OpenSSL" << std::endl;
24 assert(false);
25 }
26}
27
28void OpenSSLContextFactory::setDisconnectOnCardRemoval(bool check) {
29 if (check) {
30 SWIFT_LOG(warning) << "Smart cards not supported for OpenSSL" << std::endl;
25 } 31 }
26} 32}
27 33
diff --git a/Swiften/TLS/OpenSSL/OpenSSLContextFactory.h b/Swiften/TLS/OpenSSL/OpenSSLContextFactory.h
index bf7f08a..89033ad 100644
--- a/Swiften/TLS/OpenSSL/OpenSSLContextFactory.h
+++ b/Swiften/TLS/OpenSSL/OpenSSLContextFactory.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2010 Isode Limited. 2 * Copyright (c) 2010-2015 Isode Limited.
3 * All rights reserved. 3 * All rights reserved.
4 * See the COPYING file for more information. 4 * See the COPYING file for more information.
5 */ 5 */
@@ -18,5 +18,6 @@ namespace Swift {
18 18
19 // Not supported 19 // Not supported
20 virtual void setCheckCertificateRevocation(bool b); 20 virtual void setCheckCertificateRevocation(bool b);
21 virtual void setDisconnectOnCardRemoval(bool b);
21 }; 22 };
22} 23}
diff --git a/Swiften/TLS/Schannel/SchannelContext.cpp b/Swiften/TLS/Schannel/SchannelContext.cpp
index 5f230ec..70ff7dd 100644
--- a/Swiften/TLS/Schannel/SchannelContext.cpp
+++ b/Swiften/TLS/Schannel/SchannelContext.cpp
@@ -21,7 +21,7 @@ namespace Swift {
21 21
22//------------------------------------------------------------------------ 22//------------------------------------------------------------------------
23 23
24SchannelContext::SchannelContext(bool tls1_0Workaround) : state_(Start), secContext_(0), myCertStore_(NULL), certStoreName_("MY"), certName_(), smartCardReader_(), checkCertificateRevocation_(true), tls1_0Workaround_(tls1_0Workaround) { 24SchannelContext::SchannelContext(bool tls1_0Workaround) : state_(Start), secContext_(0), myCertStore_(NULL), certStoreName_("MY"), certName_(), smartCardReader_(), checkCertificateRevocation_(true), tls1_0Workaround_(tls1_0Workaround), disconnectOnCardRemoval_(true) {
25 contextFlags_ = ISC_REQ_ALLOCATE_MEMORY | 25 contextFlags_ = ISC_REQ_ALLOCATE_MEMORY |
26 ISC_REQ_CONFIDENTIALITY | 26 ISC_REQ_CONFIDENTIALITY |
27 ISC_REQ_EXTENDED_ERROR | 27 ISC_REQ_EXTENDED_ERROR |
@@ -625,7 +625,9 @@ bool SchannelContext::setClientCertificate(CertificateWithKey::ref certificate)
625 625
626//------------------------------------------------------------------------ 626//------------------------------------------------------------------------
627void SchannelContext::handleCertificateCardRemoved() { 627void SchannelContext::handleCertificateCardRemoved() {
628 indicateError(boost::make_shared<TLSError>(TLSError::CertificateCardRemoved)); 628 if (disconnectOnCardRemoval_) {
629 indicateError(boost::make_shared<TLSError>(TLSError::CertificateCardRemoved));
630 }
629} 631}
630 632
631//------------------------------------------------------------------------ 633//------------------------------------------------------------------------
@@ -680,5 +682,9 @@ void SchannelContext::setCheckCertificateRevocation(bool b) {
680 checkCertificateRevocation_ = b; 682 checkCertificateRevocation_ = b;
681} 683}
682 684
685void SchannelContext::setDisconnectOnCardRemoval(bool b) {
686 disconnectOnCardRemoval_ = b;
687}
688
683 689
684} 690}
diff --git a/Swiften/TLS/Schannel/SchannelContext.h b/Swiften/TLS/Schannel/SchannelContext.h
index 19cc473..36a3f0c 100644
--- a/Swiften/TLS/Schannel/SchannelContext.h
+++ b/Swiften/TLS/Schannel/SchannelContext.h
@@ -5,7 +5,7 @@
5 */ 5 */
6 6
7/* 7/*
8 * Copyright (c) 2012 Isode Limited. 8 * Copyright (c) 2012-2015 Isode Limited.
9 * All rights reserved. 9 * All rights reserved.
10 * See the COPYING file for more information. 10 * See the COPYING file for more information.
11 */ 11 */
@@ -57,6 +57,8 @@ namespace Swift
57 57
58 virtual void setCheckCertificateRevocation(bool b); 58 virtual void setCheckCertificateRevocation(bool b);
59 59
60 virtual void setDisconnectOnCardRemoval(bool b);
61
60 private: 62 private:
61 void determineStreamSizes(); 63 void determineStreamSizes();
62 void continueHandshake(const SafeByteArray& data); 64 void continueHandshake(const SafeByteArray& data);
@@ -105,5 +107,6 @@ namespace Swift
105 boost::shared_ptr<CAPICertificate> userCertificate_; 107 boost::shared_ptr<CAPICertificate> userCertificate_;
106 bool checkCertificateRevocation_; 108 bool checkCertificateRevocation_;
107 bool tls1_0Workaround_; 109 bool tls1_0Workaround_;
110 bool disconnectOnCardRemoval_;
108 }; 111 };
109} 112}
diff --git a/Swiften/TLS/Schannel/SchannelContextFactory.cpp b/Swiften/TLS/Schannel/SchannelContextFactory.cpp
index 6e83b0d..c2587c5 100644
--- a/Swiften/TLS/Schannel/SchannelContextFactory.cpp
+++ b/Swiften/TLS/Schannel/SchannelContextFactory.cpp
@@ -15,7 +15,7 @@
15 15
16namespace Swift { 16namespace Swift {
17 17
18SchannelContextFactory::SchannelContextFactory() : checkCertificateRevocation(true) { 18SchannelContextFactory::SchannelContextFactory() : checkCertificateRevocation(true), disconnectOnCardRemoval(true) {
19} 19}
20 20
21bool SchannelContextFactory::canCreate() const { 21bool SchannelContextFactory::canCreate() const {
@@ -25,6 +25,7 @@ bool SchannelContextFactory::canCreate() const {
25TLSContext* SchannelContextFactory::createTLSContext(const TLSOptions& tlsOptions) { 25TLSContext* SchannelContextFactory::createTLSContext(const TLSOptions& tlsOptions) {
26 SchannelContext* context = new SchannelContext(tlsOptions.schannelTLS1_0Workaround); 26 SchannelContext* context = new SchannelContext(tlsOptions.schannelTLS1_0Workaround);
27 context->setCheckCertificateRevocation(checkCertificateRevocation); 27 context->setCheckCertificateRevocation(checkCertificateRevocation);
28 context->setDisconnectOnCardRemoval(disconnectOnCardRemoval);
28 return context; 29 return context;
29} 30}
30 31
@@ -32,5 +33,8 @@ void SchannelContextFactory::setCheckCertificateRevocation(bool b) {
32 checkCertificateRevocation = b; 33 checkCertificateRevocation = b;
33} 34}
34 35
36void SchannelContextFactory::setDisconnectOnCardRemoval(bool b) {
37 disconnectOnCardRemoval = b;
38}
35 39
36} 40}
diff --git a/Swiften/TLS/Schannel/SchannelContextFactory.h b/Swiften/TLS/Schannel/SchannelContextFactory.h
index 789d15f..27b7dc9 100644
--- a/Swiften/TLS/Schannel/SchannelContextFactory.h
+++ b/Swiften/TLS/Schannel/SchannelContextFactory.h
@@ -24,7 +24,10 @@ namespace Swift {
24 24
25 virtual void setCheckCertificateRevocation(bool b); 25 virtual void setCheckCertificateRevocation(bool b);
26 26
27 virtual void setDisconnectOnCardRemoval(bool b);
28
27 public: 29 public:
28 bool checkCertificateRevocation; 30 bool checkCertificateRevocation;
31 bool disconnectOnCardRemoval;
29 }; 32 };
30} 33}
diff --git a/Swiften/TLS/TLSContextFactory.h b/Swiften/TLS/TLSContextFactory.h
index 90da4a1..b67c34f 100644
--- a/Swiften/TLS/TLSContextFactory.h
+++ b/Swiften/TLS/TLSContextFactory.h
@@ -20,5 +20,6 @@ namespace Swift {
20 20
21 virtual TLSContext* createTLSContext(const TLSOptions& tlsOptions) = 0; 21 virtual TLSContext* createTLSContext(const TLSOptions& tlsOptions) = 0;
22 virtual void setCheckCertificateRevocation(bool b) = 0; 22 virtual void setCheckCertificateRevocation(bool b) = 0;
23 virtual void setDisconnectOnCardRemoval(bool b) = 0;
23 }; 24 };
24} 25}