summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_ReceivedCredentials.cpp
blob: a28808b374b2956ddbb1d10398d00aa81bc95063 (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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
// -*- C++ -*-

#include "SSLIOP_ReceivedCredentials.h"

ACE_RCSID (TAO_SSLIOP,
           SSLIOP_ReceivedCredentials,
           "$Id$")


TAO_SSLIOP_ReceivedCredentials::TAO_SSLIOP_ReceivedCredentials (X509 *cert,
                                                                EVP_PKEY *evp)
  : TAO_SSLIOP_Credentials (cert, evp)
{
}

SecurityLevel2::Credentials_ptr
TAO_SSLIOP_ReceivedCredentials::copy (TAO_ENV_SINGLE_ARG_DECL)
  ACE_THROW_SPEC ((CORBA::SystemException))
{
  TAO_SSLIOP_ReceivedCredentials *c = 0;
  ACE_NEW_THROW_EX (c,
                    TAO_SSLIOP_ReceivedCredentials (this->x509_.in (),
                                                    this->evp_.in ()),
                    CORBA::NO_MEMORY (
                      CORBA::SystemException::_tao_minor_code (
                        TAO_DEFAULT_MINOR_CODE,
                        ENOMEM),
                      CORBA::COMPLETED_NO));
  ACE_CHECK_RETURN (SecurityLevel2::Credentials::_nil ());

  return c;
}

Security::InvocationCredentialsType
TAO_SSLIOP_ReceivedCredentials::credentials_type (
    TAO_ENV_SINGLE_ARG_DECL_NOT_USED)
  ACE_THROW_SPEC ((CORBA::SystemException))
{
  return Security::SecReceivedCredentials;
}

SecurityLevel2::Credentials_ptr
TAO_SSLIOP_ReceivedCredentials::accepting_credentials (
    TAO_ENV_SINGLE_ARG_DECL)
  ACE_THROW_SPEC ((CORBA::SystemException))
{
  ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (
                      CORBA::SystemException::_tao_minor_code (
                        TAO_DEFAULT_MINOR_CODE,
                        ENOTSUP),
                      CORBA::COMPLETED_NO),
                    SecurityLevel2::Credentials::_nil ());
}

Security::AssociationOptions
TAO_SSLIOP_ReceivedCredentials::association_options_used (
    TAO_ENV_SINGLE_ARG_DECL)
  ACE_THROW_SPEC ((CORBA::SystemException))
{
  ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (
                      CORBA::SystemException::_tao_minor_code (
                        TAO_DEFAULT_MINOR_CODE,
                        ENOTSUP),
                      CORBA::COMPLETED_NO),
                    Security::Integrity
                    | Security::Confidentiality
                    | Security::NoDelegation);
}

Security::DelegationState
TAO_SSLIOP_ReceivedCredentials::delegation_state (
  TAO_ENV_SINGLE_ARG_DECL_NOT_USED)
  ACE_THROW_SPEC ((CORBA::SystemException))
{
  // It is not possible to perform credentials delegation with SSLIOP,
  // meaning that the peer (i.e., the remote principal) is always the
  // invocation initiator.
  return Security::SecInitiator;
}

Security::DelegationMode
TAO_SSLIOP_ReceivedCredentials::delegation_mode (
    TAO_ENV_SINGLE_ARG_DECL_NOT_USED)
  ACE_THROW_SPEC ((CORBA::SystemException))
{
  // SSLIOP does not support delegation.
  return Security::SecDelModeNoDelegation;
}

// ---------------------------

TAO_SSLIOP_ReceivedCredentials_ptr
TAO_SSLIOP_ReceivedCredentials::_narrow (CORBA::Object_ptr obj
                                         TAO_ENV_ARG_DECL)
{
  return
    TAO_SSLIOP_ReceivedCredentials::_unchecked_narrow (obj
                                                       TAO_ENV_ARG_PARAMETER);
}

TAO_SSLIOP_ReceivedCredentials_ptr
TAO_SSLIOP_ReceivedCredentials::_unchecked_narrow (CORBA::Object_ptr obj
                                                   TAO_ENV_ARG_DECL_NOT_USED)
{
  if (CORBA::is_nil (obj))
    return TAO_SSLIOP_ReceivedCredentials::_nil ();
  return
        ACE_reinterpret_cast
          (
            TAO_SSLIOP_ReceivedCredentials_ptr,
              obj->_tao_QueryInterface
                (
                  ACE_reinterpret_cast
                    (
                      ptr_arith_t,
                      &TAO_SSLIOP_ReceivedCredentials::_tao_class_id
                    )
                )
          );
}

TAO_SSLIOP_ReceivedCredentials_ptr
TAO_SSLIOP_ReceivedCredentials::_duplicate (
  TAO_SSLIOP_ReceivedCredentials_ptr obj)
{
  if (!CORBA::is_nil (obj))
    obj->_add_ref ();

  return obj;
}

void *
TAO_SSLIOP_ReceivedCredentials::_tao_QueryInterface (ptr_arith_t type)
{
  void *retv = 0;
  if (type == ACE_reinterpret_cast
    (ptr_arith_t,
      &TAO_SSLIOP_ReceivedCredentials::_tao_class_id))
    retv = ACE_reinterpret_cast (void*, this);
  else if (type == ACE_reinterpret_cast
    (ptr_arith_t,
      &::SecurityLevel2::Credentials::_tao_class_id))
    retv = ACE_reinterpret_cast
      (
        void *,
        ACE_static_cast
          (
            SecurityLevel2::Credentials_ptr,
            this
          )
      );
  else if (type == ACE_reinterpret_cast (ptr_arith_t, &CORBA::Object::_tao_class_id))
    retv = ACE_reinterpret_cast (void *,
      ACE_static_cast (CORBA::Object_ptr, this));

  if (retv)
    this->_add_ref ();
  return retv;
}

// -----------------------------------------------------------

int TAO_SSLIOP_ReceivedCredentials::_tao_class_id = 0;