2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FNetHttpHttpAuthentication.h
20 * @brief This is the header file for the %HttpAuthentication class.
22 * This header file contains the declarations of the %HttpAuthentication class.
25 #ifndef _FNET_HTTP_HTTP_AUTHENTICATION_H_
26 #define _FNET_HTTP_HTTP_AUTHENTICATION_H_
28 #include <FNetHttpHttpTypes.h>
29 #include <FNetHttpHttpHeader.h>
30 #include <FNetHttpHttpMessage.h>
31 #include <FNetHttpHttpCredentials.h>
33 namespace Tizen { namespace Net { namespace Http
35 class HttpTransaction;
36 class _HttpAuthenticationImpl;
39 * @class HttpAuthentication
40 * @brief This class encapsulates an HTTP authentication.
44 * The %HttpAuthentication class encapsulates the HTTP authentication activity of the client over the duration of a single transaction.
46 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/http_connectivity.htm">HTTP Guide</a>.
48 * The following example demonstrates how to use the %HttpAuthentication class.
55 using namespace Tizen::Base;
56 using namespace Tizen::Net::Http;
59 MyTransactionEventListener::OnTransactionHeaderCompleted(HttpSession& httpSession, HttpTransaction& httpTransaction, int headerLen, bool authRequired)
63 HttpAuthentication* pAuth = httpTransaction.OpenAuthenticationInfoN();
64 String basicName("Name");
65 String basicpass("Pass");
66 HttpCredentials* pCredential = new HttpCredentials(basicName, basicpass);
67 String* pRealm = pAuth->GetRealmN();
68 NetHttpAuthScheme scheme = pAuth->GetAuthScheme();
69 if (scheme == NET_HTTP_AUTH_WWW_BASIC || scheme == NET_HTTP_AUTH_PROXY_BASIC)
71 HttpTransaction* pNewTransaction = pAuth->SetCredentials(*pCredential);
78 class _OSP_EXPORT_ HttpAuthentication
79 : public Tizen::Base::Object
83 * This destructor overrides Tizen::Base::Object::~Object().
87 ~HttpAuthentication(void);
90 * Gets the realm value received.
94 * @privilege %http://tizen.org/privilege/http
96 * @return The realm value
97 * @exception E_SUCCESS The method is successful.
98 * @exception E_OUT_OF_MEMORY The memory is insufficient.
99 * @exception E_SYSTEM A system error has occurred.
100 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
101 * @exception E_USER_NOT_CONSENTED The user blocks an application from calling this method. @b Since: @b 2.1
102 * @remarks The specific error code can be accessed using the GetLastResult() method.
104 Tizen::Base::String* GetRealmN(void) const;
107 * Gets the authentication scheme received.
111 * @privilege %http://tizen.org/privilege/http
113 * @return The authentication scheme, @n
114 * else @c -1 if an error occurs
115 * @exception E_SUCCESS The method is successful.
116 * @exception E_OUT_OF_MEMORY The memory is insufficient.
117 * @exception E_SYSTEM A system error has occurred.
118 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
119 * @exception E_USER_NOT_CONSENTED The user blocks an application from calling this method. @b Since: @b 2.1
120 * @remarks The specific error code can be accessed using the GetLastResult() method.
122 NetHttpAuthScheme GetAuthScheme(void) const;
125 * Sets the credentials required for setting the "WWW-Authenticate" header in the HttpRequest class.
129 * @privilege %http://tizen.org/privilege/http
131 * @return The new transaction pointer
132 * @param[in] credentials The credentials
133 * @exception E_SUCCESS The method is successful.
134 * @exception E_INVALID_STATE The method invoked is invalid.
135 * @exception E_INVALID_ARG The specified input parameter is invalid.
136 * @exception E_OUT_OF_MEMORY The memory is insufficient.
137 * @exception E_SYSTEM A system error has occurred.
138 * @exception E_AUTHENTICATION The authentication has failed.
139 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
140 * @exception E_USER_NOT_CONSENTED The user blocks an application from calling this method. @b Since: @b 2.1
141 * @remarks This method is used to set the username and password for the given domain and the authentication
142 * scheme on the reception of the IHttpTransactionEventListener::OnTransactionHeaderCompleted() callback.
143 * The specific error code can be accessed using the GetLastResult() method.
145 HttpTransaction* SetCredentials(HttpCredentials& credentials);
149 * This default constructor is intentionally declared as private so that only the platform can create an instance.
151 HttpAuthentication(void);
154 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
156 * @param[in] rhs An instance of %HttpAuthentication
158 HttpAuthentication(const HttpAuthentication& rhs);
161 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
163 * @param[in] rhs An instance of %HttpAuthentication
165 HttpAuthentication& operator =(const HttpAuthentication& rhs);
168 _HttpAuthenticationImpl* __pHttpAuthenticationImpl;
169 friend class _HttpAuthenticationImpl;
171 }; // HttpAuthentication
173 } } } //Tizen::Net::Http
174 #endif // _FNET_HTTP_HTTP_AUTHENTICATION_H_