Exemplo n.º 1
0
bool CScrobbler::DoHandshake(time_t now)
{
    XBMC::XBMC_MD5    authToken;
    CStdString        strAuthToken;
    CStdString        strTimeStamp;
    CStdString        strResponse;
    CStdString        strHandshakeRequest;

    // Create auth token. md5(md5(pass)+str(now))
    strTimeStamp.Format("%d", now);
    authToken.append(m_strPasswordHash + strTimeStamp);
    authToken.getDigest(strAuthToken);
    strAuthToken.ToLower();

    // Construct handshake URL.
    strHandshakeRequest.Format("http://%s/?hs=true"\
                               "&p=%s&c=%s&v=%s&u=%s&t=%d&a=%s", m_strHandshakeURL.c_str(),
                               SCROBBLER_PROTOCOL, SCROBBLER_CLIENT, SCROBBLER_CLIENT_VERSION,
                               m_strUsername.c_str(), now, strAuthToken.c_str());

    // Make and handle request
    if (m_pHttp->Get(strHandshakeRequest, strResponse) &&
            HandleHandshake(strResponse))
        return true;

    m_failedHandshakeDelay = // 60, 120, 240, ... 7200s
        (m_failedHandshakeDelay) ? std::min(2*m_failedHandshakeDelay, 7200) : 60;
    m_lastFailedHandshake = now;
    if (!m_bBanned && !m_bBadAuth)
        CLog::Log(LOGDEBUG, "%s: A hard error has occurred during "\
                  "handshake. Sleeping for %d minutes.",
                  m_strLogPrefix.c_str(), m_failedHandshakeDelay/60);

    return false;
}
Exemplo n.º 2
0
TEST(Testmd5, String1)
{
    XBMC::XBMC_MD5 a;
    std::string refdigest, vardigest;

    refdigest = "9E107D9D372BB6826BD81D3542A419D6";
    a.append("The quick brown fox jumps over the lazy dog");
    vardigest = a.getDigest();
    EXPECT_STREQ(refdigest.c_str(), vardigest.c_str());
}
Exemplo n.º 3
0
TEST(Testmd5, String2)
{
    XBMC::XBMC_MD5 a;
    std::string refdigest, vardigest;

    refdigest = "E4D909C290D0FB1CA068FFADDF22CBD0";
    a.append("The quick brown fox jumps over the lazy dog.");
    vardigest = a.getDigest();
    EXPECT_STREQ(refdigest.c_str(), vardigest.c_str());
}
Exemplo n.º 4
0
TEST(Testmd5, ZeroLengthString)
{
    XBMC::XBMC_MD5 a;
    std::string refdigest, vardigest;

    refdigest = "D41D8CD98F00B204E9800998ECF8427E";
    a.append("");
    vardigest = a.getDigest();
    EXPECT_STREQ(refdigest.c_str(), vardigest.c_str());
}