proxy_dbid = $fpath_or_id; } else { $this->proxy_f = $fpath_or_id; } } // parse proxy certificate file public function parseProxy () { if ( $this->proxy_f == NULL ) return FALSE; unset($exec_output); exec(MDS_ROOT_ . 'exec/proxy-parse.sh ' . $this->proxy_f, $exec_output, $exit_code); if ( $exit_code == 1 ) return FALSE; if ( $exit_code > 6 ) { echo "Unexpected exit code $exit_code returned by proxy parsing backend" . PHP_EOL; return FALSE; } if ( $exit_code >= 4 ) { $this->valid = FALSE; $exit_code-=4; } $this->vomsac = ( $exit_code == 2 ) ? FALSE : TRUE; $this->userdn = $exec_output[0]; $this->uservo = $exec_output[1]; $voattrs_base64 = $exec_output[2]; $this->voattrs = base64_decode($voattrs_base64); $this->voattrs_hash = hash('md5',$this->voattrs); $this->validtime = $exec_output[3]; return TRUE; } // load proxy params from DB public function loadDBProxy () { if ( $this->proxy_dbid == NULL ) return FALSE; $dbp = DB::QueryResultAssoc( 'SELECT userid, vo, attrs_hash, attrs, validity, fileid ' . 'FROM proxycerts WHERE id = ?(id)', $this->proxy_dbid ); if(is_null($dbp)) return FALSE; $this->userdn = $dbp['userid']; $this->uservo = $dbp['vo']; $this->vomsac = TRUE; $this->voattrs = $dbp['attrs']; $this->voattrs_hash = $dbp['attrs_hash']; $this->validtime = $dbp['validity']; $this->valid = ( $this->validtime > time() ) ? TRUE : FALSE; $this->proxy_dbfile = $dbp['fileid']; return TRUE; } public function updateDBProxyValidity ($validity) { $u = DB::UpdateQuery( 'UPDATE proxycerts SET validity = ?(validity) ' . 'WHERE id = ?(id)', $validity, $this->proxy_dbid ); if ( $u == 1 ) $this->validtime = $validity; } public function saveDBProxy ($userid) { $this->saveDBProxyFile(); $this->proxy_dbid = DB::InsertQuery( 'INSERT INTO proxycerts(`userid`,`vo`,`attrs_hash`,`attrs`,`validity`,`fileid`) '. 'VALUES (?(uid),?(vo),?(attrshash),?(attrs),?(valid),?(fileid))', $userid, $this->uservo, $this->voattrs_hash, $this->voattrs, $this->validtime, $this->getDBProxyFileID() ); } public function getDBProxyFile ($fpath = NULL) { if ( is_numeric($this->proxy_dbfile) ) { $fileid = $this->proxy_dbfile; $this->proxy_dbfile = new DBFile($fileid); } $this->proxy_f = $this->proxy_dbfile->getFile($fpath); return $this->proxy_f; } public function saveDBProxyFile () { $this->proxy_dbfile = new DBFile($this->proxy_f,'userproxy'); } public function getDBProxyFileID () { if ( is_numeric($this->proxy_dbfile) ) return $this->proxy_dbfile; return $this->proxy_dbfile->getFileID(); } public function updateDBProxyFile ($fpath) { if ( is_numeric($this->proxy_dbfile) ) { $fileid = $this->proxy_dbfile; $this->proxy_dbfile = new DBFile($fileid); } return $this->proxy_dbfile->updateFileContent($fpath); } public function isVOMSAC () { return $this->vomsac; } public function isProxyValid () { return $this->valid; } public function getProxyDN () { if ( is_numeric($this->userdn) ) { $proxyuser = new User($this->userdn); $this->userdn = $proxyuser->getName(); unset($proxyuser); } return $this->userdn; } public function getProxyVOAttrsHash () { return $this->voattrs_hash; } public function getProxyFile () { if ( $this->proxy_f == NULL ) $this->getDBProxyFile(); return $this->proxy_f; } public function getProxyVO () { return $this->uservo; } public function getProxyValidityTime () { return $this->validtime; } } ?>