summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Credentials.h
blob: c9f89d93b106175238786899e60393890510835a (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
164
165
166
167
168
169
170
171
172
173
174
175
// -*- C++ -*-

//=============================================================================
/**
 *  @file   SSLIOP_Credentials.h
 *
 *  $Id$
 *
 *  @author Ossama Othman <ossama@dre.vanderbilt.edu>
 */
//=============================================================================

#ifndef TAO_SSLIOP_CREDENTIALS_H
#define TAO_SSLIOP_CREDENTIALS_H

#include /**/ "ace/pre.h"

#include "orbsvcs/SSLIOP/SSLIOP_Export.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
#pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#include "orbsvcs/SSLIOP/SSLIOP_X509.h"
#include "orbsvcs/SSLIOP/SSLIOP_EVP_PKEY.h"
#include "orbsvcs/SecurityLevel3C.h"
#include "tao/LocalObject.h"


TAO_BEGIN_VERSIONED_NAMESPACE_DECL

namespace TAO
{
  class SSLIOP_Credentials;

   namespace SSLIOP
   {
     typedef SSLIOP_Credentials* Credentials_ptr;
     typedef TAO_Pseudo_Var_T<SSLIOP_Credentials> Credentials_var;
     typedef TAO_Pseudo_Out_T<SSLIOP_Credentials> Credentials_out;
   }

    /**
     * @class SSLIOP_Credentials
     *
     * @brief SSLIOP-specific implementation of the
     *        SecurityLevel3::Credentials interface.
     *
     * This class encapsulates the X.509 certificate associated with a
     * given a principal.
     *
     * @note Why is this class not the TAO::SSLIOP namespace?  Because
     *       brain damaged MSVC++ 6 cannot call a base class
     *       constructor of class declared in a namespace that is more
     *       than one level deep in a sub-class base member
     *       initializer list.
     */
    class TAO_SSLIOP_Export SSLIOP_Credentials
      : public virtual SecurityLevel3::Credentials,
        public virtual TAO_Local_RefCounted_Object
    {
    public:
      typedef SSLIOP::Credentials_ptr _ptr_type;
      typedef SSLIOP::Credentials_var _var_type;
      typedef SSLIOP::Credentials_out _out_type;

      /// Constructor
      SSLIOP_Credentials (::X509 * cert, ::EVP_PKEY * evp);

      /**
       * @name SecurityLevel3::Credentials Methods
       *
       * Methods required by the SecurityLevel3::Credentials
       * interface.
       */
      //@{
      virtual char * creds_id (void);

      virtual
      SecurityLevel3::CredentialsType creds_type (void)
        = 0;

      virtual SecurityLevel3::CredentialsUsage creds_usage ();

      virtual TimeBase::UtcT expiry_time (void);

      virtual SecurityLevel3::CredentialsState creds_state ();

      virtual char * add_relinquished_listener (
          SecurityLevel3::RelinquishedCredentialsListener_ptr listener);

      virtual void remove_relinquished_listener (const char * id);
      //@}


      //@{
      /// Return a pointer to the underlying X.509 certificate.
      /**
       * @note Caller owns the returned object.  Use a
       *       TAO::SSLIOP::X509_var.
       */
      ::X509 *x509 (void);
      //@}

      /// Return a pointer to the underlying private key.
      /**
       * @return Non-zero value if private key is used.
       *
       * @note Caller owns the returned object.  Use a
       *       TAO::SSLIOP::EVP_PKEY_var.
       */
      ::EVP_PKEY *evp (void);
      //@}

      bool operator== (const SSLIOP_Credentials &rhs);

      CORBA::ULong hash (void) const;

      // The static operations.
      static SSLIOP::Credentials_ptr _duplicate (SSLIOP::Credentials_ptr obj);

      static SSLIOP::Credentials_ptr _narrow (CORBA::Object_ptr obj);

      static SSLIOP::Credentials_ptr _nil (void)
      {
        return (SSLIOP::Credentials_ptr) 0;
      }

      //@}

    protected:

      /// Destructor.
      /**
       * Protected destructor to enforce proper memory management
       * through the reference counting  mechanism.
       */
      ~SSLIOP_Credentials (void);

    protected:

      /// Reference to the X.509 certificate associated with this SSLIOP
      /// Credentials object.
      SSLIOP::X509_var x509_;

      /// Reference to the private key associated with the X.509
      /// certificate.
      SSLIOP::EVP_PKEY_var evp_;

      /// Credentials Identifier.
      CORBA::String_var id_;

      /// The intended usage of the Credentials.
      SecurityLevel3::CredentialsUsage creds_usage_;

      /// The time these Credentials expire.
      TimeBase::UtcT expiry_time_;

      /// The validity of the Credentials.
      SecurityLevel3::CredentialsState creds_state_;

    };

//   } // End SSLIOP namespace
}   // End TAO namespace

TAO_END_VERSIONED_NAMESPACE_DECL

#if defined (__ACE_INLINE__)
# include "orbsvcs/SSLIOP/SSLIOP_Credentials.inl"
#endif /* __ACE_INLINE__ */

#include /**/ "ace/post.h"

#endif  /* TAO_SSLIOP_CREDENTIALS_H */