1 martin 1.14 //%LICENSE////////////////////////////////////////////////////////////////
|
2 martin 1.15 //
|
3 martin 1.14 // Licensed to The Open Group (TOG) under one or more contributor license
4 // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with
5 // this work for additional information regarding copyright ownership.
6 // Each contributor licenses this file to you under the OpenPegasus Open
7 // Source License; you may not use this file except in compliance with the
8 // License.
|
9 martin 1.15 //
|
10 martin 1.14 // Permission is hereby granted, free of charge, to any person obtaining a
11 // copy of this software and associated documentation files (the "Software"),
12 // to deal in the Software without restriction, including without limitation
13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 // and/or sell copies of the Software, and to permit persons to whom the
15 // Software is furnished to do so, subject to the following conditions:
|
16 martin 1.15 //
|
17 martin 1.14 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
|
19 martin 1.15 //
|
20 martin 1.14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
21 martin 1.15 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
22 martin 1.14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
27 martin 1.15 //
|
28 martin 1.14 //////////////////////////////////////////////////////////////////////////
|
29 mike 1.2 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
32 #ifndef Pegasus_BasicAuthenticationHandler_h
33 #define Pegasus_BasicAuthenticationHandler_h
34
35 #include <Pegasus/Common/Config.h>
36 #include <Pegasus/Common/String.h>
|
37 kumpf 1.4
|
38 mike 1.2 #include "Authenticator.h"
|
39 kumpf 1.4 #include "BasicAuthenticator.h"
|
40 chuck 1.6
41 #include <Pegasus/Security/Authentication/Linkage.h>
|
42 mike 1.2
|
43 kumpf 1.4
|
44 mike 1.2 PEGASUS_NAMESPACE_BEGIN
45
|
46 kumpf 1.13 /**
|
47 mike 1.2 Implements the AuthenticationHandler for Basic authentication
48 */
49
|
50 kumpf 1.13 static const char BASIC_AUTHENTICATION_FAILED_KEY [] =
51 "Security.Authentication.BasicAuthenticationHandler."
|
52 harsha.bm 1.16 "BASIC_AUTHENTICATION_FAILURE";
|
53 w.otsuka 1.11
|
54 kumpf 1.13 static const char BASIC_AUTHENTICATION_FAILED [] =
|
55 harsha.bm 1.16 "Authentication failed for user $0 from client IP address $1.";
|
56 w.otsuka 1.11
|
57 kumpf 1.13 class PEGASUS_SECURITY_LINKAGE BasicAuthenticationHandler
58 : public Authenticator
|
59 mike 1.2 {
60 public:
61
62 /** Constructors */
63 BasicAuthenticationHandler();
64
65 /** Destructor */
66 ~BasicAuthenticationHandler();
|
67 kumpf 1.13
68 /** Verify the authentication of the user passed in the authorization
69 header.
|
70 kumpf 1.4 @param authHeader String containing the Authorization header
71 @param authInfo Reference to AuthenticationInfo object
72 @return true on successful authentication, false otherwise
|
73 mike 1.2 */
|
74 kumpf 1.3 Boolean authenticate(
|
75 kumpf 1.13 const String& authHeader,
|
76 kumpf 1.3 AuthenticationInfo* authInfo);
|
77 kumpf 1.13
|
78 kumpf 1.4 /** Construct and return the Basic authentication challenge header
|
79 kumpf 1.13 @param authType An optional string containing the HTTP authentication
80 type
81 @param userName An optional string containing the user name
82 (Parameters are not used to generate the Basic authentication challenge
83 header, hence they are optional)
|
84 kumpf 1.4 @return A string containing the authentication challenge header.
|
85 kumpf 1.3 */
86 String getAuthResponseHeader(
|
87 kumpf 1.4 const String& authType = String::EMPTY,
88 const String& userName = String::EMPTY,
89 AuthenticationInfo* authInfo = 0);
|
90 mike 1.2
|
91 marek 1.17 Boolean validateUser(
92 const String& userName,
93 AuthenticationInfo* authInfo);
|
94 sushma.fernandes 1.10
|
95 w.otsuka 1.11
|
96 mike 1.2 private:
97
|
98 kumpf 1.4 BasicAuthenticator* _basicAuthenticator;
|
99 mike 1.2 };
100
101 PEGASUS_NAMESPACE_END
102
103 #endif /* Pegasus_BasicAuthenticationHandler_h*/
|