summaryrefslogtreecommitdiff
path: root/cpp/test/Glacier2/ssl/Client.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/test/Glacier2/ssl/Client.cpp')
-rwxr-xr-xcpp/test/Glacier2/ssl/Client.cpp119
1 files changed, 119 insertions, 0 deletions
diff --git a/cpp/test/Glacier2/ssl/Client.cpp b/cpp/test/Glacier2/ssl/Client.cpp
new file mode 100755
index 00000000000..90f9a56cff2
--- /dev/null
+++ b/cpp/test/Glacier2/ssl/Client.cpp
@@ -0,0 +1,119 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2006 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#include <Ice/Application.h>
+#include <Glacier2/Router.h>
+#include <TestCommon.h>
+
+using namespace std;
+using namespace Ice;
+//using namespace Test;
+
+class CallbackClient : public Application
+{
+public:
+
+ virtual int run(int, char*[]);
+};
+
+int
+main(int argc, char* argv[])
+{
+ //
+ // We must disable connection warnings, because we attempt to ping
+ // the router before session establishment, as well as after
+ // session destruction. Both will cause a ConnectionLostException.
+ //
+ Ice::PropertiesPtr properties = Ice::getDefaultProperties(argc, argv);
+ properties->setProperty("Ice.Warn.Connections", "0");
+
+ CallbackClient app;
+ return app.main(argc, argv);
+}
+
+int
+CallbackClient::run(int argc, char* argv[])
+{
+ Glacier2::RouterPrx router = Glacier2::RouterPrx::uncheckedCast(
+ communicator()->stringToProxy("abc/def:tcp -h 127.0.0.1 -p 12347 -t 10000"));
+ communicator()->setDefaultRouter(router);
+
+ //
+ // First try to create a non ssl sessions.
+ //
+ cout << "creating non-ssl session with tcp connection... ";
+ try
+ {
+ Glacier2::SessionPrx session = router->createSession("nossl", "");
+ router->destroySession();
+ }
+ catch(const Ice::ConnectionLostException&)
+ {
+ }
+ catch(const Glacier2::PermissionDeniedException&)
+ {
+ test(false);
+ }
+ cout << "ok" << endl;
+ cout << "creating ssl session with tcp connection... ";
+ try
+ {
+ Glacier2::SessionPrx session = router->createSession("ssl", "");
+ test(false);
+ }
+ catch(const Glacier2::PermissionDeniedException&)
+ {
+ }
+ cout << "ok" << endl;
+
+ //
+ // Switch to using the SSL router. First, clear the router. Then
+ // set a new SSL based router.
+ //
+ communicator()->setDefaultRouter(Glacier2::RouterPrx());
+ router = Glacier2::RouterPrx::uncheckedCast(
+ communicator()->stringToProxy("abc/def:ssl -h 127.0.0.1 -p 12348 -t 10000"));
+ communicator()->setDefaultRouter(router);
+
+ //
+ // Next try to create a non ssl session. This should succeed.
+ //
+ cout << "creating non-ssl session with ssl connection... ";
+ try
+ {
+ Glacier2::SessionPrx session = router->createSession("nossl", "");
+ test(false);
+ }
+ catch(const Glacier2::PermissionDeniedException&)
+ {
+ }
+ cout << "ok" << endl;
+
+ cout << "creating ssl session with ssl connection... ";
+ try
+ {
+ Glacier2::SessionPrx session = router->createSession("ssl", "");
+ router->destroySession();
+ }
+ catch(const Ice::ConnectionLostException&)
+ {
+ }
+ catch(const Glacier2::PermissionDeniedException&)
+ {
+ test(false);
+ }
+ cout << "ok" << endl;
+
+ communicator()->setDefaultRouter(0);
+ Glacier2::AdminPrx admin = Glacier2::AdminPrx::checkedCast(
+ communicator()->stringToProxy("ABC/DEF:tcp -h 127.0.0.1 -p 12349 -t 10000"));
+ admin->shutdown();
+
+ return EXIT_SUCCESS;
+}