// URL at the start of authentication $url = isset($_GET['openid_identifier']) ? $_GET['openid_identifier'] : $session->load(); } $action = isset($_GET['action']) ? strtolower($_GET['action']) : null; $credentials = new ezcAuthenticationIdCredentials($url); $authentication = new ezcAuthentication($credentials); $authentication->session = $session; if ($action === 'logout') { $session->destroy(); } else { $options = new ezcAuthenticationOpenidOptions(); $options->mode = ezcAuthenticationOpenidFilter::MODE_SMART; $options->openidVersion = ezcAuthenticationOpenidFilter::VERSION_2_0; $options->store = new ezcAuthenticationOpenidFileStore('/tmp/store'); $filter = new ezcAuthenticationOpenidFilter($options); $filter->registerFetchData(array('fullname', 'gender', 'country', 'language')); $authentication->addFilter($filter); } if (!$authentication->run()) { // authentication did not succeed, so inform the user $status = $authentication->getStatus(); $err = array(); $err["user"] = ""; $err["session"] = ""; for ($i = 0; $i < count($status); $i++) { list($key, $value) = each($status[$i]); switch ($key) { case 'ezcAuthenticationOpenidFilter': if ($value === ezcAuthenticationOpenidFilter::STATUS_SIGNATURE_INCORRECT) { $err["user"] = "******"; }
public function testOpenidCliExceptionRegisterFetchData() { $credentials = new ezcAuthenticationIdCredentials(self::$url); $authentication = new ezcAuthentication($credentials); $filter = new ezcAuthenticationOpenidFilter(); $filter->registerFetchData(array('fullname', 'gender', 'country', 'language')); $authentication->addFilter($filter); try { $authentication->run(); $this->fail("Expected exception was not thrown."); } catch (ezcAuthenticationOpenidException $e) { $result = $e->getMessage(); $expected = "Could not redirect to 'http://www.myopenid.com/server?openid.return_to=http%3A%2F%2Flocalhost%2Fopenid.php%3Faction%3Dlogin%26openid_identifier%3Dhttp%253A%252F%252Fezc.myopenid.com%26nonce%3D859610&openid.trust_root=http%3A%2F%2Flocalhost&openid.identity=http%3A%2F%2Fezc.myopenid.com%2F&openid.sreg.optional=fullname,gender,country,language&openid.ns.sreg=http%3A%2F%2Fopenid.net%2Fsreg%2F1.0&openid.mode=checkid_setup'. Most probably your browser does not support redirection or JavaScript."; $this->assertEquals(substr($expected, 0, 192), substr($result, 0, 192)); $this->assertEquals(substr($expected, 198), substr($result, 198)); } }