1 karl 1.14 //%2004////////////////////////////////////////////////////////////////////////
|
2 kumpf 1.1 //
|
3 karl 1.14 // 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.14 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 kumpf 1.1 //
|
10 kumpf 1.4 // Permission is hereby granted, free of charge, to any person obtaining a copy
11 // of this software and associated documentation files (the "Software"), to
12 // deal in the Software without restriction, including without limitation the
13 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
14 // sell copies of the Software, and to permit persons to whom the Software is
15 // furnished to do so, subject to the following conditions:
16 //
17 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
18 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
19 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
20 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
21 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
23 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
25 kumpf 1.1 //
26 //==============================================================================
27 //
28 // Author: Nag Boranna, Hewlett-Packard Company(nagaraja_boranna@hp.com)
29 //
|
30 kumpf 1.7 // Modified By: Yi Zhou, Hewlett-Packard Company(yi_zhou@hp.com)
|
31 kumpf 1.8 // Sushma Fernandes, Hewlett-Packard Company
32 // (sushma_fernandes@hp.com)
|
33 kumpf 1.1 //
34 //%/////////////////////////////////////////////////////////////////////////////
35
36 #ifndef Pegasus_PAMBasicAuthenticator_h
37 #define Pegasus_PAMBasicAuthenticator_h
38
39 #include <Pegasus/Common/Config.h>
|
40 kumpf 1.8 #include <Pegasus/Common/IPC.h>
|
41 kumpf 1.1 #include "BasicAuthenticator.h"
42
|
43 kumpf 1.10
|
44 chuck 1.5 #include <Pegasus/Security/Authentication/Linkage.h>
|
45 kumpf 1.1
|
46 kumpf 1.6
|
47 kumpf 1.1 PEGASUS_NAMESPACE_BEGIN
48
|
49 kumpf 1.10 /** This class provides PAM basic authentication by communicating with a
50 standalone process.
51 */
52
53 #if defined(PEGASUS_USE_PAM_STANDALONE_PROC)
54
55 class PEGASUS_SECURITY_LINKAGE PAMBasicAuthenticatorStandAlone
56 {
57 public:
58
59 /** constructor. */
60 PAMBasicAuthenticatorStandAlone();
61
62 /** destructor. */
63 ~PAMBasicAuthenticatorStandAlone();
64
65 /** Verify the authentication of the requesting user.
66 @param userName String containing the user name
67 @param password String containing the user password
68 @return true on successful authentication, false otherwise
69 */
70 kumpf 1.10 Boolean authenticate(
71 const String& userName,
72 const String& password);
73
74 private:
75 String _realm;
76
77 Boolean _authenticateByPAM(
78 const String& userName,
79 const String& password);
80
81 void _createPAMStandalone();
82 };
83
84 #endif /* if defined(PEGASUS_USE_PAM_STANDALONE_PROC) */
85
|
86 kumpf 1.1 /** This class provides PAM basic authentication implementation by extending
87 the BasicAuthenticator.
88 */
89 class PEGASUS_SECURITY_LINKAGE PAMBasicAuthenticator : public BasicAuthenticator
90 {
91 public:
92
93 /** constructor. */
94 PAMBasicAuthenticator();
95
96 /** destructor. */
97 ~PAMBasicAuthenticator();
98
99 /** Verify the authentication of the requesting user.
100 @param userName String containing the user name
101 @param password String containing the user password
102 @return true on successful authentication, false otherwise
103 */
104 Boolean authenticate(
105 const String& userName,
106 const String& password);
107 kumpf 1.1
108 /** Construct and return the HTTP Basic authentication challenge header
109 @return A string containing the authentication challenge header.
110 */
111 String getAuthResponseHeader();
112
113 /** PAM Call back function, the pointer to this function is passed to the PAM module.
114 @param num_msg int containing the message count
115 @param msg pointer to a pam_message structure
116 @param resp pointer to a pam_respone structure
117 @param appdata_prt application data pointer
118 @return PAM_SUCCESS on successful execution, a PAM error code otherwise
119 */
120 static Sint32 PAMCallback(
121 Sint32 num_msg,
|
122 kumpf 1.6 #if defined (PEGASUS_OS_LINUX) && defined(PEGASUS_PAM_AUTHENTICATION)
123
124 const struct pam_message **msg,
125 #else
|
126 kumpf 1.1 struct pam_message **msg,
|
127 kumpf 1.6 #endif
|
128 kumpf 1.1 struct pam_response **resp,
129 void *appdata_ptr);
130
131 private:
|
132 kumpf 1.8 /**
133 A mutex to serialize authentication calls.
134 */
135 static Mutex _authSerializeMutex;
|
136 kumpf 1.1
137 String _realm;
|
138 kumpf 1.7
139 Boolean _authenticateByPAM(
140 const String& userName,
141 const String& password);
142
|
143 kumpf 1.12 #if defined(PEGASUS_USE_PAM_STANDALONE_PROC)
|
144 kumpf 1.10 PAMBasicAuthenticatorStandAlone* _pamBasicAuthenticatorStandAlone;
|
145 kumpf 1.12 #endif
146
|
147 kumpf 1.1 };
148
149
150 PEGASUS_NAMESPACE_END
151
152 #endif /* Pegasus_PAMBasicAuthenticator_h */
|