PageRenderTime 227ms CodeModel.GetById 101ms app.highlight 18ms RepoModel.GetById 63ms app.codeStats 0ms

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