proxygen
folly::PasswordInFile Class Reference

#include <PasswordInFile.h>

Inheritance diagram for folly::PasswordInFile:
folly::PasswordCollector

Public Member Functions

 PasswordInFile (const std::string &file)
 
 ~PasswordInFile () override
 
void getPassword (std::string &password, int) const override
 
const char * getPasswordStr () const
 
std::string describe () const override
 
- Public Member Functions inherited from folly::PasswordCollector
virtual ~PasswordCollector ()=default
 

Protected Attributes

std::string fileName_
 
std::string password_
 

Detailed Description

Definition at line 22 of file PasswordInFile.h.

Constructor & Destructor Documentation

folly::PasswordInFile::PasswordInFile ( const std::string file)
explicit

Definition at line 24 of file PasswordInFile.cpp.

References password_, and folly::readFile().

24  : fileName_(file) {
25  readFile(file.c_str(), password_);
26  auto p = password_.find('\0');
27  if (p != std::string::npos) {
28  password_.erase(p);
29  }
30 }
bool readFile(int fd, Container &out, size_t num_bytes=std::numeric_limits< size_t >::max())
Definition: FileUtil.h:125
folly::PasswordInFile::~PasswordInFile ( )
override

Definition at line 32 of file PasswordInFile.cpp.

References password_.

32  {
33  OPENSSL_cleanse((char*)password_.data(), password_.length());
34 }

Member Function Documentation

std::string folly::PasswordInFile::describe ( ) const
inlineoverridevirtual

Return a description of this collector for logging purposes

Implements folly::PasswordCollector.

Definition at line 35 of file PasswordInFile.h.

References fileName_.

35  {
36  return fileName_;
37  }
void folly::PasswordInFile::getPassword ( std::string password,
int  size 
) const
inlineoverridevirtual

Interface for customizing how to collect private key password.

By default, OpenSSL prints a prompt on screen and request for password while loading private key. To implement a custom password collector, implement this interface and register it with SSLContext.

Parameters
passwordPass collected password back to OpenSSL
sizeMaximum length of password including nullptr character

Implements folly::PasswordCollector.

Definition at line 27 of file PasswordInFile.h.

References password_.

27  {
28  password = password_;
29  }
const char* folly::PasswordInFile::getPasswordStr ( ) const
inline

Definition at line 31 of file PasswordInFile.h.

References password_.

31  {
32  return password_.c_str();
33  }

Member Data Documentation

std::string folly::PasswordInFile::fileName_
protected

Definition at line 40 of file PasswordInFile.h.

Referenced by describe().

std::string folly::PasswordInFile::password_
protected

Definition at line 41 of file PasswordInFile.h.

Referenced by getPassword(), getPasswordStr(), PasswordInFile(), and ~PasswordInFile().


The documentation for this class was generated from the following files: