summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Mollekopf <mollekopf@kolabsys.com>2012-10-25 22:54:34 (GMT)
committerChristian Mollekopf <mollekopf@kolabsys.com>2012-10-25 22:54:34 (GMT)
commit2d8f933c59c238b65a52b6df2bcb7d039a597503 (patch)
tree214498151dd6748389c5cd7f366a5a52c44257d3
parent9a8c66ec3b1fbd873815403a8e038140af7ee736 (diff)
downloadkolab-utils-2d8f933c59c238b65a52b6df2bcb7d039a597503.tar.gz
Allow to set encryption and authentication modes
-rw-r--r--migrationutility/main.cpp52
-rw-r--r--migrationutility/sourceserver.cpp10
-rw-r--r--migrationutility/sourceserver.h2
3 files changed, 64 insertions, 0 deletions
diff --git a/migrationutility/main.cpp b/migrationutility/main.cpp
index 0d27376..a8bf55f 100644
--- a/migrationutility/main.cpp
+++ b/migrationutility/main.cpp
@@ -25,6 +25,46 @@
#include "sourceserver.h"
#include "kolabserver.h"
+KIMAP::LoginJob::EncryptionMode getEncryptionMode(const QString &encrypt)
+{
+ KIMAP::LoginJob::EncryptionMode encryptionMode = KIMAP::LoginJob::TlsV1;
+ if (encrypt == "NONE") {
+ encryptionMode = KIMAP::LoginJob::Unencrypted;
+ } else if (encrypt == "SSL") {
+ encryptionMode = KIMAP::LoginJob::AnySslVersion;
+ } else if (encrypt == "TLS") {
+ encryptionMode = KIMAP::LoginJob::TlsV1;
+ } else {
+ Error() << "unknown encryption mode";
+ }
+ return encryptionMode;
+}
+
+KIMAP::LoginJob::AuthenticationMode getAuthenticationMode(const QString &auth)
+{
+ KIMAP::LoginJob::AuthenticationMode authenticationMode = KIMAP::LoginJob::Plain;
+ if (auth == "PLAIN") {
+ authenticationMode = KIMAP::LoginJob::Plain;
+ } else if (auth == "LOGIN") {
+ authenticationMode = KIMAP::LoginJob::Login;
+ } else if (auth == "CRAMMD5") {
+ authenticationMode = KIMAP::LoginJob::CramMD5;
+ } else if (auth == "DIGESTMD5") {
+ authenticationMode = KIMAP::LoginJob::DigestMD5;
+ } else if (auth == "NTLM") {
+ authenticationMode = KIMAP::LoginJob::NTLM;
+ } else if (auth == "GSSAPI") {
+ authenticationMode = KIMAP::LoginJob::GSSAPI;
+ } else if (auth == "ANONYMOUS") {
+ authenticationMode = KIMAP::LoginJob::Anonymous;
+ } else if (auth == "CLEARTEXT") {
+ authenticationMode = KIMAP::LoginJob::ClearText;
+ } else {
+ Error() << "unknown authentication mode";
+ }
+ return authenticationMode;
+}
+
/**
* kolab-migrate --from caldav --to kolab (implied?) --caldav-host caldav.example.org --caldav-authn <admin> --caldav-authz <user> --caldav-pass <pass> --<folder-selection> --<folder-mapping> --kolab-host kolab.example.org --kolab-authn <admin> --kolab-authz <user> --kolab-pass <pass>
@@ -46,18 +86,24 @@ int main(int argc, char *argv[])
options.add("from-kolab2-user <loginname>", ki18n("Username for single-user migration"));
options.add("from-kolab2-proxyauth <loginname>", ki18n("Username to be used for authentication together with password (optional, works with PLAIN/SASL authentication)"));
options.add("from-kolab2-password <password>", ki18n("Password"));
+ options.add("from-kolab2-encrypt <mode>", ki18n("Encryption mode to be used (NONE, TLS, SSL)"), "TLS");
+ options.add("from-kolab2-auth <mode>", ki18n("Authentication mode to be used (PLAIN, LOGIN, CRAMMD5, DIGESTMD5, NTLM, GSSAPI, ANONYMOUS, CLEARTEXT)"), "PLAIN");
options.add("from-kolab3-host <host>", ki18n("Source Kolab3 host"));
options.add("from-kolab3-port <port>", ki18n("Port"), "143");
options.add("from-kolab3-user <loginname>", ki18n("Username for single-user migration"));
options.add("from-kolab3-proxyauth <loginname>", ki18n("Username to be used for authentication together with password (optional, works with PLAIN/SASL authentication)"));
options.add("from-kolab3-password <password>", ki18n("Password"));
+ options.add("from-kolab3-encrypt <mode>", ki18n("Encryption mode to be used (NONE, TLS, SSL)"), "TLS");
+ options.add("from-kolab3-auth <mode>", ki18n("Authentication mode to be used (PLAIN, LOGIN, CRAMMD5, DIGESTMD5, NTLM, GSSAPI, ANONYMOUS, CLEARTEXT)"), "PLAIN");
options.add("from-exchangeimap-host <host>", ki18n("Source Exchange IMAP host"));
options.add("from-exchangeimap-port <port>", ki18n("Port"), "143");
options.add("from-exchangeimap-user <loginname>", ki18n("Username for single-user migration"));
options.add("from-exchangeimap-proxyauth <loginname>", ki18n("Username to be used for authentication together with password (optional, works with PLAIN/SASL authentication)"));
options.add("from-exchangeimap-password <password>", ki18n("Password"));
+ options.add("from-exchangeimap-encrypt <mode>", ki18n("Encryption mode to be used (NONE, TLS, SSL)"), "TLS");
+ options.add("from-exchangeimap-auth <mode>", ki18n("Authentication mode to be used (PLAIN, LOGIN, CRAMMD5, DIGESTMD5, NTLM, GSSAPI, ANONYMOUS, CLEARTEXT)"), "PLAIN");
options.add("to <type>", ki18n("Target host type"));
options.add("to-kolab3-host <host>", ki18n("Target Kolab3 host"));
@@ -80,6 +126,8 @@ int main(int argc, char *argv[])
KolabSourceServer *kolabSourceServer = new KolabSourceServer(&app);
kolabSourceServer->setHost(args->getOption("from-kolab2-host"), args->getOption("from-kolab2-port").toInt());
kolabSourceServer->setAdminCredentials(args->getOption("from-kolab2-proxyauth"), args->getOption("from-kolab2-password"));
+ kolabSourceServer->setEncryption(getEncryptionMode(args->getOption("from-kolab2-encrypt")));
+ kolabSourceServer->setAuthentication(getAuthenticationMode(args->getOption("from-kolab2-auth")));
if (args->isSet("from-kolab2-user")) {
kolabSourceServer->setSingleUser(args->getOption("from-kolab2-user"));
}
@@ -89,6 +137,8 @@ int main(int argc, char *argv[])
KolabSourceServer *kolabSourceServer = new KolabSourceServer(&app);
kolabSourceServer->setHost(args->getOption("from-kolab3-host"), args->getOption("from-kolab3-port").toInt());
kolabSourceServer->setAdminCredentials(args->getOption("from-kolab3-proxyauth"), args->getOption("from-kolab3-password"));
+ kolabSourceServer->setEncryption(getEncryptionMode(args->getOption("from-kolab3-encrypt")));
+ kolabSourceServer->setAuthentication(getAuthenticationMode(args->getOption("from-kolab3-auth")));
if (args->isSet("from-kolab3-user")) {
kolabSourceServer->setSingleUser(args->getOption("from-kolab3-user"));
}
@@ -98,6 +148,8 @@ int main(int argc, char *argv[])
ExchangeIMAPSourceServer *source = new ExchangeIMAPSourceServer(&app);
source->setHost(args->getOption("from-exchangeimap-host"), args->getOption("from-exchangeimap-port").toInt());
source->setAdminCredentials(args->getOption("from-exchangeimap-proxyauth"), args->getOption("from-exchangeimap-password"));
+ source->setEncryption(getEncryptionMode(args->getOption("from-exchangeimap-encrypt")));
+ source->setAuthentication(getAuthenticationMode(args->getOption("from-exchangeimap-auth")));
if (args->isSet("from-exchangeimap-user")) {
source->setSingleUser(args->getOption("from-exchangeimap-user"));
}
diff --git a/migrationutility/sourceserver.cpp b/migrationutility/sourceserver.cpp
index b3383fd..3630c2e 100644
--- a/migrationutility/sourceserver.cpp
+++ b/migrationutility/sourceserver.cpp
@@ -99,6 +99,16 @@ void KolabSourceServer::setAdminCredentials(const QString& username, const QStri
mPw = pw;
}
+void KolabSourceServer::setEncryption(KIMAP::LoginJob::EncryptionMode enc)
+{
+ mEncryptionMode = enc;
+}
+
+void KolabSourceServer::setAuthentication(KIMAP::LoginJob::AuthenticationMode auth)
+{
+ mAuthenticationMode = auth;
+}
+
SourceAccount* KolabSourceServer::getSourceAccount(const QString& user)
{
KIMAP::Session *session = new KIMAP::Session( mHost, mPort, this );
diff --git a/migrationutility/sourceserver.h b/migrationutility/sourceserver.h
index ae88d91..45e0d32 100644
--- a/migrationutility/sourceserver.h
+++ b/migrationutility/sourceserver.h
@@ -61,6 +61,8 @@ public:
void setHost(const QString &host, qint16 port);
void setAdminCredentials(const QString &username, const QString &pw);
+ void setEncryption(KIMAP::LoginJob::EncryptionMode);
+ void setAuthentication(KIMAP::LoginJob::AuthenticationMode);
protected:
void logout();
KIMAP::Session *mSession;