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