summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMili Verma <mili.verma@isode.com>2015-06-25 12:13:14 (GMT)
committerKevin Smith <kevin.smith@isode.com>2015-06-29 17:02:01 (GMT)
commit394642c69bc232429621e209b787d3496967b37b (patch)
tree12fda8350b5694b4e6dc93899debc5a8c46e0adf /Swiften/SASL/WindowsServicePrincipalName.h
parentac45f360be049242a89ae80258e4ea8350f909ba (diff)
downloadswift-394642c69bc232429621e209b787d3496967b37b.zip
swift-394642c69bc232429621e209b787d3496967b37b.tar.bz2
Add WindowsServicePrincipalName class
Test-information: Tested on Windows using WIP GSSAPI code. Unit tests pass. Change-Id: If872863d6a8b5a164f8ebec4f88e9939b4e73c62
Diffstat (limited to 'Swiften/SASL/WindowsServicePrincipalName.h')
-rw-r--r--Swiften/SASL/WindowsServicePrincipalName.h71
1 files changed, 71 insertions, 0 deletions
diff --git a/Swiften/SASL/WindowsServicePrincipalName.h b/Swiften/SASL/WindowsServicePrincipalName.h
new file mode 100644
index 0000000..dc97c93
--- /dev/null
+++ b/Swiften/SASL/WindowsServicePrincipalName.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2015 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <string>
+
+#include <Windows.h>
+
+#include <Swiften/Base/API.h>
+
+namespace Swift {
+ /*
+ * This represents the SPN used on Windows to identify a service
+ * instance.
+ */
+ class SWIFTEN_API WindowsServicePrincipalName {
+ public:
+ /*
+ * This assigns the provided service name,
+ * "xmpp" service class, no instance name or referrer,
+ * and default port. All of these (except the service
+ * name) can be set to other values using the provided
+ * methods.
+ * If the constructor is called with the service name
+ * "hostname.example.com" and the provided methods are
+ * not used to change the defaults, then toString()
+ * will return the SPN "xmpp/hostname.example.com".
+ */
+ WindowsServicePrincipalName(const std::string& serviceName);
+
+ ~WindowsServicePrincipalName();
+
+ void setServiceClass(const std::string& serviceClass);
+
+ void setInstanceName(const std::string& instanceName);
+
+ void setReferrer(const std::string& referrer);
+
+ /*
+ * This sets a non-default port for the service. Note
+ * that the default value is 0 which indicates the
+ * default port for the service. So if the XMPP service
+ * is using the default port of 5222 for client
+ * connections, then do not set the port to 5222 but let
+ * it remain 0 to indicate that the default port is
+ * used.
+ */
+ void setInstancePort(short int instancePort) { instancePort_ = instancePort; }
+
+ /*
+ * This follows the rules of SPN creation on Windows and
+ * returns the SPN string constructed from the set
+ * values.
+ */
+ std::string toString();
+
+ private:
+ DWORD dsMakeSpn(DWORD* length, wchar_t* value);
+
+ private:
+ std::wstring serviceClass_;
+ std::wstring serviceName_;
+ std::wstring instanceName_;
+ USHORT instancePort_;
+ std::wstring referrer_;
+ };
+}