/mordor/http/auth.h

http://github.com/mozy/mordor · C Header · 55 lines · 45 code · 9 blank · 1 comment · 0 complexity · ba9dd7932ab6be03f1ec988ac76ab043 MD5 · raw file

  1. #ifndef __MORDOR_HTTP_AUTH_H__
  2. #define __MORDOR_HTTP_AUTH_H__
  3. // Copyright (c) 2009 - Mozy, Inc.
  4. #include <boost/function.hpp>
  5. #include <boost/noncopyable.hpp>
  6. #include <boost/scoped_ptr.hpp>
  7. #include "broker.h"
  8. #include "mordor/version.h"
  9. namespace Mordor {
  10. namespace HTTP {
  11. class AuthRequestBroker : public RequestBrokerFilter
  12. {
  13. public:
  14. AuthRequestBroker(RequestBroker::ptr parent,
  15. boost::function<bool (const URI &,
  16. boost::shared_ptr<ClientRequest> /* priorRequest = ClientRequest::ptr() */,
  17. std::string & /* scheme */, std::string & /* realm */,
  18. std::string & /* username */, std::string & /* password */,
  19. size_t /* attempts */)>
  20. getCredentialsDg,
  21. boost::function<bool (const URI &,
  22. boost::shared_ptr<ClientRequest> /* priorRequest = ClientRequest::ptr() */,
  23. std::string & /* scheme */, std::string & /* realm */,
  24. std::string & /* username */, std::string & /* password */,
  25. size_t /* attempts */)>
  26. getProxyCredentialsDg)
  27. : RequestBrokerFilter(parent),
  28. m_getCredentialsDg(getCredentialsDg),
  29. m_getProxyCredentialsDg(getProxyCredentialsDg)
  30. {}
  31. boost::shared_ptr<ClientRequest> request(Request &requestHeaders,
  32. bool forceNewConnection = false,
  33. boost::function<void (boost::shared_ptr<ClientRequest>)> bodyDg = NULL);
  34. private:
  35. boost::function<bool (const URI &, boost::shared_ptr<ClientRequest>,
  36. std::string &, std::string &, std::string &, std::string &, size_t)>
  37. m_getCredentialsDg, m_getProxyCredentialsDg;
  38. };
  39. #ifdef OSX
  40. bool getCredentialsFromKeychain(const URI &uri,
  41. boost::shared_ptr<ClientRequest> priorRequest,
  42. std::string &scheme, std::string &realm, std::string &username,
  43. std::string &password, size_t attempts);
  44. #endif
  45. }}
  46. #endif