1 karl 1.11 //%2005////////////////////////////////////////////////////////////////////////
|
2 mike 1.2 //
|
3 karl 1.10 // 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.9 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.10 // 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.11 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 mike 1.2 //
|
12 kumpf 1.7 // Permission is hereby granted, free of charge, to any person obtaining a copy
13 // of this software and associated documentation files (the "Software"), to
14 // deal in the Software without restriction, including without limitation the
15 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
16 // sell copies of the Software, and to permit persons to whom the Software is
17 // furnished to do so, subject to the following conditions:
18 //
19 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
20 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
21 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
22 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
23 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
25 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
27 mike 1.2 //
28 //==============================================================================
29 //
30 // Author: Nag Boranna, Hewlett-Packard Company(nagaraja_boranna@hp.com)
31 //
|
32 joyce.j 1.12 // Modified By: Josephine Eskaline Joyce (jojustin@in.ibm.com) for PEP#101
|
33 sushma.fernandes 1.13 // Sushma Fernandes, Hewlett-Packard Company(sushma_fernandes@hp.com)
|
34 mike 1.2 //
35 //%/////////////////////////////////////////////////////////////////////////////
36
37 #include <Pegasus/Common/Logger.h>
|
38 kumpf 1.3 #include <Pegasus/Common/Tracer.h>
|
39 kumpf 1.5
40 #include "SecureLocalAuthenticator.h"
|
41 mike 1.2 #include "LocalAuthenticationHandler.h"
42
|
43 kumpf 1.5
|
44 mike 1.2 PEGASUS_USING_STD;
45
46 PEGASUS_NAMESPACE_BEGIN
47
48
49 LocalAuthenticationHandler::LocalAuthenticationHandler()
50 {
|
51 kumpf 1.5 PEG_METHOD_ENTER(TRC_AUTHENTICATION,
52 "LocalAuthenticationHandler::LocalAuthenticationHandler()");
|
53 mike 1.2
|
54 joyce.j 1.12 _localAuthenticator.reset((LocalAuthenticator*) new SecureLocalAuthenticator());
|
55 kumpf 1.3
|
56 kumpf 1.5 PEG_METHOD_EXIT();
|
57 mike 1.2 }
58
59 LocalAuthenticationHandler::~LocalAuthenticationHandler()
60 {
|
61 kumpf 1.5 PEG_METHOD_ENTER(TRC_AUTHENTICATION,
62 "LocalAuthenticationHandler::~LocalAuthenticationHandler()");
|
63 kumpf 1.3
|
64 kumpf 1.5 PEG_METHOD_EXIT();
|
65 mike 1.2 }
66
67 Boolean LocalAuthenticationHandler::authenticate(
|
68 kumpf 1.3 const String& authHeader,
|
69 mike 1.2 AuthenticationInfo* authInfo)
70 {
|
71 kumpf 1.5 PEG_METHOD_ENTER(TRC_AUTHENTICATION,
72 "LocalAuthenticationHandler::authenticate()");
|
73 kumpf 1.3
|
74 mike 1.2 Boolean authenticated = false;
75
76 // Look for ':' seperator
77 Uint32 colon1 = authHeader.find(':');
78
79 if ( colon1 == PEG_NOT_FOUND )
80 {
|
81 kumpf 1.5 PEG_METHOD_EXIT();
|
82 mike 1.2 return ( authenticated );
83 }
84
85 String userName = authHeader.subString(0, colon1);
86
87 // Look for another ':' seperator
88 Uint32 colon2 = authHeader.find(colon1 + 1, ':');
89
|
90 kumpf 1.4 String filePath;
91
92 String secretReceived;
93
94 if ( colon2 == PEG_NOT_FOUND )
|
95 mike 1.2 {
|
96 kumpf 1.4 filePath = String::EMPTY;
97
98 secretReceived = authHeader.subString( colon1 + 1 );
|
99 mike 1.2 }
|
100 kumpf 1.4 else
101 {
102 filePath = authHeader.subString( colon1 + 1, (colon2 - colon1 - 1) );
|
103 mike 1.2
|
104 kumpf 1.4 secretReceived = authHeader.subString( colon2 + 1 );
105 }
|
106 mike 1.2
|
107 kumpf 1.6 //
108 // Check if the user is a valid system user
109 //
|
110 kumpf 1.8 if ( !System::isSystemUser( userName.getCString() ) )
|
111 kumpf 1.6 {
112 PEG_METHOD_EXIT();
113 return (authenticated);
114 }
115
|
116 mike 1.2 authenticated = _localAuthenticator->authenticate(filePath,
117 secretReceived, authInfo->getAuthChallenge());
118
119 if (authenticated)
120 {
121 authInfo->setAuthenticatedUser(userName);
122 }
123
|
124 kumpf 1.5 PEG_METHOD_EXIT();
|
125 kumpf 1.3
|
126 mike 1.2 return ( authenticated );
127 }
128
|
129 sushma.fernandes 1.13 Boolean LocalAuthenticationHandler::validateUser(const String& userName)
130 {
131 return _localAuthenticator->validateUser(userName);
132 }
133
|
134 mike 1.2 String LocalAuthenticationHandler::getAuthResponseHeader(
|
135 kumpf 1.3 const String& authType,
136 const String& userName,
|
137 mike 1.2 AuthenticationInfo* authInfo)
138 {
|
139 kumpf 1.5 PEG_METHOD_ENTER(TRC_AUTHENTICATION,
140 "LocalAuthenticationHandler::getAuthResponseHeader()");
|
141 kumpf 1.3
|
142 kumpf 1.6 String challenge = String::EMPTY;
143 String authResp = String::EMPTY;
144
145 //
146 // Check if the user is a valid system user
147 //
|
148 kumpf 1.8 if ( !System::isSystemUser( userName.getCString() ) )
|
149 kumpf 1.6 {
150 PEG_METHOD_EXIT();
151 return ( authResp );
152 }
|
153 mike 1.2
|
154 kumpf 1.6 authResp = _localAuthenticator->getAuthResponseHeader(authType, userName, challenge);
|
155 mike 1.2
156 authInfo->setAuthChallenge(challenge);
|
157 kumpf 1.3
|
158 kumpf 1.5 PEG_METHOD_EXIT();
|
159 mike 1.2
|
160 kumpf 1.6 return ( authResp );
|
161 mike 1.2 }
162
163 PEGASUS_NAMESPACE_END
|