PEP 55 Update license on source files to current license text and date
[tpot/pegasus/.git] / InterfaceArchive / v002001 / include / Pegasus / Common / OperationContext.h
1 //%2003////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (c) 2000, 2001, 2002  BMC Software, Hewlett-Packard Development
4 // Company, L. P., IBM Corp., The Open Group, Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.;
6 // IBM Corp.; EMC Corporation, The Open Group.
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to
10 // deal in the Software without restriction, including without limitation the
11 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 // sell copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 // 
15 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
16 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
17 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
18 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
19 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 //
24 //==============================================================================
25 //
26 //%/////////////////////////////////////////////////////////////////////////////
27
28 #ifndef Pegasus_OperationContext_h
29 #define Pegasus_OperationContext_h
30
31 #include <Pegasus/Common/Config.h>
32 #include <Pegasus/Common/Exception.h>
33 #include <Pegasus/Common/Linkage.h>
34
35 PEGASUS_NAMESPACE_BEGIN
36
37 class OperationContextRep;
38
39 /**
40 Context information from client.
41
42 <p>The <tt>OperationContext</tt> class carries information about
43 the context in which the client program issued the request.
44 Currently, the identity of the user is the only supported
45 information. Providers must use this to determine whether
46 the requested operation should be permitted on behalf of
47 the issuing user.
48
49 For example, providers can get the user name information from the
50 IdentityContext in an OperationContext as shown below:
51
52     <PRE>
53     IdentityContainer container(context.get(IdentityContainer::NAME));
54     String userName = container.getUserName();
55     </PRE>
56 </p>
57 */
58 class PEGASUS_COMMON_LINKAGE OperationContext
59 {
60 public:
61     /**
62         An element of client context information.
63     
64         <p>The <tt>Container</tt> object carries the information that
65         the provider may access. A container name determines which
66         container is being referenced. Currently, only the container
67         carrying the user identity of the client is available.</p>
68     */
69     class PEGASUS_COMMON_LINKAGE Container
70     {
71     public:
72
73         ///
74         virtual ~Container(void);
75
76         ///
77         virtual String getName(void) const = 0;
78
79
80         /** Makes a copy of the Container object. Caller is responsible 
81             for deleting dynamically allocated memory by calling 
82             destroy() method.
83         */
84         virtual Container * clone(void) const = 0;
85
86         /** Cleans up the object, including dynamically allocated memory.
87             This should only be used to clean up memory allocated using 
88             the clone() method.
89         */
90         virtual void destroy(void) = 0;
91
92     };
93
94 public:
95     ///
96     OperationContext(void);
97
98     ///
99     OperationContext(const OperationContext & context);
100
101     ///
102     virtual ~OperationContext(void);
103
104     ///
105     OperationContext & operator=(const OperationContext & context);
106
107     /// Removes all containers in the current object.
108     void clear(void);
109
110     ///
111     const Container & get(const String& containerName) const;
112
113     ///
114     void set(const Container & container);
115
116     ///
117     void insert(const Container & container);
118
119     ///
120     void remove(const String& containerName);
121
122 protected:
123     OperationContextRep* _rep;
124
125 };
126
127
128 class IdentityContainerRep;
129
130 ///
131 class PEGASUS_COMMON_LINKAGE IdentityContainer
132     :
133       virtual
134               public OperationContext::Container
135 {
136 public:
137     static const String NAME;
138
139     ///
140     IdentityContainer(const OperationContext::Container & container);
141     ///
142     IdentityContainer(const IdentityContainer & container);
143     ///
144     IdentityContainer(const String & userName);
145     ///
146     virtual ~IdentityContainer(void);
147     ///
148     IdentityContainer & operator=(const IdentityContainer & container);
149     ///
150     virtual String getName(void) const;
151     ///
152     virtual OperationContext::Container * clone(void) const;
153     ///
154     virtual void destroy(void);
155     ///
156     String getUserName(void) const;
157
158 protected:
159     IdentityContainerRep* _rep;
160
161 };
162
163 PEGASUS_NAMESPACE_END
164
165 #endif