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.cpp
20 * @brief This is the implementation file for HttpAuthentication class.
22 * This file contains the implementation of HttpAuthentication class.
25 #include <FBaseString.h>
26 #include <FNetHttpHttpAuthentication.h>
27 #include <FBaseSysLog.h>
28 #include <FSec_AccessController.h>
29 #include "FNetHttp_HttpAuthenticationImpl.h"
31 using namespace Tizen::Base;
32 using namespace Tizen::Security;
34 namespace Tizen { namespace Net { namespace Http
37 HttpAuthentication::HttpAuthentication(void)
39 __pHttpAuthenticationImpl = new (std::nothrow) _HttpAuthenticationImpl();
40 SysTryReturnVoidResult(NID_NET_HTTP, __pHttpAuthenticationImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
43 HttpAuthentication::~HttpAuthentication(void)
45 if (__pHttpAuthenticationImpl != null)
47 delete __pHttpAuthenticationImpl;
48 __pHttpAuthenticationImpl = null;
53 HttpAuthentication::GetRealmN(void) const
57 r = _AccessController::CheckUserPrivilege(_PRV_HTTP);
58 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED, E_OUT_OF_MEMORY);
59 SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
61 String* pRealm = __pHttpAuthenticationImpl->GetRealmN();
64 SysLogException(NID_NET_HTTP, r, "[%s] Propagating.", GetErrorMessage(r));
76 HttpAuthentication::GetAuthScheme(void) const
80 r = _AccessController::CheckUserPrivilege(_PRV_HTTP);
81 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED, E_OUT_OF_MEMORY);
82 SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, NET_HTTP_AUTH_NONE, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
84 NetHttpAuthScheme scheme = __pHttpAuthenticationImpl->GetAuthScheme();
86 SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, NET_HTTP_AUTH_NONE, r, "[%s] Propagating.", GetErrorMessage(r));
92 HttpAuthentication::SetCredentials(HttpCredentials& credentials)
96 r = _AccessController::CheckUserPrivilege(_PRV_HTTP);
97 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED, E_OUT_OF_MEMORY);
98 SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
100 HttpTransaction* pTransaction = __pHttpAuthenticationImpl->SetCredentials(credentials);
102 SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
107 } } } // Tizen::Net::Http