proxygen
FizzClientContext.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-present, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree.
7  */
8 
9 #pragma once
10 
11 #include <fizz/client/PskCache.h>
14 #include <fizz/protocol/Factory.h>
15 #include <fizz/record/Types.h>
16 
17 namespace fizz {
18 namespace client {
19 
21  public:
23  virtual ~FizzClientContext() = default;
24 
28  void setSupportedVersions(std::vector<ProtocolVersion> versions) {
29  supportedVersions_ = std::move(versions);
30  }
31 
32  const auto& getSupportedVersions() const {
33  return supportedVersions_;
34  }
35 
39  void setSupportedCiphers(std::vector<CipherSuite> ciphers) {
40  supportedCiphers_ = std::move(ciphers);
41  }
42 
43  const auto& getSupportedCiphers() const {
44  return supportedCiphers_;
45  }
46 
50  void setSupportedSigSchemes(std::vector<SignatureScheme> schemes) {
52  }
53 
54  const auto& getSupportedSigSchemes() const {
55  return supportedSigSchemes_;
56  }
57 
61  void setSupportedGroups(std::vector<NamedGroup> groups) {
62  supportedGroups_ = std::move(groups);
63  }
64 
65  const auto& getSupportedGroups() const {
66  return supportedGroups_;
67  }
68 
72  void setDefaultShares(std::vector<NamedGroup> groups) {
73  defaultShares_ = std::move(groups);
74  }
75  const auto& getDefaultShares() const {
76  return defaultShares_;
77  }
78 
82  void setSupportedPskModes(std::vector<PskKeyExchangeMode> modes) {
84  }
85 
86  const auto& getSupportedPskModes() const {
87  return supportedPskModes_;
88  }
89 
93  void setSupportedAlpns(std::vector<std::string> protocols) {
94  supportedAlpns_ = std::move(protocols);
95  }
96 
97  const auto& getSupportedAlpns() const {
98  return supportedAlpns_;
99  }
100 
104  void setClientCertificate(std::shared_ptr<SelfCert> cert) {
105  clientCert_ = std::move(cert);
106  }
107 
108  const auto& getClientCertificate() const {
109  return clientCert_;
110  }
111 
115  void setPskCache(std::shared_ptr<PskCache> pskCache) {
116  pskCache_ = std::move(pskCache);
117  }
118 
120  if (pskCache_) {
121  return pskCache_->getPsk(identity);
122  } else {
123  return folly::none;
124  }
125  }
126 
127  void putPsk(const std::string& identity, CachedPsk psk) const {
128  if (pskCache_) {
129  pskCache_->putPsk(identity, std::move(psk));
130  }
131  }
132 
133  void removePsk(const std::string& identity) const {
134  if (pskCache_) {
135  pskCache_->removePsk(identity);
136  }
137  }
138 
142  void setSendEarlyData(bool sendEarlyData) {
143  sendEarlyData_ = sendEarlyData;
144  }
145 
146  bool getSendEarlyData() const {
147  return sendEarlyData_;
148  }
149 
154  void setCompatibilityMode(bool enabled) {
155  compatMode_ = enabled;
156  }
157 
158  bool getCompatibilityMode() const {
159  return compatMode_;
160  }
161 
165  void setFactory(std::unique_ptr<Factory> factory) {
166  factory_ = std::move(factory);
167  }
168 
169  const Factory* getFactory() const {
170  return factory_.get();
171  }
172 
177  std::shared_ptr<CertDecompressionManager> mgr) {
179  }
180 
185  std::vector<CertificateCompressionAlgorithm>
188  return certDecompressionManager_->getSupportedAlgorithms();
189  } else {
190  return {};
191  }
192  }
193 
198  std::shared_ptr<CertificateDecompressor> getCertDecompressorForAlgorithm(
199  CertificateCompressionAlgorithm algo) const {
201  return certDecompressionManager_->getDecompressor(algo);
202  } else {
203  return nullptr;
204  }
205  }
206 
207  private:
208  std::unique_ptr<Factory> factory_;
209 
210  std::vector<ProtocolVersion> supportedVersions_ = {ProtocolVersion::tls_1_3};
211  std::vector<CipherSuite> supportedCiphers_ = {
214 #if FOLLY_OPENSSL_IS_110
216 #endif // FOLLY_OPENSSL_IS_110
217  };
218  std::vector<SignatureScheme> supportedSigSchemes_ = {
221  std::vector<NamedGroup> supportedGroups_ = {NamedGroup::x25519,
223  std::vector<NamedGroup> defaultShares_ = {NamedGroup::x25519};
224  std::vector<PskKeyExchangeMode> supportedPskModes_ = {
227  std::vector<std::string> supportedAlpns_;
228  bool sendEarlyData_{false};
229 
230  bool compatMode_{false};
231 
232  std::shared_ptr<PskCache> pskCache_;
233  std::shared_ptr<const SelfCert> clientCert_;
234  std::shared_ptr<CertDecompressionManager> certDecompressionManager_;
235 };
236 } // namespace client
237 } // namespace fizz
const auto & getSupportedGroups() const
std::vector< PskKeyExchangeMode > supportedPskModes_
CertificateCompressionAlgorithm
Definition: Types.h:167
const auto & getSupportedAlpns() const
std::vector< NamedGroup > defaultShares_
const auto & getSupportedVersions() const
std::shared_ptr< const SelfCert > clientCert_
std::unique_ptr< Factory > factory_
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::vector< NamedGroup > supportedGroups_
void setSendEarlyData(bool sendEarlyData)
STL namespace.
std::shared_ptr< CertificateDecompressor > getCertDecompressorForAlgorithm(CertificateCompressionAlgorithm algo) const
void setCompatibilityMode(bool enabled)
std::vector< std::string > supportedAlpns_
const Factory * getFactory() const
const auto & getSupportedCiphers() const
void setSupportedPskModes(std::vector< PskKeyExchangeMode > modes)
const auto & getDefaultShares() const
void setClientCertificate(std::shared_ptr< SelfCert > cert)
void setPskCache(std::shared_ptr< PskCache > pskCache)
void setSupportedAlpns(std::vector< std::string > protocols)
std::vector< SignatureScheme > supportedSigSchemes_
void setSupportedCiphers(std::vector< CipherSuite > ciphers)
folly::Optional< CachedPsk > getPsk(const std::string &identity) const
Definition: Actions.h:16
void setSupportedGroups(std::vector< NamedGroup > groups)
std::enable_if<!std::is_array< T >::value, std::unique_ptr< T > >::type make_unique(Args &&...args)
Definition: Memory.h:259
void setFactory(std::unique_ptr< Factory > factory)
void setDefaultShares(std::vector< NamedGroup > groups)
const auto & getSupportedSigSchemes() const
std::vector< CipherSuite > supportedCiphers_
std::vector< CertificateCompressionAlgorithm > getSupportedCertDecompressionAlgorithms() const
const auto & getSupportedPskModes() const
const char * string
Definition: Conv.cpp:212
std::shared_ptr< PskCache > pskCache_
void removePsk(const std::string &identity) const
void setSupportedVersions(std::vector< ProtocolVersion > versions)
void putPsk(const std::string &identity, CachedPsk psk) const
std::shared_ptr< CertDecompressionManager > certDecompressionManager_
std::vector< ProtocolVersion > supportedVersions_
const auto & getClientCertificate() const
void setSupportedSigSchemes(std::vector< SignatureScheme > schemes)
virtual ~FizzClientContext()=default
void setCertDecompressionManager(std::shared_ptr< CertDecompressionManager > mgr)
constexpr None none
Definition: Optional.h:87