12#ifndef OPENVPN_COMMON_USERPASS_H
13#define OPENVPN_COMMON_USERPASS_H
75 const std::string &opt_name,
76 const unsigned int flags,
83 throw creds_error(opt_name +
" : credentials option missing");
88 if (auth_user_pass->
size() != 2)
89 throw creds_error(opt_name +
" : credentials option incorrectly specified");
95 for (
int i = 0; in(
true) && i < 2; ++i)
145 const std::string &opt_name,
146 const unsigned int flags,
152 std::vector<std::string> up;
158 user = std::move(up[0]);
160 pass = std::move(up[1]);
163 throw creds_error(opt_name +
" : username empty");
165 throw creds_error(opt_name +
" : password empty");
187 const unsigned int flags,
202 throw creds_error(path +
" : username empty");
204 throw creds_error(path +
" : password empty");
const Option * get_ptr(const std::string &name) const
const std::string & get(const size_t index, const size_t max_len) const
#define OPENVPN_EXCEPTION(C)
@ OPT_REQUIRED
option must be present
@ PASSWORD_REQUIRED
password must be present
@ USERNAME_REQUIRED
username must be present
@ OPT_OPTIONAL
if option is not present, USERNAME_REQUIRED and PASSWORD_REQUIRED are ignored
@ TRY_FILE
option argument might be a filename, try to load creds from it
bool parse(const OptionList &options, const std::string &opt_name, const unsigned int flags, std::vector< std::string > *user_pass)
interpret user-pass option
void parse_file(const std::string &path, const unsigned int flags, std::string &user, std::string &pass)
read username/password from file
bool is_multiline(const std::string &str)
bool is_empty(const std::string &str)
std::string read_text_utf8(const std::string &filename, const std::uint64_t max_size=0)
os<< "Session Name: "<< tbc-> session_name<< '\n';os<< "Layer: "<< tbc-> layer str()<< '\n'
const std::vector< std::string > user_pass