1 mike 1.2 //%/////////////////////////////////////////////////////////////////////////////
2 //
|
3 kumpf 1.7 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,
|
4 mike 1.2 // The Open Group, Tivoli Systems
5 //
|
6 kumpf 1.7 // Permission is hereby granted, free of charge, to any person obtaining a copy
7 // of this software and associated documentation files (the "Software"), to
8 // deal in the Software without restriction, including without limitation the
9 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 // sell copies of the Software, and to permit persons to whom the Software is
11 // furnished to do so, subject to the following conditions:
12 //
13 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
14 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
15 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
16 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
17 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
18 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21 mike 1.2 //
22 //==============================================================================
23 //
24 // Author: Nag Boranna, Hewlett-Packard Company(nagaraja_boranna@hp.com)
25 //
26 // Modified By:
27 //
28 //%/////////////////////////////////////////////////////////////////////////////
29
30 #ifndef Pegasus_AuthenticationInfo_h
31 #define Pegasus_AuthenticationInfo_h
32
33 #include <Pegasus/Common/Config.h>
|
34 kumpf 1.10 #include <Pegasus/Common/InternalException.h>
|
35 kumpf 1.5 #include <Pegasus/Common/Tracer.h>
36 #include <Pegasus/Common/AuthenticationInfoRep.h>
|
37 kumpf 1.8 #include <Pegasus/Common/Linkage.h>
|
38 mike 1.2
|
39 gerarda 1.13 #ifdef PEGASUS_KERBEROS_AUTHENTICATION
40 #include "CIMKerberosSecurityAssociation.h"
41 #endif
|
42 mike 1.2
43 PEGASUS_NAMESPACE_BEGIN
44
|
45 kumpf 1.5
|
46 mike 1.2 /**
47 This class keeps the authentication information of a connection
|
48 kumpf 1.5 persistent until the connection is destroyed.
|
49 mike 1.3
|
50 kumpf 1.5 The HTTPConnection object creates a AuthenticationInfo object on a new
51 socket connection and includes this object reference in the HTTPMessage
52 that gets passed to the Delegator and in turn to the AuthenticationManager.
53 The AuthenticationManager and the related authentication classes use the
54 AuthenticationInfo to store and access the persistent authentication
55 information for a connection.
|
56 mike 1.2 */
57 class PEGASUS_COMMON_LINKAGE AuthenticationInfo
58 {
59 public:
60
|
61 kumpf 1.5 /** Constructor - Creates an uninitiated new AuthenticationInfo
62 object reprenting a AuthenticationInfo class. The class object
63 created by this constructor can only be used in an operation such as the
64 copy constructor. It cannot be used to do method calls like
65 setAuthStatus, getAuthType, etc. since it is unitiated.
66
67 Use one of the other constructors to create an initiated new
68 AuthenticationInfo class object. Throws an exception
69 "unitialized handle" if this unitialized handle is used for
70 method calls.
71 */
72 AuthenticationInfo() : _rep(0)
73 {
74 PEG_METHOD_ENTER(
75 TRC_AUTHENTICATION, "AuthenticationInfo::AuthenticationInfo");
76
77
78 PEG_METHOD_EXIT();
79 }
80
81 /** Creates and instantiates a AuthenticationInfo from another
82 kumpf 1.5 AuthenticationInfo instance
83 @return pointer to the new AuthenticationInfo instance
84 */
85 AuthenticationInfo(const AuthenticationInfo& x)
86 {
87 PEG_METHOD_ENTER(
88 TRC_AUTHENTICATION, "AuthenticationInfo::AuthenticationInfo");
89
90 Inc(_rep = x._rep);
91
92 PEG_METHOD_EXIT();
93 }
94
95 /** Assignment operator */
96 AuthenticationInfo& operator=(const AuthenticationInfo& x)
97 {
98 PEG_METHOD_ENTER(
99 TRC_AUTHENTICATION, "AuthenticationInfo::AuthenticationInfo");
100
101 if (x._rep != _rep)
102 {
103 kumpf 1.5 Dec(_rep);
104 Inc(_rep = x._rep);
105 }
106
107 PEG_METHOD_EXIT();
108 return *this;
109 }
110
111 /** Constructor - Instantiates a AuthenticationInfo object.
112 @param flag - used only to distinguish from the default constructor.
113 */
114 AuthenticationInfo(Boolean flag)
115 {
116 PEG_METHOD_ENTER(
117 TRC_AUTHENTICATION, "AuthenticationInfo::AuthenticationInfo");
|
118 mike 1.2
|
119 kumpf 1.5 _rep = new AuthenticationInfoRep(flag);
120
121 PEG_METHOD_EXIT();
122 }
|
123 mike 1.2
124 /** Destructor */
|
125 kumpf 1.5 ~AuthenticationInfo()
126 {
127 PEG_METHOD_ENTER(
128 TRC_AUTHENTICATION, "AuthenticationInfo::~AuthenticationInfo");
129
130 Dec(_rep);
131
132 PEG_METHOD_EXIT();
133 }
134
135 /** Get the authentication status of the request
136 @return the current authentication status
137 */
138 AuthenticationInfoRep::AuthStatus getAuthStatus() const
139 {
140 _checkRep();
141 return _rep->getAuthStatus();
142 }
143
144 /** Sets the authentication status of the request to the status
145 specified.
146 kumpf 1.5 @param status - the new authentication status
147 */
148 void setAuthStatus(AuthenticationInfoRep::AuthStatus status)
149 {
150 _checkRep();
151 _rep->setAuthStatus(status);
152 }
153
154 /** Get the previously authenticated user name
155 @return the authenticated user name
156 */
157 String getAuthenticatedUser() const
158 {
159 _checkRep();
160 return _rep->getAuthenticatedUser();
161 }
162
163 /** Sets the authenticated user name
164 @param userName - string containing the authenticated user name
165 */
166 void setAuthenticatedUser(const String& userName)
167 kumpf 1.5 {
168 _checkRep();
169 _rep->setAuthenticatedUser(userName);
170 }
171
172 /** Get the authentication challenge that was sent to the client
173 @return string containing the authentication challenge
174 */
175 String getAuthChallenge() const
176 {
177 _checkRep();
178 return _rep->getAuthChallenge();
179 }
180
181 /** Sets the authentication challenge to the specified challenge
182 @param challenge - string containing the authentication challenge
183 */
184 void setAuthChallenge(const String& challenge)
185 {
186 _checkRep();
187 _rep->setAuthChallenge(challenge);
188 kumpf 1.5 }
189
190 /** Get the authentication secret that was sent to client
191 @return string containing the authentication secret
192 */
193 String getAuthSecret() const
194 {
195 _checkRep();
196 return _rep->getAuthSecret();
197 }
198
199 /** Set the authentication secret to the specified secret
200 @param secret - string containing the authentication secret
201 */
202 void setAuthSecret(const String& secret)
203 {
204 _checkRep();
205 _rep->setAuthSecret(secret);
206 }
207
208 /** Returns the connection type of the previous authenticated request
209 kumpf 1.5 @return true if the connection is privileged, false otherwise
210 */
211 Boolean isPrivileged() const
212 {
213 _checkRep();
214 return _rep->isPrivileged();
215 }
216
217 /** Set the privileged flag to the specified value
218 @param privileged - boolean flag indicating the connection type
219 */
220 void setPrivileged(Boolean privileged)
221 {
222 _checkRep();
223 _rep->setPrivileged(privileged);
224 }
225
226 /** Is the request authenticated
227 */
228 /** Returns the authentication status of the current connection.
229 @return true if the connection was authenticated, false otherwise
230 kumpf 1.5 */
231 Boolean isAuthenticated() const
232 {
233 _checkRep();
234 return _rep->isAuthenticated();
235 }
236
237 /** Set the authentication type to the specified type
238 @param string containing the authentication type
239 */
240 void setAuthType(const String& authType)
241 {
242 _checkRep();
243 _rep->setAuthType(authType);
244 }
245
246 /** Get the authentication type of the connection
247 @return string containing the authentication type
248 */
249 String getAuthType() const
250 {
251 kumpf 1.5 _checkRep();
252 return _rep->getAuthType();
253 }
|
254 gerarda 1.13
255 #ifdef PEGASUS_KERBEROS_AUTHENTICATION
256 /** Get the CIM Security Association
|
257 gerarda 1.14 @return a pointer to the CIM Security Association
|
258 gerarda 1.13 */
259 CIMKerberosSecurityAssociation* getSecurityAssociation() const
260 {
261 _checkRep();
262 return _rep->getSecurityAssociation();
|
263 gerarda 1.14 }
264
265 /** Set the CIM Security Association
266 The pointer will only be set once. If it is already set it will
267 not reset it.
268 */
269 void setSecurityAssociation()
270 {
271 _checkRep();
272 return _rep->setSecurityAssociation();
|
273 gerarda 1.13 }
274 #endif
|
275 kumpf 1.4
|
276 mike 1.2 private:
277
|
278 kumpf 1.5 AuthenticationInfo(AuthenticationInfoRep* rep) : _rep(rep)
279 {
|
280 mike 1.2
|
281 kumpf 1.5 }
|
282 mike 1.2
|
283 kumpf 1.5 void _checkRep() const
284 {
285 if (!_rep)
|
286 kumpf 1.12 throw UninitializedObjectException();
|
287 kumpf 1.5 }
|
288 kumpf 1.4
|
289 kumpf 1.5 AuthenticationInfoRep* _rep;
|
290 mike 1.2 };
291
292 PEGASUS_NAMESPACE_END
293
294 #endif /* Pegasus_AuthenticationInfo_h*/
|