/** * discover * * @return void */ public function discover() { $service = new OpenID_ServiceEndpoints($this->identifier); $service->addService(self::$opEndpoint); $date = new DateTime(date('c', time() + 3600 * 8)); $service->setExpiresHeader($date->format(DATE_RFC1123)); return $service; }
/** * Tests that the count method via the Countable interface works correctly * * @return void */ public function testCount() { $this->object->addService($this->goodService); $this->object->addService($this->goodService); $this->object->addService($this->goodService); $this->object->addService($this->goodService); $count = count($this->object); $this->assertInternalType('int', $count); $this->assertEquals(4, $count); }
/** * Performs YADIS discovery * * @throws OpenID_Discover_Exception on error * @return OpenID_ServiceEndpoints */ public function discover() { try { try { $discoveredServices = $this->getServicesYadis()->discover(); } catch (Services_Yadis_Exception $e) { $message = 'Yadis protocol could not locate a valid XRD document'; if ($e->getMessage() == $message) { return false; } throw $e; } if (!$discoveredServices->valid()) { return false; } $service = new OpenID_ServiceEndpoints($this->getServicesYadis()->getYadisId()); foreach ($discoveredServices as $discoveredService) { $types = $discoveredService->getTypes(); if (array_key_exists($types[0], OpenID::$versionMap)) { $version = $types[0]; $localID = null; $localIDs = $discoveredService->getElements('xrd:LocalID'); if (!empty($localIDs[0])) { $localID = $localIDs[0]; } // Modify version if appropriate if ($localID && $version == OpenID::SERVICE_2_0_SERVER) { $version = OpenID::SERVICE_2_0_SIGNON; } $opEndpoint = new OpenID_ServiceEndpoint(); $opEndpoint->setVersion($types[0]); // Choose OpenID 2.0 if it's available if (count($types) > 1) { foreach ($types as $type) { if ($type == OpenID::SERVICE_2_0_SERVER || $type == OpenID::SERVICE_2_0_SIGNON) { $opEndpoint->setVersion($type); break; } } } $opEndpoint->setTypes($types); $opEndpoint->setURIs($discoveredService->getUris()); $opEndpoint->setLocalID($localID); $opEndpoint->setSource(OpenID_Discover::TYPE_YADIS); $service->addService($opEndpoint); } } // Add in expires information $service->setExpiresHeader($this->getServicesYadis()->getHTTPResponse()->getHeader('Expires')); return $service; } catch (Services_Yadis_Exception $e) { // Add logging or observer? throw new OpenID_Discover_Exception($e->getMessage()); } // Did the identifier even respond to the initial HTTP request? if ($this->yadis->getUserResponse() === false) { throw new OpenID_Discover_Exception('No response from identifier'); } }