int RemoteViewerCore::negotiateAboutSecurityType()
{
  m_logWriter.detail(_T("Reading list of security types..."));
  // read list of security types
  vector<UINT32> secTypes;
  readSecurityTypeList(&secTypes);
  m_logWriter.debug(_T("List of security type is read"));
  if (secTypes.size() == 0) {
    m_logWriter.warning(_T("Error in negotiate about of security: only security type is 0"));
    return 0;
  }

  // log information about security list
  StringStorage secTypeString;
  for (vector<UINT32>::iterator i = secTypes.begin(); i != secTypes.end(); i++) {
    if(i != secTypes.begin())
      secTypeString.appendString(_T(", "));
    StringStorage nameType;
    nameType.format(_T("%s (%d)"), getSecurityTypeName(*i).getString(), *i);
    secTypeString.appendString(nameType.getString());
  }
  m_logWriter.detail(_T("Security Types received (%d): %s"),
                   secTypes.size(), secTypeString.getString()); 

  // select type security
  m_logWriter.debug(_T("Selecting auth-handler"));
  int typeSelected = selectSecurityType(&secTypes, &m_authHandlers);
  m_logWriter.info(_T("Security type is selected: %d"), typeSelected);
  if (typeSelected == SecurityDefs::TIGHT) {
    m_logWriter.info(_T("Tight capabilities is enable"));
    m_isTight = true;

    m_output->writeUInt8(typeSelected);
    m_output->flush();

    initTunnelling();
    return initAuthentication();
  }

  if (m_minor >= 7) {
    m_output->writeUInt8(typeSelected);
    m_output->flush();
  }

  return typeSelected;
}
CommandLinePluginInterface::RunResult RemoteAccessFeaturePlugin::handle_control( const QStringList& arguments )
{
	if( arguments.count() < 1 )
	{
		return NotEnoughArguments;
	}

	if( initAuthentication() == false )
	{
		return Failed;
	}

	Computer remoteComputer;
	remoteComputer.setHostAddress( arguments.first() );

	new RemoteAccessWidget( remoteComputer, false );

	qApp->exec();

	return Successful;
}
Exemple #3
0
VeyonCore::VeyonCore( QCoreApplication* application, const QString& appComponentName, QObject* parent ) :
	QObject( parent ),
	m_config( nullptr ),
	m_logger( nullptr ),
	m_authenticationCredentials( nullptr ),
	m_cryptoCore( nullptr ),
	m_pluginManager( nullptr ),
	m_accessControlDataBackendManager( nullptr ),
	m_platformPluginManager( nullptr ),
	m_platformPlugin( nullptr ),
	m_applicationName( QStringLiteral( "Veyon" ) ),
	m_userRole( RoleTeacher )
{
	setupApplicationParameters();

	s_instance = this;

	m_config = new VeyonConfiguration( VeyonConfiguration::defaultConfiguration() );
	*m_config += VeyonConfiguration( Configuration::Store::LocalBackend );

	m_logger = new Logger( appComponentName, m_config );

	// only perform partial initialization when running without QCoreApplication
	// (e.g. as service monitor)
	if( application == nullptr )
	{
		return;
	}

	QLocale configuredLocale( QLocale::C );

	QRegExp localeRegEx( QStringLiteral( "[^(]*\\(([^)]*)\\)") );
	if( localeRegEx.indexIn( config().uiLanguage() ) == 0 )
	{
		configuredLocale = QLocale( localeRegEx.cap( 1 ) );
	}

	if( configuredLocale.language() != QLocale::English )
	{
		auto tr = new QTranslator;
		if( configuredLocale == QLocale::C ||
				tr->load( QStringLiteral( ":/resources/%1.qm" ).arg( configuredLocale.name() ) ) == false )
		{
			configuredLocale = QLocale::system();
			tr->load( QStringLiteral( ":/resources/%1.qm" ).arg( QLocale::system().name() ) );
		}

		QLocale::setDefault( configuredLocale );

		QCoreApplication::installTranslator( tr );

		auto qtTr = new QTranslator;
#ifdef QT_TRANSLATIONS_DIR
		qtTr->load( QStringLiteral( "qt_%1.qm" ).arg( configuredLocale.name() ), QStringLiteral( QT_TRANSLATIONS_DIR ) );
#else
		qtTr->load( QStringLiteral( ":/qttranslations/qt_%1.qm" ).arg( configuredLocale.name() ) );
#endif
		QCoreApplication::installTranslator( qtTr );
	}

	if( configuredLocale.language() == QLocale::Hebrew ||
		configuredLocale.language() == QLocale::Arabic )
	{
		QApplication::setLayoutDirection( Qt::RightToLeft );
	}

	if( config().applicationName().isEmpty() == false )
	{
		m_applicationName = config().applicationName();
	}

	m_cryptoCore = new CryptoCore;

	initAuthentication( AuthenticationCredentials::None );

	m_pluginManager = new PluginManager( this );

	m_accessControlDataBackendManager = new AccessControlDataBackendManager( *m_pluginManager );
	m_platformPluginManager = new PlatformPluginManager( *m_pluginManager );

	m_platformPlugin = m_platformPluginManager->platformPlugin();
}