summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/tests/Security/MT_IIOP_SSL/test_i.cpp
blob: c2b447fab3a33cbaef7cfc011ef43c32259dc484 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// $Id$

#include "test_i.h"
#include "tao/debug.h"
#include "tao/ORB_Core.h"
#include "tao/Thread_Lane_Resources.h"
#include "tao/Transport_Cache_Manager.h"
#include "orbsvcs/SSLIOP/SSLIOP_Transport.h"
#include "ace/OS_NS_unistd.h"

#if !defined(__ACE_INLINE__)
#include "test_i.inl"
#endif /* __ACE_INLINE__ */

ACE_RCSID (MT_IIOP_SSL,
           test_i,
           "$Id$")

void
Simple_Server_i::ping (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
    ACE_THROW_SPEC ((CORBA::SystemException))
{
  return;
}

void
Simple_Server_i::validate_protocol (ACE_ENV_SINGLE_ARG_DECL)
  ACE_THROW_SPEC ((Simple_Server::WrongProtocolType,
                   CORBA::SystemException))
{
  if (this->validated_ == NOT_VALIDATED)
    {
      ACE_MT (ACE_GUARD (TAO_SYNCH_MUTEX,
                         ace_mon,
                         this->mutex_));

      if (this->validated_ != NOT_VALIDATED)
        return;

      TAO_Transport_Cache_Manager::HASH_MAP &map =
        this->orb_->orb_core ()->lane_resources ().transport_cache ().map ();

      TAO_Transport_Cache_Manager::HASH_MAP_ITER st_iter =
        map.begin ();

      TAO_Transport_Cache_Manager::HASH_MAP_ITER end_iter =
        map.end ();

      for (TAO_Transport_Cache_Manager::HASH_MAP_ITER iter = st_iter;
           iter != end_iter;
           ++iter)
        {
          TAO_Transport *t =
            (*iter).int_id_.transport ();

          // @@ Worst possible way to check. If SSLIOP had a tag
          // things would have been a  lot simpler.
          TAO::SSLIOP::Transport *ssl_t =
            ACE_dynamic_cast (TAO::SSLIOP::Transport *,
                              t);

          // There should be no SSL Transport
          if (ssl_t != 0)
            {
              this->validated_ = VALIDATED_NOSUCCESS;
              break;
            }
        }

    }

  if (this->validated_ == VALIDATED_NOSUCCESS)
    ACE_THROW (Simple_Server::WrongProtocolType ());
}

CORBA::Long
Simple_Server_i::test_method (CORBA::Long x ACE_ENV_ARG_DECL_NOT_USED)
    ACE_THROW_SPEC ((CORBA::SystemException))
{
  if (TAO_debug_level > 0)
    ACE_DEBUG ((LM_DEBUG, "Request in thread [%t]\n"));
  ACE_Time_Value tv (0, 15000);
  ACE_OS::sleep (tv);
  return x;
}

void
Simple_Server_i::shutdown (ACE_ENV_SINGLE_ARG_DECL)
    ACE_THROW_SPEC ((CORBA::SystemException))
{
  this->orb_->shutdown (0 ACE_ENV_ARG_PARAMETER);
}