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.
93 * @privilege %http://tizen.org/privilege/http
95 * @return The realm value
96 * @exception E_SUCCESS The method is successful.
97 * @exception E_OUT_OF_MEMORY The memory is insufficient.
98 * @exception E_SYSTEM A system error has occurred.
99 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
100 * @remarks The specific error code can be accessed using the GetLastResult() method.
102 Tizen::Base::String* GetRealmN(void) const;
105 * Gets the authentication scheme received.
108 * @privilege %http://tizen.org/privilege/http
110 * @return The authentication scheme, @n
111 * else @c -1 if an error occurs
112 * @exception E_SUCCESS The method is successful.
113 * @exception E_OUT_OF_MEMORY The memory is insufficient.
114 * @exception E_SYSTEM A system error has occurred.
115 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
116 * @remarks The specific error code can be accessed using the GetLastResult() method.
118 NetHttpAuthScheme GetAuthScheme(void) const;
121 * Sets the credentials required for setting the "WWW-Authenticate" header in the HttpRequest class.
124 * @privilege %http://tizen.org/privilege/http
126 * @return The new transaction pointer
127 * @param[in] credentials The credentials
128 * @exception E_SUCCESS The method is successful.
129 * @exception E_INVALID_STATE The method invoked is invalid.
130 * @exception E_INVALID_ARG The specified input parameter is invalid.
131 * @exception E_OUT_OF_MEMORY The memory is insufficient.
132 * @exception E_SYSTEM A system error has occurred.
133 * @exception E_AUTHENTICATION The authentication has failed.
134 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
135 * @remarks This method is used to set the username and password for the given domain and the authentication
136 * scheme on the reception of the IHttpTransactionEventListener::OnTransactionHeaderCompleted() callback.
137 * The specific error code can be accessed using the GetLastResult() method.
139 HttpTransaction* SetCredentials(HttpCredentials& credentials);
143 * This default constructor is intentionally declared as private so that only the platform can create an instance.
145 HttpAuthentication(void);
148 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
150 * @param[in] rhs An instance of %HttpAuthentication
152 HttpAuthentication(const HttpAuthentication& rhs);
155 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
157 * @param[in] rhs An instance of %HttpAuthentication
159 HttpAuthentication& operator =(const HttpAuthentication& rhs);
162 _HttpAuthenticationImpl* __pHttpAuthenticationImpl;
163 friend class _HttpAuthenticationImpl;
165 }; // HttpAuthentication
167 } } } //Tizen::Net::Http
168 #endif // _FNET_HTTP_HTTP_AUTHENTICATION_H_