Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / DevGuideExamples / PortableInterceptors / Auth / ClientInterceptor.cpp
blobe0c2bef7b5552494abfd294ffa0ad5ce4fc22a24
1 #include "ClientInterceptor.h"
2 #include "tao/OctetSeqC.h"
3 #include "tao/PI/ClientRequestInfo.h"
4 #include "ace/OS_NS_string.h"
5 #include <iostream>
7 const CORBA::ULong service_ctx_id = 0xdeed;
9 ClientInterceptor::
10 ClientInterceptor (void)
11 : myname_ ("Client_Authentication_Interceptor")
13 std::cout << "Calling ClientInterceptor constructor." << std::endl;
16 ClientInterceptor::~ClientInterceptor (void)
20 char *
21 ClientInterceptor::name ()
23 std::cout << "Calling ClientInterceptor name() method" << std::endl;
24 return CORBA::string_dup (this->myname_);
27 void
28 ClientInterceptor::destroy ()
32 void
33 ClientInterceptor::send_poll (
34 PortableInterceptor::ClientRequestInfo_ptr)
36 std::cout << "Calling send_poll()." << std::endl;
40 void
41 ClientInterceptor::send_request (
42 PortableInterceptor::ClientRequestInfo_ptr ri)
44 std::cout << "Calling send_request()." << std::endl;
46 IOP::ServiceContext sc;
47 sc.context_id = service_ctx_id;
49 const char user_name[] = "Ron Klein";
50 std::cout << "User's Name: " << user_name << std::endl;
51 CORBA::ULong string_len = sizeof (user_name) + 1;
52 CORBA::Octet *buf = 0;
54 buf = new CORBA::Octet [string_len];
56 ACE_OS::strcpy (reinterpret_cast<char*> (buf), user_name);
58 sc.context_data.replace (string_len, string_len, buf, true);
60 // Add this context to the service context list.
61 ri->add_request_service_context (sc, false);
65 void
66 ClientInterceptor::receive_reply (
67 PortableInterceptor::ClientRequestInfo_ptr ri)
69 ACE_UNUSED_ARG(ri);
70 std::cout << "Calling receive_reply()." << std::endl;
73 void
74 ClientInterceptor::receive_other (
75 PortableInterceptor::ClientRequestInfo_ptr)
77 std::cout << "Calling receive_other()." << std::endl;
80 void
81 ClientInterceptor::receive_exception (
82 PortableInterceptor::ClientRequestInfo_ptr ri)
84 ACE_UNUSED_ARG(ri);
85 std::cout << "Calling receive_exception()." << std::endl;