summaryrefslogtreecommitdiff
path: root/TAO/tao/Principal.h
blob: 234be48bcef4dd59a6b6d9176912d71a3b011159 (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
// This may look like C, but it's really -*- C++ -*-

//=============================================================================
/**
 *  @file    Principal.h
 *
 *  $Id$
 *
 *  The CORBA::Principal pseudo-object implementation.
 *
 *  @author  Copyright 1994-1995 by Sun Microsystems Inc.
 *  @author  DOC group at Wash U and UCI.
 */
//=============================================================================


#ifndef TAO_PRINCIPAL_H
#define TAO_PRINCIPAL_H
#include "ace/pre.h"

#include "corbafwd.h"

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

#include "OctetSeqC.h"
#include "ace/Synch_T.h"

namespace CORBA
{
  /**
   * @class Principal
   *
   * @brief A "Principal" identifies an authenticated entity in the
   * network administration framework.
   *
   * Identities are used to control acccess (authorization) as well as
   * in audit trails (accountability).
   *
   * @note This CORBA feature has been deprecated by the OMG.  Use the
   *       CORBA Security Service instead.
   */
  class TAO_Export Principal
  {
  public:
    // To applications, the identifier is an opaque ID.

    //  CORBA::SEQUENCE <CORBA::Octet> id;
    CORBA::OctetSeq id;

    // @@ add "==", "<", ">" operators

    // The pseudo object operations.
    static Principal* _duplicate (Principal*);
    static Principal* _nil (void);

    // = Stuff required for memory management.
    CORBA::ULong _incr_refcnt (void);
    CORBA::ULong _decr_refcnt (void);

    Principal (void);

#if !defined(__GNUC__) || __GNUC__ > 2 || __GNUC_MINOR__ >= 8
    typedef Principal_ptr _ptr_type;
    typedef Principal_var _var_type;
#endif /* __GNUC__ */
  // Useful for template programming.

  protected:

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

  private:

    // = Prevent copying
    Principal &operator = (const CORBA::Principal_ptr &);
    Principal (const CORBA::Principal_ptr &);

  private:
    /// Number of outstanding references to this object.
    CORBA::ULong refcount_;

    /// Protect the reference count, this is OK because we do no
    /// duplicates or releases on the critical path.
    TAO_SYNCH_MUTEX refcount_mutex_;

  };

  /**
   * @class Principal_var
   *
   * @brief The T_var class for CORBA::Principal
   *
   * As any other pseudo object Principal must have a T_var class,
   * the interface an semantics are specified in the CORBA spec.
   */
  class TAO_Export Principal_var
  {
  public:
    Principal_var (void);
    Principal_var (Principal_ptr);
    Principal_var (const Principal_var &);
    ~Principal_var (void);

    Principal_var &operator= (Principal_ptr);
    Principal_var &operator= (const Principal_var &);
    Principal_ptr operator-> (void) const;

    /// in, inout, out, _retn
    operator const Principal_ptr &() const;
    operator Principal_ptr &();
    Principal_ptr in (void) const;
    Principal_ptr &inout (void);
    Principal_ptr &out (void);
    Principal_ptr _retn (void);
    Principal_ptr ptr (void) const;

  private:
    Principal_ptr ptr_;
  };

  /**
   * @class Principal_out
   *
   * @brief The T_out class for CORBA::Principal
   *
   * As any other pseudo object Principal must have a T_out class,
   * the interface an semantics are specified in the CORBA spec.
   */
  class TAO_Export Principal_out
  {
  public:
    Principal_out (Principal_ptr &);
    Principal_out (Principal_var &);
    Principal_out (Principal_out &);
    Principal_out &operator= (Principal_out &);
    Principal_out &operator= (const Principal_var &);
    Principal_out &operator= (Principal_ptr);
    operator Principal_ptr &();
    Principal_ptr &ptr (void);
    Principal_ptr operator-> (void);

  private:
    Principal_ptr &ptr_;
  };
}  // End CORBA namespace

TAO_Export CORBA::Boolean
operator<< (TAO_OutputCDR&, CORBA::Principal*);

TAO_Export CORBA::Boolean
operator>> (TAO_InputCDR&, CORBA::Principal*&);

#if defined (__ACE_INLINE__)
# include "tao/Principal.i"
#endif /* __ACE_INLINE__ */

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