summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_X509.inl
blob: f45342d12a0028dd262fa98c6108a1ee29d12d32 (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
// -*- C++ -*-
//
// $Id$

ACE_INLINE ::X509 *
TAO::SSLIOP::_duplicate (::X509 *cert)
{
  // OpenSSL provides no function to increase the reference count on
  // the X509 structure, so we do it manually.  (X509_dup() performs a
  // deep copy, not a shallow copy.)
  if (cert != 0)
    CRYPTO_add (&(cert->references), 1, CRYPTO_LOCK_X509);

  return cert;
}

ACE_INLINE void
TAO::SSLIOP::release (::X509 *cert)
{
  // OpenSSL's X509_free() function already handles reference counting
  // properly.
  ::X509_free (cert);
}


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

ACE_INLINE
TAO::SSLIOP::X509_var::X509_var (void)
  : x509_ (0)
{
}

ACE_INLINE
TAO::SSLIOP::X509_var::X509_var (::X509 *x)
  : x509_ (x)
{
}

ACE_INLINE
TAO::SSLIOP::X509_var::X509_var (const TAO::SSLIOP::X509_var &p)
  : TAO_Base_var (),
    x509_ (TAO::SSLIOP::_duplicate (p.ptr ()))
{
}

ACE_INLINE
TAO::SSLIOP::X509_var::X509_var (const ::X509 &p)
{
  this->x509_ = X509_dup (const_cast< ::X509 * > (&p));
}

ACE_INLINE
TAO::SSLIOP::X509_var::~X509_var (void)
{
  TAO::SSLIOP::release (this->x509_);
}

ACE_INLINE TAO::SSLIOP::X509_var &
TAO::SSLIOP::X509_var::operator= (::X509 *p)
{
  TAO::SSLIOP::release (this->x509_);
  this->x509_ = p;
  return *this;
}

ACE_INLINE ::TAO::SSLIOP::X509_var &
TAO::SSLIOP::X509_var::operator= (const ::TAO::SSLIOP::X509_var &p)
{
  if (this != &p)
    {
      TAO::SSLIOP::release (this->x509_);
      this->x509_ = TAO::SSLIOP::_duplicate (p.ptr ());
    }

  return *this;
}

ACE_INLINE TAO::SSLIOP::X509_var &
TAO::SSLIOP::X509_var::operator= (const ::X509 &p)
{
  if (this->x509_ != &p)
    {
      TAO::SSLIOP::release (this->x509_);
      this->x509_ = X509_dup (const_cast< ::X509 * > (&p));
    }

  return *this;
}

ACE_INLINE const ::X509 *
TAO::SSLIOP::X509_var::operator-> (void) const
{
  return this->x509_;
}

ACE_INLINE ::X509 *
TAO::SSLIOP::X509_var::operator-> (void)
{
  return this->x509_;
}

ACE_INLINE
TAO::SSLIOP::X509_var::operator const ::X509 &() const
{
  return *this->x509_;
}

ACE_INLINE
TAO::SSLIOP::X509_var::operator ::X509 &()
{
  return *this->x509_;
}

ACE_INLINE ::X509 *
TAO::SSLIOP::X509_var::in (void) const
{
  return this->x509_;
}

ACE_INLINE ::X509 *&
TAO::SSLIOP::X509_var::inout (void)
{
  return this->x509_;
}

ACE_INLINE ::X509 *&
TAO::SSLIOP::X509_var::out (void)
{
  X509_free (this->x509_);
  this->x509_ = 0;
  return this->x509_;
}

ACE_INLINE ::X509 *
TAO::SSLIOP::X509_var::_retn (void)
{
  // Yield ownership of the X509 structure.
  ::X509 *x = this->x509_;
  this->x509_ = 0;
  return x;
}

ACE_INLINE ::X509 *
TAO::SSLIOP::X509_var::ptr (void) const
{
  return this->x509_;
}