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