1 karl 1.18 //%2003////////////////////////////////////////////////////////////////////////
|
2 mike 1.2 //
|
3 karl 1.18 // 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 mike 1.2 //
|
8 kumpf 1.7 // 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 mike 1.2 //
24 //==============================================================================
25 //
|
26 kumpf 1.16 // Author: Nag Boranna, Hewlett-Packard Company (nagaraja_boranna@hp.com)
|
27 mike 1.2 //
|
28 kumpf 1.16 // Modified By: Jair Santos, Hewlett-Packard Company (jair.santos@hp.com)
|
29 h.sterling 1.18.4.1 // Heather Sterling, IBM (hsterl@us.ibm.com)
|
30 mike 1.2 //
31 //%/////////////////////////////////////////////////////////////////////////////
32
33 #ifndef Pegasus_AuthenticationInfo_h
34 #define Pegasus_AuthenticationInfo_h
35
36 #include <Pegasus/Common/Config.h>
|
37 kumpf 1.10 #include <Pegasus/Common/InternalException.h>
|
38 kumpf 1.5 #include <Pegasus/Common/Tracer.h>
39 #include <Pegasus/Common/AuthenticationInfoRep.h>
|
40 kumpf 1.8 #include <Pegasus/Common/Linkage.h>
|
41 h.sterling 1.18.4.1 #include <Pegasus/Common/SSLContext.h>
|
42 mike 1.2
|
43 gerarda 1.13 #ifdef PEGASUS_KERBEROS_AUTHENTICATION
|
44 gerarda 1.15 #include <Pegasus/Common/CIMKerberosSecurityAssociation.h>
|
45 gerarda 1.13 #endif
|
46 mike 1.2
47 PEGASUS_NAMESPACE_BEGIN
48
|
49 kumpf 1.5
|
50 mike 1.2 /**
51 This class keeps the authentication information of a connection
|
52 kumpf 1.5 persistent until the connection is destroyed.
|
53 mike 1.3
|
54 kumpf 1.5 The HTTPConnection object creates a AuthenticationInfo object on a new
55 socket connection and includes this object reference in the HTTPMessage
56 that gets passed to the Delegator and in turn to the AuthenticationManager.
57 The AuthenticationManager and the related authentication classes use the
58 AuthenticationInfo to store and access the persistent authentication
59 information for a connection.
|
60 mike 1.2 */
61 class PEGASUS_COMMON_LINKAGE AuthenticationInfo
62 {
63 public:
64
|
65 kumpf 1.5 /** Constructor - Creates an uninitiated new AuthenticationInfo
66 object reprenting a AuthenticationInfo class. The class object
67 created by this constructor can only be used in an operation such as the
68 copy constructor. It cannot be used to do method calls like
69 setAuthStatus, getAuthType, etc. since it is unitiated.
70
71 Use one of the other constructors to create an initiated new
72 AuthenticationInfo class object. Throws an exception
73 "unitialized handle" if this unitialized handle is used for
74 method calls.
75 */
76 AuthenticationInfo() : _rep(0)
77 {
78 PEG_METHOD_ENTER(
79 TRC_AUTHENTICATION, "AuthenticationInfo::AuthenticationInfo");
80
81
82 PEG_METHOD_EXIT();
83 }
84
85 /** Creates and instantiates a AuthenticationInfo from another
86 kumpf 1.5 AuthenticationInfo instance
87 @return pointer to the new AuthenticationInfo instance
88 */
89 AuthenticationInfo(const AuthenticationInfo& x)
90 {
91 PEG_METHOD_ENTER(
92 TRC_AUTHENTICATION, "AuthenticationInfo::AuthenticationInfo");
93
94 Inc(_rep = x._rep);
95
96 PEG_METHOD_EXIT();
97 }
98
99 /** Assignment operator */
100 AuthenticationInfo& operator=(const AuthenticationInfo& x)
101 {
102 PEG_METHOD_ENTER(
103 TRC_AUTHENTICATION, "AuthenticationInfo::AuthenticationInfo");
104
105 if (x._rep != _rep)
106 {
107 kumpf 1.5 Dec(_rep);
108 Inc(_rep = x._rep);
109 }
110
111 PEG_METHOD_EXIT();
112 return *this;
113 }
114
115 /** Constructor - Instantiates a AuthenticationInfo object.
116 @param flag - used only to distinguish from the default constructor.
117 */
118 AuthenticationInfo(Boolean flag)
119 {
120 PEG_METHOD_ENTER(
121 TRC_AUTHENTICATION, "AuthenticationInfo::AuthenticationInfo");
|
122 mike 1.2
|
123 kumpf 1.5 _rep = new AuthenticationInfoRep(flag);
124
125 PEG_METHOD_EXIT();
126 }
|
127 mike 1.2
128 /** Destructor */
|
129 kumpf 1.5 ~AuthenticationInfo()
130 {
131 PEG_METHOD_ENTER(
132 TRC_AUTHENTICATION, "AuthenticationInfo::~AuthenticationInfo");
133
134 Dec(_rep);
135
136 PEG_METHOD_EXIT();
137 }
138
139 /** Get the authentication status of the request
140 @return the current authentication status
141 */
142 AuthenticationInfoRep::AuthStatus getAuthStatus() const
143 {
144 _checkRep();
145 return _rep->getAuthStatus();
146 }
147
148 /** Sets the authentication status of the request to the status
149 specified.
150 kumpf 1.5 @param status - the new authentication status
151 */
152 void setAuthStatus(AuthenticationInfoRep::AuthStatus status)
153 {
154 _checkRep();
155 _rep->setAuthStatus(status);
156 }
157
158 /** Get the previously authenticated user name
159 @return the authenticated user name
160 */
161 String getAuthenticatedUser() const
162 {
163 _checkRep();
164 return _rep->getAuthenticatedUser();
165 }
166
167 /** Sets the authenticated user name
168 @param userName - string containing the authenticated user name
169 */
170 void setAuthenticatedUser(const String& userName)
171 kumpf 1.5 {
172 _checkRep();
173 _rep->setAuthenticatedUser(userName);
174 }
175
|
176 kumpf 1.16 /** Get the previously authenticated password
177 @return the authenticated password
178 */
179 String getAuthenticatedPassword() const
180 {
181 _checkRep();
182 return _rep->getAuthenticatedPassword();
183 }
184
185 /** Sets the authenticated password
186 @param password - string containing the authenticated password
187 */
188 void setAuthenticatedPassword(const String& password)
189 {
190 _checkRep();
191 _rep->setAuthenticatedPassword(password);
192 }
193
|
194 kumpf 1.5 /** Get the authentication challenge that was sent to the client
195 @return string containing the authentication challenge
196 */
197 String getAuthChallenge() const
198 {
199 _checkRep();
200 return _rep->getAuthChallenge();
201 }
202
203 /** Sets the authentication challenge to the specified challenge
204 @param challenge - string containing the authentication challenge
205 */
206 void setAuthChallenge(const String& challenge)
207 {
208 _checkRep();
209 _rep->setAuthChallenge(challenge);
210 }
211
212 /** Get the authentication secret that was sent to client
213 @return string containing the authentication secret
214 */
215 kumpf 1.5 String getAuthSecret() const
216 {
217 _checkRep();
218 return _rep->getAuthSecret();
219 }
220
221 /** Set the authentication secret to the specified secret
222 @param secret - string containing the authentication secret
223 */
224 void setAuthSecret(const String& secret)
225 {
226 _checkRep();
227 _rep->setAuthSecret(secret);
228 }
229
230 /** Returns the connection type of the previous authenticated request
231 @return true if the connection is privileged, false otherwise
232 */
233 Boolean isPrivileged() const
234 {
235 _checkRep();
236 kumpf 1.5 return _rep->isPrivileged();
237 }
238
239 /** Set the privileged flag to the specified value
240 @param privileged - boolean flag indicating the connection type
241 */
242 void setPrivileged(Boolean privileged)
243 {
244 _checkRep();
245 _rep->setPrivileged(privileged);
246 }
247
248 /** Is the request authenticated
249 */
250 /** Returns the authentication status of the current connection.
251 @return true if the connection was authenticated, false otherwise
252 */
253 Boolean isAuthenticated() const
254 {
255 _checkRep();
256 return _rep->isAuthenticated();
257 kumpf 1.5 }
258
259 /** Set the authentication type to the specified type
260 @param string containing the authentication type
261 */
262 void setAuthType(const String& authType)
263 {
264 _checkRep();
265 _rep->setAuthType(authType);
266 }
267
268 /** Get the authentication type of the connection
269 @return string containing the authentication type
270 */
271 String getAuthType() const
272 {
273 _checkRep();
274 return _rep->getAuthType();
275 }
|
276 gerarda 1.13
277 #ifdef PEGASUS_KERBEROS_AUTHENTICATION
278 /** Get the CIM Security Association
|
279 gerarda 1.14 @return a pointer to the CIM Security Association
|
280 gerarda 1.13 */
281 CIMKerberosSecurityAssociation* getSecurityAssociation() const
282 {
283 _checkRep();
284 return _rep->getSecurityAssociation();
|
285 gerarda 1.14 }
286
287 /** Set the CIM Security Association
288 The pointer will only be set once. If it is already set it will
289 not reset it.
290 */
291 void setSecurityAssociation()
292 {
293 _checkRep();
|
294 gerarda 1.17 _rep->setSecurityAssociation();
|
295 h.sterling 1.18.4.1 }
296 #endif
297
|
298 h.sterling 1.18.4.2 #ifdef PEGASUS_USE_232_CLIENT_VERIFICATION
|
299 h.sterling 1.18.4.1 #ifdef PEGASUS_HAS_SSL
300 /** Retrieves the SSL Certificate object
301 */
302 SSLCertificateInfo* getPeerCertificate() const
303 {
304 _checkRep();
305 return _rep->getPeerCertificate();
306 }
307
308 /** Set the SSL Certificate object
309 */
310 void setPeerCertificate(SSLCertificateInfo* peerCertificate)
311 {
312 _checkRep();
313 _rep->setPeerCertificate(peerCertificate);
314 }
315
316 /** Retrieves the SSL Certificate status object
317 Returns one of the following values from SSLSocket
318 enum certificateStatusFlag
319 {
320 h.sterling 1.18.4.1 VERIFICATION_DISABLED, //no request for certificate is sent
321 NO_CERT, //certificate is requested, but client does not send one
322 CERT_SUCCESS, //certificate is received and verified against truststore
323 CERT_FAILURE //certificate is received but fails verification against truststore
324 };
325 */
326 Sint32 getCertificateStatus() const
327 {
328 _checkRep();
329 return _rep->getCertificateStatus();
330 }
331
332 /** Sets the certificate status to one of the above values from SSLSocket
333 */
334 void setCertificateStatus(Sint32 certificateStatus)
335 {
336 _checkRep();
337 _rep->setCertificateStatus(certificateStatus);
|
338 gerarda 1.13 }
|
339 h.sterling 1.18.4.2 #endif
|
340 gerarda 1.13 #endif
|
341 kumpf 1.4
|
342 mike 1.2 private:
343
|
344 kumpf 1.5 AuthenticationInfo(AuthenticationInfoRep* rep) : _rep(rep)
345 {
|
346 mike 1.2
|
347 kumpf 1.5 }
|
348 mike 1.2
|
349 kumpf 1.5 void _checkRep() const
350 {
351 if (!_rep)
|
352 kumpf 1.12 throw UninitializedObjectException();
|
353 kumpf 1.5 }
|
354 kumpf 1.4
|
355 kumpf 1.5 AuthenticationInfoRep* _rep;
|
356 mike 1.2 };
357
358 PEGASUS_NAMESPACE_END
359
360 #endif /* Pegasus_AuthenticationInfo_h*/
|