36 const bool password_required,
37 const bool throw_on_error)
43 for (
auto &h : headlist)
46 && h.value.length() >= 7
49 const std::string creds =
base64->
decode(h.value.substr(6));
52 throw Exception(
"error splitting credentials");
59 if (password_required && cv[1].empty())
67 catch (
const std::exception &e)
70 throw web_creds_error(e.what());
76 const bool password_required,
77 const bool throw_on_error)
86 throw Exception(fn +
" : username missing");
88 throw Exception(fn +
" : password missing");
90 throw Exception(fn +
" : username empty");
91 if (password_required && p.empty())
92 throw Exception(fn +
" : password empty");
93 ret.username = std::move(u);
94 ret.password = std::move(p);
96 catch (
const std::exception &e)
99 throw web_creds_error(e.what());
105 const std::string &opt_name,
106 const unsigned int flags)
136 atomic_thread_fence(std::memory_order_acq_rel);
138 atomic_thread_fence(std::memory_order_acq_rel);
145 atomic_thread_fence(std::memory_order_acq_rel);
size_t decode(void *data, size_t len, const std::string &str) const
Status next(std::string &ln, const bool trim=true)
@ S_OKAY
next line was successfully read
bool is_valid_utf8(const STRING &str, const size_t max_len_flags=0)
bool parse(const OptionList &options, const std::string &opt_name, const unsigned int flags, std::vector< std::string > *user_pass)
interpret user-pass option
bool str_neq(const char *s1, const char *s2)
int strcasecmp(const char *s1, const char *s2)
std::vector< T > split(const T &str, const typename T::value_type sep, const int maxsplit=-1)
std::string read_text_utf8(const std::string &filename, const std::uint64_t max_size=0)
void write_private(const std::string &path, const void *buf, ssize_t count)
static Creds load_from_options(const OptionList &opt, const std::string &opt_name, const unsigned int flags)
static Creds load_from_header(const HTTP::HeaderList &headlist, const bool password_required, const bool throw_on_error)
bool defined_full() const
bool operator!=(const Creds &rhs) const
static Creds load_from_file(const std::string &fn, const bool password_required, const bool throw_on_error)
std::string to_string() const
void save_to_file(const std::string &fn) const
OPENVPN_EXCEPTION(web_creds_error)
bool password_eq(const Creds &rhs) const
bool operator==(const Creds &rhs) const