copy wangle back into folly
[folly.git] / folly / wangle / ssl / PasswordInFile.h
1 /*
2  *  Copyright (c) 2015, 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. An additional grant
7  *  of patent rights can be found in the PATENTS file in the same directory.
8  *
9  */
10 #pragma once
11
12 #include <folly/io/async/SSLContext.h> // PasswordCollector
13
14 namespace folly {
15
16 class PasswordInFile: public folly::PasswordCollector {
17  public:
18   explicit PasswordInFile(const std::string& file);
19   ~PasswordInFile();
20
21   void getPassword(std::string& password, int size) override {
22     password = password_;
23   }
24
25   const char* getPasswordStr() const {
26     return password_.c_str();
27   }
28
29   std::string describe() const override {
30     return fileName_;
31   }
32
33  protected:
34   std::string fileName_;
35   std::string password_;
36 };
37
38 }