1 //%2003////////////////////////////////////////////////////////////////////////
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.
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:
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.
24 //==============================================================================
26 //%/////////////////////////////////////////////////////////////////////////////
28 #ifndef Pegasus_OperationContext_h
29 #define Pegasus_OperationContext_h
31 #include <Pegasus/Common/Config.h>
32 #include <Pegasus/Common/Exception.h>
33 #include <Pegasus/Common/Linkage.h>
35 PEGASUS_NAMESPACE_BEGIN
37 class OperationContextRep;
40 Context information from client.
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
49 For example, providers can get the user name information from the
50 IdentityContext in an OperationContext as shown below:
53 IdentityContainer container(context.get(IdentityContainer::NAME));
54 String userName = container.getUserName();
58 class PEGASUS_COMMON_LINKAGE OperationContext
62 An element of client context information.
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>
69 class PEGASUS_COMMON_LINKAGE Container
74 virtual ~Container(void);
77 virtual String getName(void) const = 0;
80 /** Makes a copy of the Container object. Caller is responsible
81 for deleting dynamically allocated memory by calling
84 virtual Container * clone(void) const = 0;
86 /** Cleans up the object, including dynamically allocated memory.
87 This should only be used to clean up memory allocated using
90 virtual void destroy(void) = 0;
96 OperationContext(void);
99 OperationContext(const OperationContext & context);
102 virtual ~OperationContext(void);
105 OperationContext & operator=(const OperationContext & context);
107 /// Removes all containers in the current object.
111 const Container & get(const String& containerName) const;
114 void set(const Container & container);
117 void insert(const Container & container);
120 void remove(const String& containerName);
123 OperationContextRep* _rep;
128 class IdentityContainerRep;
131 class PEGASUS_COMMON_LINKAGE IdentityContainer
134 public OperationContext::Container
137 static const String NAME;
140 IdentityContainer(const OperationContext::Container & container);
142 IdentityContainer(const IdentityContainer & container);
144 IdentityContainer(const String & userName);
146 virtual ~IdentityContainer(void);
148 IdentityContainer & operator=(const IdentityContainer & container);
150 virtual String getName(void) const;
152 virtual OperationContext::Container * clone(void) const;
154 virtual void destroy(void);
156 String getUserName(void) const;
159 IdentityContainerRep* _rep;
163 PEGASUS_NAMESPACE_END