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
40 PEGASUS_NAMESPACE_BEGIN
41
|
42 kumpf 1.5
|
43 mike 1.2 /**
44 This class keeps the authentication information of a connection
|
45 kumpf 1.5 persistent until the connection is destroyed.
|
46 mike 1.3
|
47 kumpf 1.5 The HTTPConnection object creates a AuthenticationInfo object on a new
48 socket connection and includes this object reference in the HTTPMessage
49 that gets passed to the Delegator and in turn to the AuthenticationManager.
50 The AuthenticationManager and the related authentication classes use the
51 AuthenticationInfo to store and access the persistent authentication
52 information for a connection.
|
53 mike 1.2 */
54 class PEGASUS_COMMON_LINKAGE AuthenticationInfo
55 {
56 public:
57
|
58 kumpf 1.5 /** Constructor - Creates an uninitiated new AuthenticationInfo
59 object reprenting a AuthenticationInfo class. The class object
60 created by this constructor can only be used in an operation such as the
61 copy constructor. It cannot be used to do method calls like
62 setAuthStatus, getAuthType, etc. since it is unitiated.
63
64 Use one of the other constructors to create an initiated new
65 AuthenticationInfo class object. Throws an exception
66 "unitialized handle" if this unitialized handle is used for
67 method calls.
68 */
69 AuthenticationInfo() : _rep(0)
70 {
71 PEG_METHOD_ENTER(
72 TRC_AUTHENTICATION, "AuthenticationInfo::AuthenticationInfo");
73
74
75 PEG_METHOD_EXIT();
76 }
77
78 /** Creates and instantiates a AuthenticationInfo from another
79 kumpf 1.5 AuthenticationInfo instance
80 @return pointer to the new AuthenticationInfo instance
81 */
82 AuthenticationInfo(const AuthenticationInfo& x)
83 {
84 PEG_METHOD_ENTER(
85 TRC_AUTHENTICATION, "AuthenticationInfo::AuthenticationInfo");
86
87 Inc(_rep = x._rep);
88
89 PEG_METHOD_EXIT();
90 }
91
92 /** Assignment operator */
93 AuthenticationInfo& operator=(const AuthenticationInfo& x)
94 {
95 PEG_METHOD_ENTER(
96 TRC_AUTHENTICATION, "AuthenticationInfo::AuthenticationInfo");
97
98 if (x._rep != _rep)
99 {
100 kumpf 1.5 Dec(_rep);
101 Inc(_rep = x._rep);
102 }
103
104 PEG_METHOD_EXIT();
105 return *this;
106 }
107
108 /** Constructor - Instantiates a AuthenticationInfo object.
109 @param flag - used only to distinguish from the default constructor.
110 */
111 AuthenticationInfo(Boolean flag)
112 {
113 PEG_METHOD_ENTER(
114 TRC_AUTHENTICATION, "AuthenticationInfo::AuthenticationInfo");
|
115 mike 1.2
|
116 kumpf 1.5 _rep = new AuthenticationInfoRep(flag);
117
118 PEG_METHOD_EXIT();
119 }
|
120 mike 1.2
121 /** Destructor */
|
122 kumpf 1.5 ~AuthenticationInfo()
123 {
124 PEG_METHOD_ENTER(
125 TRC_AUTHENTICATION, "AuthenticationInfo::~AuthenticationInfo");
126
127 Dec(_rep);
128
129 PEG_METHOD_EXIT();
130 }
131
132 /** Get the authentication status of the request
133 @return the current authentication status
134 */
135 AuthenticationInfoRep::AuthStatus getAuthStatus() const
136 {
137 _checkRep();
138 return _rep->getAuthStatus();
139 }
140
141 /** Sets the authentication status of the request to the status
142 specified.
143 kumpf 1.5 @param status - the new authentication status
144 */
145 void setAuthStatus(AuthenticationInfoRep::AuthStatus status)
146 {
147 _checkRep();
148 _rep->setAuthStatus(status);
149 }
150
151 /** Get the previously authenticated user name
152 @return the authenticated user name
153 */
154 String getAuthenticatedUser() const
155 {
156 _checkRep();
157 return _rep->getAuthenticatedUser();
158 }
159
160 /** Sets the authenticated user name
161 @param userName - string containing the authenticated user name
162 */
163 void setAuthenticatedUser(const String& userName)
164 kumpf 1.5 {
165 _checkRep();
166 _rep->setAuthenticatedUser(userName);
167 }
168
169 /** Get the authentication challenge that was sent to the client
170 @return string containing the authentication challenge
171 */
172 String getAuthChallenge() const
173 {
174 _checkRep();
175 return _rep->getAuthChallenge();
176 }
177
178 /** Sets the authentication challenge to the specified challenge
179 @param challenge - string containing the authentication challenge
180 */
181 void setAuthChallenge(const String& challenge)
182 {
183 _checkRep();
184 _rep->setAuthChallenge(challenge);
185 kumpf 1.5 }
186
187 /** Get the authentication secret that was sent to client
188 @return string containing the authentication secret
189 */
190 String getAuthSecret() const
191 {
192 _checkRep();
193 return _rep->getAuthSecret();
194 }
195
196 /** Set the authentication secret to the specified secret
197 @param secret - string containing the authentication secret
198 */
199 void setAuthSecret(const String& secret)
200 {
201 _checkRep();
202 _rep->setAuthSecret(secret);
203 }
204
205 /** Returns the connection type of the previous authenticated request
206 kumpf 1.5 @return true if the connection is privileged, false otherwise
207 */
208 Boolean isPrivileged() const
209 {
210 _checkRep();
211 return _rep->isPrivileged();
212 }
213
214 /** Set the privileged flag to the specified value
215 @param privileged - boolean flag indicating the connection type
216 */
217 void setPrivileged(Boolean privileged)
218 {
219 _checkRep();
220 _rep->setPrivileged(privileged);
221 }
222
223 /** Is the request authenticated
224 */
225 /** Returns the authentication status of the current connection.
226 @return true if the connection was authenticated, false otherwise
227 kumpf 1.5 */
228 Boolean isAuthenticated() const
229 {
230 _checkRep();
231 return _rep->isAuthenticated();
232 }
233
234 /** Set the authentication type to the specified type
235 @param string containing the authentication type
236 */
237 void setAuthType(const String& authType)
238 {
239 _checkRep();
240 _rep->setAuthType(authType);
241 }
242
243 /** Get the authentication type of the connection
244 @return string containing the authentication type
245 */
246 String getAuthType() const
247 {
248 kumpf 1.5 _checkRep();
249 return _rep->getAuthType();
250 }
|
251 kumpf 1.4
|
252 mike 1.2 private:
253
|
254 kumpf 1.5 AuthenticationInfo(AuthenticationInfoRep* rep) : _rep(rep)
255 {
|
256 mike 1.2
|
257 kumpf 1.5 }
|
258 mike 1.2
|
259 kumpf 1.5 void _checkRep() const
260 {
261 if (!_rep)
|
262 kumpf 1.11 throw UninitializedHandleException();
|
263 kumpf 1.5 }
|
264 kumpf 1.4
|
265 kumpf 1.5 AuthenticationInfoRep* _rep;
|
266 mike 1.2 };
267
268 PEGASUS_NAMESPACE_END
269
270 #endif /* Pegasus_AuthenticationInfo_h*/
|