diff --git a/src/accounts/hatchet/account/HatchetAccount.cpp b/src/accounts/hatchet/account/HatchetAccount.cpp index 46bc09eb6..acd874deb 100644 --- a/src/accounts/hatchet/account/HatchetAccount.cpp +++ b/src/accounts/hatchet/account/HatchetAccount.cpp @@ -269,7 +269,7 @@ HatchetAccount::loginWithPassword( const QString& username, const QString& passw QNetworkRequest req( QUrl( c_loginServer + "/authentication/password") ); req.setHeader( QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded" ); - + QUrl params; params.addQueryItem( "username", username ); params.addQueryItem( "password", password ); diff --git a/src/accounts/hatchet/sip/HatchetSip.cpp b/src/accounts/hatchet/sip/HatchetSip.cpp index 5e167095b..2672b3626 100644 --- a/src/accounts/hatchet/sip/HatchetSip.cpp +++ b/src/accounts/hatchet/sip/HatchetSip.cpp @@ -51,6 +51,7 @@ HatchetSipPlugin::HatchetSipPlugin( Tomahawk::Accounts::Account *account ) connect( m_account, SIGNAL( accessTokenFetched() ), this, SLOT( connectWebSocket() ) ); connect( Servent::instance(), SIGNAL( dbSyncTriggered() ), this, SLOT( dbSyncTriggered() )); + /* QFile pemFile( ":/hatchet-account/dreamcatcher.pem" ); pemFile.open( QIODevice::ReadOnly ); tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "certs/dreamcatcher.pem: " << pemFile.readAll(); @@ -64,6 +65,7 @@ HatchetSipPlugin::HatchetSipPlugin( Tomahawk::Accounts::Account *account ) return; } m_publicKey = new QCA::PublicKey( publicKey ); + */ m_reconnectTimer.setInterval( 0 ); m_reconnectTimer.setSingleShot( true ); @@ -90,7 +92,8 @@ HatchetSipPlugin::~HatchetSipPlugin() bool HatchetSipPlugin::isValid() const { - return m_account->enabled() && m_account->isAuthenticated() && m_publicKey; + //return m_account->enabled() && m_account->isAuthenticated() && m_publicKey; + return m_account->enabled() && m_account->isAuthenticated(); } @@ -189,8 +192,17 @@ HatchetSipPlugin::webSocketConnected() hatchetAccount()->setConnectionState( Tomahawk::Accounts::Account::Connected ); m_sipState = AcquiringVersion; + /* + m_uuid = QUuid::createUuid().toString(); + QCA::SecureArray sa( m_uuid.toLatin1() ); + QCA::SecureArray result = m_publicKey->encrypt( sa, QCA::EME_PKCS1_OAEP ); + + tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "uuid:" << m_uuid << ", size of uuid:" << m_uuid.size() << ", size of sa:" << sa.size() << ", size of result:" << result.size(); + */ + QVariantMap nonceVerMap; nonceVerMap[ "version" ] = VERSION; + //nonceVerMap[ "nonce" ] = QString( result.toByteArray().toBase64() ); sendBytes( nonceVerMap ); } @@ -268,10 +280,10 @@ HatchetSipPlugin::messageReceived( const QByteArray &msg ) if ( m_sipState == AcquiringVersion ) { - tLog() << Q_FUNC_INFO << "In acquiring version state, expecting version information"; - if ( !retMap.contains( "version" ) ) + tLog() << Q_FUNC_INFO << "In acquiring version state, expecting version/nonce information"; + if ( !retMap.contains( "version" ) || !retMap.contains( "nonce" ) ) { - tLog() << Q_FUNC_INFO << "Failed to acquire version information"; + tLog() << Q_FUNC_INFO << "Failed to acquire version or nonce information"; disconnectPlugin(); return; } @@ -284,6 +296,13 @@ HatchetSipPlugin::messageReceived( const QByteArray &msg ) return; } + if ( retMap[ "nonce" ].toString() != m_uuid ) + { + tLog() << Q_FUNC_INFO << "Failed to validate nonce"; + disconnectPlugin(); + return; + } + m_version = ver; QVariantMap registerMap;