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

  1 karl  1.11 //%2006////////////////////////////////////////////////////////////////////////
  2 mike  1.2  //
  3 karl  1.8  // 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.7  // IBM Corp.; EMC Corporation, The Open Group.
  7 karl  1.8  // 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.9  // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10            // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 karl  1.11 // 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.6  // 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            // Author: Nag Boranna, Hewlett-Packard Company(nagaraja_boranna@hp.com)
 33            //
 34            // Modified By:
 35            //
 36            //%/////////////////////////////////////////////////////////////////////////////
 37            
 38            
 39            #include <Pegasus/Common/FileSystem.h>
 40 kumpf 1.3  #include <Pegasus/Common/Tracer.h>
 41 mike  1.11.30.3 #include <Pegasus/Common/Executor.h>
 42 kumpf 1.5       
 43                 #include "LocalAuthFile.h"
 44 mike  1.2       #include "SecureLocalAuthenticator.h"
 45                 
 46 kumpf 1.5       PEGASUS_USING_STD;
 47                 
 48 mike  1.2       PEGASUS_NAMESPACE_BEGIN
 49                 
 50                 
 51 kumpf 1.5       /**
 52                     Constant representing the pegasus authentication challenge header.
 53                 */
 54                 static const String PEGASUS_CHALLENGE_HEADER = "WWW-Authenticate: ";
 55                 
 56                 
 57 mike  1.2       /* constructor. */
 58                 SecureLocalAuthenticator::SecureLocalAuthenticator() 
 59                 { 
 60 kumpf 1.5           PEG_METHOD_ENTER(TRC_AUTHENTICATION,
 61                         "SecureLocalAuthenticator::SecureLocalAuthenticator()");
 62 kumpf 1.3       
 63 kumpf 1.5           PEG_METHOD_EXIT();
 64 mike  1.2       
 65                 }
 66                 
 67                 /* destructor. */
 68                 SecureLocalAuthenticator::~SecureLocalAuthenticator() 
 69                 { 
 70 kumpf 1.5           PEG_METHOD_ENTER(TRC_AUTHENTICATION,
 71                         "SecureLocalAuthenticator::~SecureLocalAuthenticator()");
 72 kumpf 1.3       
 73 kumpf 1.5           PEG_METHOD_EXIT();
 74 mike  1.2       
 75                 }
 76                 
 77                 //
 78                 // Does local authentication
 79                 //
 80                 Boolean SecureLocalAuthenticator::authenticate
 81                 (
 82 kumpf 1.3          const String& filePath, 
 83                    const String& secretReceived, 
 84                    const String& secretKept
 85 mike  1.2       )
 86                 {
 87 kumpf 1.5           PEG_METHOD_ENTER(TRC_AUTHENTICATION,
 88                         "SecureLocalAuthenticator::authenticate()");
 89 kumpf 1.3       
 90 kumpf 1.5           Boolean authenticated = false;
 91 kumpf 1.3       
 92 mike  1.2       
 93                     if ((!String::equal(secretReceived, String::EMPTY)) &&
 94                         (!String::equal(secretKept, String::EMPTY)))
 95                     {
 96                         if (String::equal(secretKept, secretReceived))
 97                         {
 98                             authenticated = true;
 99                         }
100                     }
101                 
102                     //
103                     // remove the auth file created for this user request
104                     //
105 kumpf 1.4           if (filePath.size())
106 mike  1.2           {
107 kumpf 1.4               if (FileSystem::exists(filePath))
108 mike  1.2               {
109 mike  1.11.30.3             Executor::removeFile(filePath.getCString());
110 mike  1.2               }
111                     }
112                 
113 kumpf 1.5           PEG_METHOD_EXIT();
114 kumpf 1.3       
115 mike  1.2           return (authenticated);
116                 }
117                 
118 sushma.fernandes 1.10      
119                            Boolean SecureLocalAuthenticator::validateUser (const String& userName)
120                            {
121                                PEG_METHOD_ENTER(TRC_AUTHENTICATION,
122                                    "SecureLocalAuthenticator::validateUser()");
123                            
124                                Boolean authenticated = false;
125                            
126                                if (System::isSystemUser(userName.getCString()))
127                                {
128                                    authenticated = true;
129                                }
130                            
131                                PEG_METHOD_EXIT();
132                                return (authenticated);
133                            }
134                            
135 mike             1.2       //
136                            // Create authentication response header
137                            //
138                            String SecureLocalAuthenticator::getAuthResponseHeader(
139 kumpf            1.3           const String& authType, 
140                                const String& userName, 
141 mike             1.2           String& challenge)
142                            {
143 kumpf            1.5           PEG_METHOD_ENTER(TRC_AUTHENTICATION,
144                                    "SecureLocalAuthenticator::getAuthResponseHeader()");
145 kumpf            1.3       
146 kumpf            1.5           String responseHeader = PEGASUS_CHALLENGE_HEADER;
147 kumpf            1.3           responseHeader.append(authType);
148                                responseHeader.append(" \"");
149 kumpf            1.5       
150 mike             1.2           //
151                                // create a file using user name and write a random number in it.
152                                //
153                                LocalAuthFile localAuthFile(userName);
154                                String filePath  = localAuthFile.create();
155                            
156                                //
157                                // get the challenge string
158                                //
159                                String temp = localAuthFile.getChallengeString();
160                                challenge = temp;
161                            
162                                // 
163                                // build response header with file path and challenge string.
164                                //
165                                responseHeader.append(filePath);
166                                responseHeader.append("\"");
167 kumpf            1.3       
168 kumpf            1.5           PEG_METHOD_EXIT();
169 mike             1.2       
170                                return (responseHeader);
171                            }
172                            
173                            
174                            PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2