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 kumpf 1.3
|
41 mike 1.2 PEGASUS_NAMESPACE_BEGIN
42
43
|
44 kumpf 1.14 /** This class owns client authentication
|
45 mike 1.2 */
46 class PEGASUS_CLIENT_LINKAGE ClientAuthenticator
47 {
48 public:
49
|
50 kumpf 1.15 enum AuthType { NONE, BASIC, DIGEST, LOCAL };
|
51 mike 1.2
52 /** Constuctor. */
53 ClientAuthenticator();
54
55 /** Destructor. */
56 ~ClientAuthenticator();
57
58 /** Build the request authentication header.
59 */
60 String buildRequestAuthHeader();
61
|
62 mateus.baur 1.12 /** Check whether the response header has authentication challenge
|
63 mike 1.2 (i.e, WWW-Authenticate header).
64 */
65 Boolean checkResponseHeaderForChallenge(Array<HTTPHeader> headers);
66
67 /** Save the request message for resending on a challenge.
68 */
69 void setRequestMessage(Message* message);
70
|
71 kumpf 1.11 /** Get the request message saved for resending on a challenge while
72 retaining memory ownership for the message.
|
73 mike 1.2 */
74 Message* getRequestMessage();
75
|
76 kumpf 1.11 /** Get the request message saved for resending on a challenge and
77 release memory ownership for the message.
78 */
79 Message* releaseRequestMessage();
80
|
81 mike 1.2 /** Clear the request buffer and other authentication informations
82 from the earlier request.
83 */
|
84 kumpf 1.8 void clear();
|
85 mike 1.2
|
86 kumpf 1.16 /**
87 Reset the challenge status for the connection.
88 */
89 void resetChallengeStatus();
90
|
91 mike 1.2 /** Set the user name
92 */
93 void setUserName(const String& userName);
94
95 /** Get the user name
96 */
97 String getUserName();
98
99 /** Set the upasswor
100 */
101 void setPassword(const String& password);
102
103 /** Set the authentication type
104 */
105 void setAuthType(AuthType type);
106
107 /** Get the authentication type
108 */
109 AuthType getAuthType();
110
111 private:
112 mike 1.2
|
113 kumpf 1.4 String _buildLocalAuthResponse();
114
|
115 kumpf 1.16 String _getFileContent(const String& filePath);
|
116 mike 1.2
|
117 kumpf 1.4 Boolean _parseAuthHeader(
|
118 kumpf 1.19 const char* authHeader,
|
119 kumpf 1.4 String& authType,
120 String& authRealm);
121
122 String _getSubStringUptoMarker(
123 const char** line,
124 char marker);
125
|
126 kumpf 1.14 AutoPtr<Message> _requestMessage;
|
127 mike 1.2
|
128 kumpf 1.16 Boolean _challengeReceived;
|
129 mike 1.2
|
130 kumpf 1.16 String _userName;
131 String _password;
|
132 kumpf 1.3
|
133 kumpf 1.16 String _localAuthFile;
134 String _localAuthFileContent;
|
135 mike 1.2
136 AuthType _authType;
137 };
138
139 PEGASUS_NAMESPACE_END
140
141 #endif /* Pegasus_ClientAuthenticator_h */
|