Ejemplo n.º 1
0
 public static function login(Trace $trace, Login $login, AIS2ServerConnection $connection)
 {
     $trace->tlog("Creating AIS2Session");
     $session = new AIS2Session($login);
     $trace->tlog("logging in");
     if (!$login->login($connection)) {
         return false;
     }
     $trace->tlog("logged in correctly.");
     $_SESSION['AISSession'] = $session;
     self::redirect();
     return true;
 }
Ejemplo n.º 2
0
 public function login(Trace $trace, ServerConfig $serverConfig, LoginFactory $factory, AIS2ServerConnection $connection)
 {
     $login = $this->provideLogin($serverConfig, $factory, $this->request);
     if ($login === null) {
         return false;
     }
     $trace->tlog("logging in");
     if (!$login->login($connection)) {
         return false;
     }
     $trace->tlog("logged in correctly.");
     $this->session->write('login/login.class', $login);
     FajrUtils::redirect();
     assert(false);
 }
Ejemplo n.º 3
0
 public function login(Trace $trace, ServerConfig $serverConfig, LoginFactory $factory, AIS2ServerConnection $connection)
 {
     $login = $this->provideLogin($serverConfig, $factory, $this->request);
     if ($login === null) {
         return false;
     }
     $trace->tlog("logging in");
     if (!$login->login($connection)) {
         return false;
     }
     $trace->tlog("logged in correctly.");
     $this->session->write('login/login.class', $login);
     $this->session->write('server', $serverConfig);
     FajrUtils::redirect();
     // it should be safe to end script execution here.
     exit;
 }
 /**
  * Nadviaže spojenie, spustí danú "aplikáciu" v AISe
  * a natiahne prvotné dáta do atribútu $data.
  */
 public function requestOpen(Trace $trace, ScreenData $data)
 {
     $trace->tlog("open screen");
     $url = $this->requestBuilder->getAppInitializationUrl($data);
     $response = $this->connection->request($trace->addChild("get app id"), $url);
     $this->appId = $this->parseAppIdFromResponse($response);
     $response = $this->doRequest($trace->addChild("Init command"), array('eventClass' => 'avc.ui.event.AVCComponentEvent', 'command' => 'INIT'));
     $this->formName = $this->parseFormNameFromResponse($response);
 }
Ejemplo n.º 5
0
 /**
  * Zatvorí danú "aplikáciu" v AISe,
  */
 public function closeIfNeeded(Trace $trace)
 {
     if (!$this->inUse) {
         return;
     }
     assert($this->openedDialog === null);
     $trace->tlog('closing screen ' . get_class($this));
     $this->inUse = false;
 }
Ejemplo n.º 6
0
 /**
  * Zatvorí danú "aplikáciu" v AISe
  */
 public function closeIfNeeded(Trace $trace)
 {
     if (!$this->inUse) {
         return;
     }
     if (!$this->terminated) {
         $trace->tlog('closing dialog ' . get_class($this));
     }
     $this->inUse = false;
     $this->parent->closeDialog($this->uid);
 }
 /**
  * Parse a line of proxy file in a string
  *
  * @param Trace  $trace trace object
  * @param string $line not including line termination characters
  * @returns array service, value and domain from parsed line, indexed by
  *                those strings or false if this is not correct proxy line
  */
 private function parseString(Trace $trace, $line)
 {
     Preconditions::checkIsString($line, 'line');
     $matches = array();
     if (!preg_match(self::PROXY_LINE_PATTERN, $line, $matches)) {
         $trace->tlog('Line did not match');
         $trace->tlogVariable('line', $line);
         throw new ParseException('Proxy file line does not match');
     }
     try {
         return new CosignServiceCookie($matches[1], $matches[2], $matches[3]);
     } catch (InvalidArgumentException $e) {
         throw new ParseException('Proxy file arguments are invalid', null, $e);
     }
 }
Ejemplo n.º 8
0
 public function post(Trace $trace, $url, $data)
 {
     $trace->tlog("Http POST");
     $trace->tlogVariable("URL", $url);
     $child = $trace->addChild("POST data");
     $child->tlogVariable("post_data", $data);
     $this->_curlSetOption(CURLOPT_URL, $url);
     $this->_curlSetOption(CURLOPT_POST, true);
     $newPost = '';
     foreach ($data as $key => $value) {
         $newPost .= urlencode($key) . '=' . urlencode($value) . '&';
     }
     $post = substr($newPost, 0, -1);
     $this->_curlSetOption(CURLOPT_POSTFIELDS, $post);
     return $this->exec($trace);
 }
 private function check(Trace $trace, $url, $response)
 {
     $matches = array();
     if (preg_match(self::INTERNAL_ERROR_PATTERN, $response, $matches)) {
         $trace->tlog("Expection encountered");
         throw $this->newException($matches[1], $url);
     }
     if (preg_match(self::APACHE_ERROR_PATTERN, $response, $matches)) {
         $trace->tlog("Expection encountered");
         throw $this->newException($matches[1], $url);
     }
     if (preg_match(self::UNAUTHORIZED, $response)) {
         $trace->tlog("Exception encountered");
         throw new LoginException("AIS hlási neautorizovaný prístup - má užívateľ prístup k aplikácii?");
     }
     return $response;
 }
Ejemplo n.º 10
0
 public function getTableDefinition(Trace $trace, DOMDocument $dom)
 {
     $trace->tlog("finding table definition element");
     $trace->tlogVariable("", $dom->saveXML());
     $element = $dom->getElementById('dataTabColGroup');
     if ($element == null) {
         throw new ParseException("Can't find table headers");
     }
     $list = $element->getElementsByTagName('col');
     $columns = array();
     foreach ($list as $node) {
         assert($node->hasAttribute('shortname'));
         $columns[] = $node->getAttribute('shortname');
     }
     $trace->tlogVariable("Parsed columns:", $columns);
     return $columns;
 }
Ejemplo n.º 11
0
 /**
  * Get the full name of the user.
  * Note: resulting string is not sanitized and shouldn't be
  * used by file/other access.
  *
  * @returns string
  */
 public function getFullUserName(Trace $trace)
 {
     $trace->tlog('getting ais username');
     return "Ing. Janko Hraško";
 }
Ejemplo n.º 12
0
 /**
  * Parses ais html into DOM.
  *
  * @param Trace $trace
  * @param string $html
  *
  * @returns DOMDocument parsed DOM
  * @throws ParseException on failure
  */
 public static function createDomFromHtml(Trace $trace, $html)
 {
     Preconditions::checkIsString($html);
     $dom = new DOMDocument();
     $trace->tlog("Loading html to DOM");
     $loaded = @$dom->loadHTML($html);
     if (!$loaded) {
         throw new ParseException("Problem parsing html to DOM.");
     }
     $trace->tlog('Fixing id attributes in the DOM');
     ParserUtils::fixIdAttributes($trace, $dom);
     return $dom;
 }
 /**
  * Parses div tag. If it contains <b> element, it calls method spracujB,
  * which parses element <b>.
  *
  * @param domNode $final
  *
  * @returns array
  */
 public function parseDiv(Trace $trace, $final)
 {
     $final2 = $final->childNodes;
     foreach ($final2 as $key) {
         if ($key->nodeType != \XML_ELEMENT_NODE) {
             continue;
         }
         if ($key->tagName == 'b') {
             $trace->tlog("Parsing node with tag name 'b' inside 'div' tag");
             $pole = $this->spracujB($trace, $key);
         }
     }
     return $pole;
 }
Ejemplo n.º 14
0
 public function getTableData(Trace $trace, DOMDocument $dom)
 {
     $data = array();
     $trace->tlog("finding tbody element");
     $element = $dom->getElementById('dataTabBody0');
     if ($element == null) {
         throw new ParseException("Can't find table data");
     }
     foreach ($element->childNodes as $aisRow) {
         assert($aisRow->tagName == "tr");
         assert($aisRow->hasAttribute("id"));
         assert($aisRow->hasChildNodes());
         // TODO: asserty prerobit na exceptiony
         $row = array();
         $rowId = $aisRow->getAttribute("id");
         $index = StrUtil::match('@^row_([0-9]+)$@', $rowId);
         if ($index === false) {
             throw new ParseException("Unexpected row id format");
         }
         foreach ($aisRow->childNodes as $ais_td) {
             assert($ais_td->tagName == "td");
             $row[] = $this->getCellContent($ais_td);
         }
         $data[$index] = $row;
     }
     $trace->tlogVariable("data", $data);
     return $data;
 }