From 5be21f6b003e22bbcb2b26074add66fdb86fec13 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Mon, 19 Aug 2013 21:01:18 +0000 Subject: QPID-5083: provide simple default where sasl functionality is not available git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1515602 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/CMakeLists.txt | 4 +++ qpid/cpp/src/qpid/NullSaslClient.cpp | 53 ++++++++++++++++++++++++++++++++++++ qpid/cpp/src/qpid/NullSaslClient.h | 41 ++++++++++++++++++++++++++++ qpid/cpp/src/qpid/SaslFactory.cpp | 4 ++- 4 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 qpid/cpp/src/qpid/NullSaslClient.cpp create mode 100644 qpid/cpp/src/qpid/NullSaslClient.h (limited to 'qpid/cpp/src') diff --git a/qpid/cpp/src/CMakeLists.txt b/qpid/cpp/src/CMakeLists.txt index 3c77c4e33f..21f562d0a0 100644 --- a/qpid/cpp/src/CMakeLists.txt +++ b/qpid/cpp/src/CMakeLists.txt @@ -578,6 +578,9 @@ if (BUILD_SASL) qpid/sys/cyrus/CyrusSecurityLayer.cpp ) set(qpidcommon_sasl_lib sasl2) +else (BUILD_SASL) + set(HAVE_SASL OFF) + set(BROKER_SASL_NAME "qpidd" CACHE STRING "SASL app name for the qpid broker") endif (BUILD_SASL) # Optional SSL/TLS support. Requires Netscape Portable Runtime on Linux. @@ -979,6 +982,7 @@ set (qpidcommon_SOURCES qpid/StringUtils.cpp qpid/Url.cpp qpid/UrlArray.cpp + qpid/NullSaslClient.cpp qpid/NullSaslServer.cpp qpid/amqp_0_10/SessionHandler.cpp qpid/framing/AccumulatedAck.cpp diff --git a/qpid/cpp/src/qpid/NullSaslClient.cpp b/qpid/cpp/src/qpid/NullSaslClient.cpp new file mode 100644 index 0000000000..828ccbb886 --- /dev/null +++ b/qpid/cpp/src/qpid/NullSaslClient.cpp @@ -0,0 +1,53 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#include "NullSaslClient.h" +#include "Exception.h" + +namespace qpid { +namespace { +const std::string ANONYMOUS("ANONYMOUS"); +} + +bool NullSaslClient::start(const std::string& mechanisms, std::string&, + const qpid::sys::SecuritySettings*) +{ + if (mechanisms.find(ANONYMOUS) == std::string::npos) { + throw qpid::Exception("No suitable mechanism!"); + } + return false; +} +std::string NullSaslClient::step(const std::string&) +{ + return std::string(); +} +std::string NullSaslClient::getMechanism() +{ + return ANONYMOUS; +} +std::string NullSaslClient::getUserId() +{ + return ANONYMOUS; +} +std::auto_ptr NullSaslClient::getSecurityLayer(uint16_t) +{ + return std::auto_ptr(); +} +} // namespace qpid diff --git a/qpid/cpp/src/qpid/NullSaslClient.h b/qpid/cpp/src/qpid/NullSaslClient.h new file mode 100644 index 0000000000..b0a63a8ecb --- /dev/null +++ b/qpid/cpp/src/qpid/NullSaslClient.h @@ -0,0 +1,41 @@ +#ifndef QPID_NULLSASLCLIENT_H +#define QPID_NULLSASLCLIENT_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#include "Sasl.h" + +namespace qpid { + +class NullSaslClient : public Sasl +{ + public: + bool start(const std::string& mechanisms, std::string& response, + const qpid::sys::SecuritySettings* externalSecuritySettings = 0); + std::string step(const std::string& challenge); + std::string getMechanism(); + std::string getUserId(); + std::auto_ptr getSecurityLayer(uint16_t maxFrameSize); + private: +}; +} // namespace qpid + +#endif /*!QPID_NULLSASLCLIENT_H*/ diff --git a/qpid/cpp/src/qpid/SaslFactory.cpp b/qpid/cpp/src/qpid/SaslFactory.cpp index 97e1d6e18a..bd771fc920 100644 --- a/qpid/cpp/src/qpid/SaslFactory.cpp +++ b/qpid/cpp/src/qpid/SaslFactory.cpp @@ -20,6 +20,7 @@ */ #include "qpid/SaslFactory.h" #include "qpid/SaslServer.h" +#include "qpid/NullSaslClient.h" #include "qpid/NullSaslServer.h" #include #include @@ -48,7 +49,8 @@ SaslFactory& SaslFactory::getInstance() std::auto_ptr SaslFactory::create( const std::string &, const std::string &, const std::string &, const std::string &, int, int, bool ) { - return std::auto_ptr(); + std::auto_ptr client(new NullSaslClient); + return client; } std::auto_ptr SaslFactory::createServer(const std::string& realm, bool /*encryptionRequired*/, const qpid::sys::SecuritySettings&) -- cgit v1.2.1