1 karl 1.31 //%2006////////////////////////////////////////////////////////////////////////
|
2 kumpf 1.1 //
|
3 karl 1.24 // 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.14 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.24 // 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.25 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.31 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 kumpf 1.1 //
|
14 kumpf 1.5 // 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 kumpf 1.1 //
30 //==============================================================================
31 //
32 //%/////////////////////////////////////////////////////////////////////////////
33
|
34 kumpf 1.38 #include <Pegasus/Common/Executor.h>
35 #include <Pegasus/Config/ConfigManager.h>
|
36 kumpf 1.1 #include <Pegasus/Common/Tracer.h>
37 #include "PAMBasicAuthenticator.h"
38
39 PEGASUS_USING_STD;
40
41 PEGASUS_NAMESPACE_BEGIN
|
42 kumpf 1.3
|
43 kumpf 1.38 PAMBasicAuthenticator::PAMBasicAuthenticator()
|
44 kumpf 1.9 {
|
45 kumpf 1.1 PEG_METHOD_ENTER(TRC_AUTHENTICATION,
46 "PAMBasicAuthenticator::PAMBasicAuthenticator()");
47
|
48 kumpf 1.38 // Build up realm: <hostname>:<port>
49
|
50 kumpf 1.1 _realm.assign(System::getHostName());
51
52 // get the configured port number
53 ConfigManager* configManager = ConfigManager::getInstance();
|
54 kumpf 1.4 String port = configManager->getCurrentValue("httpPort");
|
55 kumpf 1.1
56 //
57 // Create realm that will be used for Basic challenges
58 //
59 _realm.append(":");
60 _realm.append(port);
61
62 PEG_METHOD_EXIT();
63 }
64
65 PAMBasicAuthenticator::~PAMBasicAuthenticator()
66 {
67 PEG_METHOD_ENTER(TRC_AUTHENTICATION,
68 "PAMBasicAuthenticator::~PAMBasicAuthenticator()");
69
70 PEG_METHOD_EXIT();
71 }
72
73 Boolean PAMBasicAuthenticator::authenticate(
74 const String& userName,
|
75 kumpf 1.38 const String& password)
|
76 kumpf 1.1 {
77 PEG_METHOD_ENTER(TRC_AUTHENTICATION,
78 "PAMBasicAuthenticator::authenticate()");
79
|
80 kumpf 1.38 if (Executor::authenticatePassword(
81 userName.getCString(), password.getCString()) != 0)
|
82 kumpf 1.1 {
|
83 kumpf 1.38 return false;
|
84 kumpf 1.1 }
85
|
86 kumpf 1.10 PEG_METHOD_EXIT();
|
87 kumpf 1.38 return true;
|
88 kumpf 1.10 }
89
|
90 sushma.fernandes 1.29 Boolean PAMBasicAuthenticator::validateUser(const String& userName)
91 {
92 PEG_METHOD_ENTER(TRC_AUTHENTICATION,
93 "PAMBasicAuthenticator::validateUser()");
94
|
95 kumpf 1.38 if (Executor::validateUser(userName.getCString()) != 0)
96 return false;
|
97 sushma.fernandes 1.29
98 PEG_METHOD_EXIT();
|
99 kumpf 1.38 return true;
|
100 sushma.fernandes 1.29 }
101
102
|
103 kumpf 1.1 String PAMBasicAuthenticator::getAuthResponseHeader()
104 {
105 PEG_METHOD_ENTER(TRC_AUTHENTICATION,
106 "PAMBasicAuthenticator::getAuthResponseHeader()");
107
|
108 kumpf 1.38 // Build response header: WWW-Authenticate: Basic "<hostname>:<port>"
109
110 String responseHeader = "WWW-Authenticate: Basic \"";
|
111 kumpf 1.1 responseHeader.append(_realm);
112 responseHeader.append("\"");
113
114 PEG_METHOD_EXIT();
|
115 kumpf 1.38 return responseHeader;
|
116 kumpf 1.15 }
117
|
118 kumpf 1.1 PEGASUS_NAMESPACE_END
|