Example #1
0
void
Connection::checkACLResult( const QString &nodeid, const QString &username, Tomahawk::ACLStatus::Type peerStatus )
{
    Q_D( Connection );
    QReadLocker nodeidLocker( &d->nodeidLock );

    if ( nodeid != d->nodeid )
    {
        tDebug( LOGVERBOSE ) << Q_FUNC_INFO << QString( "nodeid (%1) not ours (%2) for user %3" ).arg( nodeid ).arg( d->nodeid ).arg( username );
        return;
    }
    if ( username != bareName() )
    {
        tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "username not our barename";
        return;
    }

    disconnect( ACLRegistry::instance(), SIGNAL( aclResult( QString, QString, Tomahawk::ACLStatus::Type ) ) );
    tDebug( LOGVERBOSE ) << Q_FUNC_INFO << QString( "ACL status for user %1 is" ).arg( username ) << peerStatus;
    if ( peerStatus == Tomahawk::ACLStatus::Stream )
    {
        QTimer::singleShot( 0, this, SLOT( doSetup() ) );
        return;
    }

    shutdown();
}
Example #2
0
void
Connection::checkACL()
{
    Q_D( Connection );
    QReadLocker nodeidLocker( &d->nodeidLock );

    if ( d->nodeid.isEmpty() )
    {
        tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Not checking ACL, nodeid is empty";
        QTimer::singleShot( 0, this, SLOT( doSetup() ) );
        return;
    }

    if ( Servent::isIPWhitelisted( d_func()->peerIpAddress ) )
    {
        QTimer::singleShot( 0, this, SLOT( doSetup() ) );
        return;
    }

    tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Checking ACL for" << name();
    connect( ACLRegistry::instance(), SIGNAL( aclResult( QString, QString, Tomahawk::ACLStatus::Type ) ),
             this, SLOT( checkACLResult( QString, QString, Tomahawk::ACLStatus::Type ) ),
             Qt::QueuedConnection );
    QMetaObject::invokeMethod( ACLRegistry::instance(), "isAuthorizedUser", Qt::QueuedConnection, Q_ARG( QString, d->nodeid ), Q_ARG( QString, bareName() ), Q_ARG( Tomahawk::ACLStatus::Type, Tomahawk::ACLStatus::NotFound ) );
}
Example #3
0
void
Connection::checkACL()
{
    if ( !property( "nodeid" ).isValid() )
    {
        QTimer::singleShot( 0, this, SLOT( doSetup() ) );
        return;
    }

    QString nodeid = property( "nodeid" ).toString();
    tDebug( LOGVERBOSE ) << "Checking ACL for" << name();
    connect( ACLRegistry::instance(), SIGNAL( aclResult( QString, QString, ACLRegistry::ACL ) ), this, SLOT( checkACLResult( QString, QString, ACLRegistry::ACL ) ), Qt::QueuedConnection );
    QMetaObject::invokeMethod( ACLRegistry::instance(), "isAuthorizedUser", Qt::QueuedConnection, Q_ARG( QString, nodeid ), Q_ARG( QString, name() ), Q_ARG( ACLRegistry::ACL, ACLRegistry::NotFound ) );
}
Example #4
0
void
Connection::checkACLResult( const QString &nodeid, const QString &username, ACLRegistry::ACL peerStatus )
{
    if ( nodeid != property( "nodeid" ).toString() || username != name() )
        return;

    disconnect( ACLRegistry::instance(), SIGNAL( aclResult( QString, QString, ACLRegistry::ACL ) ) );
    tDebug( LOGVERBOSE ) << "ACL status is" << peerStatus;
    if ( peerStatus == ACLRegistry::Stream )
    {
        QTimer::singleShot( 0, this, SLOT( doSetup() ) );
        return;
    }

    shutdown();
}
Example #5
0
void
Connection::checkACLResult( const QString &nodeid, const QString &username, ACLRegistry::ACL peerStatus )
{
    QString bareName = name().contains( '/' ) ? name().left( name().indexOf( "/" ) ) : name();
    if ( nodeid != property( "nodeid" ).toString() || username != bareName )
    {
        tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "nodeid not ours, or username not our barename";
        return;
    }

    disconnect( ACLRegistry::instance(), SIGNAL( aclResult( QString, QString, ACLRegistry::ACL ) ) );
    tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "ACL status is" << peerStatus;
    if ( peerStatus == ACLRegistry::Stream )
    {
        QTimer::singleShot( 0, this, SLOT( doSetup() ) );
        return;
    }

    shutdown();
}
Example #6
0
void
Connection::checkACL()
{
    if ( !property( "nodeid" ).isValid() )
    {
        tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Not checking ACL, nodeid is empty";
        QTimer::singleShot( 0, this, SLOT( doSetup() ) );
        return;
    }

    if ( Servent::isIPWhitelisted( m_peerIpAddress ) )
    {
        QTimer::singleShot( 0, this, SLOT( doSetup() ) );
        return;
    }

    QString nodeid = property( "nodeid" ).toString();
    QString bareName = name().contains( '/' ) ? name().left( name().indexOf( "/" ) ) : name();
    tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Checking ACL for" << name();
    connect( ACLRegistry::instance(), SIGNAL( aclResult( QString, QString, ACLRegistry::ACL ) ), this, SLOT( checkACLResult( QString, QString, ACLRegistry::ACL ) ), Qt::QueuedConnection );
    QMetaObject::invokeMethod( ACLRegistry::instance(), "isAuthorizedUser", Qt::QueuedConnection, Q_ARG( QString, nodeid ), Q_ARG( QString, bareName ), Q_ARG( ACLRegistry::ACL, ACLRegistry::NotFound ) );
}