1 martin 1.17 //%LICENSE////////////////////////////////////////////////////////////////
|
2 martin 1.18 //
|
3 martin 1.17 // 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.18 //
|
10 martin 1.17 // 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.18 //
|
17 martin 1.17 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
|
19 martin 1.18 //
|
20 martin 1.17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
21 martin 1.18 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
22 martin 1.17 // 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.18 //
|
28 martin 1.17 //////////////////////////////////////////////////////////////////////////
|
29 mike 1.2 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
32 #ifndef Pegasus_ClientAuthenticator_h
33 #define Pegasus_ClientAuthenticator_h
34
35 #include <Pegasus/Common/Config.h>
36 #include <Pegasus/Common/Message.h>
37 #include <Pegasus/Common/HTTPMessage.h>
38 #include <Pegasus/Client/Linkage.h>
39
|
40 jsafrane 1.20 #ifdef PEGASUS_NEGOTIATE_AUTHENTICATION
41 #include <Pegasus/Common/Negotiate.h>
42 #endif
|
43 kumpf 1.3
|
44 mike 1.2 PEGASUS_NAMESPACE_BEGIN
45
46
|
47 kumpf 1.14 /** This class owns client authentication
|
48 mike 1.2 */
49 class PEGASUS_CLIENT_LINKAGE ClientAuthenticator
50 {
51 public:
52
|
53 jsafrane 1.20 enum AuthType { NONE, BASIC, DIGEST, LOCAL, NEGOTIATE };
|
54 mike 1.2
55 /** Constuctor. */
56 ClientAuthenticator();
57
58 /** Destructor. */
59 ~ClientAuthenticator();
60
61 /** Build the request authentication header.
62 */
63 String buildRequestAuthHeader();
64
|
65 mateus.baur 1.12 /** Check whether the response header has authentication challenge
|
66 mike 1.2 (i.e, WWW-Authenticate header).
67 */
68 Boolean checkResponseHeaderForChallenge(Array<HTTPHeader> headers);
69
70 /** Save the request message for resending on a challenge.
71 */
72 void setRequestMessage(Message* message);
73
|
74 kumpf 1.11 /** Get the request message saved for resending on a challenge while
75 retaining memory ownership for the message.
|
76 mike 1.2 */
77 Message* getRequestMessage();
78
|
79 kumpf 1.11 /** Get the request message saved for resending on a challenge and
80 release memory ownership for the message.
81 */
82 Message* releaseRequestMessage();
83
|
84 mike 1.2 /** Clear the request buffer and other authentication informations
85 from the earlier request.
86 */
|
87 kumpf 1.8 void clear();
|
88 mike 1.2
|
89 kumpf 1.16 /**
90 Reset the challenge status for the connection.
91 */
92 void resetChallengeStatus();
93
|
94 mike 1.2 /** Set the user name
95 */
96 void setUserName(const String& userName);
97
98 /** Get the user name
99 */
100 String getUserName();
101
102 /** Set the upasswor
103 */
104 void setPassword(const String& password);
105
|
106 jsafrane 1.20 /** Set the hostname
107 */
108 void setHost(const String& host);
109
|
110 mike 1.2 /** Set the authentication type
111 */
112 void setAuthType(AuthType type);
113
114 /** Get the authentication type
115 */
116 AuthType getAuthType();
117
118 private:
119
|
120 kumpf 1.4 String _buildLocalAuthResponse();
121
|
122 kumpf 1.16 String _getFileContent(const String& filePath);
|
123 mike 1.2
|
124 kumpf 1.4 Boolean _parseAuthHeader(
|
125 kumpf 1.19 const char* authHeader,
|
126 kumpf 1.4 String& authType,
127 String& authRealm);
128
|
129 jsafrane 1.20 /** Parse realm name out of realm="<realm>" */
130 String _parseBasicRealm(const String &challenge);
131
|
132 kumpf 1.4 String _getSubStringUptoMarker(
133 const char** line,
134 char marker);
135
|
136 kumpf 1.14 AutoPtr<Message> _requestMessage;
|
137 mike 1.2
|
138 kumpf 1.16 Boolean _challengeReceived;
|
139 mike 1.2
|
140 kumpf 1.16 String _userName;
141 String _password;
|
142 kumpf 1.3
|
143 kumpf 1.16 String _localAuthFile;
144 String _localAuthFileContent;
|
145 mike 1.2
146 AuthType _authType;
|
147 jsafrane 1.20
148 #ifdef PEGASUS_NEGOTIATE_AUTHENTICATION
149 AutoPtr<NegotiateClientSession> _session;
150 #endif
|
151 mike 1.2 };
152
153 PEGASUS_NAMESPACE_END
154
155 #endif /* Pegasus_ClientAuthenticator_h */
|