From: konrad Date: Sun, 4 Apr 2010 12:59:01 +0000 (+0000) Subject: change from pattern based authentication to class based authentication X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=9f7ea3812c855ef8057c419bf5beb93ac4286e5f;p=web%2Fkonrad%2Fpack.git change from pattern based authentication to class based authentication git-svn-id: https://silmor.de/svn/softmagic/pack/trunk@432 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- diff --git a/woc/phpout.cpp b/woc/phpout.cpp index a026a32..c29fc78 100644 --- a/woc/phpout.cpp +++ b/woc/phpout.cpp @@ -31,18 +31,7 @@ WocPHPServerOut::WocPHPServerOut(const QDomElement&el) m_basedir=WocProcessor::instance()->baseDir()+"/"+el.attribute("sourceDir","."); m_subdir=el.attribute("subDir","phpwob"); m_fileext=el.attribute("extension",".inc"); - QList nl=elementsByTagName(el,"Authenticator"); - if(nl.size()){ - QDomElement el2=nl.at(0).toElement(); - m_isauth=el2.attribute("isAuthenticated","false"); - m_hasrole=el2.attribute("hasRole","false"); - m_username=el2.attribute("userName","\"\""); - m_authinit=el2.attribute("init",""); - }else{ - m_isauth="false"; - m_hasrole="false"; - m_username="\"\""; - } + m_transbase=el.attribute("transactionBase","WobTransaction"); //cleanup directory (remove normal files, assume remainder is harmless) QDir d(m_basedir+"/"+m_subdir); if(d.exists() && str2bool(el.attribute("clean","0"))){ @@ -803,25 +792,23 @@ void WocPHPServerOut::newTransaction(const WocTransaction&trn) //// //generate code - QString code="/* TRANSLATOR "+cn+" */\nclass "+cn+" extends WobTransaction{\n"; + QString code="/* TRANSLATOR "+cn+" */\nclass "+cn+" extends "+m_transbase+"{\n"; //constructor code+=trnConstruct(trn); tf.write(code.toAscii()); //request handler: - code="public function handleRequest(){\n"; + code="public function handleRequest(){\n\t$this->startTransaction();\n"; //security handling switch(trn.authMode()){ case WocTransaction::Checked: code+="\t/*security check: authenticated and authorized*/\n"; - code+="\t"+m_authinit+";\n"; - code+="\tif(!"+m_isauth+"||!"+QString(m_hasrole).replace("%","\""+trn.name()+"\"")+")$this->notAuthenticated();\n"; + code+="\tif(!$this->isAuthorized(\""+trn.name()+"\""+"))$this->notAuthenticated();\n"; break; case WocTransaction::Auth: code+="\t/*security check: authenticated*/\n"; - code+="\t"+m_authinit+";\n"; - code+="\tif(!"+m_isauth+")$this->notAuthenticated();\n"; + code+="\tif(!$this->isAuthenticated())$this->notAuthenticated();\n"; break; default: code+="\t/*no security check, open function*/\n"; @@ -850,7 +837,7 @@ void WocPHPServerOut::newTransaction(const WocTransaction&trn) //encode outputs/handle errors code+=trnOutput(trn); - code+="}\n"; + code+="\t$this->commitTransaction();\n}\n"; tf.write(code.toAscii()); //getters/setters @@ -876,7 +863,8 @@ void WocPHPServerOut::newTransaction(const WocTransaction&trn) QString WocPHPServerOut::trnConstruct(const WocTransaction&trn) { - QString code="public function __construct(){\n\t$this->ainput=array("; + QString code="public function __construct(){\n\tparent::__construct();\n"; + code+="\t$this->ainput=array("; QStringList sl=trn.inputNames(); for(int i=0;i