• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef NETMANAGER_BASE_HTTP_PROXY_H
17 #define NETMANAGER_BASE_HTTP_PROXY_H
18 
19 #include <string>
20 #include <list>
21 
22 #include "parcel.h"
23 #include "securec.h"
24 
25 namespace OHOS {
26 namespace NetManagerStandard {
27 struct SecureData : public std::string {
~SecureDataSecureData28     ~SecureData()
29     {
30         // Clear Data, to keep the memory safe
31         (void)memset_s(data(), size(), 0, size());
32     }
33 };
34 class NetConnService;
35 #define NET_SYMBOL_VISIBLE __attribute__ ((visibility("default")))
36 class NET_SYMBOL_VISIBLE HttpProxy final : public Parcelable {
37 public:
38     friend class NetConnService;
39     HttpProxy();
40     HttpProxy(std::string host, uint16_t port, const std::list<std::string> &exclusionList);
41 
42     [[nodiscard]] std::string GetHost() const;
43     [[nodiscard]] uint16_t GetPort() const;
44     [[nodiscard]] std::list<std::string> GetExclusionList() const;
45     [[nodiscard]] std::string ToString() const;
SetHost(std::string && host)46     void inline SetHost(std::string &&host)
47     {
48         host_ = host;
49     }
SetPort(uint16_t port)50     void inline SetPort(uint16_t port)
51     {
52         port_ = port;
53     }
SetExclusionList(const std::list<std::string> & list)54     void inline SetExclusionList(const std::list<std::string> &list)
55     {
56         exclusionList_ = list;
57     }
SetUserName(const SecureData & username)58     void inline SetUserName(const SecureData &username)
59     {
60         username_ = username;
61     }
SetPassword(const SecureData & password)62     void inline SetPassword(const SecureData &password)
63     {
64         password_ = password;
65     }
66 
67     bool operator==(const HttpProxy &httpProxy) const;
68     bool operator!=(const HttpProxy &httpProxy) const;
69     bool Marshalling(Parcel &parcel) const override;
70     static bool Unmarshalling(Parcel &parcel, HttpProxy &httpProxy);
71 
72 private:
73     std::string host_;
74     uint16_t port_;
75     SecureData username_;
76     SecureData password_;
77     std::list<std::string> exclusionList_;
78 };
79 } // namespace NetManagerStandard
80 } // namespace OHOS
81 #endif /* NETMANAGER_BASE_HTTP_PROXY_H */
82