rmtpass.hpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*##############################################################################
  2. Copyright (C) 2011 HPCC Systems.
  3. All rights reserved. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Affero General Public License as
  5. published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Affero General Public License for more details.
  11. You should have received a copy of the GNU Affero General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ############################################################################## */
  14. #ifndef RMTPASS_HPP
  15. #define RMTPASS_HPP
  16. #ifdef REMOTE_EXPORTS
  17. #define REMOTE_API __declspec(dllexport)
  18. #else
  19. #define REMOTE_API __declspec(dllimport)
  20. #endif
  21. class REMOTE_API CachedPassword : public CInterface
  22. {
  23. public:
  24. void deserialize(MemoryBuffer & in) { ip.ipdeserialize(in); in.read(password).read(username); }
  25. void serialize(MemoryBuffer & out) { ip.ipserialize(out); out.append(password).append(username); }
  26. public:
  27. IpAddress ip;
  28. StringAttr password;
  29. StringAttr username;
  30. };
  31. class RemoteFilename;
  32. class REMOTE_API CachedPasswordProvider : public CInterface, implements IPasswordProvider
  33. {
  34. public:
  35. IMPLEMENT_IINTERFACE
  36. virtual bool getPassword(const IpAddress & ip, StringBuffer & username, StringBuffer & password);
  37. void addPasswordForFilename(const char * filename);
  38. void addPasswordForFilename(RemoteFilename & filename);
  39. void addPasswordForIp(const IpAddress & ip);
  40. void clear();
  41. void deserialize(MemoryBuffer & in);
  42. void serialize(MemoryBuffer & out);
  43. bool hasPassword(const IpAddress & ip) const;
  44. protected:
  45. CIArrayOf<CachedPassword> passwords;
  46. };
  47. #endif