rmtpass.hpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ############################################################################## */
  13. #ifndef RMTPASS_HPP
  14. #define RMTPASS_HPP
  15. #ifdef REMOTE_EXPORTS
  16. #define REMOTE_API DECL_EXPORT
  17. #else
  18. #define REMOTE_API DECL_IMPORT
  19. #endif
  20. class REMOTE_API CachedPassword : public CInterface
  21. {
  22. public:
  23. void deserialize(MemoryBuffer & in) { ip.ipdeserialize(in); in.read(password).read(username); }
  24. void serialize(MemoryBuffer & out) { ip.ipserialize(out); out.append(password).append(username); }
  25. public:
  26. IpAddress ip;
  27. StringAttr password;
  28. StringAttr username;
  29. };
  30. class RemoteFilename;
  31. class REMOTE_API CachedPasswordProvider : public CInterface, implements IPasswordProvider
  32. {
  33. public:
  34. IMPLEMENT_IINTERFACE
  35. virtual bool getPassword(const IpAddress & ip, StringBuffer & username, StringBuffer & password);
  36. void addPasswordForFilename(const char * filename);
  37. void addPasswordForFilename(RemoteFilename & filename);
  38. void addPasswordForIp(const IpAddress & ip);
  39. void clear();
  40. void deserialize(MemoryBuffer & in);
  41. void serialize(MemoryBuffer & out);
  42. bool hasPassword(const IpAddress & ip) const;
  43. protected:
  44. CIArrayOf<CachedPassword> passwords;
  45. };
  46. #endif