summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/tests/Security/mixed_security_test/Foo_i.cpp
blob: 95f90ea6b778b764cb406de963f521acbab66de4 (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
// -*- C++ -*-

#include "Foo_i.h"

#include "ace/OS_NS_string.h"


ACE_RCSID (Secure_Invocation,
           Foo_i,
           "$Id$")


Foo_i::Foo_i (CORBA::ORB_ptr orb,
              SecurityLevel3::SecurityCurrent_ptr current)
  : orb_ (CORBA::ORB::_duplicate (orb)),
    current_ (SecurityLevel3::SecurityCurrent::_duplicate (current))
{
}

void
Foo_i::baz (void)
{
  if (this->current_.in() == 0)
    {
      ACE_DEBUG ((LM_DEBUG, "FOO (%P|%t) No ClientCredentials available \n"));
      return;
    }

  try
    {
      SecurityLevel3::ClientCredentials_var credentials =
        this->current_->client_credentials ();

      CORBA::String_var id = credentials->creds_id ();

      ACE_DEBUG ((LM_DEBUG,
                  "FOO (%P|%t) ClientCredentials ID: %s\n", id.in ()));
      return;
    }
  catch (const CORBA::BAD_INV_ORDER &ex)
    {
      ACE_DEBUG ((LM_INFO,
                  "FOO (%P|%t) Caught BAD_INV_ORDER exception trying to obtain "
                  "client credentials.  This is okay if the invocation was via "
                  "non-secured means.\n"));
      ex._tao_print_exception ("obtaining client credentials");
      // should we re-throw? No, because what we're testing is whether
      // we go into this method, not whether the method itself operates
      // properly.
    }
  catch (CORBA::Exception& ex)
    {
      ACE_DEBUG ((LM_ERROR, "FOO (%P|%t) Caught exception, trying to obtain ClientCredentials"));
      ex._tao_print_exception ("Exception");
    }

}

void
Foo_i::shutdown (void)
{
  this->orb_->shutdown (0);
}