Exemplo n.º 1
0
 public function logout(AIS2ServerConnection $serverConnection)
 {
     $connection = $serverConnection->getHttpConnection();
     $response = $connection->post(new NullTrace(), self::COSIGN_LOGOUT, array("verify" => "Odhlásiť", "url" => "https://login.uniba.sk/"));
     if (!preg_match(self::IIKS_LOGIN_PATTERN, $response)) {
         throw new LoginException("Unexpected response.");
     }
 }
Exemplo n.º 2
0
 public function isLoggedIn(AIS2ServerConnection $serverConnection)
 {
     $connection = $serverConnection->getHttpConnection();
     $data = $connection->get(new NullTrace(), self::COSIGN_LOGIN);
     if (preg_match(self::LOGGED_ALREADY_PATTERN, $data)) {
         return true;
     }
     if (preg_match(self::IIKS_LOGIN_PATTERN, $data)) {
         return false;
     }
     return new LoginException("Unexpected response.");
 }
Exemplo n.º 3
0
 public function isLoggedIn(AIS2ServerConnection $serverConnection)
 {
     $connection = $serverConnection->getHttpConnection();
     $urlMap = $serverConnection->getUrlMap();
     $data = $connection->get(new NullTrace(), $urlMap->getStartPageUrl());
     if (preg_match(self::NOT_LOGGED_IN_PATTERN, $data)) {
         return false;
     }
     if (preg_match(self::LOGGED_IN_PATTERN, $data)) {
         return true;
     }
     throw new LoginException("Cannot tell if user is logged in: Unexpected response.");
 }
Exemplo n.º 4
0
 /**
  * Returns user's full name as reported by ais.
  *
  * @returns string
  */
 public function getFullUserName(Trace $trace)
 {
     $userNameParser = new AIS2UserNameParser();
     $simpleConn = $this->connection->getSimpleConnection();
     $urlMap = $this->connection->getUrlMap();
     $html = $simpleConn->request($trace->addChild('requesting AIS2 main page'), $urlMap->getStartPageUrl());
     $html = $this->convertEncoding($html);
     $username = $userNameParser->parseUserNameFromMainPage($html);
     $trace->tlogVariable('username', $username);
     return $username;
 }
Exemplo n.º 5
0
 public function login(AIS2ServerConnection $serverConnection)
 {
     $connection = $serverConnection->getHttpConnection();
     $urlMap = $serverConnection->getUrlMap();
     $login = $this->username;
     $password = $this->password;
     $this->username = null;
     $this->password = null;
     $data = $connection->post(new NullTrace(), $urlMap->getLoginUrl(), array("login" => $login, "password" => $password));
     $loggedIn = preg_match(self::LOGGED_IN_PATTERN, $data);
     $loggedOut = preg_match(self::NOT_LOGGED_IN_PATTERN, $data);
     if (!$loggedIn || $loggedOut) {
         $reason = Strutil::match(self::LOGIN_ERROR_PATTERN, $data);
         if ($reason) {
             $reason = iconv("WINDOWS-1250", "UTF-8", $reason);
             throw new LoginException('Login failed, reason: ' . $reason);
         }
         throw new LoginException("Login failed, unknown reason.");
     }
     return true;
 }
Exemplo n.º 6
0
 public function login(AIS2ServerConnection $serverConnection)
 {
     $connection = $serverConnection->getHttpConnection();
     $connection->addCookie($this->cookie->getName(), $this->cookie->getValue(), 0, '/', $this->cookie->getDomain());
     return true;
 }
Exemplo n.º 7
0
 public function logout(AIS2ServerConnection $serverConnection)
 {
     $connection = $serverConnection->getHttpConnection();
     $connection->clearCookies();
     return true;
 }
Exemplo n.º 8
0
 public function ais2Relogin(AIS2ServerConnection $serverConnection)
 {
     $connection = $serverConnection->getHttpConnection();
     $urlMap = $serverConnection->getUrlMap();
     $data = $connection->get(new NullTrace(), $urlMap->getLoginUrl());
     if (!preg_match(self::LOGGED_IN_PATTERN, $data)) {
         throw new ReloginFailedException("Relogin failed. Cosign cookie expired.");
     }
     return true;
 }