void HTTPCredentials::updateAuthInfo(HTTPRequest& request)
{
    if (request.has(HTTPRequest::AUTHORIZATION)) {
        const std::string& authorization = request.get(HTTPRequest::AUTHORIZATION);

        if (isBasicCredentials(authorization)) {
            HTTPBasicCredentials(_digest.getUsername(), _digest.getPassword()).authenticate(request);
        } else if (isDigestCredentials(authorization)) {
            _digest.updateAuthInfo(request);
        }
    }
}
Ejemplo n.º 2
0
SiriTokenProvider::Ptr SiriTokenProvider::FromAceHeader( const string& header )
{
    SiriTokenProvider::Ptr p=new SiriTokenProvider();
    p->m_http_string=header;
    if(p->m_http_string.find("Assistant(iPhone/iPhone4,1;")!=-1)
    {
        stringstream ss(p->m_http_string);
        HTTPRequest req;
        req.read(ss);
        if(req.has("X-Ace-Host"))
        {
            p->m_Ticket.x_ace_host=req["X-Ace-Host"];
        }
        if(req.has("User-Agent"))
        {
            p->m_Ticket.user_agent=req["User-Agent"];
        }
        p->iPhone4s=true;
        p->m_Ticket.iPhone4s=true;
        if(!p->CheckHeader())
        {
            delete p;
            return NULL;
        }
    }
    else
    {
        p->m_http_string=iPhone4s_header_tmpl;
        p->iPhone4s=false;
        p->m_Ticket.iPhone4s=false;
        if(!p->CheckHeader())
        {
            delete p;
            return NULL;
        }

        stringstream ss(p->m_http_string);
        HTTPRequest req;
        req.read(ss);

        string strAceHost;
        size_t offset=p->m_http_string.find("X-Ace-Host");
        if(offset!=-1)
        {
            size_t n1=p->m_http_string.find(":",offset);
            if(n1==(offset+strlen("X-Ace-Host")))
            {
                size_t n2=p->m_http_string.find("\r\n",n1);
                if(n2>n1)
                {
                    string ace_host=p->m_http_string.substr(n1+1,n2-n1);
                    p->m_Ticket.x_ace_host=ace_host;
                    strAceHost=ace_host;
                }
            }
        }
        if(req.has("X-Ace-Host"))
        {
            strAceHost==req.get("X-Ace-Host");
            if(!strAceHost.empty())
                p->m_Ticket.x_ace_host=strAceHost;
        }

        p->m_Ticket.x_ace_host_tmpl=p->m_Ticket.x_ace_host;

        if(!SiriTokenProvider::GetNextTicket(&p->m_Ticket))
        {
            delete p;
            return NULL;
        }

        p->m_http_string=Poco::replace(p->m_http_string,strAceHost,p->m_Ticket.x_ace_host);
        p->m_http_string=Poco::replace(p->m_http_string,"siri.cd-team.org","guzzoni.apple.com");

    }

    return p;
}
bool HTTPCredentials::hasDigestCredentials(const HTTPRequest& request)
{
    return request.has(HTTPRequest::AUTHORIZATION) && isDigestCredentials(request.get(HTTPRequest::AUTHORIZATION));
}
Ejemplo n.º 4
0
bool HTTPCredentials::hasProxyBasicCredentials(const HTTPRequest& request)
{
	return request.has(HTTPRequest::PROXY_AUTHORIZATION) && isBasicCredentials(request.get(HTTPRequest::PROXY_AUTHORIZATION));
}