summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjeliazkov_i <jeliazkov_i@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2004-09-24 14:03:19 +0000
committerjeliazkov_i <jeliazkov_i@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2004-09-24 14:03:19 +0000
commit3e3bf73ca628e4dbf04d50682ed8e84131a7deb5 (patch)
tree0bf689f9b0cfecf2c42309ce5eff53a2c4199709
parentc43d67d5807e72c057f355597434b84b7c00209d (diff)
downloadATCD-3e3bf73ca628e4dbf04d50682ed8e84131a7deb5.tar.gz
Fri Sep 24 08:58:40 2004 Iliyan Jeliazkov <jeliazkov_i@ociweb.com>
Added capability to use INS-style corbaloc references to specify SSLIOP references. This was motivated by a desire to access a naming service exclusively using SSLIOP, but needing to specify its endpoint to clients via a corbaloc-style IOR. This change originated in OCITAO 1.3a, and relies (and brings along with it) code from OCITAO that refactored the CORBALOC parser to support corbaloc and corbaname parsing via protocols beyond iiop. Thanks to Phil Mesnier and Jonathan Pollack for contributing this functionality. Their changes are credited accordingly in the text below.
-rw-r--r--TAO/ChangeLog114
-rw-r--r--TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connector.cpp76
-rw-r--r--TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connector.h7
-rw-r--r--TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Factory.cpp11
-rw-r--r--TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Profile.cpp24
-rw-r--r--TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Profile.h16
-rw-r--r--TAO/orbsvcs/tests/Security/MT_SSLIOP/MT_SSLIOP.mpc2
-rw-r--r--TAO/orbsvcs/tests/Security/MT_SSLIOP/server.cpp33
-rw-r--r--TAO/orbsvcs/tests/Security/ssliop_corbaloc/README87
-rw-r--r--TAO/orbsvcs/tests/Security/ssliop_corbaloc/client.conf5
-rw-r--r--TAO/orbsvcs/tests/Security/ssliop_corbaloc/client.conf.xml9
-rw-r--r--TAO/orbsvcs/tests/Security/ssliop_corbaloc/client.cpp1280
-rw-r--r--TAO/orbsvcs/tests/Security/ssliop_corbaloc/client.h334
-rw-r--r--TAO/orbsvcs/tests/Security/ssliop_corbaloc/corbaloc_ssliop.mpc9
-rw-r--r--TAO/orbsvcs/tests/Security/ssliop_corbaloc/pvtkey-client.pem16
-rw-r--r--TAO/orbsvcs/tests/Security/ssliop_corbaloc/pvtkey.pem10
-rwxr-xr-xTAO/orbsvcs/tests/Security/ssliop_corbaloc/run_test.pl161
-rw-r--r--TAO/orbsvcs/tests/Security/ssliop_corbaloc/selfsigncert-client.pem24
-rw-r--r--TAO/orbsvcs/tests/Security/ssliop_corbaloc/selfsigncert.pem16
-rw-r--r--TAO/orbsvcs/tests/Security/ssliop_corbaloc/server.conf6
-rw-r--r--TAO/orbsvcs/tests/Security/ssliop_corbaloc/server.conf.xml8
-rw-r--r--TAO/orbsvcs/tests/Security/ssliop_corbaloc/test_object.idl11
-rw-r--r--TAO/tao/CORBALOC_Parser.cpp634
-rw-r--r--TAO/tao/CORBALOC_Parser.h86
-rw-r--r--TAO/tao/Connector_Registry.cpp22
-rw-r--r--TAO/tao/IIOP_Connector.cpp4
-rw-r--r--TAO/tao/IIOP_Profile.cpp10
-rw-r--r--TAO/tao/Strategies/UIOP_Connector.cpp30
-rw-r--r--TAO/tao/Strategies/UIOP_Connector.h3
-rw-r--r--TAO/tao/Strategies/UIOP_Profile.cpp37
-rw-r--r--TAO/tao/Transport_Connector.cpp24
-rw-r--r--TAO/tao/Transport_Connector.h12
32 files changed, 2629 insertions, 492 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index cffc85dd3e3..c2b0748f0df 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,3 +1,117 @@
+Fri Sep 24 08:58:40 2004 Iliyan Jeliazkov <jeliazkov_i@ociweb.com>
+
+ Added capability to use INS-style corbaloc references to specify SSLIOP
+ references. This was motivated by a desire to access a naming service
+ exclusively using SSLIOP, but needing to specify its endpoint to clients
+ via a corbaloc-style IOR.
+
+ This change originated in OCITAO 1.3a, and relies (and brings along with
+ it) code from OCITAO that refactored the CORBALOC parser to support
+ corbaloc and corbaname parsing via protocols beyond iiop. Thanks to
+ Phil Mesnier and Jonathan Pollack for contributing this functionality.
+ Their changes are credited accordingly in the text below.
+
+ * orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connector.h:
+ * orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connector.cpp:
+
+ Added code to check for the new "ssliop:" protocol prefix and to parse
+ a corbaloc-style URL with ssliop prefix.
+
+ * orbsvcs/orbsvcs/SSLIOP/SSLIOP_Factory.cpp:
+
+ Updated the factory to correctly recognize ssliop: and iiop: protocol
+ prefixes.
+
+ * orbsvcs/orbsvcs/SSLIOP/SSLIOP_Profile.h:
+ * orbsvcs/orbsvcs/SSLIOP/SSLIOP_Profile.cpp:
+
+ Modified to allow creation of profiles that allways use SSL (when the
+ ssliop: protocol prefix is present). Such profiles will allways create
+ connections with Security::NoProtection disabled.
+
+ * orbsvcs/tests/Security/MT_SSLIOP/MT_SSLIOP.mpc:
+ * orbsvcs/tests/Security/MT_SSLIOP/server.cpp:
+
+ Added a "-i ObjectKey" option to provide an object key in the IORTable for
+ the object reference, so that clients can use corbaloc object
+ references like "corbaloc:ssliop:localhost:12345/ObjectKey". The intent
+ was to use it in testing the working of the corbaloc:ssliop, however it
+ is suiteable for more general use and that is why I left it here.
+
+ * orbsvcs/tests/Security/ssliop_corbaloc/README:
+ * orbsvcs/tests/Security/ssliop_corbaloc/client.conf:
+ * orbsvcs/tests/Security/ssliop_corbaloc/client.h:
+ * orbsvcs/tests/Security/ssliop_corbaloc/client.conf.xml:
+ * orbsvcs/tests/Security/ssliop_corbaloc/client.cpp:
+ * orbsvcs/tests/Security/ssliop_corbaloc/corbaloc_ssliop.mpc:
+ * orbsvcs/tests/Security/ssliop_corbaloc/pvtkey-client.pem:
+ * orbsvcs/tests/Security/ssliop_corbaloc/pvtkey.pem:
+ * orbsvcs/tests/Security/ssliop_corbaloc/run_test.pl:
+ * orbsvcs/tests/Security/ssliop_corbaloc/selfsigncert-client.pem:
+ * orbsvcs/tests/Security/ssliop_corbaloc/selfsigncert.pem:
+ * orbsvcs/tests/Security/ssliop_corbaloc/server.conf:
+ * orbsvcs/tests/Security/ssliop_corbaloc/server.conf.xml:
+ * orbsvcs/tests/Security/ssliop_corbaloc/test_object.idl:
+
+ Added the test to demonstrate the use of corbaloc:ssliop-style
+ object references and exclusive use of secure connection.
+ Introduced client- and server-side configuration file(s) for
+ the SSL-based tests, which I borrowed from
+ $TAO_ROOT/orbsvcs/tests/Security/Security/MT_SSLIOP.
+ Also generated a pair of private keys and the corresponding
+ certificates.
+
+
+ * tao/CORBALOC_Parser.h:
+ * tao/CORBALOC_Parser.cpp:
+
+ Phil Mesnier refactored CORBALOC_Parser. The goal of this effort is to
+ support corbaloc and corbaname style object URLs with protocols other than those
+ shipped with TAO. Now the corbaloc parser works in conjunction
+ with the connector registry to allow the loaded transport
+ connectors to parse out known address strings. This change works
+ in conjunction with the changed TAO_Transport_Connector class,
+ described below. Thanks also to Jonathan Pollack for contributing, and
+ reviewing the final version.
+
+ * tao/Connector_Registry.cpp:
+ * tao/IIOP_Connector.cpp:
+
+ Phil Mesnier added an "" to the list of valid prefixes. This allows the
+ corbaloc parser code to remain clean, while still allowing corbaloc:: to
+ be eqivalent to corbaloc:iiop:.
+
+ * tao/IIOP_Profile.cpp:
+
+ Added a better error message for the case when a port number appears
+ with no host name specified. Originaly this threw and exception, but
+ provided no clues why the object reference would be invalid.
+
+ * tao/Strategies/UIOP_Connector.h:
+ * tao/Strategies/UIOP_Connector.cpp:
+
+ Phil Mesnier overode corbaloc parsing for UIOP, as it is a profile that
+ may contain commas or slashes in the address, therefore it must provide
+ its own implementation of corbaloc_scan method. The UIOP parser scans
+ for a '|' preceeding the comma or slash.
+
+ * tao/Strategies/UIOP_Profile.cpp:
+
+ Phil Mesnier updated the to_string method to output a stringified object
+ reference compatible with the updated corbaloc parser.
+
+ * tao/Transport_Connector.h:
+ * tao/Transport_Connector.cpp:
+
+ Phil Mesnier added a new virtual method, corbaloc_scan, which is called by
+ the corbaloc parser in order to find the end of the address specification,
+ ordinarily a comma or a slash. This method is virtual so that specific
+ protocols that need to have an additional adornment, or may include a comma
+ or slash in a valid endpoint string, may use an alternative method to
+ determine the end of the address. Ensured (in corbaloc_scan) that commas
+ that appear inside object key, following a slash are not counted as
+ separators between addresses.
+
Fri Sep 24 07:12:12 2004 Carlos O'Ryan <coryan@atdesk.com>
* tests/Sequence_Unit_Tests/allocation_traits.hpp:
diff --git a/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connector.cpp b/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connector.cpp
index ba933c34608..00be46eb157 100644
--- a/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connector.cpp
+++ b/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connector.cpp
@@ -271,7 +271,7 @@ TAO::SSLIOP::Connector::create_profile (TAO_InputCDR& cdr)
}
TAO_Profile *
-TAO::SSLIOP::Connector::make_profile (ACE_ENV_SINGLE_ARG_DECL)
+TAO::SSLIOP::Connector::make_profile (int is_secure ACE_ENV_ARG_DECL)
{
// The endpoint should be of the form:
// N.n@host:port/object_key
@@ -281,7 +281,7 @@ TAO::SSLIOP::Connector::make_profile (ACE_ENV_SINGLE_ARG_DECL)
TAO_Profile *profile = 0;
ACE_NEW_THROW_EX (profile,
TAO_SSLIOP_Profile (this->orb_core (),
- 0), // SSL component
+ is_secure), // SSL component
CORBA::NO_MEMORY (
CORBA::SystemException::_tao_minor_code (
TAO_DEFAULT_MINOR_CODE,
@@ -292,6 +292,78 @@ TAO::SSLIOP::Connector::make_profile (ACE_ENV_SINGLE_ARG_DECL)
return profile;
}
+
+TAO_Profile *
+TAO::SSLIOP::Connector::corbaloc_scan (const char *endpoint,
+ size_t &len
+ ACE_ENV_ARG_DECL)
+{
+ int ssl_only = 0;
+ if( this->check_prefix( endpoint) == 0)
+ {
+ ssl_only = 1;
+ }
+ else
+ {
+ if (this->TAO_IIOP_Connector::check_prefix ( endpoint) != 0)
+ return 0;
+ }
+
+ // Determine the (first in a list of possibly > 1) endpoint address
+ const char *comma_pos = ACE_OS::strchr ( endpoint,',');
+ const char *slash_pos = ACE_OS::strchr ( endpoint,'/');
+ if( comma_pos == 0 && slash_pos == 0)
+ {
+ if( TAO_debug_level)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT("(%P|%t) SSLIOP_Connector::corbaloc_scan warning: ")
+ ACE_TEXT("supplied string contains no comma or slash: %s\n"),
+ endpoint));
+ }
+ len = ACE_OS::strlen (endpoint);
+ }
+ else if( slash_pos != 0 || comma_pos > slash_pos)
+ {
+ // The endpoint address does not extend past the first '/' or ','
+ len = slash_pos - endpoint;
+ }
+ else
+ {
+ len = comma_pos - endpoint;
+ }
+
+ return this->make_profile( ssl_only ACE_ENV_ARG_PARAMETER);
+}
+
+int
+TAO::SSLIOP::Connector::check_prefix (const char *endpoint)
+{
+ // Check for a valid string
+ if (!endpoint || !*endpoint) return -1; // Failure
+
+ const char *protocol[] = { "ssliop", "sslioploc" };
+
+ size_t first_slot = ACE_OS::strchr (endpoint, ':') - endpoint;
+
+ size_t len0 = ACE_OS::strlen (protocol[0]);
+ size_t len1 = ACE_OS::strlen (protocol[1]);
+
+ // Check for the proper prefix in the IOR. If the proper prefix
+ // isn't in the IOR then it is not an IOR we can use.
+ if (first_slot == len0 && ACE_OS::strncmp (endpoint, protocol[0], len0) == 0)
+ return 0;
+
+ if (first_slot == len1 && ACE_OS::strncmp (endpoint, protocol[1], len1) == 0)
+ return 0;
+
+ // Failure: not an SSLIOP IOR
+ // DO NOT throw an exception here.
+ return -1;
+}
+
+
+
TAO_Transport*
TAO::SSLIOP::Connector::iiop_connect (
TAO_SSLIOP_Endpoint *ssl_endpoint,
diff --git a/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connector.h b/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connector.h
index 9a3a5ddb1a2..518fe6310dd 100644
--- a/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connector.h
+++ b/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connector.h
@@ -70,6 +70,11 @@ namespace TAO
ACE_ENV_ARG_DECL);
virtual TAO_Profile *create_profile (TAO_InputCDR& cdr);
+ virtual int check_prefix (const char *endpoint);
+ virtual TAO_Profile * corbaloc_scan (const char *ior,
+ size_t &len
+ ACE_ENV_ARG_DECL);
+
//@}
protected:
@@ -79,7 +84,7 @@ namespace TAO
*
* Please check the documentation in Pluggable.h.
*/
- virtual TAO_Profile * make_profile (ACE_ENV_SINGLE_ARG_DECL);
+ virtual TAO_Profile * make_profile (int is_secure ACE_ENV_ARG_DECL);
/// Cancel the passed cvs handler from the connector
virtual int cancel_svc_handler (TAO_Connection_Handler * svc_handler);
diff --git a/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Factory.cpp b/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Factory.cpp
index fbb32f89f96..c209a7aa563 100644
--- a/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Factory.cpp
+++ b/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Factory.cpp
@@ -18,7 +18,7 @@ ACE_RCSID (SSLIOP,
"$Id$")
-static const char prefix_[] = "iiop";
+static const char *prefix_[] = {"iiop", "ssliop"};
namespace TAO
{
@@ -44,13 +44,18 @@ int
TAO::SSLIOP::Protocol_Factory::match_prefix (const ACE_CString &prefix)
{
// Check for the proper prefix for this protocol.
- return (ACE_OS::strcasecmp (prefix.c_str (), ::prefix_) == 0);
+ return (ACE_OS::strcasecmp (prefix.c_str (), ::prefix_[0]) == 0)
+ || (ACE_OS::strcasecmp (prefix.c_str (), ::prefix_[1]) == 0);
}
const char *
TAO::SSLIOP::Protocol_Factory::prefix (void) const
{
- return ::prefix_;
+ // Note: This method doesn't seem to be used anywhere. Moreover,
+ // keeping it may make things more confusing - a Factory can
+ // well be handling multiple protocol prefixes, not just one!
+ // Shouldn't it be deprecated?
+ return ::prefix_[0];
}
char
diff --git a/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Profile.cpp b/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Profile.cpp
index 23642aaa94a..6a203a8813b 100644
--- a/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Profile.cpp
+++ b/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Profile.cpp
@@ -23,7 +23,8 @@ TAO_SSLIOP_Profile::TAO_SSLIOP_Profile (const ACE_INET_Addr & addr,
object_key,
version,
orb_core),
- ssl_endpoint_ (ssl_component, 0)
+ ssl_endpoint_ (ssl_component, 0),
+ ssl_only_ (0)
{
this->ssl_endpoint_.iiop_endpoint (&this->endpoint_, true);
}
@@ -41,7 +42,8 @@ TAO_SSLIOP_Profile::TAO_SSLIOP_Profile (const char * host,
addr,
version,
orb_core),
- ssl_endpoint_ (ssl_component, 0)
+ ssl_endpoint_ (ssl_component, 0),
+ ssl_only_ (0)
{
this->ssl_endpoint_.iiop_endpoint (&this->endpoint_, true);
}
@@ -49,14 +51,16 @@ TAO_SSLIOP_Profile::TAO_SSLIOP_Profile (const char * host,
TAO_SSLIOP_Profile::TAO_SSLIOP_Profile (TAO_ORB_Core * orb_core,
const ::SSLIOP::SSL * ssl_component)
: TAO_IIOP_Profile (orb_core),
- ssl_endpoint_ (ssl_component, 0)
+ ssl_endpoint_ (ssl_component, 0),
+ ssl_only_ (0)
{
this->ssl_endpoint_.iiop_endpoint (&this->endpoint_, true);
}
-TAO_SSLIOP_Profile::TAO_SSLIOP_Profile (TAO_ORB_Core * orb_core)
+TAO_SSLIOP_Profile::TAO_SSLIOP_Profile (TAO_ORB_Core * orb_core, int ssl_only)
: TAO_IIOP_Profile (orb_core),
- ssl_endpoint_ (0, 0)
+ ssl_endpoint_ (0, 0),
+ ssl_only_ (ssl_only)
{
this->ssl_endpoint_.iiop_endpoint (&this->endpoint_, true);
}
@@ -340,4 +344,14 @@ TAO_SSLIOP_Profile::parse_string (const char * ior
ACE_CHECK;
this->ssl_endpoint_.iiop_endpoint (&this->endpoint_, true);
+
+ if( ssl_only_)
+ {
+ this->ssl_endpoint_.ssl_component_.port = this->endpoint_.port_;
+
+ // Note that the Security::NoProtection bit is cleared since we
+ // are sure the server supports SSL (we're told so)
+ ACE_CLR_BITS (this->ssl_endpoint_.ssl_component_.target_supports,
+ Security::NoProtection);
+ }
}
diff --git a/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Profile.h b/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Profile.h
index 026765b860b..7d90d00f290 100644
--- a/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Profile.h
+++ b/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Profile.h
@@ -68,8 +68,10 @@
TAO_SSLIOP_Profile (TAO_ORB_Core * orb_core,
const ::SSLIOP::SSL * ssl_component);
- /// Profile constructor, default.
- TAO_SSLIOP_Profile (TAO_ORB_Core * orb_core);
+ /// Profile constructor. ssl_only != 0 will force secure
+ /// connections, pnly.
+ TAO_SSLIOP_Profile (TAO_ORB_Core * orb_core, int ssl_only = 0);
+
// = Please see Profile.h for the documentation of these methods.
virtual int decode (TAO_InputCDR& cdr);
@@ -153,6 +155,16 @@
* rest of the SSL endpoint list is transmitted.
*/
TAO_SSLIOP_Endpoint ssl_endpoint_;
+
+ /**
+ * Allways treat this endpoint as secure, even if the constructor
+ * did not explicitely specify a tagged component for SSL.
+ * @par
+ * Most likely the parse_string() will supply a subset of the
+ * attributes - port number, for instance.
+ */
+ int ssl_only_;
+
};
// } // End SSLIOP namespace.
diff --git a/TAO/orbsvcs/tests/Security/MT_SSLIOP/MT_SSLIOP.mpc b/TAO/orbsvcs/tests/Security/MT_SSLIOP/MT_SSLIOP.mpc
index 48f43312e62..1e76f1acf6f 100644
--- a/TAO/orbsvcs/tests/Security/MT_SSLIOP/MT_SSLIOP.mpc
+++ b/TAO/orbsvcs/tests/Security/MT_SSLIOP/MT_SSLIOP.mpc
@@ -1,7 +1,7 @@
// -*- MPC -*-
// $Id$
-project(*security server): orbsvcsexe, portableserver, ssl {
+project(*security server): orbsvcsexe, portableserver, ssl, iortable {
Source_Files {
Server_Worker.cpp
test_i.cpp
diff --git a/TAO/orbsvcs/tests/Security/MT_SSLIOP/server.cpp b/TAO/orbsvcs/tests/Security/MT_SSLIOP/server.cpp
index 29c53ecb7b8..e67568600ad 100644
--- a/TAO/orbsvcs/tests/Security/MT_SSLIOP/server.cpp
+++ b/TAO/orbsvcs/tests/Security/MT_SSLIOP/server.cpp
@@ -1,21 +1,27 @@
// $Id$
#include "ace/Get_Opt.h"
+#include "tao/IORTable/IORTable.h"
#include "test_i.h"
#include "Server_Worker.h"
const char *ior_output_file = 0;
+const char *ior_table_name = 0;
int nthreads = 4;
int
parse_args (int argc, char *argv[])
{
- ACE_Get_Opt get_opts (argc, argv, "o:n:");
+ ACE_Get_Opt get_opts (argc, argv, "i:o:n:");
int c;
while ((c = get_opts ()) != -1)
switch (c)
{
+ case 'i':
+ ior_table_name = get_opts.opt_arg ();
+ break;
+
case 'o':
ior_output_file = get_opts.opt_arg ();
break;
@@ -28,6 +34,7 @@ parse_args (int argc, char *argv[])
default:
ACE_ERROR_RETURN ((LM_ERROR,
"usage: %s "
+ "[-i <iortable name>]"
"-o <iorfile>"
"\n",
argv [0]),
@@ -80,7 +87,29 @@ main (int argc, char *argv[])
orb->object_to_string (server.in () ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
- ACE_DEBUG ((LM_DEBUG, "Activated as <%s>\n", ior.in ()));
+ ACE_DEBUG ((LM_DEBUG, "Activated as <%s>\n", ior.in ()));A
+
+
+ if (ior_table_name != 0)
+ {
+ CORBA::Object_var table_object =
+ orb->resolve_initial_references ("IORTable" ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (-1);
+
+ IORTable::Table_var adapter =
+ IORTable::Table::_narrow (table_object.in () ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (-1);
+
+ if (CORBA::is_nil (adapter.in ()))
+ {
+ ACE_ERROR ((LM_ERROR, "Nil IORTable\n"));
+ return -1;
+ }
+
+ adapter->bind ( ior_table_name, ior.in () ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (-1);
+ }
+
// If the ior_output_file exists, output the ior to it
if (ior_output_file != 0)
diff --git a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/README b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/README
new file mode 100644
index 00000000000..6e28b065fb8
--- /dev/null
+++ b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/README
@@ -0,0 +1,87 @@
+// $Id$
+
+These application tests address various features of TAO's
+Naming Service. The functionality is the same as in the
+Simple_Naming test, but the difference is that all the
+communication is done over SSLIOP and clients are using
+INS-style corbaloc URLs.
+
+To run all tests automatically -
+ execute Perl script run_test.pl
+
+To run tests manually -
+ start the Naming Service (see
+ TAO/orbsvcs/Naming_Service/README for valid options).
+ Make sure you use " -ORBSvcConf server.conf" and
+ "-ORBEndpoint iiop://localhost:23456/ssl_port=12345"
+
+ Then run ./client with one of the options below.
+ Make sure you add " -ORBSvcConf client.conf" and
+ "-ORBInitRef NameService=corbaloc:ssliop:localhost:12345/NameService"
+
+NOTE: if running tests manually, Naming Service has to be restarted
+before each test (this is due to some tests not 'cleaning up' bindings
+after themselves).
+
+The following options exist:
+---------------------------
+-s Run the Simple test of the Naming Service.
+
+-t Run the Tree test of the Naming Service.
+
+-e Run the Exceptions test of the Naming Service
+
+-i Run the Iterator test of the Naming Service.
+
+-y Run the Destroy test of the Naming Service.
+
+Persistent test consists of two parts (below).
+
+-p <file_name>
+ Run the Persistent Naming Service test, part 1. Requires an
+ argument specifying the name of the file in which to store an ior for
+ use by Persistent Naming Service test, part 2. Note, in order
+ to test out persistent capabilities of the Naming Service, the
+ Naming Service must be started with -f and -ORBendpoint options.
+ The values for these options must be the same for both runs of
+ the Naming Service (i.e., for part 1 and part 2 of persistent test).
+
+-c <ior>
+ Run the Persistent Naming Service test, part 2. Requires an
+ argument specifying the ior, which was produced in part 1 of
+ the test. Note, in order to test out persistent capabilities
+ of the Naming Service, the Naming Service must be started with
+ -f and -ORBendpoint options. The values for these options
+ must remain the same for both runs of the Naming Service (i.e.,
+ for part 1 and part 2 of persistent test).
+
+ Example of testing persistence on a Unix system:
+ $ ../../Naming_Service -f log -ORBendpoint iiop://localhost:20000
+ $ ./client -p ior_file
+ kill the Naming_Service process
+ $ ../../Naming_Service -f log -ORBendpoint iiop://localhost:20000
+ $ ./client -c file://ior_file
+
+ where the steps correspond to 1)starting the Naming Service on
+ port 20000 in persistent mode, with persistent state being
+ stored in file called "log", 2) running the first part of the
+ client persistent naming test, and sending its data to file
+ called "ior_file", 3) killing the Naming Service process, 4)
+ restarting the Naming Service on the same port with the same
+ persistent state storage file, and 5) running the second part
+ of the client persistence test by specifying the ior from part
+ 1 in the file format.
+
+ We kill the Naming Service process between 2 client runs to
+ make sure it can recreate its state from persistent storage.
+ It is necessary to restart the Naming Service on the same
+ host/port in order for the persistent IORs from the first
+ run to be valid for the second run.
+
+If no option is specified, Simple test is run. If more than one
+option is specified, only one test runs.
+
+
+DESCRIPTION AND EXPECTED OUTPUT FOR EACH TEST
+*******************************************
+Please see $TAO_ROOT/orbsvcs/tests/Simple_Naming/README
diff --git a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/client.conf b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/client.conf
new file mode 100644
index 00000000000..880c1b7d372
--- /dev/null
+++ b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/client.conf
@@ -0,0 +1,5 @@
+dynamic SSLIOP_Factory Service_Object *
+ TAO_SSLIOP:_make_TAO_SSLIOP_Protocol_Factory()
+ "-SSLPrivateKey PEM:pvtkey-client.pem -SSLCertificate PEM:selfsigncert-client.pem"
+static Resource_Factory "-ORBProtocolFactory SSLIOP_Factory"
+
diff --git a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/client.conf.xml b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/client.conf.xml
new file mode 100644
index 00000000000..50bb24f73ee
--- /dev/null
+++ b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/client.conf.xml
@@ -0,0 +1,9 @@
+<?xml version='1.0'?>
+<!-- Converted from client.conf by svcconf-convert.pl -->
+<ACE_Svc_Conf>
+ <dynamic id="SSLIOP_Factory" type="Service_Object">
+ <initializer path="TAO_SSLIOP" init="_make_TAO_SSLIOP_Protocol_Factory" params="-SSLPrivateKey PEM:pvtkey-client.pem -SSLCertificate PEM:selfsigncert-client.pem"/>
+ </dynamic>
+ <static id="Resource_Factory" params="-ORBProtocolFactory SSLIOP_Factory"/>
+</ACE_Svc_Conf>
+
diff --git a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/client.cpp b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/client.cpp
new file mode 100644
index 00000000000..1279dee82b7
--- /dev/null
+++ b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/client.cpp
@@ -0,0 +1,1280 @@
+// $Id$
+
+// ============================================================================
+//
+// = LIBRARY
+// TAO/orbsvcs/Naming_Service/
+//
+// = FILENAME
+// client.cpp
+//
+// = DESCRIPTION
+// This class implements a simple CORBA client for the CosNaming
+// example using stubs generated by the TAO ORB IDL compiler.
+//
+// = AUTHORS
+// Sergio Flores-Gaitan <sergio@cs.wustl.edu>,
+// Marina Spivak <marina@cs.wustl.edu>, and
+// Douglas C. Schmidt <schmidt@cs.wustl.edu>
+// ============================================================================
+
+#include "client.h"
+#include "tao/debug.h"
+#include "ace/Get_Opt.h"
+
+ACE_RCSID(Simple_Naming, client, "$Id$")
+
+#if defined (_MSC_VER)
+# pragma warning (disable : 4250)
+#endif /* _MSC_VER */
+
+class My_Test_Object :
+ public virtual PortableServer::RefCountServantBase,
+ public virtual POA_Test_Object
+{
+public:
+ // = Initialization and termination methods.
+ My_Test_Object (CORBA::Short id = 0);
+ // Constructor.
+
+ ~My_Test_Object (void);
+ // Destructor.
+
+ // = Interface implementation accessor methods.
+
+ void id (CORBA::Short id ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+ // Sets id.
+
+ CORBA::Short id (ACE_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+ // Gets id.
+
+private:
+ short id_;
+};
+
+My_Test_Object::My_Test_Object (CORBA::Short id)
+ : id_ (id)
+{
+}
+
+My_Test_Object::~My_Test_Object (void)
+{
+}
+
+CORBA::Short
+My_Test_Object::id (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ return id_;
+}
+
+void
+My_Test_Object::id (CORBA::Short id ACE_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ id_ = id;
+}
+
+// Constructor.
+
+CosNaming_Client::CosNaming_Client (void)
+ : argc_ (0),
+ argv_ (0),
+ test_ (0)
+{
+}
+
+// Parses the command line arguments and returns an error status.
+
+int
+CosNaming_Client::parse_args (void)
+{
+ ACE_Get_Opt get_opts (argc_, argv_, "p:dstieym:c:");
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'd': // debug flag
+ TAO_debug_level++;
+ break;
+ case 's':
+ if (this->test_ == 0)
+ ACE_NEW_RETURN (this->test_,
+ Simple_Test,
+ -1);
+ break;
+ case 'm':
+ if (this->test_ == 0)
+ {
+ int size = ACE_OS::atoi (get_opts.opt_arg ());
+ if (size <= 0)
+ size = 10;
+
+ ACE_NEW_RETURN (this->test_,
+ MT_Test (this->orbmgr_.orb (), size),
+ -1);
+ }
+
+ break;
+ case 't':
+ if (this->test_ == 0)
+ ACE_NEW_RETURN (this->test_,
+ Tree_Test,
+ -1);
+ break;
+ case 'i':
+ if (this->test_ == 0)
+ ACE_NEW_RETURN (this->test_,
+ Iterator_Test,
+ -1);
+ break;
+ case 'e':
+ if (this->test_ == 0)
+ ACE_NEW_RETURN (this->test_,
+ Exceptions_Test,
+ -1);
+ break;
+ case 'y':
+ if (this->test_ == 0)
+ ACE_NEW_RETURN (this->test_,
+ Destroy_Test,
+ -1);
+ break;
+ case 'p':
+ if (this->test_ == 0)
+ {
+ FILE * ior_output_file =
+ ACE_OS::fopen (get_opts.opt_arg (), "w");
+
+ if (ior_output_file == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Unable to open %s for writing: %p\n",
+ get_opts.opt_arg ()), -1);
+
+ ACE_NEW_RETURN (this->test_,
+ Persistent_Test_Begin (this->orbmgr_.orb (),
+ ior_output_file),
+ -1);
+ }
+ break;
+ case 'c':
+ if (this->test_ == 0)
+ ACE_NEW_RETURN (this->test_,
+ Persistent_Test_End (this->orbmgr_.orb (),
+ get_opts.opt_arg ()),
+ -1);
+ break;
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Argument %c \n usage: %s"
+ " [-d]"
+ " [-s or -e or -t or -i or -y or -p or -c<ior> or -m<size>]"
+ "\n",
+ c,
+ this->argv_ [0]),
+ -1);
+ }
+
+ if (this->test_ == 0)
+ ACE_NEW_RETURN (this->test_,
+ Simple_Test,
+ -1);
+
+ // Indicates successful parsing of command line.
+ return 0;
+}
+
+// Execute client example code.
+
+int
+CosNaming_Client::run (void)
+{
+ return test_->execute (naming_client_);
+}
+
+CosNaming_Client::~CosNaming_Client (void)
+{
+ delete test_;
+}
+
+int
+CosNaming_Client::init (int argc, char **argv)
+{
+ this->argc_ = argc;
+ this->argv_ = argv;
+
+ ACE_DECLARE_NEW_CORBA_ENV;
+ ACE_TRY
+ {
+ // Initialize ORB.
+ this->orbmgr_.init (this->argc_,
+ this->argv_
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ this->orbmgr_.activate_poa_manager (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ // Parse command line and verify parameters.
+ if (this->parse_args () == -1)
+ return -1;
+
+ CORBA::ORB_var orb = this->orbmgr_.orb ();
+ return this->naming_client_.init (orb.in ());
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "init");
+ // and return -1 below . . .
+ }
+ ACE_ENDTRY;
+
+ return -1;
+}
+
+MT_Test::MT_Test (CORBA::ORB_ptr orb,
+ int size)
+ :size_ (size),
+ orb_ (orb),
+ name_service_ior_ (0)
+{
+}
+
+int
+MT_Test::svc (void)
+{
+ // Obtain object reference to the Naming Service (create new stub.)
+
+ CosNaming::NamingContext_var name_service;
+
+ ACE_DECLARE_NEW_CORBA_ENV;
+ ACE_TRY_EX (SETUP)
+ {
+ CORBA::Object_var name_service_obj =
+ orb_->string_to_object (name_service_ior_ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK_EX (SETUP);
+
+ name_service =
+ CosNaming::NamingContext::_narrow (name_service_obj.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK_EX (SETUP);
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Unexpected exception in MT test setup");
+ return -1;
+ }
+ ACE_ENDTRY;
+ ACE_CHECK_RETURN (-1);
+
+ if (name_service.in () == 0)
+ return -1;
+
+ // Bind the object.
+ ACE_TRY_EX (BIND)
+ {
+ name_service->bind (test_name_,
+ test_ref_.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK_EX (BIND);
+ ACE_DEBUG ((LM_DEBUG,
+ "Bound name OK in thread %t\n"));
+ }
+ ACE_CATCH (CosNaming::NamingContext::AlreadyBound, ex)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Unable to bind in thread %t\n"));
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Unexpected exception in MT test bind");
+ // This debug statement works around a IRIX/MIPSPro 7.3 bug (it
+ // fails with optimize=1 debug=0; but works with any other
+ // settings for those flags).
+ ACE_DEBUG ((LM_DEBUG, "MT_Test(%t) - bind[3] %d\n",
+ test_name_.length ()));
+ return -1;
+ }
+ ACE_ENDTRY;
+ ACE_CHECK_RETURN (-1);
+
+ // Resolve the object from the Naming Context.
+ ACE_TRY_EX (RESOLVE)
+ {
+ CORBA::Object_var result_obj_ref =
+ name_service->resolve (test_name_
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK_EX (RESOLVE);
+
+ Test_Object_var result_object =
+ Test_Object::_narrow (result_obj_ref.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK_EX (RESOLVE);
+
+ if (!CORBA::is_nil (result_object.in ()))
+ {
+ CORBA::Short id = result_object->id (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK_EX (RESOLVE);
+
+ if (id == CosNaming_Client::OBJ1_ID)
+ ACE_DEBUG ((LM_DEBUG,
+ "Resolved name OK in thread %t\n"));
+ }
+ }
+ ACE_CATCH (CosNaming::NamingContext::NotFound, ex)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Unable to resolve in thread %t\n"));
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Unexpected exception in MT test resolve");
+ return -1;
+ }
+ ACE_ENDTRY;
+ ACE_CHECK_RETURN (-1);
+
+ // Unbind the object from the Naming Context.
+ ACE_TRY_EX (UNBIND)
+ {
+ name_service->unbind (test_name_
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK_EX (UNBIND);
+ ACE_DEBUG ((LM_DEBUG,
+ "Unbound name OK in thread %t\n"));
+ }
+ ACE_CATCH (CosNaming::NamingContext::NotFound, ex)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Unable to unbind in thread %t\n"));
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Unexpected exception in MT test unbind");
+ return -1;
+ }
+ ACE_ENDTRY;
+ ACE_CHECK_RETURN (-1);
+
+ return 0;
+}
+
+int
+MT_Test::execute (TAO_Naming_Client &root_context)
+{
+ if (CORBA::is_nil (this->orb_.in ()))
+ return -1;
+
+ // Create data which will be used by all threads.
+
+ // Dummy object instantiation.
+ My_Test_Object *test_obj_impl =
+ new My_Test_Object (CosNaming_Client::OBJ1_ID);
+
+ ACE_DECLARE_NEW_CORBA_ENV;
+ ACE_TRY
+ {
+ test_ref_ =
+ test_obj_impl->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ test_obj_impl->_remove_ref (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ // Get the IOR for the Naming Service. Each thread can use it
+ // in <string_to_object> to create its own stub for the Naming
+ // Service. This 'trick' is necessary, because multiple threads
+ // cannot be using the same stub - bad things happen... This is
+ // just a way to give each thread its own stub.
+
+ CosNaming::NamingContext_var context =
+ root_context.get_context ();
+
+ name_service_ior_ =
+ orb_->object_to_string (context.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Unexpected exception while instantiating dummy");
+ return -1;
+ }
+ ACE_ENDTRY;
+ ACE_CHECK_RETURN (-1);
+
+ // Create a name for dummy.
+ test_name_.length (1);
+ test_name_[0].id = CORBA::string_dup ("Foo");
+
+ // Spawn threads, each of which will be executing svc ().
+ int status = this->activate (THR_NEW_LWP | THR_JOINABLE,
+ size_);
+
+ if (status == -1)
+ return -1;
+
+ status = this->wait ();
+ return status;
+}
+
+int
+Simple_Test::execute (TAO_Naming_Client &root_context)
+{
+ ACE_DECLARE_NEW_CORBA_ENV;
+ ACE_TRY
+ {
+ // Dummy object instantiation.
+ My_Test_Object *test_obj_impl = new My_Test_Object (CosNaming_Client::OBJ1_ID);
+ Test_Object_var test_obj_ref =
+ test_obj_impl->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ // Give ownership of this object to POA.
+ test_obj_impl->_remove_ref (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ // Bind an object to the Naming Context.
+ CosNaming::Name test_name;
+ test_name.length (1);
+ test_name[0].id = CORBA::string_dup ("Foo");
+ root_context->bind (test_name,
+ test_obj_ref.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ ACE_DEBUG ((LM_DEBUG,
+ "Bound name OK\n"));
+
+ // Resolve the object from the Naming Context.
+ CORBA::Object_var result_obj_ref =
+ root_context->resolve (test_name
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ Test_Object_var result_object =
+ Test_Object::_narrow (result_obj_ref.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ if (!CORBA::is_nil (result_object.in ()))
+ {
+ CORBA::Short id = result_object->id (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ if (id == CosNaming_Client::OBJ1_ID)
+ ACE_DEBUG ((LM_DEBUG, "Resolved name OK\n"));
+ }
+
+ // Unbind the object from the Naming Context.
+ root_context->unbind (test_name
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ ACE_DEBUG ((LM_DEBUG,
+ "Unbound name OK\n"));
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Unexpected exception in Simple test");
+ return -1;
+ }
+ ACE_ENDTRY;
+ ACE_CHECK_RETURN (-1);
+
+ return 0;
+}
+
+int
+Tree_Test::execute (TAO_Naming_Client &root_context)
+{
+ ACE_DECLARE_NEW_CORBA_ENV;
+ ACE_TRY
+ {
+ // Create a tree of contexts: root->level1->level2. Bind object
+ // foo under context level2.
+
+ // Bind level1 context under root.
+ CosNaming::Name level1;
+ level1.length (1);
+ level1[0].id = CORBA::string_dup ("level1_context");
+ CosNaming::NamingContext_var level1_context;
+ level1_context = root_context->bind_new_context (level1
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ // Create a new context.
+ CosNaming::NamingContext_var level2_context;
+ level2_context = root_context->new_context (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ // Instantiate a dummy object and bind it under the new context.
+ My_Test_Object *impl1 =
+ new My_Test_Object (CosNaming_Client::OBJ1_ID);
+ Test_Object_var obj1 = impl1->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ impl1->_remove_ref (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ CosNaming::Name obj_name;
+ obj_name.length (1);
+ obj_name[0].id = CORBA::string_dup ("foo");
+ level2_context->bind (obj_name, obj1.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ // Bind the context we just created under level1.
+ CosNaming::Name level2 (level1);
+ level2.length (2);
+ level2[1].id = CORBA::string_dup ("level2_context");
+ root_context->bind_context (level2,
+ level2_context.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ // Resolve and unbind level1/level2/foo, and bind it back.
+ CosNaming::Name test_name (level2);
+ test_name.length (3);
+ test_name[2].id = obj_name[0].id;
+ CORBA::Object_var result_obj_ref =
+ root_context->resolve (test_name
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ Test_Object_var result_object =
+ Test_Object::_narrow (result_obj_ref.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ if (CORBA::is_nil (result_object.in ()))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Problems with resolving foo in Tree Test - nil object ref.\n"),
+ -1);
+
+ CORBA::Short id = result_object->id (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ if (id != CosNaming_Client::OBJ1_ID)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Problems with resolving foo in Tree Test - wrong id.\n"),
+ -1);
+
+ // Unbind the object from the Naming Context and bind it back
+ // in.
+ root_context->unbind (test_name
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ root_context->bind (test_name,
+ obj1.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ // Create new context and rebind under the name level1/level2.
+ CosNaming::NamingContext_var new_level2_context;
+ new_level2_context =
+ root_context->new_context (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ root_context->rebind_context (level2,
+ new_level2_context.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ // Bind, resolve, rebind, and resolve foo under level1/level2.
+ root_context->bind (test_name,
+ obj1.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ result_obj_ref = root_context->resolve (test_name
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ result_object = Test_Object::_narrow (result_obj_ref.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ CORBA::Short obj_id = result_object->id (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ if (CORBA::is_nil (result_object.in ())
+ || !(obj_id == CosNaming_Client::OBJ1_ID))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Problems in the Tree Test\n"),
+ -1);
+
+ My_Test_Object *impl2 =
+ new My_Test_Object (CosNaming_Client::OBJ2_ID);
+ Test_Object_var obj2 = impl2->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ impl2->_remove_ref (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ root_context->rebind (test_name,
+ obj2.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ result_obj_ref = root_context->resolve (test_name
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ result_object = Test_Object::_narrow (result_obj_ref.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ obj_id = result_object->id (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ if (CORBA::is_nil (result_object.in ())
+ || !( obj_id == CosNaming_Client::OBJ2_ID))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Problems with rebind in Tree Test\n"),
+ -1);
+ }
+
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Unexpected exception in Tree test");
+ return -1;
+ }
+
+ ACE_ENDTRY;
+ ACE_CHECK_RETURN (-1);
+
+ ACE_DEBUG ((LM_DEBUG,
+ "All functions work properly \n"));
+ return 0;
+}
+
+int
+Exceptions_Test::execute (TAO_Naming_Client &root_context)
+{
+ ACE_DECLARE_NEW_CORBA_ENV;
+ ACE_TRY
+ {
+ // Set things up.
+
+ // Create a tree of contexts root->level1->level2.
+ CosNaming::Name context_name;
+ context_name.length (1);
+ context_name[0].id = CORBA::string_dup ("level1_context");
+ CosNaming::NamingContext_var level1_context;
+ level1_context = root_context->bind_new_context (context_name
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ context_name[0].id = CORBA::string_dup ("level2_context");
+ CosNaming::NamingContext_var level2_context;
+ level2_context = level1_context->bind_new_context (context_name
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ // Bind a dummy object foo under each context.
+ My_Test_Object *impl = new My_Test_Object;
+ Test_Object_var obj = impl->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ impl->_remove_ref (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ CosNaming::Name object_name;
+ object_name.length (1);
+ object_name[0].id = CORBA::string_dup ("foo");
+ root_context->bind (object_name,
+ obj.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ level1_context->bind (object_name,
+ obj.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ level2_context->bind (object_name,
+ obj.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ // Run exceptions tests.
+ invalid_name_test (root_context
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ already_bound_test (root_context
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ already_bound_test2 (root_context
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ not_found_test (root_context
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ not_found_test2 (root_context
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ not_found_test3 (root_context
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Unexpected exception in Exceptions test");
+ return -1;
+ }
+ ACE_ENDTRY;
+ ACE_CHECK_RETURN (-1);
+
+ return 0;
+}
+
+void
+Exceptions_Test::invalid_name_test (TAO_Naming_Client &root_context
+ ACE_ENV_ARG_DECL)
+{
+ ACE_TRY
+ {
+ CosNaming::Name test_name;
+ test_name.length (0);
+
+ root_context->resolve (test_name
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ ACE_DEBUG ((LM_DEBUG, "Invalid name test failed\n"));
+ }
+ ACE_CATCH (CosNaming::NamingContext::InvalidName, ex)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "InvalidName exception works properly\n"));
+ }
+ ACE_CATCHANY
+ {
+ ACE_DEBUG ((LM_DEBUG, "Invalid name test failed\n"));
+ ACE_RE_THROW;
+ }
+ ACE_ENDTRY;
+ ACE_CHECK;
+}
+
+void
+Exceptions_Test::already_bound_test (TAO_Naming_Client &root_context
+ ACE_ENV_ARG_DECL)
+{
+ ACE_TRY
+ {
+ CosNaming::Name test_name;
+ test_name.length (1);
+ test_name[0].id = CORBA::string_dup ("foo");
+ My_Test_Object *impl = new My_Test_Object;
+ Test_Object_var obj = impl->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ impl->_remove_ref (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ root_context->bind (test_name,
+ obj.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ ACE_DEBUG ((LM_DEBUG, "Already bound (case 1) test failed\n"));
+ }
+ ACE_CATCH (CosNaming::NamingContext::AlreadyBound, ex)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "AlreadyBound exception (case 1) works properly\n"));
+ }
+ ACE_CATCHANY
+ {
+ ACE_DEBUG ((LM_DEBUG, "Already bound (case 1) test failed\n"));
+ ACE_RE_THROW;
+ }
+
+ ACE_ENDTRY;
+ ACE_CHECK;
+}
+
+void
+Exceptions_Test::already_bound_test2 (TAO_Naming_Client &root_context
+ ACE_ENV_ARG_DECL)
+{
+ ACE_TRY
+ {
+ CosNaming::Name test_name;
+ test_name.length (2);
+ test_name[0].id = CORBA::string_dup ("level1_context");
+ test_name[1].id = CORBA::string_dup ("foo");
+ My_Test_Object *impl = new My_Test_Object;
+ Test_Object_var obj = impl->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ impl->_remove_ref (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ root_context->bind (test_name,
+ obj.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ ACE_DEBUG ((LM_DEBUG, "Already bound (case 2) test failed\n"));
+ }
+ ACE_CATCH (CosNaming::NamingContext::AlreadyBound, ex)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "AlreadyBound exception (case 2) works properly\n"));
+ }
+ ACE_CATCHANY
+ {
+ ACE_DEBUG ((LM_DEBUG, "Already bound (case 2) test failed\n"));
+ ACE_RE_THROW;
+ }
+ ACE_ENDTRY;
+ ACE_CHECK;
+}
+
+void
+Exceptions_Test::not_found_test (TAO_Naming_Client &root_context
+ ACE_ENV_ARG_DECL)
+{
+ ACE_TRY
+ {
+ CosNaming::Name test_name;
+ test_name.length (3);
+ test_name[0].id = CORBA::string_dup ("level1_context");
+ test_name[1].id = CORBA::string_dup ("level2_context");
+ test_name[2].id = CORBA::string_dup ("bar");
+
+ root_context->unbind (test_name
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ ACE_DEBUG ((LM_DEBUG, "Not found test failed\n"));
+ }
+ ACE_CATCH (CosNaming::NamingContext::NotFound, ex)
+ {
+ if (ex.why == CosNaming::NamingContext::missing_node &&
+ ex.rest_of_name.length () == 1
+ && ACE_OS::strcmp (ex.rest_of_name[0].id.in (),
+ "bar") == 0)
+ ACE_DEBUG ((LM_DEBUG,
+ "NotFound exception (case 1) works properly\n"));
+ else
+ ACE_DEBUG ((LM_DEBUG,
+ "NotFound exception (case 1)"
+ " - parameters aren't set correctly\n"));
+ }
+ ACE_CATCHANY
+ {
+ ACE_DEBUG ((LM_DEBUG, "Not found test failed\n"));
+ ACE_RE_THROW;
+ }
+ ACE_ENDTRY;
+ ACE_CHECK;
+}
+
+void
+Exceptions_Test::not_found_test2 (TAO_Naming_Client &root_context
+ ACE_ENV_ARG_DECL)
+{
+ ACE_TRY
+ {
+ CosNaming::Name test_name;
+ test_name.length (3);
+ test_name[0].id = CORBA::string_dup ("level1_context");
+ test_name[1].id = CORBA::string_dup ("level3_context");
+ test_name[2].id = CORBA::string_dup ("foo");
+
+ root_context->unbind (test_name
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ ACE_DEBUG ((LM_DEBUG, "Unbind test failed\n"));
+ }
+ ACE_CATCH (CosNaming::NamingContext::NotFound, ex)
+ {
+ if (ex.why == CosNaming::NamingContext::missing_node
+ && ex.rest_of_name.length () == 2
+ && ACE_OS::strcmp (ex.rest_of_name[0].id.in (),
+ "level3_context") == 0
+ && ACE_OS::strcmp (ex.rest_of_name[1].id.in (),
+ "foo") == 0)
+ ACE_DEBUG ((LM_DEBUG,
+ "NotFound exception (case 2) works properly\n"));
+ else
+ ACE_DEBUG ((LM_DEBUG,
+ "NotFound exception (case 2)"
+ " - parameters aren't set correctly\n"));
+ }
+ ACE_CATCHANY
+ {
+ ACE_DEBUG ((LM_DEBUG, "Unbind test failed\n"));
+ ACE_RE_THROW;
+ }
+
+ ACE_ENDTRY;
+ ACE_CHECK;
+}
+
+void
+Exceptions_Test::not_found_test3 (TAO_Naming_Client &root_context
+ ACE_ENV_ARG_DECL)
+{
+ ACE_TRY
+ {
+ CosNaming::Name test_name;
+ test_name.length (3);
+ test_name[0].id = CORBA::string_dup ("level1_context");
+ test_name[1].id = CORBA::string_dup ("foo");
+ test_name[2].id = CORBA::string_dup ("foo");
+
+ root_context->unbind (test_name ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ ACE_DEBUG ((LM_DEBUG, "Not found (case 3) test failed - no exception was thrown\n"));
+ }
+ ACE_CATCH (CosNaming::NamingContext::NotFound, ex)
+ {
+ if (ex.why == CosNaming::NamingContext::not_context
+ && ex.rest_of_name.length () == 2
+ && ACE_OS::strcmp (ex.rest_of_name[0].id.in (),
+ "foo") == 0
+ && ACE_OS::strcmp (ex.rest_of_name[1].id.in (),
+ "foo") == 0)
+ ACE_DEBUG ((LM_DEBUG,
+ "NotFound exception (case 3) works properly\n"));
+ else
+ ACE_DEBUG ((LM_DEBUG,
+ "NotFound exception (case 3)"
+ " - parameters aren't set correctly\n"));
+ }
+ ACE_CATCHANY
+ {
+ ACE_DEBUG ((LM_DEBUG, "Not found (case 3) test failed\n"));
+ ACE_RE_THROW;
+ }
+ ACE_ENDTRY;
+ ACE_CHECK;
+}
+
+int
+Iterator_Test::execute (TAO_Naming_Client &root_context)
+{
+ ACE_DECLARE_NEW_CORBA_ENV;
+ ACE_TRY
+ {
+ // Instantiate four dummy objects.
+ My_Test_Object *impl = new My_Test_Object;
+ Test_Object_var obj = impl->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ impl->_remove_ref (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ // Bind objects to the naming context.
+ CosNaming::Name name1;
+ name1.length (1);
+ name1[0].id = CORBA::string_dup ("foo1");
+ CosNaming::Name name2;
+ name2.length (1);
+ name2[0].id = CORBA::string_dup ("foo2");
+ CosNaming::Name name3;
+ name3.length (1);
+ name3[0].id = CORBA::string_dup ("foo3");
+ CosNaming::Name name4;
+ name4.length (1);
+ name4[0].id = CORBA::string_dup ("foo4");
+ root_context->bind (name1,
+ obj.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ root_context->bind (name2,
+ obj.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ root_context->bind (name3,
+ obj.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ root_context->bind (name4,
+ obj.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ // List the content of the Naming Context.
+ CosNaming::BindingIterator_var iter;
+ CosNaming::BindingList_var bindings_list;
+ root_context->list (1,
+ bindings_list.out (),
+ iter.out ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ if (CORBA::is_nil (iter.in ())
+ || bindings_list->length () != 1
+ || bindings_list[0u].binding_type != CosNaming::nobject)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "CosNaming::list does not function properly\n"),
+ -1);
+ ACE_DEBUG ((LM_DEBUG,
+ "First binding: %s\n",
+ bindings_list[0u].binding_name[0u].id.in ()));
+
+ // Invoke operations on the iterator.
+ CosNaming::Binding_var binding;
+ iter->next_one (binding.out ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ if (binding->binding_type != CosNaming::nobject)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "CosNaming::next_one does not function properly\n"),
+ -1);
+ ACE_DEBUG ((LM_DEBUG,
+ "Second binding: %s\n",
+ binding->binding_name[0].id.in ()));
+
+ iter->next_n (2, bindings_list.out () ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ if (bindings_list->length () != 2
+ || bindings_list[0u].binding_type != CosNaming::nobject
+ || bindings_list[1u].binding_type != CosNaming::nobject)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "CosNaming::BindingIterator does not function properly\n"),
+ -1);
+ ACE_DEBUG ((LM_DEBUG,
+ "Third binding: %s\n"
+ "Fourth binding: %s\n",
+ bindings_list[0u].binding_name[0].id.in (),
+ bindings_list[1u].binding_name[0].id.in ()));
+
+ // We already iterated over all the bindings, so the following
+ // should return false.
+ CORBA::Boolean result = iter->next_one (binding.out ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ if (result)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "CosNaming::BindingIterator does not function properly\n"),
+ -1);
+ iter->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Unexpected exception in Iterator test");
+ return -1;
+ }
+ ACE_ENDTRY;
+ ACE_CHECK_RETURN (-1);
+
+ return 0;
+}
+
+int
+Destroy_Test::execute (TAO_Naming_Client &root_context)
+{
+ ACE_DECLARE_NEW_CORBA_ENV;
+ ACE_TRY
+ {
+ // Create a context and bind an object under it.
+
+ CosNaming::NamingContext_var my_context;
+ my_context = root_context->new_context (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ // Bind a dummy object foo under my_context.
+ My_Test_Object *impl = new My_Test_Object;
+ Test_Object_var obj = impl->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ impl->_remove_ref (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ CosNaming::Name object_name;
+ object_name.length (1);
+ object_name[0].id = CORBA::string_dup ("foo");
+ my_context->bind (object_name,
+ obj.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ // Do the testing.
+ not_empty_test (my_context
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ my_context->unbind (object_name ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ my_context->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ not_exist_test (my_context
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
+
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Unexpected exception in Destroy test");
+ return -1;
+ }
+ ACE_ENDTRY;
+ ACE_CHECK_RETURN (-1);
+
+ return 0;
+}
+
+void
+Destroy_Test::not_empty_test (CosNaming::NamingContext_var &ref
+ ACE_ENV_ARG_DECL)
+{
+ ACE_TRY
+ {
+ ref->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
+
+ ACE_CATCH (CosNaming::NamingContext::NotEmpty, ex)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "NotEmpty exception works properly\n"));
+ }
+ ACE_ENDTRY;
+ ACE_CHECK;
+}
+
+void
+Destroy_Test::not_exist_test (CosNaming::NamingContext_var &ref
+ ACE_ENV_ARG_DECL)
+{
+ ACE_TRY
+ {
+ ref->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
+
+ ACE_CATCH (CORBA::OBJECT_NOT_EXIST, ex)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Destroy works properly\n"));
+ }
+ ACE_ENDTRY;
+ ACE_CHECK;
+}
+
+Persistent_Test_Begin::Persistent_Test_Begin (CORBA::ORB_ptr orb,
+ FILE * ior_output_file)
+ : orb_ (orb),
+ file_ (ior_output_file)
+{
+}
+
+Persistent_Test_Begin::~Persistent_Test_Begin (void)
+{
+}
+
+int
+Persistent_Test_Begin::execute (TAO_Naming_Client &root_context)
+{
+ ACE_DECLARE_NEW_CORBA_ENV;
+ ACE_TRY
+ {
+ // Create a name structure we will reuse.
+ CosNaming::Name test_name;
+ test_name.length (1);
+ test_name[0].id = CORBA::string_dup ("level1");
+
+ // Create and bind a naming context under the <root> context.
+ CosNaming::NamingContext_var level1_context =
+ root_context->bind_new_context (test_name
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ // Create and bind a naming context under <level1> context.
+ test_name[0].id = CORBA::string_dup ("level2");
+ CosNaming::NamingContext_var level2_context =
+ level1_context->bind_new_context (test_name
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ // Log the ior of <level1_context> for use by <Persistent_Test_End>.
+ CORBA::String_var ior =
+ orb_->object_to_string (level1_context.in () ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ ACE_OS::fprintf (this->file_,
+ "%s",
+ ior.in ());
+ ACE_OS::fclose (this->file_);
+
+ ACE_DEBUG ((LM_DEBUG, "Persistent Naming test (part 1) OK.\n"));
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ "Unexpected exception in Persistent Test (part 1)");
+ return -1;
+ }
+ ACE_ENDTRY;
+ ACE_CHECK_RETURN (-1);
+
+ return 0;
+}
+
+Persistent_Test_End::Persistent_Test_End (CORBA::ORB_ptr orb,
+ const char *ior)
+ : orb_ (orb),
+ ior_ (ior)
+{
+}
+
+Persistent_Test_End::~Persistent_Test_End (void)
+{
+}
+
+int
+Persistent_Test_End::execute (TAO_Naming_Client &root_context)
+{
+ ACE_DECLARE_NEW_CORBA_ENV;
+ ACE_TRY
+ {
+ // Create a name structure we will reuse.
+ CosNaming::Name test_name;
+ test_name.length (1);
+ test_name[0].id = CORBA::string_dup ("level2");
+
+ // Convert stringified ior we got from <Persistent_Test_Begin>
+ // for <level1> Naming Context to Naming Context reference.
+ CORBA::Object_var obj =
+ orb_->string_to_object (ior_ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ CosNaming::NamingContext_var level1_context =
+ CosNaming::NamingContext::_narrow (obj.in () ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ if (CORBA::is_nil (level1_context.in ()))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Cannot narrow object to Naming Context\n"),
+ -1);
+
+ // Resolve for <level2> context through the persistent ior we
+ // got from part 1 of this test.
+ obj = level1_context->resolve (test_name ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ // Now, resolve for <level2> context using the <root> context
+ // reference which we obtained through <resolve_initial_references>.
+ test_name.length (2);
+ test_name[0].id = CORBA::string_dup ("level1");
+ test_name[1].id = CORBA::string_dup ("level2");
+ CORBA::Object_var obj2 =
+ root_context->resolve (test_name ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ // Make sure we got the same answer through both methods.
+ if (obj2->_is_equivalent (obj.in ()))
+ ACE_DEBUG ((LM_DEBUG, "Persistent Naming test (part 2) OK.\n"));
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ "Unexpected exception in Persistent Test (part 2)");
+ return -1;
+ }
+ ACE_ENDTRY;
+ ACE_CHECK_RETURN (-1);
+
+ return 0;
+}
+
+// This function runs the test.
+
+int
+main (int argc, char **argv)
+{
+ CosNaming_Client cosnaming_client;
+
+ if (cosnaming_client.init (argc, argv) == -1)
+ return 1;
+
+ return cosnaming_client.run ();
+}
diff --git a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/client.h b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/client.h
new file mode 100644
index 00000000000..15eb7fe577e
--- /dev/null
+++ b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/client.h
@@ -0,0 +1,334 @@
+/* -*- C++ -*- */
+// $Id$
+
+// ============================================================================
+//
+// = LIBRARY
+// TAO/orbsvcs/tests
+//
+// = FILENAME
+// client.h
+//
+// = DESCRIPTION
+// This class tests the facilities to connect to the naming service.
+//
+// = AUTHORS
+// Marina Spivak <marina@cs.wustl.edu>
+//
+// ============================================================================
+
+#include "test_objectS.h"
+#include "orbsvcs/CosNamingC.h"
+#include "orbsvcs/Naming/Naming_Client.h"
+#include "tao/PortableServer/ORB_Manager.h"
+#include "ace/Task.h"
+
+class Naming_Test
+{
+ // = TITLE
+ // This is an abstract class which is subclassed
+ // to create different Naming Service tests.
+ //
+ // = DESCRIPTION
+ // This is a basic example of the "Strategy" pattern. This class
+ // provides a common interface for different tests (or
+ // "strategies"), so that a specific test to be used can be
+ // chosen at runtime.
+
+public:
+ virtual int execute (TAO_Naming_Client &root_context) = 0;
+ // Execute the test code. <root_context> is the context to assume
+ // as the root for all tests operations.
+};
+
+class Simple_Test : public Naming_Test
+{
+ // = TITLE
+ // This class implements a simple Naming Service test.
+ //
+ // = DESCRIPTION
+ // The test binds(), resolves(), and unbinds() an object
+ // reference from the given Naming Context.
+public:
+ virtual int execute (TAO_Naming_Client &root_context);
+ // Execute the simple test code.
+};
+
+class MT_Test : public Naming_Test, public ACE_Task_Base
+{
+ // = TITLE
+ // This class implements a simple Multithreaded (multiclient) Naming Service test.
+ //
+ // = DESCRIPTION
+ // The test spawns multiple threads: each attempts to
+ // bind(), resolve(), and unbind() an object
+ // reference using the same name, and the same Naming Context.
+public:
+ // = Initialization and termination methods.
+
+ MT_Test (CORBA::ORB_ptr orb,
+ int size = 10);
+ // Constructor. Takes in an orb pointer and number of threads to spawn.
+
+ virtual int execute (TAO_Naming_Client &root_context);
+ // Execute the MT test code.
+
+ virtual int svc (void);
+ // This code is executed by each thread.
+
+private:
+ int size_;
+ // Number of threads to spawn. By default is set to 10.
+
+ CORBA::ORB_var orb_;
+ // A pointer to our ORB.
+
+ char* name_service_ior_;
+ // IOR in the string format for Naming Service we are to deal with.
+ // Each thread will use string_to_object() and this IOR to create
+ // its own NamingContext stub for invoking operations on the
+ // Naming Service. If all threads try to use the same stub, bad things
+ // happen...
+
+ // This can be replaced with CORBA::String_var when <string_to_object>
+ // is fixed - this will clean up the memory properly.
+
+ CosNaming::Name test_name_;
+ // Holds name used for registering the object with Naming Service.
+
+ Test_Object_var test_ref_;
+ // Holds object to be registered with the Naming Service by each thread.
+
+};
+
+class Tree_Test : public Naming_Test
+{
+ // = TITLE
+ // This class implements a test of all Naming Service functions
+ // on a tree of Naming Contexts.
+ //
+ // = DESCRIPTION
+ // Bind_context() under the root context with the name level1.
+ // Create_new_context(), bind() foo object into it, and
+ // bind the context into root/level1 under the name level2.
+ // Resolve (root/level1/level2/foo).
+ // Unbind (root/level1/level2/foo).
+ // Bind (root/level1/level2/foo, obj)
+ // Create_new_context()
+ // and invoke rebind_context() to substitute it for the current
+ // level2 context.
+ // Bind (root/level1/level2/foo, obj)
+ // Resolve (root/level1/level2/foo).
+ // Rebind() to have a different object under the name bar.
+ // Resolve (root/level1/level2/foo) to make sure correct reference is returned.
+public:
+ virtual int execute (TAO_Naming_Client &root_context);
+ // Execute the tree test code.
+};
+
+class Iterator_Test : public Naming_Test
+{
+ // = TITLE
+ // This class implements a test of Naming Service functions
+ // which involve BindingIterator.
+ //
+ // = DESCRIPTION
+ // The test binds foo1, foo2, foo3, and foo4 objects to the
+ // Naming Context. It lists() one binding and receives
+ // BindingIterator to iterate over the rest of the bindings. It
+ // then invokes next_one(), next_n(2), next_one(), and destroy()
+ // on the iterator.
+public:
+ virtual int execute (TAO_Naming_Client &root_context);
+ // Execute the iterator test code.
+};
+
+class Exceptions_Test : public Naming_Test
+{
+ // = TITLE
+ // This class implements a test of exceptions in the Naming Service.
+ //
+ // = DESCRIPTION
+ // Makes sure that Naming Service throws exceptions as expected, and
+ // data inside exceptions is set correctly. The test creates a tree of
+ // of Naming Contexts: root context -> level1 -> level2. It then binds() an
+ // object with the name foo to each of Naming Contexts in the tree.
+ // Invoke resolve() with a Name of length 0 - make sure we get InvalidName exception.
+ // Invoke bind( foo, obj) on root context - make sure we get AlreadyBound exception.
+ // Invoke bind( level1/foo, obj) on root context - make sure we get AlreadyBound exc.
+ // Invoke unbind( level1/level2/bar) on root context - make sure we get NotFound exc.
+ // with why = not_object, rest_of_name = bar.
+ // Invoke unbind( level1/level3/foo) on root context - make sure we get NotFound exc.
+ // with why = missing_node, rest_of_name = level3/foo.
+ // Invoke unbind( level1/foo/foo) on root context - make sure we get NotFound exc.
+ // with why = not_context, rest_of_name = foo/foo.
+public:
+ virtual int execute (TAO_Naming_Client &root_context);
+ // Execute the exceptions test code.
+
+private:
+ // the following functions isolate specific tests due to the
+ // limitation of only 1 TAO_TRY being allowed per function.
+
+ void invalid_name_test (TAO_Naming_Client &root_context
+ ACE_ENV_ARG_DECL);
+ void already_bound_test (TAO_Naming_Client &root_context
+ ACE_ENV_ARG_DECL);
+ void already_bound_test2 (TAO_Naming_Client &root_context
+ ACE_ENV_ARG_DECL);
+ void not_found_test (TAO_Naming_Client &root_context
+ ACE_ENV_ARG_DECL);
+ void not_found_test2 (TAO_Naming_Client &root_context
+ ACE_ENV_ARG_DECL);
+ void not_found_test3 (TAO_Naming_Client &root_context
+ ACE_ENV_ARG_DECL);
+};
+
+class Destroy_Test : public Naming_Test
+{
+ // = TITLE
+ // This class implements a test of destroy() function
+ // in the Naming Service.
+ //
+ // = DESCRIPTION
+ // Create a context and bind an object under it.
+ // Attempt to destroy the context - NotEmpty exception should be raised.
+ //
+ // Unbind the object and call destroy on the context.
+ // Attempt to call destroy on the object again - OBJECT_NOT_EXIST
+ // exception should be raised.
+ //
+public:
+ virtual int execute (TAO_Naming_Client &root_context);
+ // Execute the destroy test code.
+
+private:
+ // = The following functions isolate specific tests.
+ void not_empty_test (CosNaming::NamingContext_var &ref
+ ACE_ENV_ARG_DECL);
+ void not_exist_test (CosNaming::NamingContext_var &ref
+ ACE_ENV_ARG_DECL);
+};
+
+class Persistent_Test_Begin : public Naming_Test
+{
+ // = TITLE
+ // This class implements the first part of the Persistent Naming
+ // Service test.
+ //
+ // = DESCRIPTION
+ // This test creates the Naming Context hierarchy:
+ // root -> level1_context -> level2_context,
+ // and prints out the ior of the <level1_context>.
+public:
+ // = Initialization and termination methods.
+
+ Persistent_Test_Begin (CORBA::ORB_ptr orb,
+ FILE * ior_output_file);
+ // Constructor. Takes in an orb pointer.
+
+ virtual ~Persistent_Test_Begin (void);
+ // Destructor.
+
+ virtual int execute (TAO_Naming_Client &root_context);
+ // Execute the persistent test (part 1) code.
+
+private:
+
+ CORBA::ORB_var orb_;
+ // A pointer to our ORB (needed for object/string conversion).
+
+ FILE *file_;
+ // File where we output the ior for use by part 2 of persistent test.
+};
+
+class Persistent_Test_End : public Naming_Test
+{
+ // = TITLE
+ // This class implements the second part of the Persistent Naming
+ // Service test.
+ //
+ // = DESCRIPTION
+ // This test attempts to resolve <level2_context> both through the
+ // <root> Naming Context, which it gets from <resolve_initial_references>, and
+ // through <level1_context> stringified ior, which it gets from part 1 of
+ // the persistent test. The results of both methods are then
+ // compared for equality.
+public:
+ // = Initialization and termination methods.
+
+ Persistent_Test_End (CORBA::ORB_ptr orb,
+ const char * ior);
+ // Constructor. Takes in an orb pointer and the ior received from
+ // <Persistent_Test_Begin>.
+
+ virtual ~Persistent_Test_End (void);
+ // Destructor.
+
+ virtual int execute (TAO_Naming_Client &root_context);
+ // Execute the persistent test (part 2).
+
+private:
+
+ CORBA::ORB_var orb_;
+ // A pointer to our ORB (used for string/object conversion).
+
+ const char* ior_;
+ // IOR of <level1_context> recorded during the run of part 1 of
+ // persistent test.
+};
+
+class CosNaming_Client
+{
+ // = TITLE,
+ // Defines a class that encapsulates behaviour of the CosNaming
+ // client example. Provides a better understanding of the logic
+ // in an object-oriented way.
+ //
+ // = DESCRIPTION
+ // This class declares an interface to run the example client for
+ // CosNaming CORBA server. All the complexity for initializing
+ // the server is hidden in the class. Just the <run> interface
+ // is needed.
+public:
+ // = Initialization and termination methods.
+
+ CosNaming_Client (void);
+ // Constructor.
+
+ ~CosNaming_Client (void);
+ // Destructor.
+
+ int run (void);
+ // Execute client example code.
+
+ int init (int argc, char **argv);
+ // Initialize the client communication endpoint with server.
+
+ // = Symbolic ids.
+ enum OBJ_ID
+ {
+ OBJ1_ID = 5,
+ OBJ2_ID = 6
+ };
+
+private:
+ int parse_args (void);
+ // Parses the arguments passed on the command line.
+
+ int argc_;
+ // # of arguments on the command line.
+
+ char **argv_;
+ // arguments from command line.
+
+ Naming_Test *test_;
+ // A pointer to the specific Naming Service test a client will
+ // execute.
+
+ TAO_ORB_Manager orbmgr_;
+ // Our ORB manager helper class.
+
+ TAO_Naming_Client naming_client_;
+ // Our naming client helper class.
+};
diff --git a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/corbaloc_ssliop.mpc b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/corbaloc_ssliop.mpc
new file mode 100644
index 00000000000..97620a0feb0
--- /dev/null
+++ b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/corbaloc_ssliop.mpc
@@ -0,0 +1,9 @@
+// -*- MPC -*-
+// $Id$
+
+project(*Client) : namingexe, portableserver {
+ Source_Files {
+ client.cpp
+ }
+}
+
diff --git a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/pvtkey-client.pem b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/pvtkey-client.pem
new file mode 100644
index 00000000000..cf53308cae2
--- /dev/null
+++ b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/pvtkey-client.pem
@@ -0,0 +1,16 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIICXwIBAAKBgQD3LcZOo8tF7BHEYMsm5pn3zYV+u6NhhvPC5G5bErY8qi8Xt4CZ
+PSQPm4JmVFvLsY2H6Eme8Oe7j4bCquRuB1D/U5auKdINQ1aG2CgKqPtBy1SliHE3
+FD1Ht43O+z2mRzGHtqLowhEvFEpEVHcJLUQ7HVHPJaRNQkn80DA/nN9+5wIDAQAB
+AoGBANpBJPWTU43uINIR1dAHlrRkWRfKfz1CeEMCiR8JqrhuXR7H/VlRz2Goor/Q
+hS2bHal/xmH9veCznv6M/x7Yfv74hhUJxyqngNxbwGI4G+LfR3/x1fqVcweDGmv6
+LYLL4JWyDLEL5I3PEZP/dUnT6+bmmuXWU5z83itqYw8VRbsBAkEA/MnqXFlWl1KF
+jTee5pijKOXGAvllrpN8MkTKM2MdjltzOkuhC1OEwhXYy86e90gRQvXAs3t7A4dT
+Q5/eUYHgYQJBAPpRnYcqqDP0Rj/JqMDapwIVjMoMDQP+thB4Ey6fSRC7dYiX4+Qo
+cyX8j0YnF0RYl426+Qv2O6egmOmzrQwQxEcCQQDAfUBocd7t+3iWv/PPxAr56X2O
+Zjp3ZPb9kEQoPSEUda6YhV5sMXy2Dcy35O5Hfikmw9uo0C4r0bAlnma7yhoBAkEA
+tI0/6ansDyVnskTbktdj1Q4EMgxFKxeC7RgfBebghdAg87hTKVO/0qt8EGbL0oFw
+N0ugrW8bEkq1YQQ3kldZqwJBAJPIe/NE+NhSOoSo3kEQ70SkjU5EB2sbVxhjq6ci
+UdXa+EOAna5JS5ZFMDq4AI+qU8OoSgI26hdH5S8lf10fIDo=
+-----END RSA PRIVATE KEY-----
+
diff --git a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/pvtkey.pem b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/pvtkey.pem
new file mode 100644
index 00000000000..81ba8e3f968
--- /dev/null
+++ b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/pvtkey.pem
@@ -0,0 +1,10 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIBOwIBAAJBAPXZ7YNyFU8T8PVitNwZmdwuc4tG64V/lDYHnmzolmFPQ6gvI2uo
+KBQeHeJFPI6LJ5TGb8hCnypy+zbc+pve8vECAwEAAQJAE/fmZbW/a1PYT2X8AKCH
+sa2ILvjMqmQpWpYV1QyzIiYQPEmQ/5GMUj/t3PZd/17BOH8aPakBT/c1Gp+os6vR
+zQIhAP2RDmm6UyMrJhAtAcNC5s8nbfhKPG80Q0DZ2kiodjQfAiEA+DXqwEZlCh0j
+VPzEXY7vrdQa641zQ5XIX1S/+WbCdu8CIDT9m4V86uLuoYW/4h5sXM/t7Y119itH
+QMbMwFFu40UBAiEA9z+mN6An2BpMbsVXyiavREYMBuahkgprTeM7VHHzdssCIQCY
+QEgmpzGzfdZoREy9B7ooNeRO919lR9qvbte9vvJvWQ==
+-----END RSA PRIVATE KEY-----
+
diff --git a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/run_test.pl b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/run_test.pl
new file mode 100755
index 00000000000..a63768a2dc3
--- /dev/null
+++ b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/run_test.pl
@@ -0,0 +1,161 @@
+eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
+ & eval 'exec perl -S $0 $argv:q'
+ if 0;
+
+# $Id$
+# -*- perl -*-
+
+# This is a Perl script that runs some Naming Service tests.
+# It runs all the tests that will run with min CORBA.
+# It starts all the servers and clients as necessary.
+
+use lib '../../../../../bin';
+use PerlACE::Run_Test;
+
+# Amount of delay (in seconds) between starting a server and a client
+# to allow proper server initialization.
+$sleeptime = 10;
+
+# The default host name.
+$TARGETHOSTNAME = "localhost";
+
+$quiet = 0;
+$use_ssl = 1;
+$debug_level = 0;
+
+while (my $argument = shift) {
+ if ($argument eq '-q') {
+ $quiet = 1;
+ next;
+ }
+ if ($argument eq '-d') {
+ $debug_level = shift;
+ next;
+ }
+ print STDERR "Unknown: $argument\nUsage $0 [-q] [-d n]\n";
+ exit(-1);
+}
+
+# Variables for command-line arguments to client and server
+# executables.
+$ns_multicast_port = 10001 + PerlACE::uniqueid (); # Can not be 10000 on Chorus 4.0
+$ns_orb_port = 12000 + PerlACE::uniqueid ();
+$ns_ssl_port = 14000 + PerlACE::uniqueid ();
+$iorfile = PerlACE::LocalFile ("ns.ior");
+$persistent_ior_file = PerlACE::LocalFile ("pns.ior");
+$persistent_log_file = PerlACE::LocalFile ("test_log");
+$data_file = PerlACE::LocalFile ("test_run.data");
+
+$status = 0;
+
+sub name_server
+{
+ my $args = "-ORBNameServicePort $ns_multicast_port -o $iorfile -m 1 @_";
+ my $prog = "../../../Naming_Service/Naming_Service";
+ $NS = new PerlACE::Process ($prog, $args);
+
+ unlink $iorfile;
+
+ print STDERR "CommandLine: server " . $NS->Arguments() . "\n\n" unless $quiet;
+ $NS->Spawn ();
+
+ if (PerlACE::waitforfile_timed ($iorfile, $sleeptime) == -1) {
+ print STDERR "ERROR: cannot find IOR file <$iorfile>\n";
+ $NS->Kill ();
+ exit 1;
+ }
+}
+
+sub client
+{
+ my $args = "@_"." ";
+ my $prog = "client";
+
+ $CL = new PerlACE::Process ($prog, $args);
+
+ print STDERR "CommandLine: client " . $CL->Arguments() . "\n\n" unless $quiet;
+ $client = $CL->SpawnWaitKill (60);
+
+ if ($client != 0) {
+ print STDERR "ERROR: client returned $client\n";
+ $status = 1;
+ }
+}
+
+## The options below have been reordered due to a
+## initialization problem (within the Naming_Service)
+## that has only been seen on Windows XP.
+
+$orb_debug_level = ($quiet || $debug_level == 0) ? "" : "-ORBDebugLevel $debug_level";
+
+# Options for all simple tests recognized by the 'client' program.
+@opts = (
+ "-s -ORBInitRef NameService=corbaloc:ssliop:$TARGETHOSTNAME:$ns_ssl_port/NameService"
+ . " -ORBSvcConf client.conf $orb_debug_level",
+ "-t -ORBInitRef NameService=corbaloc:ssliop:$TARGETHOSTNAME:$ns_ssl_port/NameService"
+ . " -ORBSvcConf client.conf $orb_debug_level",
+ "-i -ORBInitRef NameService=corbaloc:ssliop:$TARGETHOSTNAME:$ns_ssl_port/NameService"
+ . " -ORBSvcConf client.conf $orb_debug_level",
+ "-e -ORBInitRef NameService=corbaloc:ssliop:$TARGETHOSTNAME:$ns_ssl_port/NameService"
+ . " -ORBSvcConf client.conf $orb_debug_level",
+ "-y -ORBInitRef NameService=corbaloc:ssliop:$TARGETHOSTNAME:$ns_ssl_port/NameService"
+ . " -ORBSvcConf client.conf $orb_debug_level",
+
+ );
+
+@server_opts = (
+ "-ORBEndpoint iiop://$TARGETHOSTNAME:$ns_orb_port/ssl_port=$ns_ssl_port"
+ . " -ORBSvcConf server.conf $orb_debug_level",
+ "-ORBEndpoint iiop://$TARGETHOSTNAME:$ns_orb_port/ssl_port=$ns_ssl_port"
+ . " -ORBSvcConf server.conf $orb_debug_level",
+ "-ORBEndpoint iiop://$TARGETHOSTNAME:$ns_orb_port/ssl_port=$ns_ssl_port"
+ . " -ORBSvcConf server.conf $orb_debug_level",
+ "-ORBEndpoint iiop://$TARGETHOSTNAME:$ns_orb_port/ssl_port=$ns_ssl_port"
+ . " -ORBSvcConf server.conf $orb_debug_level",
+ "-ORBEndpoint iiop://$TARGETHOSTNAME:$ns_orb_port/ssl_port=$ns_ssl_port"
+ . " -ORBSvcConf server.conf $orb_debug_level",
+
+ );
+
+@comments = (
+ "(SSL) Simple Test:",
+ "(SSL) Tree Test:",
+ "(SSL) Iterator Test:",
+ "(SSL) Exceptions Test:",
+ "(SSL) Destroy Test:",
+ );
+
+$test_number = 0;
+
+unlink ($persistent_ior_file, $persistent_log_file);
+
+# Run server and client for each of the tests. Client uses ior in a
+# file to bootstrap to the server.
+foreach $o (@opts) {
+
+ print STDERR "\n " . $comments[$test_number];
+ if ($use_ssl == 0 && $comments[$test_number] =~ /SSL/) {
+ print STDERR " - Skipping, use -s to run the SSL tests";
+ next;
+ }
+
+ print STDERR "\n";
+ name_server ($server_opts[$test_number]);
+ client ($o);
+
+ $NS->Kill ();
+
+ ## For some reason, only on Windows XP, we need to
+ ## wait before starting another Naming_Service when
+ ## the mmap persistence option is used
+ if ($^O eq "MSWin32") {
+ sleep(1);
+ }
+
+ $test_number++;
+}
+
+unlink ($persistent_ior_file, $persistent_log_file);
+unlink $iorfile;
+
+exit $status;
diff --git a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/selfsigncert-client.pem b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/selfsigncert-client.pem
new file mode 100644
index 00000000000..dc0a69d76e6
--- /dev/null
+++ b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/selfsigncert-client.pem
@@ -0,0 +1,24 @@
+-----BEGIN CERTIFICATE-----
+MIID3zCCA0igAwIBAgIBADANBgkqhkiG9w0BAQUFADCBrDELMAkGA1UEBhMCVVMx
+ETAPBgNVBAgTCE1pc3NvdXJpMRMwEQYDVQQHEwpDcmV2ZSBDb3JlMR4wHAYDVQQK
+ExVPYmplY3QgQ29tcHV0aW5nIEluYy4xETAPBgNVBAsTCFRBTyBUZWFtMRswGQYD
+VQQDExJvY2kxMTc5Lm9jaXdlYi5jb20xJTAjBgkqhkiG9w0BCQEWFmplbGlhemtv
+dl9pQG9jaXdlYi5jb20wHhcNMDQwOTEwMTY0MjMwWhcNMDUwOTEwMTY0MjMxWjCB
+rDELMAkGA1UEBhMCVVMxETAPBgNVBAgTCE1pc3NvdXJpMRMwEQYDVQQHEwpDcmV2
+ZSBDb3JlMR4wHAYDVQQKExVPYmplY3QgQ29tcHV0aW5nIEluYy4xETAPBgNVBAsT
+CFRBTyBUZWFtMRswGQYDVQQDExJvY2kxMTc5Lm9jaXdlYi5jb20xJTAjBgkqhkiG
+9w0BCQEWFmplbGlhemtvdl9pQG9jaXdlYi5jb20wgZ8wDQYJKoZIhvcNAQEBBQAD
+gY0AMIGJAoGBAPctxk6jy0XsEcRgyybmmffNhX67o2GG88LkblsStjyqLxe3gJk9
+JA+bgmZUW8uxjYfoSZ7w57uPhsKq5G4HUP9Tlq4p0g1DVobYKAqo+0HLVKWIcTcU
+PUe3jc77PaZHMYe2oujCES8USkRUdwktRDsdUc8lpE1CSfzQMD+c337nAgMBAAGj
+ggENMIIBCTAdBgNVHQ4EFgQUgtnhUdIQh1ESq81PL+urdJj1LRkwgdkGA1UdIwSB
+0TCBzoAUgtnhUdIQh1ESq81PL+urdJj1LRmhgbKkga8wgawxCzAJBgNVBAYTAlVT
+MREwDwYDVQQIEwhNaXNzb3VyaTETMBEGA1UEBxMKQ3JldmUgQ29yZTEeMBwGA1UE
+ChMVT2JqZWN0IENvbXB1dGluZyBJbmMuMREwDwYDVQQLEwhUQU8gVGVhbTEbMBkG
+A1UEAxMSb2NpMTE3OS5vY2l3ZWIuY29tMSUwIwYJKoZIhvcNAQkBFhZqZWxpYXpr
+b3ZfaUBvY2l3ZWIuY29tggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQAD
+gYEAVZSDOJ40+iAJPb1GZWmmh5y5Y1DVXsQF5vRENYq15Pi5Y9GBhHaYFn3qjN2U
++zyO2Cp2IJJG4HNazhBoDEj7EhDsxEyOYZiG2pd6BLe1dPl/viy6ysvdijjpcXw7
+bFPbXpCIa5rg8VKQsGYscWerLxvi79uoo+p6DrOU1FxDcYo=
+-----END CERTIFICATE-----
+
diff --git a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/selfsigncert.pem b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/selfsigncert.pem
new file mode 100644
index 00000000000..e616730ca63
--- /dev/null
+++ b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/selfsigncert.pem
@@ -0,0 +1,16 @@
+-----BEGIN CERTIFICATE-----
+MIICeDCCAiKgAwIBAgIBADANBgkqhkiG9w0BAQQFADBjMQswCQYDVQQGEwJVUzEL
+MAkGA1UECBMCTU8xDDAKBgNVBAcTA1NUTDELMAkGA1UEChMCV1UxDDAKBgNVBAsT
+A0RPQzELMAkGA1UEAxMCS0ExETAPBgkqhkiG9w0BCQEWAktBMB4XDTAxMDgyNzE2
+NTUxMVoXDTAxMDkyNjE2NTUxMVowYzELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAk1P
+MQwwCgYDVQQHEwNTVEwxCzAJBgNVBAoTAldVMQwwCgYDVQQLEwNET0MxCzAJBgNV
+BAMTAktBMREwDwYJKoZIhvcNAQkBFgJLQTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgC
+QQD12e2DchVPE/D1YrTcGZncLnOLRuuFf5Q2B55s6JZhT0OoLyNrqCgUHh3iRTyO
+iyeUxm/IQp8qcvs23Pqb3vLxAgMBAAGjgcAwgb0wHQYDVR0OBBYEFL8LnC8csuIX
++TUw6FCoReB27PHoMIGNBgNVHSMEgYUwgYKAFL8LnC8csuIX+TUw6FCoReB27PHo
+oWekZTBjMQswCQYDVQQGEwJVUzELMAkGA1UECBMCTU8xDDAKBgNVBAcTA1NUTDEL
+MAkGA1UEChMCV1UxDDAKBgNVBAsTA0RPQzELMAkGA1UEAxMCS0ExETAPBgkqhkiG
+9w0BCQEWAktBggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEEBQADQQAZP9CT
+TVRxAz3Acxxxn32rsnwSeNJr1uTA4hew7f4QZ187oZia+rcFLOILrwgCmtqEmWVj
+dj6COUrqKo60BI5V
+-----END CERTIFICATE-----
diff --git a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/server.conf b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/server.conf
new file mode 100644
index 00000000000..672a471014d
--- /dev/null
+++ b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/server.conf
@@ -0,0 +1,6 @@
+dynamic SSLIOP_Factory Service_Object *
+ TAO_SSLIOP:_make_TAO_SSLIOP_Protocol_Factory()
+ "-SSLPrivateKey PEM:pvtkey.pem -SSLCertificate PEM:selfsigncert.pem"
+static Resource_Factory "-ORBProtocolFactory SSLIOP_Factory"
+
+
diff --git a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/server.conf.xml b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/server.conf.xml
new file mode 100644
index 00000000000..5aa645eb3bf
--- /dev/null
+++ b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/server.conf.xml
@@ -0,0 +1,8 @@
+<?xml version='1.0'?>
+<!-- Converted from server.conf by svcconf-convert.pl -->
+<ACE_Svc_Conf>
+ <dynamic id="SSLIOP_Factory" type="Service_Object">
+ <initializer path="TAO_SSLIOP" init="_make_TAO_SSLIOP_Protocol_Factory" params="-SSLPrivateKey PEM:pvtkey.pem -SSLCertificate PEM:selfsigncert.pem"/>
+ </dynamic>
+ <static id="Resource_Factory" params="-ORBProtocolFactory SSLIOP_Factory"/>
+</ACE_Svc_Conf>
diff --git a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/test_object.idl b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/test_object.idl
new file mode 100644
index 00000000000..4737f6dc6c8
--- /dev/null
+++ b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/test_object.idl
@@ -0,0 +1,11 @@
+// $Id$
+
+interface Test_Object
+{
+ // = TITLE
+ // This is a simple interface that tests the Naming Service.
+
+ attribute short id;
+ // This provides an easy way to differentiate objects if each
+ // objects is served by a separate servant.
+};
diff --git a/TAO/tao/CORBALOC_Parser.cpp b/TAO/tao/CORBALOC_Parser.cpp
index cd64090e2b4..4ac9f101828 100644
--- a/TAO/tao/CORBALOC_Parser.cpp
+++ b/TAO/tao/CORBALOC_Parser.cpp
@@ -1,301 +1,40 @@
#include "CORBALOC_Parser.h"
#include "ORB_Core.h"
#include "Stub.h"
+#include "MProfile.h"
#include "Connector_Registry.h"
-#include "SystemException.h"
+#include "Transport_Connector.h"
+#include "Protocol_Factory.h"
#include "tao/debug.h"
-#include "ace/OS_NS_strings.h"
-#include "ace/OS_NS_string.h"
+#include "ace/Vector_T.h"
+#include "ace/INET_Addr.h"
#if !defined(__ACE_INLINE__)
#include "CORBALOC_Parser.i"
#endif /* __ACE_INLINE__ */
-
-ACE_RCSID (tao,
+ACE_RCSID (TAO,
CORBALOC_Parser,
"$Id$")
-
TAO_CORBALOC_Parser::~TAO_CORBALOC_Parser (void)
{
}
-static const char corbaloc_prefix[] = "corbaloc:";
-
-static const char* protocol_prefixes[] = {
- "iiop",
- "miop",
- "rir",
- "sciop",
- "shmiop",
- "uiop"
-};
+static const char prefix[] = "corbaloc:";
+static const size_t prefix_len = sizeof prefix - 1;
+static const char rir_token[] = "rir:/"; // includes key separator
+static const size_t rir_token_len = sizeof rir_token - 1;
+static const char iiop_token[] = "iiop:";
+static const char iiop_token_len = sizeof iiop_token - 1;
int
TAO_CORBALOC_Parser::match_prefix (const char *ior_string) const
{
// Check if the prefix is 'corbaloc:' and return the result.
return (ACE_OS::strncmp (ior_string,
- corbaloc_prefix,
- sizeof corbaloc_prefix - 1) == 0);
-}
-
-void
-TAO_CORBALOC_Parser::parse_string_count_helper (const char * s,
- CORBA::ULong &addr_list_length,
- CORBA::ULong &addr_count
- ACE_ENV_ARG_DECL)
- ACE_THROW_SPEC ((CORBA::SystemException))
-{
- char object_key_delimiter = '/';
-
- if (ACE_OS::strncmp (s, "uiop", 4) == 0)
- object_key_delimiter = '|';
-
- for (const char *i = s; *i != '\0'; ++i)
- {
- if (*i == ',')
- {
- // Increment the address count
- ++addr_count;
- }
-
- if (*i == ':'
- && *(i + 1) == '/'
- && *(i + 2) == '/')
- {
- if (TAO_debug_level > 0)
- ACE_ERROR((LM_ERROR,
- ACE_TEXT ("TAO (%P|%t) Invalid Syntax: %s\n"),
- ACE_TEXT_CHAR_TO_TCHAR (s)));
-
- ACE_THROW (CORBA::BAD_PARAM (CORBA::OMGVMCID | 10,
- CORBA::COMPLETED_NO));
- }
-
- if (*i == object_key_delimiter
- && *(i+1) != object_key_delimiter)
- {
- // Indication that the next characters are to be
- // assigned to key_string
- return;
- }
-
- ++addr_list_length;
- }
-}
-
-void
-TAO_CORBALOC_Parser::assign_key_string (char *& cloc_name_ptr,
- ACE_CString & key_string,
- CORBA::ULong
- &addr_list_length,
- CORBA::ORB_ptr orb,
- TAO_MProfile &mprofile
- ACE_ENV_ARG_DECL)
- ACE_THROW_SPEC ((CORBA::SystemException))
-{
- CORBA::String_var end_point;
- const char protocol_prefix[] = ":";
- const char protocol_suffix_append[] = "://";
- const char iiop_prefix[] = "iiop";
- const char uiop_prefix[] = "uiop";
- const char def_port[] = ":2809";
-
- // Copy the cloc_name_ptr to cloc_name_cstring.
- ACE_CString cloc_name_cstring (cloc_name_ptr,
- addr_list_length,
- 0,
- 1);
-
- // pos_colon is the position of the ':' in the iiop_id
- // <iiop_id> = ":" | <iiop_prot_token>":"
- int pos_colon = cloc_name_cstring.find (':', 0);
-
- if (ACE_OS::strncmp (cloc_name_ptr,
- protocol_prefix,
- sizeof (protocol_prefix) - 1) == 0)
- {
- // If there is no protocol explicitly specified then default to
- // "iiop".
- end_point = CORBA::string_alloc (addr_list_length
- + sizeof (iiop_prefix) - 1
- + 1 // Object key separator
- + 3 // "://"
- + sizeof (def_port) - 1
- + static_cast<CORBA::ULong> (
- key_string.length ()));
-
- // Copy the default <iiop> prefix.
- ACE_OS::strcpy (end_point.inout (),
- iiop_prefix);
-
- // Append '://'
- ACE_OS::strcat (end_point.inout (),
- protocol_suffix_append);
- }
- else
- {
- // The case where the protocol to be used is explicitly
- // specified.
-
- // The space allocated for the default IIOP port is not needed
- // for all protocols, but it is only 5 bytes. No biggy.
- end_point = CORBA::string_alloc (addr_list_length
- + 1 // Object key separator
- + 3 // "://"
- + sizeof (def_port) - 1
- + static_cast<CORBA::ULong> (
- key_string.length ()));
-
- ACE_CString prot_name = cloc_name_cstring.substring (0,
- pos_colon);
-
- // Form the endpoint
-
- // Example:
- // prot_name.c_str () = iiop
- ACE_OS::strcpy (end_point.inout (),
- prot_name.c_str ());;
-
-
- // Example:
- // The endpoint will now be of the form 'iiop'
-
- ACE_OS::strcat (end_point.inout (),
- protocol_suffix_append);
-
- // The endpoint will now be of the form 'iiop://'
- }
-
- ACE_CString addr =
- cloc_name_cstring.substring (pos_colon + 1, -1);
-
- ACE_OS::strcat (end_point.inout (),
- addr.c_str ());
-
- // Check for an IIOP corbaloc IOR. If the port number is not
- // specified, append the default corbaloc port number (i.e. "2809")
- if (ACE_OS::strncmp (end_point.in (),
- iiop_prefix,
- sizeof (iiop_prefix) - 1) == 0
- && addr.find (':') == ACE_CString::npos)
- ACE_OS::strcat (end_point.inout (), def_port);
-
- // Example:
- // The End_point will now be of the form
- // 'iiop://1.0@doc.ece.uci.edu:12345'
-
- if (ACE_OS::strncmp (cloc_name_ptr,
- uiop_prefix,
- sizeof (uiop_prefix) - 1) == 0)
- {
- // The separator for the uiop protocol is '|'. This should
- // actually be later changed so that the separator is '/' as the
- // other protocols.
- ACE_OS::strcat (end_point.inout (), "|");
- }
- else
- {
- ACE_OS::strcat (end_point.inout (), "/");
- }
-
- // Append the key string.
- ACE_OS::strcat (end_point.inout (),
- key_string.c_str ());
-
- // Example: The End_point will now be of the form:
- // 'iiop://1.0@doc.ece.uci.edu:12345/object_name'
-
- // Call the mprofile helper which makes an mprofile for this
- // endpoint and adds it to the big mprofile.
- this->parse_string_mprofile_helper (end_point.in (),
- orb,
- mprofile
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK;
-}
-
-void
-TAO_CORBALOC_Parser::parse_string_assign_helper (
- ACE_CString &key_string,
- ACE_CString &cloc_name,
- CORBA::ORB_ptr orb,
- TAO_MProfile &mprofile
- ACE_ENV_ARG_DECL)
- ACE_THROW_SPEC ((CORBA::SystemException))
-{
- char *cloc_name_ptr = 0;
-
- // Tokenize using "," as the seperator
- char *last_addr = 0;
-
- cloc_name_ptr =
- ACE_OS::strtok_r (const_cast<char *> (cloc_name.c_str ()),
- ",",
- &last_addr);
-
- CORBA::ULong length;
- while (cloc_name_ptr != 0)
- {
- length = static_cast<CORBA::ULong> (ACE_OS::strlen (cloc_name_ptr));
- // Forms the endpoint and calls the mprofile_helper.
- this->assign_key_string (cloc_name_ptr,
- key_string,
- length,
- orb,
- mprofile
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK;
-
- // Get the next token.
- cloc_name_ptr = ACE_OS::strtok_r ((char*)NULL,
- ",",
- &last_addr);
- }
-}
-
-
-void
-TAO_CORBALOC_Parser::parse_string_mprofile_helper (
- const char * end_point,
- CORBA::ORB_ptr orb,
- TAO_MProfile &mprofile
- ACE_ENV_ARG_DECL)
- ACE_THROW_SPEC ((CORBA::SystemException))
-{
- TAO_MProfile jth_mprofile;
-
- TAO_Connector_Registry *conn_reg =
- orb->orb_core ()->connector_registry (ACE_ENV_SINGLE_ARG_PARAMETER);
- ACE_CHECK;
-
- int retv =
- conn_reg->make_mprofile (end_point,
- jth_mprofile
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK;
-
- if (retv != 0)
- {
- ACE_THROW (CORBA::INV_OBJREF (
- CORBA::SystemException::_tao_minor_code (
- 0,
- EINVAL),
- CORBA::COMPLETED_NO));
- }
-
- TAO_MProfile *jth_mprofile_ptr = &jth_mprofile;
-
- // Add this profile to the main mprofile.
- int result = mprofile.add_profiles (jth_mprofile_ptr);
-
- if (result == -1)
- {
- // The profile is not added. Either way, go to the next
- // endpoint.
- }
+ prefix,
+ prefix_len) == 0);
}
CORBA::Object_ptr
@@ -316,176 +55,263 @@ TAO_CORBALOC_Parser::make_stub_from_mprofile (CORBA::ORB_ptr orb,
if (!CORBA::is_nil (obj.in ()))
{
- // All is well, so release the stub object from its auto_ptr.
+ /// All is well, so release the stub object from its
+ /// auto_ptr.
(void) safe_data.release ();
- // Return the object reference to the application.
+ /// Return the object reference to the application.
return obj._retn ();
}
- // Shouldn't come here: if so, return nil reference.
+ /// Shouldnt come here: if so, return nil reference.
return CORBA::Object::_nil ();
}
CORBA::Object_ptr
-TAO_CORBALOC_Parser::parse_string_rir_helper (const char *& corbaloc_name,
+TAO_CORBALOC_Parser::parse_string_rir_helper (const char * ior,
CORBA::ORB_ptr orb
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
-
-
- // "rir" protocol. Pass the key string as an
- // argument to the resolve_initial_references.
- const char *key_string = corbaloc_name + sizeof ("rir:/") -1;
-
- if (ACE_OS::strcmp (key_string, "") == 0)
- {
- // If the key string is empty, assume the default
- // "NameService".
- key_string = "NameService";
- }
+ // Pass the key string as an argument to resolve_initial_references.
+ // NameService is the default if an empty key string is supplied.
+ const char *objkey = ior + rir_token_len;
CORBA::Object_var rir_obj =
- orb->resolve_initial_references (key_string
+ orb->resolve_initial_references (*objkey == '\0' ? "NameService" :
+ objkey
ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (CORBA::Object::_nil ());
return rir_obj._retn ();
}
-int
-TAO_CORBALOC_Parser::check_prefix (const char *end_point
+CORBA::Object_ptr
+TAO_CORBALOC_Parser::parse_string (const char * ior,
+ CORBA::ORB_ptr orb
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
+ // The decomposition of a corbaloc string is in Section 13.6.10.
+ //
+ // following the "corbaloc:"
+ // a comma separated list of <prot_addr> strings
+ // for each,
+ // Separate out the key, delimited by '/'
+ // Split out the various parts of our corbaloc string, comma-delimited
+ // For each part
+ // Determine the protocol
+ // If rir, defer to another function and return the object
+ // If iiop, make the profile with <endpoint>:<port>/<key>
+ // If another protocol, use <remainder>/<key>
+ // Search through the collection of protocols for the correct one
+ // If not found, throw exception
+ // If found, make our_connector from it.
+ // our_connector->make_mprofile_unchecked (...);
+ // object = this->make_stub_from_mprofile (...);
+ // Return the object
- // This checks if the prefix is "rir:" or not. Returns a -1 if it is
- // "rir:" else returns a zero;
- // Check for a valid string
- if (!end_point || !*end_point)
- return -1; // Failure
-
- const char *protocol[] = {"rir:"};
- size_t slot = ACE_OS::strchr (end_point, '/') - end_point;
- const char* colon_pos = ACE_OS::strchr (end_point, ':');
- size_t colon_slot = colon_pos ? colon_pos - end_point : 0;
- size_t len0 = ACE_OS::strlen (protocol[0]);
-
- // Lets first check if it is a valid protocol:
- if (colon_slot != 0)
- {
- size_t i;
- const size_t protocol_prefixes_size =
- sizeof(protocol_prefixes)/sizeof(protocol_prefixes[0]);
-
- for (i = 0; i < protocol_prefixes_size ; ++i)
- {
- if (ACE_OS::strncmp (end_point,
- protocol_prefixes[i],
- colon_slot) == 0)
- break;
- }
-
- if (i == protocol_prefixes_size)
+ // Skip the prefix. We know it is there because this method is only
+ // called if match_prefix() returns 1.
+ ior += ACE_OS::strlen(prefix);
+
+ // First check for rir
+ if (ACE_OS::strncmp (ior,rir_token,rir_token_len) == 0)
+ return this->parse_string_rir_helper (ior,orb
+ ACE_ENV_ARG_PARAMETER);
+
+ // set up space for parsed endpoints. there will be at least 1, and
+ // most likely commas will separate endpoints, although they could be
+ // part of an endpoint address for some protocols.
+ size_t max_endpoint_count = 1;
+ for (const char *comma = ACE_OS::strchr (ior,',');
+ comma;
+ comma = ACE_OS::strchr (comma+1,','))
+ max_endpoint_count++;
+
+ ACE_Array<parsed_endpoint> endpoints(max_endpoint_count);
+ endpoints.size (0);
+
+ // Get the Connector Registry from the ORB.
+ TAO_Connector_Registry *conn_reg =
+ orb->orb_core ()->connector_registry(ACE_ENV_SINGLE_ARG_PARAMETER);
+
+ while (1) { // will loop on comma only.
+ size_t len = 0;
+ size_t ndx = endpoints.size();
+ endpoints.size(ndx+1);
+ int uiop_compatible = 0;
+ TAO_ConnectorSetIterator conn_iter = 0;
+ for (conn_iter = conn_reg->begin();
+ conn_iter != conn_reg->end() &&
+ endpoints[ndx].profile_ == 0;
+ conn_iter ++)
+ {
+ endpoints[ndx].profile_ =
+ (*conn_iter)->corbaloc_scan(ior,len
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (CORBA::Object::_nil ());
+
+ if (endpoints[ndx].profile_)
+ {
+ endpoints[ndx].obj_key_sep_ =
+ (*conn_iter)->object_key_delimiter();
+ uiop_compatible = (endpoints[ndx].obj_key_sep_ == '|');
+ this->make_canonical (ior,len,endpoints[ndx].prot_addr_
+ ACE_ENV_ARG_PARAMETER);
+ ior += len;
+ break;
+ }
+ }
+
+ if (endpoints[ndx].profile_ == 0)
+ {
+ if (TAO_debug_level)
+ ACE_ERROR ((LM_ERROR,
+ "(%P|%t) TAO_CORBALOC_Parser::parse_string "
+ "could not parse from %s",ior));
+ ACE_THROW_RETURN (CORBA::BAD_PARAM (CORBA::OMGVMCID | 10,
+ CORBA::COMPLETED_NO),
+ CORBA::Object::_nil ());
+ }
+ if (*ior == ',') // more endpoints follow
+ {
+ ior++;
+ continue;
+ }
+
+ if (*ior == '/') // found key separator
+ {
+ ior ++;
+ break;
+ }
+
+ if (uiop_compatible && *(ior - 1) == '|')
+ // Assume this is an old uiop style corbaloc. No need to warn here,
+ // the UIOP_Connector::corbaloc_scan already did.
+ break;
+
+ // anything else is a violation.
+ if (TAO_debug_level)
+ ACE_ERROR ((LM_ERROR,
+ "(%P|%t) TAO_CORBALOC_Parser::parse_string "
+ "could not parse from %s",ior));
+ ACE_THROW_RETURN (CORBA::BAD_PARAM (CORBA::OMGVMCID | 10,
+ CORBA::COMPLETED_NO),
+ CORBA::Object::_nil ());
+ } // end of while
+
+ // At this point, ior points at the start of the object key
+ ACE_CString obj_key (*ior ? ior : (const char *)"NameService");
+
+ // now take the collection of endpoints along with the decoded key and
+ // mix them together to get the mprofile.
+ TAO_MProfile mprofile (endpoints.size());
+
+ for (size_t i = 0; i < endpoints.size(); i++)
{
- if (TAO_debug_level > 0)
- ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("TAO (%P|%t) ")
- ACE_TEXT ("no usable transport protocol ")
- ACE_TEXT ("was found.\n")));
-
- ACE_THROW_RETURN (CORBA::BAD_PARAM (CORBA::OMGVMCID | 10,
- CORBA::COMPLETED_NO),
- -1);
+ ACE_CString full_ep = endpoints[i].prot_addr_ +
+ endpoints[i].obj_key_sep_ +
+ obj_key;
+ const char * str = full_ep.c_str();
+ endpoints[i].profile_->parse_string (str
+ ACE_ENV_ARG_PARAMETER);
+ if (mprofile.add_profile(endpoints[i].profile_) != -1)
+ endpoints[i].profile_ = 0;
}
- }
- // Check for the proper prefix in the IOR. If the proper prefix
- // isn't in the IOR then it is not an IOR we can use.
- if (slot == len0
- && ACE_OS::strncasecmp (end_point, protocol[0], len0) == 0)
- return 0;
+ CORBA::Object_ptr object = CORBA::Object::_nil ();
+ // Get an object stub out.
+ object = this->make_stub_from_mprofile (orb,
+ mprofile
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (CORBA::Object::_nil ());
- return 1;
+ return object;
}
-CORBA::Object_ptr
-TAO_CORBALOC_Parser::parse_string (const char * ior,
- CORBA::ORB_ptr orb
- ACE_ENV_ARG_DECL)
+void
+TAO_CORBALOC_Parser::make_canonical (const char *ior,
+ size_t prot_addr_len,
+ ACE_CString &canonical_endpoint
+ ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
- // MProfile which consists of the profiles for each endpoint.
- TAO_MProfile mprofile;
+ const char *separator = ACE_OS::strchr (ior, ':');
- // Skip the prefix. We know it is there because this method is only
- // called if match_prefix() returns 1.
- const char *corbaloc_name =
- ior + sizeof corbaloc_prefix - 1;
+ // A special case for handling iiop
+ if (ior[0] != ':' && ACE_OS::strncmp (ior,iiop_token,iiop_token_len) != 0)
+ {
+ canonical_endpoint.set (separator+1,
+ prot_addr_len - (separator - ior) - 1,1);
+ return;
+ }
- CORBA::Object_ptr object = CORBA::Object::_nil ();
+ const char *addr_base = separator+1;
+ const char *addr_tail = ior + prot_addr_len;
+ // skip past version, if any
+ separator = ACE_OS::strchr (addr_base,'@');
+ if (separator != 0 && separator < addr_tail)
+ {
+ canonical_endpoint.set (addr_base,(separator - addr_base)+1,1);
+ addr_base = separator + 1;
+ }
+ else
+ canonical_endpoint.clear ();
- // Number of endpoints
- CORBA::ULong count_addr = 1;
+ ACE_CString raw_host;
+ ACE_CString raw_port;
+ separator = ACE_OS::strchr (addr_base,':');
+ if (separator != 0 && separator < addr_tail)
+ {
+ // we have a port number
+ if (separator - addr_base > 0)
+ raw_host.set (addr_base, (separator - addr_base),1);
+ raw_port.set (separator, (addr_tail - separator), 1);
+ }
+ else
+ {
+ // we must default port #
+ if (addr_base < addr_tail)
+ raw_host.set (addr_base, (addr_tail - addr_base),1);
+ raw_port.set (":2809");
+ }
- // Length of obj_addr_list
- CORBA::ULong addr_list_length = 0;
+ if (raw_host.length() == 0)
+ {
+ ACE_INET_Addr host_addr;
- // If the protocol is not "rir:" and also is a valid protocol
- int check_prefix_result = this->check_prefix (corbaloc_name
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK_RETURN (CORBA::Object::_nil ());
+ char tmp_host [MAXHOSTNAMELEN + 1];
- if (check_prefix_result != 0)
- {
- // Count the length of the obj_addr_list and number of
- // endpoints in the obj_addr_list
- this->parse_string_count_helper (corbaloc_name,
- addr_list_length,
- count_addr
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK_RETURN (CORBA::Object::_nil ());
-
- // Convert corbaloc_name to an ACE_CString
- ACE_CString corbaloc_name_str (corbaloc_name, 0, 1);
-
- // Get the key_string which is a substring of corbaloc_name_str
- ACE_CString key_string =
- corbaloc_name_str.substring (addr_list_length + 1);
-
- // Copy the <obj_addr_list> to cloc_name.
- ACE_CString cloc_name (corbaloc_name,
- addr_list_length,
- 0,
- 1);
-
- // Get each endpoint: For each endpoint, make a MProfile and add
- // it to the main MProfile whose reference is passed to the
- // application
- this->parse_string_assign_helper (key_string,
- cloc_name,
- orb,
- mprofile
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK_RETURN (CORBA::Object::_nil ());
-
- // Create the stub for the mprofile and get the object reference
- // to it which is to be returned to the client application.
- object = this->make_stub_from_mprofile (orb,
- mprofile
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK_RETURN (CORBA::Object::_nil ());
+ // If no host is specified: assign the default host, i.e. the
+ // local host.
+ if (host_addr.get_host_name (tmp_host,
+ sizeof (tmp_host)) != 0)
+ {
+ // Can't get the IP address since the INET_Addr wasn't
+ // initialized. Just throw an exception.
+
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("TAO (%P|%t) ")
+ ACE_TEXT ("cannot determine hostname.\n")));
+
+ ACE_THROW (CORBA::INV_OBJREF
+ (CORBA::SystemException::_tao_minor_code
+ (0, EINVAL),
+ CORBA::COMPLETED_NO));
+ }
+ else
+ {
+ canonical_endpoint += tmp_host;
+ }
}
else
{
- // RIR case:
- object = this->parse_string_rir_helper (corbaloc_name,
- orb
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK_RETURN (CORBA::Object::_nil ());
+ canonical_endpoint += raw_host;
}
- return object;
+
+ canonical_endpoint += raw_port;
}
ACE_STATIC_SVC_DEFINE (TAO_CORBALOC_Parser,
@@ -499,7 +325,7 @@ ACE_STATIC_SVC_DEFINE (TAO_CORBALOC_Parser,
ACE_FACTORY_DEFINE (TAO, TAO_CORBALOC_Parser)
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
-template class ACE_Array_Base<char *>;
+template class ACE_Array_Base<TAO_CORBALOC_Parser::parsed_endpoint>;
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
-#pragma instantiate ACE_Array_Base<char *>
+#pragma instantiate ACE_Array_Base<TAO_CORBALOC_Parser::parsed_endpoint>
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
diff --git a/TAO/tao/CORBALOC_Parser.h b/TAO/tao/CORBALOC_Parser.h
index 0d12aa87d95..115923899a3 100644
--- a/TAO/tao/CORBALOC_Parser.h
+++ b/TAO/tao/CORBALOC_Parser.h
@@ -11,20 +11,24 @@
*/
//=============================================================================
+
#ifndef TAO_CORBALOC_PARSER_H
#define TAO_CORBALOC_PARSER_H
+#include "ace/pre.h"
-#include /**/ "ace/pre.h"
-#include "ace/Service_Config.h"
+#include "tao/IOR_Parser.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
-#include "tao/IOR_Parser.h"
+#include "ace/Service_Config.h"
+#include "ace/Array.h"
+#include "tao/Profile.h"
class TAO_MProfile;
+
/**
* @class TAO_CORBALOC_Parser
*
@@ -51,78 +55,40 @@ public:
/// Parse the ior-string that is passed.
virtual CORBA::Object_ptr parse_string (const char *ior,
CORBA::ORB_ptr orb
- ACE_ENV_ARG_DECL_NOT_USED)
+ ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException));
private:
- /// Checks the prefix to see if it is RIR.
- virtual int check_prefix (const char *endpoint
- ACE_ENV_ARG_DECL)
- ACE_THROW_SPEC ((CORBA::SystemException));
-
- /// Helps count the length of the <obj_addr_list> and the number of
- /// individual <obj_addr> in the <obj_addr_list>.
- virtual void parse_string_count_helper (const char * corbaloc_name,
- CORBA::ULong &addr_list_length,
- CORBA::ULong &count_addr
- ACE_ENV_ARG_DECL_NOT_USED)
- ACE_THROW_SPEC ((CORBA::SystemException));
-
- /**
- * Creates a MProfile for the endpoint passed and each such mprofile
- * is added to the big mprofile <mprofile_> from which a pointer to
- * the Object represented by the key_string is obtained and passed
- * to the application.
- */
- virtual void parse_string_mprofile_helper (const char * end_point,
- CORBA::ORB_ptr orb,
- TAO_MProfile &mprofile
- ACE_ENV_ARG_DECL_NOT_USED)
- ACE_THROW_SPEC ((CORBA::SystemException));
-
/**
* Make a stub from the MProfile that is created in
* parse_string_mprofile_helper. Using this stub, create an object
* reference which is sent to the application.
*/
- virtual CORBA::Object_ptr
- make_stub_from_mprofile (CORBA::ORB_ptr orb,
- TAO_MProfile &mprofile
- ACE_ENV_ARG_DECL_NOT_USED)
+ CORBA::Object_ptr make_stub_from_mprofile (CORBA::ORB_ptr orb,
+ TAO_MProfile &mprofile
+ ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException));
/// Gets the pointer to the key_string when the protocol used is RIR
- virtual CORBA::Object_ptr
- parse_string_rir_helper (const char * &corbaloc_name,
- CORBA::ORB_ptr orb
- ACE_ENV_ARG_DECL_NOT_USED)
- ACE_THROW_SPEC ((CORBA::SystemException));
-
- /// Tokenizes the <obj_addr_list> using "," as the seperator. Assigns
- /// individual endpoints to the elements of the ACE_Array_Base.
- virtual void parse_string_assign_helper (
- ACE_CString &key_string,
- ACE_CString &cloc_name,
- CORBA::ORB_ptr orb,
- TAO_MProfile &mprofile
- ACE_ENV_ARG_DECL_NOT_USED)
+ CORBA::Object_ptr parse_string_rir_helper (const char *corbaloc_name,
+ CORBA::ORB_ptr orb
+ ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException));
- /**
- * Helps parse_string_assign_helper by assigning in the case when
- * the protocol name is present and we have to append jsut the key
- * string.
- */
- virtual void
- assign_key_string(char * &cloc_name_ptr,
- ACE_CString &key_string,
- CORBA::ULong &addr_list_length,
- CORBA::ORB_ptr orb,
- TAO_MProfile &mprofile
- ACE_ENV_ARG_DECL_NOT_USED)
+ void make_canonical (const char *ior,
+ size_t ior_len,
+ ACE_CString &canonical_endpoint
+ ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException));
+ struct parsed_endpoint {
+ parsed_endpoint () : profile_ (0) {}
+ ~parsed_endpoint () { delete this->profile_; }
+ TAO_Profile *profile_;
+ char obj_key_sep_;
+ ACE_CString prot_addr_;
+ };
};
#if defined (__ACE_INLINE__)
@@ -132,5 +98,5 @@ private:
ACE_STATIC_SVC_DECLARE_EXPORT (TAO, TAO_CORBALOC_Parser)
ACE_FACTORY_DECLARE (TAO, TAO_CORBALOC_Parser)
-#include /**/ "ace/post.h"
+#include "ace/post.h"
#endif /* TAO_CORBALOC_PARSER_H */
diff --git a/TAO/tao/Connector_Registry.cpp b/TAO/tao/Connector_Registry.cpp
index 57bc3f9d201..7fd840cffc8 100644
--- a/TAO/tao/Connector_Registry.cpp
+++ b/TAO/tao/Connector_Registry.cpp
@@ -71,18 +71,22 @@ TAO_Connector_Registry::open (TAO_ORB_Core *orb_core)
TAO_Connector * connector =
(*factory)->factory ()->make_connector ();
- if (connector && connector->open (orb_core) != 0)
+ if (connector)
{
- delete connector;
-
- ACE_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("TAO (%P|%t) unable to open connector for ")
- ACE_TEXT ("<%s>.\n"),
- ACE_TEXT_CHAR_TO_TCHAR((*factory)->protocol_name ().c_str ())),
- -1);
+ if (connector->open (orb_core) != 0)
+ {
+ delete connector;
+
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_LIB_TEXT ("TAO (%P|%t) unable to open connector for ")
+ ACE_LIB_TEXT ("<%s>.\n"),
+ ACE_TEXT_CHAR_TO_TCHAR((*factory)->protocol_name ().c_str ())),
+ -1);
+ }
+ this->connectors_[this->size_++] = connector;
}
else
- this->connectors_[this->size_++] = connector;
+ return -1;
}
return 0;
diff --git a/TAO/tao/IIOP_Connector.cpp b/TAO/tao/IIOP_Connector.cpp
index 8deb1c31355..b99f47d2132 100644
--- a/TAO/tao/IIOP_Connector.cpp
+++ b/TAO/tao/IIOP_Connector.cpp
@@ -349,7 +349,9 @@ TAO_IIOP_Connector::check_prefix (const char *endpoint)
static const char *protocol[] = { "iiop", "iioploc" };
const size_t slot = ACE_OS::strchr (endpoint, ':') - endpoint;
-
+ if (slot == 0) // an empty string is valid for corbaloc.
+ return 0;
+
const size_t len0 = ACE_OS::strlen (protocol[0]);
const size_t len1 = ACE_OS::strlen (protocol[1]);
diff --git a/TAO/tao/IIOP_Profile.cpp b/TAO/tao/IIOP_Profile.cpp
index 724fcd451fc..af4d0b85cc3 100644
--- a/TAO/tao/IIOP_Profile.cpp
+++ b/TAO/tao/IIOP_Profile.cpp
@@ -136,7 +136,15 @@ TAO_IIOP_Profile::parse_string_i (const char *ior
if (cp_pos == ior)
{
- // No hostname specified! It is required by the spec.
+ // No hostname, however one is required by the spec when specifying a port.
+ // See formal-04-03-01, section 13.6.10.3
+ if (TAO_debug_level > 0)
+ {
+ ACE_DEBUG ((LM_ERROR,
+ ACE_LIB_TEXT ("\nTAO (%P|%t) IIOP_Profile: ")
+ ACE_LIB_TEXT ("Host address may be omited only when no port has been specified.\n")));
+ }
+
ACE_THROW (CORBA::INV_OBJREF (
CORBA::SystemException::_tao_minor_code (
0,
diff --git a/TAO/tao/Strategies/UIOP_Connector.cpp b/TAO/tao/Strategies/UIOP_Connector.cpp
index 9d1b9692ad9..bc39c9c89dc 100644
--- a/TAO/tao/Strategies/UIOP_Connector.cpp
+++ b/TAO/tao/Strategies/UIOP_Connector.cpp
@@ -105,7 +105,37 @@ TAO_UIOP_Connector::close (void)
return this->base_connector_.close ();
}
+TAO_Profile *
+TAO_UIOP_Connector::corbaloc_scan (const char *str, size_t &len
+ ACE_ENV_ARG_DECL)
+{
+ if (this->check_prefix (str) != 0)
+ return 0;
+
+ const char *separator = ACE_OS::strchr (str,'|');
+ if (separator == 0)
+ {
+ if (TAO_debug_level)
+ ACE_DEBUG ((LM_DEBUG,
+ "(%P|%t) TAO_UIOP_CONNECTOR::corbaloc_scan error: "
+ "explicit terminating charactor '|' is missing from <%s>",
+ str));
+ return 0;
+ }
+ if (*(separator+1) != ',' && *(separator+1) != '/')
+ {
+ if (TAO_debug_level)
+ ACE_DEBUG ((LM_DEBUG,
+ "(%P|%t) TAO_UIOP_CONNECTOR::corbaloc_scan warning: "
+ "terminating charactor '|' should be followed by a ','"
+ "or a '/' in <%s>",
+ str));
+ }
+ len = (separator - str) + 1;
+ return this->make_profile (ACE_ENV_SINGLE_ARG_PARAMETER);
+}
+
int
TAO_UIOP_Connector::set_validate_endpoint (TAO_Endpoint *endpoint)
{
diff --git a/TAO/tao/Strategies/UIOP_Connector.h b/TAO/tao/Strategies/UIOP_Connector.h
index ba23060bd9d..f86ad350719 100644
--- a/TAO/tao/Strategies/UIOP_Connector.h
+++ b/TAO/tao/Strategies/UIOP_Connector.h
@@ -72,6 +72,9 @@ public:
virtual int check_prefix (const char *endpoint);
+ virtual TAO_Profile *corbaloc_scan (const char *str, size_t &len
+ ACE_ENV_ARG_DECL);
+
virtual char object_key_delimiter (void) const;
/// Cancel the passed cvs handler from the connector
diff --git a/TAO/tao/Strategies/UIOP_Profile.cpp b/TAO/tao/Strategies/UIOP_Profile.cpp
index 7a24e0745e1..4c34e227c91 100644
--- a/TAO/tao/Strategies/UIOP_Profile.cpp
+++ b/TAO/tao/Strategies/UIOP_Profile.cpp
@@ -101,6 +101,43 @@ void
TAO_UIOP_Profile::parse_string_i (const char *string
ACE_ENV_ARG_DECL)
{
+ if (!string || !*string)
+ {
+ ACE_THROW (CORBA::INV_OBJREF (
+ CORBA::SystemException::_tao_minor_code (
+ 0,
+ EINVAL),
+ CORBA::COMPLETED_NO));
+ }
+
+ // Remove the "N.n@" version prefix, if it exists, and verify the
+ // version is one that we accept.
+
+ // Check for version
+ if (isdigit (string [0]) &&
+ string[1] == '.' &&
+ isdigit (string [2]) &&
+ string[3] == '@')
+ {
+ // @@ This may fail for non-ascii character sets [but take that
+ // with a grain of salt]
+ this->version_.set_version ((char) (string [0] - '0'),
+ (char) (string [2] - '0'));
+ string += 4;
+ // Skip over the "N.n@"
+ }
+
+ if (this->version_.major != TAO_DEF_GIOP_MAJOR ||
+ this->version_.minor > TAO_DEF_GIOP_MINOR)
+ {
+ ACE_THROW (CORBA::INV_OBJREF (
+ CORBA::SystemException::_tao_minor_code (
+ 0,
+ EINVAL),
+ CORBA::COMPLETED_NO));
+ }
+
+
// Pull off the "rendezvous point" part of the objref
// Copy the string because we are going to modify it...
CORBA::String_var copy (string);
diff --git a/TAO/tao/Transport_Connector.cpp b/TAO/tao/Transport_Connector.cpp
index 7ef578dfd72..9a2c55c9883 100644
--- a/TAO/tao/Transport_Connector.cpp
+++ b/TAO/tao/Transport_Connector.cpp
@@ -36,6 +36,30 @@ TAO_Connector::~TAO_Connector (void)
delete this->active_connect_strategy_;
}
+TAO_Profile *
+TAO_Connector::corbaloc_scan (const char *str,
+ size_t &len
+ ACE_ENV_ARG_DECL)
+{
+ if (this->check_prefix (str) != 0)
+ return 0;
+ const char *comma_pos = ACE_OS::strchr (str,',');
+ const char *slash_pos = ACE_OS::strchr (str,'/');
+ if (comma_pos == 0 && slash_pos == 0)
+ {
+ if (TAO_debug_level)
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT("(%P|%t) TAO_CONNECTOR::corbaloc_scan warning: ")
+ ACE_TEXT("supplied string contains no comma or slash: %s\n"),
+ str));
+ len = ACE_OS::strlen (str);
+ }
+ else if (comma_pos == 0 || comma_pos > slash_pos)
+ len = (slash_pos - str);
+ else len = comma_pos - str;
+ return this->make_profile(ACE_ENV_SINGLE_ARG_PARAMETER);
+}
+
int
TAO_Connector::make_mprofile (const char *string,
TAO_MProfile &mprofile
diff --git a/TAO/tao/Transport_Connector.h b/TAO/tao/Transport_Connector.h
index 73347185874..e05a3c1eed3 100644
--- a/TAO/tao/Transport_Connector.h
+++ b/TAO/tao/Transport_Connector.h
@@ -75,12 +75,22 @@ public:
CORBA::ULong tag (void) const;
/// Parse a string containing a URL style IOR and return an
- /// MProfile.
+ /// MProfile. Verify that ior is in the correct format.
int make_mprofile (
const char *ior,
TAO_MProfile &mprofile
ACE_ENV_ARG_DECL);
+ /// Helper function to assist corbaloc parsing. The default simply validates
+ /// the protocol identifyier and scans up to the next comma or slash.
+ /// Any protocol that has a specific need, such as uiop, can override this
+ /// method to provide a custom scanner.
+ /// The profile returned is either null if this the ior does not match or an
+ /// empty profile of the correct type, obtained from make_profile().
+ virtual TAO_Profile * corbaloc_scan (const char *ior,
+ size_t &len
+ ACE_ENV_ARG_DECL);
+
/// Initialize object and register with reactor.
virtual int open (
TAO_ORB_Core *orb_core) = 0;