コード例 #1
0
ファイル: discovery.php プロジェクト: shupp/openid
/**
 * getServiceContent 
 * 
 * @param mixed $identifier Identifier
 * @param bool  $skipcache  Whether or not to skip cache
 * 
 * @access public
 * @return void
 */
function getServiceContent($identifier, $skipcache)
{
    $content = null;
    if (!$skipcache) {
        $store = OpenID::getStore();
        $d = $store->getDiscover($identifier);
        if ($d === false) {
            $d = new OpenID_Discover($identifier);
            try {
                $result = $d->discover();
                if ($result === false) {
                    $content = 'Discovery failed';
                    return $content;
                }
                $store->setDiscover($d);
            } catch (OpenID_Exception $e) {
                return get_class($e) . ': ' . $e->getMessage();
            }
        } else {
            $cache = true;
        }
    } else {
        $d = new OpenID_Discover($identifier);
        try {
            $result = $d->discover();
            if ($result === false) {
                $content = 'Discovery failed';
                return $content;
            }
        } catch (OpenID_Exception $e) {
            return get_class($e) . ': ' . $e->getMessage();
        }
    }
    $content = array();
    if (!empty($cache)) {
        $content['cached'] = true;
    }
    $content['OpenID_Discover'] = $d->services;
    $extensions = array('OAuth', 'AX', 'SREG11', 'UI');
    $supported = array();
    foreach ($extensions as $extension) {
        $supported[$extension] = $d->extensionSupported($extension);
    }
    $content['Extensions Supported'] = $supported;
    return $content;
}
コード例 #2
0
ファイル: OpenIDTest.php プロジェクト: shupp/openid
 /**
  * testSetAndGetStore 
  * 
  * @return void
  */
 public function testSetAndGetStore()
 {
     $this->assertInstanceOf('OpenID_Store_CacheLite', OpenID::getStore());
     OpenID::setStore(OpenID_Store::factory('Mock'));
     $this->assertInstanceOf('OpenID_Store_Mock', OpenID::getStore());
 }
コード例 #3
0
ファイル: Nonce.php プロジェクト: shupp/openid
 /**
  * Creates a nonce and also stores it.
  * 
  * @param int $length Lenth of the random string, defaults to 6
  * @param int $time   A unix timestamp in seconds
  * 
  * @return string The nonce
  * @see createNonce()
  */
 public function createNonceAndStore($length = 6, $time = null)
 {
     $nonce = $this->createNonce($length, $time);
     OpenID::getStore()->setNonce($nonce, $this->opEndpointURL);
     return $nonce;
 }