/* */ #ifndef _D_AUTH_CONFIG_FACTORY_H_ #define _D_AUTH_CONFIG_FACTORY_H_ #include "common.h" #include #include #include "SharedHandle.h" #include "SingletonHolder.h" namespace aria2 { class Option; class Netrc; class AuthConfig; class Request; class AuthResolver; class AuthConfigFactory { private: const Option* _option; SharedHandle _netrc; SharedHandle createAuthConfig(const std::string& user, const std::string& password) const; SharedHandle createHttpAuthResolver() const; SharedHandle createFtpAuthResolver() const; public: class BasicCred { public: std::string _user; std::string _password; std::string _host; std::string _path; bool _activated; BasicCred(const std::string& user, const std::string& password, const std::string& host, const std::string& path, bool activated = false); void activate(); bool isActivated() const; bool operator==(const BasicCred& cred) const; bool operator<(const BasicCred& cred) const; }; private: std::deque _basicCreds; public: AuthConfigFactory(const Option* option); ~AuthConfigFactory(); SharedHandle createAuthConfig (const SharedHandle& request); void setNetrc(const SharedHandle& netrc); // Find a BasicCred using findBasicCred() and activate it then // return true. If matching BasicCred is not found, then return // false. bool activateBasicCred(const std::string& host, const std::string& path); // Find a BasicCred using host and path and return the iterator // pointing to it. If not found, then return _basicCreds.end(). std::deque::iterator findBasicCred(const std::string& host, const std::string& path); // If the same BasicCred is already added, then it is replaced with // given basicCred. Otherwise, insert given basicCred to // _basicCreds. void updateBasicCred(const BasicCred& basicCred); static const std::string ANONYMOUS; static const std::string ARIA2USER_AT; }; typedef SharedHandle AuthConfigFactoryHandle; } // namespace aria2 #endif // _D_AUTH_CONFIG_FACTORY_H_