Beispiel #1
0
bool TMdContr::cfgChange( TCfg &icfg )
{
    TController::cfgChange(icfg);

    try
    {
	if(icfg.name() == "EndPoint" && enableStat())
	{
	    tr.at().setAddr("TCP:"+epParse());
	    ResAlloc res(nodeRes(), false);
	    SecuritySetting ss("", -1);
	    if(epLst.find(icfg.getS()) != epLst.end()) ss = epLst[icfg.getS()];
	    res.release();

	    if(ss.policy.size() && mSecPol.fld().values().find(ss.policy) != string::npos)
	    {
		setSecPolicy(ss.policy);
		setSecMessMode(ss.messageMode);
	    }

	    XML_N req("opc.tcp");

	    //> Send FindServers request for EndPoints list provide
	    req.setAttr("id", "FindServers");
	    reqService(req);

	    res.request(true);
	    epLst.clear();
	    for(unsigned i_s = 0; i_s < req.childSize(); i_s++)
		for(unsigned i_d = 0; i_d < req.childGet(i_s)->childSize(); i_d++)
		    epLst[req.childGet(i_s)->childGet(i_d)->text()] = SecuritySetting();
	    res.release();

	    //> Send GetEndpoints request for EndPoints list provide
	    req.clear()->setAttr("id", "GetEndpoints");
	    reqService(req);

	    res.request(true);
	    for(unsigned i_ch = 0; i_ch < req.childSize(); i_ch++)
	    {
		XML_N *xep = req.childGet(i_ch);
		string ep = xep->attr("endpointUrl");
		if(epLst.find(ep) != epLst.end()) ep += "/"+TSYS::strParse(xep->attr("securityPolicyUri"),1,"#")+"/"+xep->attr("securityMode");
		epLst[ep] = SecuritySetting(TSYS::strParse(xep->attr("securityPolicyUri"),1,"#"), atoi(xep->attr("securityMode").c_str()));
	    }
	}
	else if(icfg.name() == "SecPolicy")
	{
	    if(icfg.getS() == "None" && secMessMode() != MS_None)	setSecMessMode(MS_None);
	    if(icfg.getS() != "None" && secMessMode() == MS_None)	setSecMessMode(MS_Sign);
	}
	else if(icfg.name() == "SecMessMode" &&
		((icfg.getI() != MS_None && secPolicy() == "None") || (icfg.getI() == MS_None && secPolicy() != "None")))
	    return false;
    } catch(...) { }

    return true;
}
Beispiel #2
0
string MTable::getVal( TCfg &cfg )
{
    switch( cfg.fld().type() )
    {
	case TFld::String:	return cfg.getS();
	case TFld::Integer:	return SYS->int2str(cfg.getI());
	case TFld::Real:	return SYS->real2str(cfg.getR());
	case TFld::Boolean:	return SYS->int2str(cfg.getB());
	default: break;
    }
    return "";
}
Beispiel #3
0
bool TCfg::operator==( TCfg &cfg )
{
    if(fld().type() == cfg.fld().type())
	switch(fld().type()) {
	    case TFld::String:	return (getS() == cfg.getS());
	    case TFld::Integer:	return (getI() == cfg.getI());
	    case TFld::Real:	return (getR() == cfg.getR());
	    case TFld::Boolean:	return (getB() == cfg.getB());
	    default: break;
	}
    return false;
}
Beispiel #4
0
string MTable::getVal( TCfg &cfg, db_str_rec *fld_rec )
{
    string rez;
    switch(cfg.fld().type()) {
	case TFld::Boolean:	rez = cfg.getB() ? "T" : "F";	break;
	case TFld::Integer:	rez = i2s(cfg.getI());		break;
	case TFld::Real: {
	    if(!fld_rec)	{ rez = r2s(cfg.getR()); break; }

	    char str[200];
	    snprintf(str, sizeof(str), "%*.*f", fld_rec->len_fild, fld_rec->dec_field, cfg.getR());
	    rez = str;
	    break;
	}
	default: rez = Mess->codeConvOut(codepage, cfg.getS());	break;
    }

    return rez;
}