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