summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/SASL/WindowsServicePrincipalName.cpp')
-rw-r--r--Swiften/SASL/WindowsServicePrincipalName.cpp104
1 files changed, 52 insertions, 52 deletions
diff --git a/Swiften/SASL/WindowsServicePrincipalName.cpp b/Swiften/SASL/WindowsServicePrincipalName.cpp
index 187e9ac..419395c 100644
--- a/Swiften/SASL/WindowsServicePrincipalName.cpp
+++ b/Swiften/SASL/WindowsServicePrincipalName.cpp
@@ -17,90 +17,90 @@
namespace Swift {
WindowsServicePrincipalName::WindowsServicePrincipalName(const std::string& serviceName) : serviceClass_(L"xmpp"), instancePort_(0) {
- serviceName_ = convertStringToWString(serviceName);
+ serviceName_ = convertStringToWString(serviceName);
}
WindowsServicePrincipalName::~WindowsServicePrincipalName() {
}
void WindowsServicePrincipalName::setServiceClass(const std::string& serviceClass) {
- serviceClass_ = convertStringToWString(serviceClass);
+ serviceClass_ = convertStringToWString(serviceClass);
}
void WindowsServicePrincipalName::setInstanceName(const std::string& instanceName) {
- instanceName_ = convertStringToWString(instanceName);
+ instanceName_ = convertStringToWString(instanceName);
}
void WindowsServicePrincipalName::setReferrer(const std::string& referrer) {
- referrer_ = convertStringToWString(referrer);
+ referrer_ = convertStringToWString(referrer);
}
std::string WindowsServicePrincipalName::toString() {
- DWORD length = 512;
- DWORD status = ERROR_BUFFER_OVERFLOW;
- bool firstCall = true;
- std::string str;
+ DWORD length = 512;
+ DWORD status = ERROR_BUFFER_OVERFLOW;
+ bool firstCall = true;
+ std::string str;
- while (status == ERROR_BUFFER_OVERFLOW) {
- std::vector<wchar_t> value(length);
+ while (status == ERROR_BUFFER_OVERFLOW) {
+ std::vector<wchar_t> value(length);
- /* length after this call will contain the required length if current length is not enough - so the next call should succeed */
- status = dsMakeSpn(&length, vecptr(value));
- if (status == ERROR_SUCCESS) {
- str = convertWStringToString(std::wstring(vecptr(value), length-1 /* trailing 0 character */));
- break;
- }
+ /* length after this call will contain the required length if current length is not enough - so the next call should succeed */
+ status = dsMakeSpn(&length, vecptr(value));
+ if (status == ERROR_SUCCESS) {
+ str = convertWStringToString(std::wstring(vecptr(value), length-1 /* trailing 0 character */));
+ break;
+ }
- if ((firstCall == false) || (status != ERROR_BUFFER_OVERFLOW)) {
- std::stringstream errorString;
- boost::system::error_code errorCode(status, boost::system::system_category());
+ if ((firstCall == false) || (status != ERROR_BUFFER_OVERFLOW)) {
+ std::stringstream errorString;
+ boost::system::error_code errorCode(status, boost::system::system_category());
- errorString << "Error creating Service Principal Name: status: 0x" << std::hex << status << ": " << errorCode.message();
+ errorString << "Error creating Service Principal Name: status: 0x" << std::hex << status << ": " << errorCode.message();
- /* Any other error will be a programming error */
- throw std::runtime_error(errorString.str());
- }
+ /* Any other error will be a programming error */
+ throw std::runtime_error(errorString.str());
+ }
- firstCall = false;
- }
+ firstCall = false;
+ }
- SWIFT_LOG(debug) << "SPN: " << str << std::endl;
- return str;
+ SWIFT_LOG(debug) << "SPN: " << str << std::endl;
+ return str;
}
DWORD WindowsServicePrincipalName::dsMakeSpn(DWORD* length, wchar_t* value) {
- DWORD status;
+ DWORD status;
#ifdef UNICODE
- SWIFT_LOG(debug) << "UNICODE is defined" << std::endl;
+ SWIFT_LOG(debug) << "UNICODE is defined" << std::endl;
#else
- SWIFT_LOG(debug) << "UNICODE is not defined" << std::endl;
+ SWIFT_LOG(debug) << "UNICODE is not defined" << std::endl;
#endif
- SWIFT_LOG(debug) << "serviceClass_: " << convertWStringToString(serviceClass_.c_str()) << std::endl;
- SWIFT_LOG(debug) << "serviceName_: " << convertWStringToString(serviceName_.c_str()) << std::endl;
- SWIFT_LOG(debug) << "instanceName_: " << convertWStringToString(instanceName_.c_str()) << std::endl;
- SWIFT_LOG(debug) << "referrer_: " << convertWStringToString(referrer_.c_str()) << std::endl;
- SWIFT_LOG(debug) << "instancePort_: " << instancePort_ << std::endl;
- SWIFT_LOG(debug) << "length: " << *length << std::endl;
+ SWIFT_LOG(debug) << "serviceClass_: " << convertWStringToString(serviceClass_.c_str()) << std::endl;
+ SWIFT_LOG(debug) << "serviceName_: " << convertWStringToString(serviceName_.c_str()) << std::endl;
+ SWIFT_LOG(debug) << "instanceName_: " << convertWStringToString(instanceName_.c_str()) << std::endl;
+ SWIFT_LOG(debug) << "referrer_: " << convertWStringToString(referrer_.c_str()) << std::endl;
+ SWIFT_LOG(debug) << "instancePort_: " << instancePort_ << std::endl;
+ SWIFT_LOG(debug) << "length: " << *length << std::endl;
- /* Call the Unicode function because that is recommended:
+ /* Call the Unicode function because that is recommended:
https://msdn.microsoft.com/en-us/library/windows/desktop/ff381407%28v=vs.85%29.aspx */
- status = DsMakeSpnW(
- serviceClass_.c_str(),
- serviceName_.c_str(),
- instanceName_.empty() ? NULL : instanceName_.c_str(),
- instancePort_,
- referrer_.empty() ? NULL : referrer_.c_str(),
- length,
- value);
- if (status != ERROR_SUCCESS) {
- boost::system::error_code errorCode(status, boost::system::system_category());
-
- SWIFT_LOG(debug) << std::hex << "status: 0x" << status << ": " << errorCode.message() << std::endl;
- }
-
- return status;
+ status = DsMakeSpnW(
+ serviceClass_.c_str(),
+ serviceName_.c_str(),
+ instanceName_.empty() ? NULL : instanceName_.c_str(),
+ instancePort_,
+ referrer_.empty() ? NULL : referrer_.c_str(),
+ length,
+ value);
+ if (status != ERROR_SUCCESS) {
+ boost::system::error_code errorCode(status, boost::system::system_category());
+
+ SWIFT_LOG(debug) << std::hex << "status: 0x" << status << ": " << errorCode.message() << std::endl;
+ }
+
+ return status;
}
}