(file) Return to AuthenticationInfo.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2