diff options
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/slice/Ice/SecurityException.ice | 14 | ||||
-rw-r--r-- | cpp/src/Ice/Collector.cpp | 2 | ||||
-rw-r--r-- | cpp/src/Ice/SecurityException2.cpp | 60 | ||||
-rw-r--r-- | cpp/src/Ice/SslAcceptor.cpp | 2 | ||||
-rw-r--r-- | cpp/src/Ice/SslConfig.cpp | 34 | ||||
-rw-r--r-- | cpp/src/Ice/SslConnectionOpenSSL.cpp | 22 | ||||
-rw-r--r-- | cpp/src/Ice/SslConnectionOpenSSLClient.cpp | 42 | ||||
-rw-r--r-- | cpp/src/Ice/SslConnectionOpenSSLServer.cpp | 60 | ||||
-rw-r--r-- | cpp/src/Ice/SslConnector.cpp | 2 | ||||
-rw-r--r-- | cpp/src/Ice/SslException.cpp | 342 | ||||
-rw-r--r-- | cpp/src/Ice/SslException.h | 142 | ||||
-rw-r--r-- | cpp/src/Ice/SslSystemOpenSSL.cpp | 50 | ||||
-rw-r--r-- | cpp/src/Ice/ice.dsp | 43 |
13 files changed, 232 insertions, 583 deletions
diff --git a/cpp/slice/Ice/SecurityException.ice b/cpp/slice/Ice/SecurityException.ice index 8947335c766..8f56769d4d3 100644 --- a/cpp/slice/Ice/SecurityException.ice +++ b/cpp/slice/Ice/SecurityException.ice @@ -25,7 +25,7 @@ module IceSecurity * for external clients/servers.
*
**/ -local exception SecurityException extemds LocalException +local exception SecurityException {
/**
*
@@ -50,7 +50,7 @@ module Ssl * <literal>communicator</literal>.
*
**/
-local exception ConfigParseException extemds SecurityException
+local exception ConfigParseException extends SecurityException
{
};
@@ -60,7 +60,7 @@ local exception ConfigParseException extemds SecurityException * problem that has led to the shutdown of an SSL connection.
*
**/
-local exception ShutdownException extemds SecurityException
+local exception ShutdownException extends SecurityException
{
};
@@ -70,7 +70,7 @@ local exception ShutdownException extemds SecurityException * protocol, causing the shutdown of the connection.
*
**/
-local exception ProtocolException extemds ShutdownException
+local exception ProtocolException extends ShutdownException
{
};
@@ -80,7 +80,7 @@ local exception ProtocolException extemds ShutdownException * a client certificate during SSL protocol handshake.
*
**/
-local exception CertificateException extemds ShutdownException
+local exception CertificateException extends ShutdownException
{
};
@@ -94,7 +94,7 @@ module OpenSSL * key files or allocating a <literal>SSL_CTX</literal> structure.
*
**/
-local exception ContextException extemds SecurityException
+local exception ContextException extends SecurityException
{
};
@@ -102,4 +102,6 @@ local exception ContextException extemds SecurityException };
+};
+
#endif diff --git a/cpp/src/Ice/Collector.cpp b/cpp/src/Ice/Collector.cpp index c3bdc46a8fd..2f8a4cc56ef 100644 --- a/cpp/src/Ice/Collector.cpp +++ b/cpp/src/Ice/Collector.cpp @@ -22,7 +22,7 @@ #include <Ice/Exception.h> #include <Ice/Protocol.h> #include <Ice/Functional.h> -#include <Ice/SslException.h> +#include <Ice/SecurityException.h> using namespace std; using namespace Ice; diff --git a/cpp/src/Ice/SecurityException2.cpp b/cpp/src/Ice/SecurityException2.cpp new file mode 100644 index 00000000000..90e5d2825bb --- /dev/null +++ b/cpp/src/Ice/SecurityException2.cpp @@ -0,0 +1,60 @@ +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+#ifdef WIN32
+#pragma warning(disable:4786)
+#endif
+
+#include <Ice/SecurityException.h>
+
+using Ice::SocketException;
+using Ice::Exception;
+using std::ostream;
+
+
+void
+IceSecurity::SecurityException::ice_print(ostream& out) const
+{
+ Exception::ice_print(out);
+ if (!_message.empty())
+ {
+ out << ":\n" << _message;
+ }
+}
+
+void
+IceSecurity::Ssl::ConfigParseException::ice_print(ostream& out) const
+{
+ SecurityException::ice_print(out);
+}
+
+void
+IceSecurity::Ssl::ShutdownException::ice_print(ostream& out) const
+{
+ SecurityException::ice_print(out);
+}
+
+void
+IceSecurity::Ssl::ProtocolException::ice_print(ostream& out) const
+{
+ SecurityException::ice_print(out);
+}
+
+void
+IceSecurity::Ssl::CertificateException::ice_print(ostream& out) const
+{
+ SecurityException::ice_print(out);
+}
+
+void
+IceSecurity::Ssl::OpenSSL::ContextException::ice_print(ostream& out) const
+{
+ SecurityException::ice_print(out);
+}
+
diff --git a/cpp/src/Ice/SslAcceptor.cpp b/cpp/src/Ice/SslAcceptor.cpp index 194fa5188a5..27e538bf833 100644 --- a/cpp/src/Ice/SslAcceptor.cpp +++ b/cpp/src/Ice/SslAcceptor.cpp @@ -21,7 +21,7 @@ #include <Ice/Logger.h> #include <Ice/Network.h> #include <Ice/Exception.h> -#include <Ice/SslException.h>
+#include <Ice/SecurityException.h>
#include <sstream>
using namespace std; diff --git a/cpp/src/Ice/SslConfig.cpp b/cpp/src/Ice/SslConfig.cpp index ddba7ef5250..6333726cf33 100644 --- a/cpp/src/Ice/SslConfig.cpp +++ b/cpp/src/Ice/SslConfig.cpp @@ -20,7 +20,7 @@ #include <util/Janitor.hpp>
#include <Ice/Security.h>
-#include <Ice/SslException.h>
+#include <Ice/SecurityException.h>
#include <Ice/SslConfigErrorReporter.h>
#include <Ice/SslConfig.h>
@@ -60,11 +60,15 @@ IceSecurity::Ssl::Parser::process() }
catch(const XMLException& toCatch)
{
- ostringstream s;
+ ConfigParseException configEx(__FILE__, __LINE__);
+
+ ostringstream s;
s << "While parsing " << _configFile << flush;
s << "Xerces-c Init Exception: " << DOMString(toCatch.getMessage());
- throw ConfigParseException(s.str().c_str(), __FILE__, __LINE__);
+ configEx._message = s.str();
+
+ throw configEx;
}
int errorCount = 0;
@@ -128,11 +132,15 @@ IceSecurity::Ssl::Parser::process() delete errReporter;
}
+ ConfigParseException configEx(__FILE__, __LINE__);
+
ostringstream s;
s << "While parsing " << _configFile << flush;
s << "Xerces-c Parsing Error: " << DOMString(e.getMessage());
- throw ConfigParseException(s.str().c_str(), __FILE__, __LINE__);
+ configEx._message = s.str();
+
+ throw configEx;
}
catch (const DOM_DOMException& e)
{
@@ -141,12 +149,16 @@ IceSecurity::Ssl::Parser::process() delete errReporter;
}
+ ConfigParseException configEx(__FILE__, __LINE__);
+
ostringstream s;
s << "While parsing " << _configFile << flush;
s << "Xerces-c DOM Parsing Error, DOMException code: " << e.code;
s << ", message: " << e.msg;
- throw ConfigParseException(s.str().c_str(), __FILE__, __LINE__);
+ configEx._message = s.str();
+
+ throw configEx;
}
catch (...)
{
@@ -155,9 +167,11 @@ IceSecurity::Ssl::Parser::process() delete errReporter;
}
- string s = "While parsing " + _configFile + "\n" + "An unknown error occured during parsing.";
+ ConfigParseException configEx(__FILE__, __LINE__);
- throw ConfigParseException(s.c_str(), __FILE__, __LINE__);
+ configEx._message = "While parsing " + _configFile + "\n" + "An unknown error occured during parsing.";
+
+ throw configEx;
}
if (errReporter != 0)
@@ -167,9 +181,11 @@ IceSecurity::Ssl::Parser::process() if (errorCount)
{
- string s = errorCount + "errors occured during parsing.";
+ ConfigParseException configEx(__FILE__, __LINE__);
+
+ configEx._message = errorCount + "errors occured during parsing.";
- throw ConfigParseException(s.c_str(), __FILE__, __LINE__);
+ throw configEx;
}
}
diff --git a/cpp/src/Ice/SslConnectionOpenSSL.cpp b/cpp/src/Ice/SslConnectionOpenSSL.cpp index 7a13f3a18de..3b3fba3554f 100644 --- a/cpp/src/Ice/SslConnectionOpenSSL.cpp +++ b/cpp/src/Ice/SslConnectionOpenSSL.cpp @@ -17,7 +17,7 @@ #include <Ice/Network.h>
#include <JTC/JTC.h>
#include <Ice/Security.h>
-#include <Ice/SslException.h>
+#include <Ice/SecurityException.h>
#include <Ice/SslConnection.h>
#include <Ice/SslSystemOpenSSL.h>
@@ -513,24 +513,28 @@ IceSecurity::Ssl::OpenSSL::Connection::readSSL(Buffer& buf, int timeout) }
else // (bytesRead == 0)
{
+ ProtocolException protocolEx(__FILE__, __LINE__);
+
// Protocol Error: Unexpected EOF
- string errorString = "Encountered an EOF that violates the SSL Protocol.\n";
+ protocolEx._message = "Encountered an EOF that violates the SSL Protocol.";
- ICE_SSLERRORS(errorString);
- ICE_EXCEPTION(errorString);
+ ICE_SSLERRORS(protocolEx._message);
+ ICE_EXCEPTION(protocolEx._message);
- throw ProtocolException(errorString.c_str(), __FILE__, __LINE__);
+ throw protocolEx;
}
}
case SSL_ERROR_SSL:
{
- string errorString = "Encountered a violation of the SSL Protocol.\n";
+ ProtocolException protocolEx(__FILE__, __LINE__);
+
+ protocolEx._message = "Encountered a violation of the SSL Protocol.";
- ICE_SSLERRORS(errorString);
- ICE_EXCEPTION(errorString);
+ ICE_SSLERRORS(protocolEx._message);
+ ICE_EXCEPTION(protocolEx._message);
- throw ProtocolException(errorString.c_str(), __FILE__, __LINE__);
+ throw protocolEx;
}
case SSL_ERROR_ZERO_RETURN:
diff --git a/cpp/src/Ice/SslConnectionOpenSSLClient.cpp b/cpp/src/Ice/SslConnectionOpenSSLClient.cpp index d4a7cf4e0dc..02b29b61012 100644 --- a/cpp/src/Ice/SslConnectionOpenSSLClient.cpp +++ b/cpp/src/Ice/SslConnectionOpenSSLClient.cpp @@ -12,7 +12,7 @@ #include <sstream>
#include <Ice/Network.h>
#include <Ice/Security.h>
-#include <Ice/SslException.h>
+#include <Ice/SecurityException.h>
#include <Ice/SslConnectionOpenSSLClient.h>
using IceSecurity::Ssl::ShutdownException;
@@ -172,24 +172,28 @@ IceSecurity::Ssl::OpenSSL::ClientConnection::init(int timeout) }
else // result == 0
{
+ ProtocolException protocolEx(__FILE__, __LINE__);
+
// Protocol Error: Unexpected EOF
- string errorString = "Encountered an EOF during handshake that violates the SSL Protocol.\n";
+ protocolEx._message = "Encountered an EOF during handshake that violates the SSL Protocol.\n";
- ICE_SSLERRORS(errorString);
- ICE_EXCEPTION(errorString);
+ ICE_SSLERRORS(protocolEx._message);
+ ICE_EXCEPTION(protocolEx._message);
- throw ProtocolException(errorString.c_str(), __FILE__, __LINE__);
+ throw protocolEx;
}
}
case SSL_ERROR_SSL:
{
- string errorString = "Encountered a violation of the SSL Protocol during handshake.\n";
+ ProtocolException protocolEx(__FILE__, __LINE__);
+
+ protocolEx._message = "Encountered a violation of the SSL Protocol during handshake.\n";
- ICE_SSLERRORS(errorString);
- ICE_EXCEPTION(errorString);
+ ICE_SSLERRORS(protocolEx._message);
+ ICE_EXCEPTION(protocolEx._message);
- throw ProtocolException(errorString.c_str(), __FILE__, __LINE__);
+ throw protocolEx;
}
}
@@ -382,13 +386,15 @@ IceSecurity::Ssl::OpenSSL::ClientConnection::write(Buffer& buf, int timeout) }
else if (bytesWritten > 0)
{
+ ProtocolException protocolEx(__FILE__, __LINE__);
+
// Protocol Error: Unexpected EOF
- string errorString = "Encountered an EOF that violates the SSL Protocol.\n";
+ protocolEx._message = "Encountered an EOF that violates the SSL Protocol.\n";
- ICE_SSLERRORS(errorString);
- ICE_EXCEPTION(errorString);
+ ICE_SSLERRORS(protocolEx._message);
+ ICE_EXCEPTION(protocolEx._message);
- throw ProtocolException(errorString.c_str(), __FILE__, __LINE__);
+ throw protocolEx;
}
else // bytesWritten == 0
{
@@ -402,12 +408,14 @@ IceSecurity::Ssl::OpenSSL::ClientConnection::write(Buffer& buf, int timeout) case SSL_ERROR_SSL:
{
- string errorString = "Encountered a violation of the SSL Protocol.\n";
+ ProtocolException protocolEx(__FILE__, __LINE__);
+
+ protocolEx._message = "Encountered a violation of the SSL Protocol.\n";
- ICE_SSLERRORS(errorString);
- ICE_EXCEPTION(errorString);
+ ICE_SSLERRORS(protocolEx._message);
+ ICE_EXCEPTION(protocolEx._message);
- throw ProtocolException(errorString.c_str(), __FILE__, __LINE__);
+ throw protocolEx;
}
case SSL_ERROR_ZERO_RETURN:
diff --git a/cpp/src/Ice/SslConnectionOpenSSLServer.cpp b/cpp/src/Ice/SslConnectionOpenSSLServer.cpp index 5df3ad1facd..772f2587d00 100644 --- a/cpp/src/Ice/SslConnectionOpenSSLServer.cpp +++ b/cpp/src/Ice/SslConnectionOpenSSLServer.cpp @@ -12,7 +12,7 @@ #include <sstream>
#include <Ice/Network.h>
#include <Ice/Security.h>
-#include <Ice/SslException.h>
+#include <Ice/SecurityException.h>
#include <Ice/SslConnectionOpenSSLServer.h>
using IceSecurity::Ssl::CertificateException;
@@ -125,20 +125,24 @@ IceSecurity::Ssl::OpenSSL::ServerConnection::init(int timeout) if (verify_error != X509_V_OK)
{
- string errorString = "SSL certificate verification error.";
+ CertificateException certEx(__FILE__, __LINE__);
- ICE_EXCEPTION(errorString);
+ certEx._message = "SSL certificate verification error.";
- throw CertificateException(errorString.c_str(), __FILE__, __LINE__);
+ ICE_EXCEPTION(certEx._message);
+
+ throw certEx;
}
else
{
- string errorString = "Encountered an SSL Protocol violation during handshake.";
+ ProtocolException protocolEx(__FILE__, __LINE__);
+
+ protocolEx._message = "Encountered an SSL Protocol violation during handshake.";
- ICE_SSLERRORS(errorString);
- ICE_EXCEPTION(errorString);
+ ICE_SSLERRORS(protocolEx._message);
+ ICE_EXCEPTION(protocolEx._message);
- throw ProtocolException(errorString.c_str(), __FILE__, __LINE__);
+ throw protocolEx;
}
}
@@ -198,24 +202,28 @@ IceSecurity::Ssl::OpenSSL::ServerConnection::init(int timeout) }
else
{
+ ProtocolException protocolEx(__FILE__, __LINE__);
+
// Protocol Error: Unexpected EOF
- string errorString = "Encountered an EOF during handshake that violates the SSL Protocol.\n";
+ protocolEx._message = "Encountered an EOF during handshake that violates the SSL Protocol.";
- ICE_SSLERRORS(errorString);
- ICE_EXCEPTION(errorString);
+ ICE_SSLERRORS(protocolEx._message);
+ ICE_EXCEPTION(protocolEx._message);
- throw ProtocolException(errorString.c_str(), __FILE__, __LINE__);
+ throw protocolEx;
}
}
case SSL_ERROR_SSL:
{
- string errorString = "Encountered a violation of the SSL Protocol during handshake.\n";
+ ProtocolException protocolEx(__FILE__, __LINE__);
- ICE_SSLERRORS(errorString);
- ICE_EXCEPTION(errorString);
+ protocolEx._message = "Encountered a violation of the SSL Protocol during handshake.";
- throw ProtocolException(errorString.c_str(), __FILE__, __LINE__);
+ ICE_SSLERRORS(protocolEx._message);
+ ICE_EXCEPTION(protocolEx._message);
+
+ throw protocolEx;
}
}
@@ -376,24 +384,28 @@ IceSecurity::Ssl::OpenSSL::ServerConnection::write(Buffer& buf, int timeout) }
else
{
+ ProtocolException protocolEx(__FILE__, __LINE__);
+
// Protocol Error: Unexpected EOF
- string errorString = "Encountered an EOF that violates the SSL Protocol.\n";
+ protocolEx._message = "Encountered an EOF that violates the SSL Protocol.";
- ICE_SSLERRORS(errorString);
- ICE_EXCEPTION(errorString);
+ ICE_SSLERRORS(protocolEx._message);
+ ICE_EXCEPTION(protocolEx._message);
- throw ProtocolException(errorString.c_str(), __FILE__, __LINE__);
+ throw protocolEx;
}
}
case SSL_ERROR_SSL:
{
- string errorString = "Encountered a violation of the SSL Protocol.\n";
+ ProtocolException protocolEx(__FILE__, __LINE__);
+
+ protocolEx._message = "Encountered a violation of the SSL Protocol.";
- ICE_SSLERRORS(errorString);
- ICE_EXCEPTION(errorString);
+ ICE_SSLERRORS(protocolEx._message);
+ ICE_EXCEPTION(protocolEx._message);
- throw ProtocolException(errorString.c_str(), __FILE__, __LINE__);
+ throw protocolEx;
}
case SSL_ERROR_ZERO_RETURN:
diff --git a/cpp/src/Ice/SslConnector.cpp b/cpp/src/Ice/SslConnector.cpp index 470aa69abc1..07ead39fc11 100644 --- a/cpp/src/Ice/SslConnector.cpp +++ b/cpp/src/Ice/SslConnector.cpp @@ -21,7 +21,7 @@ #include <Ice/Network.h> #include <Ice/Properties.h>
#include <Ice/Exception.h> -#include <Ice/SslException.h>
+#include <Ice/SecurityException.h>
#include <sstream>
using namespace std; diff --git a/cpp/src/Ice/SslException.cpp b/cpp/src/Ice/SslException.cpp deleted file mode 100644 index 7203f6ebc14..00000000000 --- a/cpp/src/Ice/SslException.cpp +++ /dev/null @@ -1,342 +0,0 @@ -// **********************************************************************
-//
-// Copyright (c) 2001
-// MutableRealms, Inc.
-// Huntsville, AL, USA
-//
-// All Rights Reserved
-//
-// **********************************************************************
-#ifdef WIN32
-#pragma warning(disable:4786)
-#endif
-
-#include <Ice/SslException.h>
-
-using Ice::SocketException;
-using Ice::Exception;
-
-using std::ostream;
-using std::string;
-
-//////////////////////////////////
-////////// SecurityException /////
-//////////////////////////////////
-
-//
-// Public Methods
-//
-
-IceSecurity::SecurityException::SecurityException(const char* errMessage, const char* file, int line) :
- LocalException(file, line),
- _message(errMessage)
-{
-}
-
-IceSecurity::SecurityException::SecurityException(const SecurityException& ex) :
- LocalException(ex),
- _message(ex._message)
-{
-}
-
-IceSecurity::SecurityException&
-IceSecurity::SecurityException::operator=(const SecurityException& ex)
-{
- LocalException::operator=(ex);
- return *this;
-}
-
-string
-IceSecurity::SecurityException::toString() const
-{
- string s = ice_name();
-
- if (_message.empty())
- {
- s += ": unspecified exception";
- }
- else
- {
- s += ": ";
- s += _message;
- }
-
- return s;
-}
-
-string
-IceSecurity::SecurityException::ice_name() const
-{
- return "IceSecurity::SecurityException";
-}
-
-void
-IceSecurity::SecurityException::ice_print(ostream& out) const
-{
- Exception::ice_print(out);
- out << ":\n" << toString();
-}
-
-Ice::Exception*
-IceSecurity::SecurityException::ice_clone() const
-{
- return new SecurityException(*this);
-}
-
-void
-IceSecurity::SecurityException::ice_throw() const
-{
- throw *this;
-}
-
-///////////////////////////////////////
-//////// ConfigParseException /////////
-///////////////////////////////////////
-
-//
-// Public Methods
-//
-
-IceSecurity::Ssl::ConfigParseException::ConfigParseException(const char* errMessage, const char* file, int line) :
- SecurityException(errMessage, file, line)
-{
-}
-
-IceSecurity::Ssl::ConfigParseException::ConfigParseException(const ConfigParseException& ex) :
- SecurityException(ex)
-{
-}
-
-IceSecurity::Ssl::ConfigParseException&
-IceSecurity::Ssl::ConfigParseException::operator=(const ConfigParseException& ex)
-{
- SecurityException::operator=(ex);
- return *this;
-}
-
-string
-IceSecurity::Ssl::ConfigParseException::ice_name() const
-{
- return "IceSecurity::ConfigParseException";
-}
-
-void
-IceSecurity::Ssl::ConfigParseException::ice_print(ostream& out) const
-{
- Exception::ice_print(out);
- out << ":\n" << toString();
-}
-
-Ice::Exception*
-IceSecurity::Ssl::ConfigParseException::ice_clone() const
-{
- return new ConfigParseException(*this);
-}
-
-void
-IceSecurity::Ssl::ConfigParseException::ice_throw() const
-{
- throw *this;
-}
-
-///////////////////////////////////////
-////////// ShutdownException //////////
-///////////////////////////////////////
-
-//
-// Public Methods
-//
-
-IceSecurity::Ssl::ShutdownException::ShutdownException(const char* errMessage, const char* file, int line) :
- SecurityException(errMessage, file, line)
-{
-}
-
-IceSecurity::Ssl::ShutdownException::ShutdownException(const ShutdownException& ex) :
- SecurityException(ex)
-{
-}
-
-IceSecurity::Ssl::ShutdownException&
-IceSecurity::Ssl::ShutdownException::operator=(const ShutdownException& ex)
-{
- SecurityException::operator=(ex);
- return *this;
-}
-
-string
-IceSecurity::Ssl::ShutdownException::ice_name() const
-{
- return "IceSecurity::Ssl::ShutdownException";
-}
-
-void
-IceSecurity::Ssl::ShutdownException::ice_print(ostream& out) const
-{
- Exception::ice_print(out);
- out << ":\n" << toString();
-}
-
-Ice::Exception*
-IceSecurity::Ssl::ShutdownException::ice_clone() const
-{
- return new ShutdownException(*this);
-}
-
-void
-IceSecurity::Ssl::ShutdownException::ice_throw() const
-{
- throw *this;
-}
-
-/////////////////////////////////////
-///////// ProtocolException /////////
-/////////////////////////////////////
-
-//
-// Public Methods
-//
-
-IceSecurity::Ssl::ProtocolException::ProtocolException(const char* errMessage, const char* file, int line) :
- ShutdownException(errMessage, file, line)
-{
-}
-
-IceSecurity::Ssl::ProtocolException::ProtocolException(const ProtocolException& ex) :
- ShutdownException(ex)
-{
-}
-
-IceSecurity::Ssl::ProtocolException&
-IceSecurity::Ssl::ProtocolException::operator=(const ProtocolException& ex)
-{
- ShutdownException::operator=(ex);
- return *this;
-}
-
-string
-IceSecurity::Ssl::ProtocolException::ice_name() const
-{
- return "IceSecurity::Ssl::ProtocolException";
-}
-
-void
-IceSecurity::Ssl::ProtocolException::ice_print(ostream& out) const
-{
- Exception::ice_print(out);
- out << ":\n" << toString();
-}
-
-Ice::Exception*
-IceSecurity::Ssl::ProtocolException::ice_clone() const
-{
- return new ProtocolException(*this);
-}
-
-void
-IceSecurity::Ssl::ProtocolException::ice_throw() const
-{
- throw *this;
-}
-
-///////////////////////////////////
-////// CertificateException ///////
-///////////////////////////////////
-
-//
-// Public Methods
-//
-
-IceSecurity::Ssl::CertificateException::CertificateException(const char* errMessage, const char* file, int line) :
- ShutdownException(errMessage, file, line)
-{
-}
-
-IceSecurity::Ssl::CertificateException::CertificateException(const CertificateException& ex) :
- ShutdownException(ex)
-{
-}
-
-IceSecurity::Ssl::CertificateException&
-IceSecurity::Ssl::CertificateException::operator=(const CertificateException& ex)
-{
- ShutdownException::operator=(ex);
- return *this;
-}
-
-string
-IceSecurity::Ssl::CertificateException::ice_name() const
-{
- return "IceSecurity::CertificateException";
-}
-
-void
-IceSecurity::Ssl::CertificateException::ice_print(ostream& out) const
-{
- Exception::ice_print(out);
- out << ":\n" << toString();
-}
-
-Ice::Exception*
-IceSecurity::Ssl::CertificateException::ice_clone() const
-{
- return new CertificateException(*this);
-}
-
-void
-IceSecurity::Ssl::CertificateException::ice_throw() const
-{
- throw *this;
-}
-
-//////////////////////////////////////
-////////// ContextException //////////
-//////////////////////////////////////
-
-//
-// Public Methods
-//
-
-IceSecurity::Ssl::OpenSSL::ContextException::ContextException(const char* errMessage, const char* file, int line) :
- SecurityException(errMessage, file, line)
-{
-}
-
-IceSecurity::Ssl::OpenSSL::ContextException::ContextException(const ContextException& ex) :
- SecurityException(ex)
-{
-}
-
-IceSecurity::Ssl::OpenSSL::ContextException&
-IceSecurity::Ssl::OpenSSL::ContextException::operator=(const ContextException& ex)
-{
- SecurityException::operator=(ex);
- return *this;
-}
-
-string
-IceSecurity::Ssl::OpenSSL::ContextException::ice_name() const
-{
- return "IceSecurity::Ssl::OpenSSL::ContextException";
-}
-
-void
-IceSecurity::Ssl::OpenSSL::ContextException::ice_print(ostream& out) const
-{
- Exception::ice_print(out);
- out << ":\n" << toString();
-}
-
-Ice::Exception*
-IceSecurity::Ssl::OpenSSL::ContextException::ice_clone() const
-{
- return new ContextException(*this);
-}
-
-void
-IceSecurity::Ssl::OpenSSL::ContextException::ice_throw() const
-{
- throw *this;
-}
-
-
diff --git a/cpp/src/Ice/SslException.h b/cpp/src/Ice/SslException.h deleted file mode 100644 index 0a7e4fd6b0c..00000000000 --- a/cpp/src/Ice/SslException.h +++ /dev/null @@ -1,142 +0,0 @@ -////*********************************************************************
-//
-// Copyright (c) 2001
-// MutableRealms, Inc.
-// Huntsville, AL, USA
-//
-// All Rights Reserved
-//
-////*********************************************************************
-
-#ifndef ICE_SSL_EXCEPTION_H
-#define ICE_SSL_EXCEPTION_H
-
-#include <Ice/LocalException.h>
-#include <string>
-#include <ostream>
-
-namespace IceSecurity
-{
-
-using std::string;
-using std::ostream;
-using Ice::Exception;
-using Ice::LocalException;
-
-// SecurityException
-//
-// This exception serves as the base for all SSL related exceptions. It should probably
-// not be constructed directly, but can be used in this manner if desired.
-//
-class ICE_API SecurityException : public LocalException
-{
-public:
-
- SecurityException(const char*, const char*, int);
- SecurityException(const SecurityException&);
- SecurityException& operator=(const SecurityException&);
- virtual string toString() const;
- virtual string ice_name() const;
- virtual void ice_print(std::ostream&) const;
- virtual Exception* ice_clone() const;
- virtual void ice_throw() const;
-
-private:
-
- string _message;
-};
-
-namespace Ssl
-{
-
-class ICE_API ConfigParseException : public SecurityException
-{
-public:
-
- ConfigParseException(const char*, const char*, int);
- ConfigParseException(const ConfigParseException&);
- ConfigParseException& operator=(const ConfigParseException&);
- virtual string ice_name() const;
- virtual void ice_print(std::ostream&) const;
- virtual Exception* ice_clone() const;
- virtual void ice_throw() const;
-
-};
-
-// ShutdownException
-//
-// This exception indicates that there has been a fatal SSL connection problem
-// that requires the shutdown of the connection and closing of the underlying
-// transport.
-//
-class ICE_API ShutdownException : public SecurityException
-{
-public:
-
- ShutdownException(const char*, const char*, int);
- ShutdownException(const ShutdownException&);
- ShutdownException& operator=(const ShutdownException&);
- virtual string ice_name() const;
- virtual void ice_print(std::ostream&) const;
- virtual Exception* ice_clone() const;
- virtual void ice_throw() const;
-
-};
-
-class ICE_API ProtocolException : public ShutdownException
-{
-public:
-
- ProtocolException(const char*, const char*, int);
- ProtocolException(const ProtocolException&);
- ProtocolException& operator=(const ProtocolException&);
- virtual string ice_name() const;
- virtual void ice_print(std::ostream&) const;
- virtual Exception* ice_clone() const;
- virtual void ice_throw() const;
-
-};
-
-class ICE_API CertificateException : public ShutdownException
-{
-public:
-
- CertificateException(const char*, const char*, int);
- CertificateException(const CertificateException&);
- CertificateException& operator=(const CertificateException&);
- virtual string ice_name() const;
- virtual void ice_print(std::ostream&) const;
- virtual Exception* ice_clone() const;
- virtual void ice_throw() const;
-
-};
-
-namespace OpenSSL
-{
-
-// ContextException
-//
-// This exception indicates that a problem occurred while setting up the
-// SSL context structure (SSL_CTX).
-//
-class ICE_API ContextException : public SecurityException
-{
-public:
-
- ContextException(const char*, const char*, int);
- ContextException(const ContextException&);
- ContextException& operator=(const ContextException&);
- virtual string ice_name() const;
- virtual void ice_print(std::ostream&) const;
- virtual Exception* ice_clone() const;
- virtual void ice_throw() const;
-
-};
-
-}
-
-}
-
-}
-
-#endif
diff --git a/cpp/src/Ice/SslSystemOpenSSL.cpp b/cpp/src/Ice/SslSystemOpenSSL.cpp index ec404c78c1a..dd04aef3d18 100644 --- a/cpp/src/Ice/SslSystemOpenSSL.cpp +++ b/cpp/src/Ice/SslSystemOpenSSL.cpp @@ -17,7 +17,7 @@ #include <openssl/rand.h>
#include <Ice/Security.h>
#include <Ice/SslSystem.h>
-#include <Ice/SslException.h>
+#include <Ice/SecurityException.h>
#include <Ice/SslConnectionOpenSSLClient.h>
#include <Ice/SslConnectionOpenSSLServer.h>
#include <Ice/SslConfig.h>
@@ -1079,16 +1079,16 @@ IceSecurity::Ssl::OpenSSL::System::addKeyCert(SSL_CTX* sslContext, // Set which Public Key file to use.
if (SSL_CTX_use_certificate_file(sslContext, publicFile, publicEncoding) <= 0)
{
- string errorString;
+ ContextException contextEx(__FILE__, __LINE__);
- errorString = "Unable to get certificate from '";
- errorString += publicFile;
- errorString += "'\n";
- errorString += sslGetErrors();
+ contextEx._message = "Unable to get certificate from '";
+ contextEx._message += publicFile;
+ contextEx._message += "'\n";
+ contextEx._message += sslGetErrors();
- ICE_EXCEPTION(errorString);
+ ICE_EXCEPTION(contextEx._message);
- throw ContextException(errorString.c_str(), __FILE__, __LINE__);
+ throw contextEx;
}
if (privateKey.getFileName().empty())
@@ -1102,35 +1102,37 @@ IceSecurity::Ssl::OpenSSL::System::addKeyCert(SSL_CTX* sslContext, // Set which Private Key file to use.
if (SSL_CTX_use_PrivateKey_file(sslContext, privKeyFile, privKeyFileType) <= 0)
{
- string errorString;
+ ContextException contextEx(__FILE__, __LINE__);
- errorString = "Unable to get private key from '";
- errorString += privKeyFile;
- errorString += "'\n";
- errorString += sslGetErrors();
+ contextEx._message = "Unable to get private key from '";
+ contextEx._message += privKeyFile;
+ contextEx._message += "'\n";
+ contextEx._message += sslGetErrors();
- ICE_EXCEPTION(errorString);
+ ICE_EXCEPTION(contextEx._message);
- throw ContextException(errorString.c_str(), __FILE__, __LINE__);
+ throw contextEx;
}
// Check to see if the Private and Public keys that have been
// set against the SSL context match up.
if (!SSL_CTX_check_private_key(sslContext))
{
- string errorString = "Private key does not match the certificate public key.";
+ ContextException contextEx(__FILE__, __LINE__);
+
+ contextEx._message = "Private key does not match the certificate public key.";
string sslError = sslGetErrors();
if (!sslError.empty())
{
- errorString += sslError;
+ contextEx._message += "\n";
+ contextEx._message += sslError;
}
- ICE_EXCEPTION(errorString);
+ ICE_EXCEPTION(contextEx._message);
- throw ContextException(errorString.c_str(), __FILE__, __LINE__);
+ throw contextEx;
}
-
}
ICE_METHOD_RET("OpenSSL::System::addKeyCert()");
@@ -1146,11 +1148,13 @@ IceSecurity::Ssl::OpenSSL::System::createContext(SslProtocol sslProtocol) if (context == 0)
{
- string errorString = "Unable to create SSL Context.\n" + sslGetErrors();
+ ContextException contextEx(__FILE__, __LINE__);
+
+ contextEx._message = "Unable to create SSL Context.\n" + sslGetErrors();
- ICE_EXCEPTION(errorString);
+ ICE_EXCEPTION(contextEx._message);
- throw ContextException(errorString.c_str(), __FILE__, __LINE__);
+ throw contextEx;
}
ICE_METHOD_RET("OpenSSL::System::createContext()");
diff --git a/cpp/src/Ice/ice.dsp b/cpp/src/Ice/ice.dsp index c5311c86146..bb616c556b9 100644 --- a/cpp/src/Ice/ice.dsp +++ b/cpp/src/Ice/ice.dsp @@ -228,6 +228,14 @@ SOURCE=.\Reference.cpp # End Source File
# Begin Source File
+SOURCE=.\SecurityException.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\SecurityException2.cpp
+# End Source File
+# Begin Source File
+
SOURCE=.\ServantLocator.cpp
# End Source File
# Begin Source File
@@ -272,10 +280,6 @@ SOURCE=.\SslConnector.cpp # End Source File
# Begin Source File
-SOURCE=.\SslException.cpp
-# End Source File
-# Begin Source File
-
SOURCE=.\SslFactory.cpp
# End Source File
# Begin Source File
@@ -644,10 +648,6 @@ SOURCE=.\SslConnector.h # End Source File
# Begin Source File
-SOURCE=.\SslException.h
-# End Source File
-# Begin Source File
-
SOURCE=.\SslFactory.h
# End Source File
# Begin Source File
@@ -1171,6 +1171,33 @@ InputPath=..\..\slice\Ice\PropertiesF.ice # End Source File
# Begin Source File
+SOURCE=..\..\slice\Ice\SecurityException.ice
+
+!IF "$(CFG)" == "Ice - Win32 Release"
+
+!ELSEIF "$(CFG)" == "Ice - Win32 Debug"
+
+# Begin Custom Build
+InputPath=..\..\slice\Ice\SecurityException.ice
+
+BuildCmds= \
+ set PATH=%PATH%;..\..\lib \
+ ..\..\bin\slice2cpp.exe --dll-export ICE_API --include-dir Ice -I../../slice ../../slice/Ice/SecurityException.ice \
+ move SecurityException.h ..\..\include\Ice \
+
+
+"..\..\include\Ice\SecurityException.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"SecurityException.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
SOURCE=..\..\slice\Ice\ServantLocator.ice
!IF "$(CFG)" == "Ice - Win32 Release"
|