Beispiel #1
0
void OptionsLoader::setValue(const std::string &key,
                             std::string &value) {
    if (value.length()>0) {
        try {
            bool isWriteable;
            if (myOptions.isBool(key)) {
                std::transform(value.begin(), value.end(), value.begin(), tolower);
                if (value=="1"||value=="yes"||value=="true"||value=="on"||value=="x") {
                    isWriteable = setSecure(key, true);
                } else if (value=="0"||value=="no"||value=="false"||value=="off") {
                    isWriteable = setSecure(key, false);
                } else {
                    throw InvalidArgument("Invalid boolean value for option '" + key + "'.");
                }
            } else {
                isWriteable = setSecure(key, value);
            }
            if (!isWriteable) {
                MsgHandler::getErrorInstance()->inform("Could not set option '" + key + "' (probably defined twice).");
                myError = true;
            }
        } catch (InvalidArgument &e) {
            MsgHandler::getErrorInstance()->inform(e.what());
            myError = true;
        }
    }
}
Beispiel #2
0
SslSocket::SslSocket(SslDriver *driver, struct ev_loop *loop, int fd, int af) :
	x0::Socket(loop, fd, af),
#ifndef XZERO_NDEBUG
	ctime_(ev_now(loop)),
#endif
	driver_(driver),
	context_(nullptr),
	session_()
{
	TRACE("SslSocket()");

	setSecure(true);
	setState(Handshake);

	GNUTLS_CHECK( gnutls_init(&session_, GNUTLS_SERVER) );

	gnutls_handshake_set_post_client_hello_function(session_, &SslSocket::onClientHello);

	gnutls_certificate_server_set_request(session_, GNUTLS_CERT_REQUEST);
	gnutls_dh_set_prime_bits(session_, 1024);

	gnutls_session_enable_compatibility_mode(session_);

	gnutls_session_set_ptr(session_, this);
	gnutls_transport_set_ptr(session_, reinterpret_cast<gnutls_transport_ptr_t>(handle()));

	driver_->initialize(this);
}
Beispiel #3
0
HTTPCookie::HTTPCookie(const NameValueCollection& nvc):
	_version(0),
	_secure(false),
	_maxAge(-1),
	_httpOnly(false)
{
	for (NameValueCollection::ConstIterator it = nvc.begin(); it != nvc.end(); ++it)
	{
		const std::string& name  = it->first;
		const std::string& value = it->second;
		if (icompare(name, "comment") == 0)
		{
			setComment(value);
		}
		else if (icompare(name, "domain") == 0)
		{
			setDomain(value);
		}
		else if (icompare(name, "path") == 0)
		{
			setPath(value);
		}
		else if (icompare(name, "max-age") == 0)
		{
			setMaxAge(NumberParser::parse(value));
		}
		else if (icompare(name, "secure") == 0)
		{
			setSecure(true);
		}
		else if (icompare(name, "expires") == 0)
		{
			int tzd;
			DateTime exp = DateTimeParser::parse(value, tzd);
			Timestamp now;
			setMaxAge((int) ((exp.timestamp() - now) / Timestamp::resolution()));
		}
		else if (icompare(name, "version") == 0)
		{
			setVersion(NumberParser::parse(value));
		}
		else if (icompare(name, "HttpOnly") == 0)
		{
			setHttpOnly(true);
		}
		else
		{
			setName(name);
			setValue(value);
		}
	}
}
void OptionsLoader::setValue(const std::string& key,
                             std::string& value) {
    if (value.length() > 0) {
        try {
            if (!setSecure(key, value)) {
                WRITE_ERROR("Could not set option '" + key + "' (probably defined twice).");
                myError = true;
            }
        } catch (ProcessError& e) {
            WRITE_ERROR(e.what());
            myError = true;
        }
    }
}
Beispiel #5
0
void Session::initFrom(const ConnectionInfo& connection)
{
    setName(connection.name);
    setSecure(connection.secure);
    setPassword(connection.pass);
    setHost(connection.host);
    setPort(connection.port);
    setNickName(connection.nick);
    QString appName = QApplication::applicationName();
    setUserName(connection.user.isEmpty() ? appName : connection.user);
    setRealName(connection.real.isEmpty() ? appName : connection.real);
    setChannels(connection.channels);
    m_quit = connection.quit;
}
Beispiel #6
0
HTTPCookie::HTTPCookie(const NameValueCollection& nvc):
    _version(0),
    _secure(false),
    _maxAge(-1),
    _httpOnly(false)
{
    for (NameValueCollection::ConstIterator it = nvc.begin(); it != nvc.end(); ++it) {
        const std::string& name  = it->first;
        const std::string& value = it->second;

        if (icompare(name, "comment") == 0) {
            setComment(value);
        }
        else if (icompare(name, "domain") == 0) {
            setDomain(value);
        }
        else if (icompare(name, "path") == 0) {
            setPath(value);
        }
        else if (icompare(name, "priority") == 0) {
            setPriority(value);
        }
        else if (icompare(name, "max-age") == 0) {
            throw NotImplementedException("HTTPCookie::HTTPCookie max-age");
        }
        else if (icompare(name, "secure") == 0) {
            setSecure(true);
        }
        else if (icompare(name, "expires") == 0) {
            throw NotImplementedException("HTTPCookie::HTTPCookie expires");
        }
        else if (icompare(name, "version") == 0) {
            throw NotImplementedException("HTTPCookie::HTTPCookie version");
        }
        else if (icompare(name, "HttpOnly") == 0) {
            setHttpOnly(true);
        }
        else {
            setName(name);
            setValue(value);
        }
    }
}
void CWizardIrcConnection::setConnection( const ConnectionInfo& connection )
{
	if ( !connection.nick.isEmpty() )
	{
		setNickName( connection.nick );
	}
	else
	{
		setNickName( quazaaSettings.Profile.IrcNickname );
	}

	if ( !connection.real.isEmpty() )
	{
		setRealName( connection.real );
	}
	else
	{
		setRealName( quazaaSettings.Profile.IrcUserName );
	}

	if ( !connection.host.isEmpty() )
	{
		setHostName( connection.host );
	}
	else
	{
		setHostName( "irc.paradoxirc.net" );
	}

	if ( connection.port )
	{
		setPort( connection.port );
	}
	else
	{
		setPort( 6667 );
	}

	setSecure( connection.secure );
	setUserName( connection.user );
	setPassword( connection.pass );
	setConnectionName( connection.name );
}