(file) Return to LocalAuthenticationHandler.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Security / Authentication

  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           #include <Pegasus/Common/Logger.h>
 31 kumpf 1.3 #include <Pegasus/Common/Tracer.h>
 32 kumpf 1.6 #include <Pegasus/Common/Destroyer.h>
 33 kumpf 1.5 
 34           #include "SecureLocalAuthenticator.h"
 35 mike  1.2 #include "LocalAuthenticationHandler.h"
 36           
 37 kumpf 1.5 
 38 mike  1.2 PEGASUS_USING_STD;
 39           
 40           PEGASUS_NAMESPACE_BEGIN
 41           
 42           
 43           LocalAuthenticationHandler::LocalAuthenticationHandler()
 44           {
 45 kumpf 1.5     PEG_METHOD_ENTER(TRC_AUTHENTICATION, 
 46                  "LocalAuthenticationHandler::LocalAuthenticationHandler()");
 47 mike  1.2 
 48               _localAuthenticator = (LocalAuthenticator*) new SecureLocalAuthenticator();
 49 kumpf 1.3 
 50 kumpf 1.5     PEG_METHOD_EXIT();
 51 mike  1.2 }
 52           
 53           LocalAuthenticationHandler::~LocalAuthenticationHandler()
 54           {
 55 kumpf 1.5     PEG_METHOD_ENTER(TRC_AUTHENTICATION, 
 56                   "LocalAuthenticationHandler::~LocalAuthenticationHandler()");
 57 kumpf 1.3 
 58 kumpf 1.5     delete _localAuthenticator;
 59 kumpf 1.3 
 60 kumpf 1.5     PEG_METHOD_EXIT();
 61 mike  1.2 }
 62           
 63           Boolean LocalAuthenticationHandler::authenticate(    
 64 kumpf 1.3     const String& authHeader,
 65 mike  1.2     AuthenticationInfo* authInfo)
 66           {
 67 kumpf 1.5     PEG_METHOD_ENTER(TRC_AUTHENTICATION, 
 68                   "LocalAuthenticationHandler::authenticate()");
 69 kumpf 1.3 
 70 mike  1.2     Boolean authenticated   = false; 
 71           
 72               // Look for ':' seperator
 73               Uint32 colon1 = authHeader.find(':');
 74           
 75               if ( colon1 == PEG_NOT_FOUND )
 76               {
 77 kumpf 1.5         PEG_METHOD_EXIT();
 78 mike  1.2         return ( authenticated );
 79               }
 80           
 81               String userName = authHeader.subString(0, colon1);
 82           
 83               // Look for another ':' seperator
 84               Uint32 colon2 = authHeader.find(colon1 + 1, ':');
 85           
 86 kumpf 1.4     String filePath;
 87           
 88               String secretReceived;
 89           
 90               if ( colon2 == PEG_NOT_FOUND )
 91 mike  1.2     {
 92 kumpf 1.4         filePath = String::EMPTY;
 93           
 94                   secretReceived = authHeader.subString( colon1 + 1 );    
 95 mike  1.2     }
 96 kumpf 1.4     else
 97               {
 98                   filePath = authHeader.subString( colon1 + 1, (colon2 - colon1 - 1) );
 99 mike  1.2 
100 kumpf 1.4         secretReceived = authHeader.subString( colon2 + 1 );    
101               }
102 mike  1.2 
103 kumpf 1.6     //
104               // Check if the user is a valid system user
105               //
106 kumpf 1.8     if ( !System::isSystemUser( userName.getCString() ) )
107 kumpf 1.6     {
108                   PEG_METHOD_EXIT();
109                   return (authenticated);
110               }
111           
112 mike  1.2     authenticated = _localAuthenticator->authenticate(filePath, 
113                   secretReceived, authInfo->getAuthChallenge());
114           
115               if (authenticated)
116               {
117                   authInfo->setAuthenticatedUser(userName);
118               }
119           
120 kumpf 1.5     PEG_METHOD_EXIT();
121 kumpf 1.3 
122 mike  1.2     return ( authenticated );
123           }
124           
125           String LocalAuthenticationHandler::getAuthResponseHeader(
126 kumpf 1.3     const String& authType,
127               const String& userName,
128 mike  1.2     AuthenticationInfo* authInfo)
129           {
130 kumpf 1.5     PEG_METHOD_ENTER(TRC_AUTHENTICATION, 
131                   "LocalAuthenticationHandler::getAuthResponseHeader()");
132 kumpf 1.3 
133 kumpf 1.6     String challenge = String::EMPTY;
134               String authResp = String::EMPTY;
135           
136               //
137               // Check if the user is a valid system user
138               //
139 kumpf 1.8     if ( !System::isSystemUser( userName.getCString() ) )
140 kumpf 1.6     {
141                   PEG_METHOD_EXIT();
142                   return ( authResp );
143               }
144 mike  1.2 
145 kumpf 1.6     authResp = _localAuthenticator->getAuthResponseHeader(authType, userName, challenge);
146 mike  1.2 
147               authInfo->setAuthChallenge(challenge);
148 kumpf 1.3 
149 kumpf 1.5     PEG_METHOD_EXIT();
150 mike  1.2 
151 kumpf 1.6     return ( authResp );
152 mike  1.2 }
153           
154           PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2