当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_OpenId类代码示例

本文整理汇总了PHP中Zend_OpenId的典型用法代码示例。如果您正苦于以下问题:PHP Zend_OpenId类的具体用法?PHP Zend_OpenId怎么用?PHP Zend_OpenId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Zend_OpenId类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getMail

 /**
  * @return Zend_Mail
  * @throws Zend_Mail_Protocol_Exception
  */
 public static function getMail(Users_Model_User $user, $subject)
 {
     $file = CommunityID_Resources::getResourcePath('reminder_mail.txt');
     $emailTemplate = file_get_contents($file);
     $emailTemplate = str_replace('{userName}', $user->getFullName(), $emailTemplate);
     $currentUrl = Zend_OpenId::selfURL();
     preg_match('#(.*)/manageusers/sendreminder#', $currentUrl, $matches);
     $emailTemplate = str_replace('{registrationURL}', $matches[1] . '/register/eula?token=' . $user->token, $emailTemplate);
     // can't use $this->_config 'cause it's a static function
     $configEmail = Zend_Registry::get('config')->email;
     switch (strtolower($configEmail->transport)) {
         case 'smtp':
             Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Smtp($configEmail->host, $configEmail->toArray()));
             break;
         case 'mock':
             Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Mock());
             break;
         default:
             Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Sendmail());
     }
     $mail = new Zend_Mail('UTF-8');
     $mail->setBodyText($emailTemplate);
     $mail->setFrom($configEmail->supportemail);
     $mail->addTo($user->email);
     $mail->setSubject($subject);
     return $mail;
 }
开发者ID:sdgdsffdsfff,项目名称:auth-center,代码行数:31,代码来源:ManageusersController.php

示例2: indexAction

 public function indexAction()
 {
     $this->view->headTitle("User", 'PREPEND');
     $openid = $this->getRequest()->getParam('openid');
     if (isset($openid)) {
         $this->view->openIdServer = Zend_OpenId::absoluteURL("/provider/");
     } else {
         $this->_redirect('/user/login');
     }
 }
开发者ID:heiglandreas,项目名称:Zend-Framework-OpenID-Provider,代码行数:10,代码来源:IndexController.php

示例3: save

 public function save(Default_Model_User $user)
 {
     $data = array('username' => $user->getUsername(), 'password' => md5($user->getUsername() . $user->getPassword()), 'created' => date('Y-m-d H:i:s'), 'openid' => Zend_OpenId::absoluteURL('/openid/' . $user->getUsername()), 'user_type' => $user->getUserType());
     if (null === ($id = $user->getId())) {
         $id = $this->getDbTable()->insert($data);
     } else {
         $this->getDbTable()->update($data, array('id = ?' => $id));
     }
     return $id;
 }
开发者ID:heiglandreas,项目名称:Zend-Framework-OpenID-Provider,代码行数:10,代码来源:UserMapper.php

示例4: login

 /**
  * Performs login of user with given $id, $password and $username
  * Returns true in case of success and false otherwise
  *
  * @param string $id user identity URL
  * @param string $password user password
  * @param string $username Tine 2.0 login name
  * @return bool
  */
 public function login($id, $password, $username = null)
 {
     if (!Zend_OpenId::normalize($id)) {
         return false;
     }
     if (!$this->_storage->checkUser($id, $password, $username)) {
         return false;
     }
     $this->_user->setLoggedInUser($id);
     return true;
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:20,代码来源:Provider.php

示例5: direct

 public function direct($config)
 {
     $currentUrl = urldecode(Zend_OpenId::selfURL());
     if ($config->subdomain->enabled) {
         $protocol = Monkeys_Controller_Action::getProtocol();
         preg_match('#(.*)\\.' . $config->subdomain->hostname . '#', $currentUrl, $matches);
         return "{$protocol}://" . ($config->subdomain->use_www ? 'www.' : '') . $config->subdomain->hostname . '/openid/provider';
     } else {
         preg_match('#(.*)/(identity|openid)?/#', $currentUrl, $matches);
         return $matches[1] . '/openid/provider';
     }
 }
开发者ID:sdgdsffdsfff,项目名称:auth-center,代码行数:12,代码来源:ProviderUrl.php

示例6: normalize

 /**
  * Normalizes OpenID identifier that can be URL or XRI name.
  * Returns true on success and false of failure.
  *
  * Normalization is performed according to the following rules:
  * 1. If the user's input starts with one of the "xri://", "xri://$ip*",
  *    or "xri://$dns*" prefixes, they MUST be stripped off, so that XRIs
  *    are used in the canonical form, and URI-authority XRIs are further
  *    considered URL identifiers.
  * 2. If the first character of the resulting string is an XRI Global
  *    Context Symbol ("=", "@", "+", "$", "!"), then the input SHOULD be
  *    treated as an XRI.
  * 3. Otherwise, the input SHOULD be treated as an http URL; if it does
  *    not include a "http" or "https" scheme, the Identifier MUST be
  *    prefixed with the string "http://".
  * 4. URL identifiers MUST then be further normalized by both following
  *    redirects when retrieving their content and finally applying the
  *    rules in Section 6 of [RFC3986] to the final destination URL.
  * @param string &$id identifier to be normalized
  * @return bool
  */
 public static function normalize(&$id)
 {
     $validator = new Zend_Validate_EmailAddress();
     if ($validator->isValid($id)) {
         if (false !== strpos($id, 'gmail')) {
             $id = 'https://www.google.com/accounts/o8/id';
             return true;
         }
         $email = explode('@', $id);
         $id = 'https://www.google.com/accounts/o8/site-xrds?ns=2&hd=' . $email[1];
         return true;
     } else {
         return Zend_OpenId::normalize($id);
     }
 }
开发者ID:highfidelity,项目名称:love,代码行数:36,代码来源:OpenId.php

示例7: getMail

    /**
     * @return Zend_Mail
     * @throws Zend_Mail_Protocol_Exception
     */
    public static function getMail(Exception $ex, User $user, $errors)
    {
        $exceptionClass = get_class($ex);
        $stack = $ex->getTraceAsString();
        $stackDetail = print_r($errors, true);
        $currentUrl = Zend_OpenId::selfURL();
        if ($user->role = ROLE_GUEST) {
            $userLabel = 'Anonymous';
        } else {
            $userLabel = $user->getFullName() . '(' . $user->username . ')';
        }
        $body = <<<EOD
Dear Admin,

An error has occured in your Community-ID installation.

URL requested: {$currentUrl}

By User: {$userLabel}

Exception: {$exceptionClass}

Call stack:
{$stack}

Call stack detail:
{$stackDetail}
EOD;
        // can't use $this-_config 'cause it's a static function
        $configEmail = Zend_Registry::get('config')->email;
        switch (strtolower($configEmail->transport)) {
            case 'smtp':
                Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Smtp($configEmail->host, $configEmail->toArray()));
                break;
            case 'mock':
                Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Mock());
                break;
            default:
                Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Sendmail());
        }
        $mail = new Zend_Mail();
        $mail->setBodyText($body);
        $mail->setFrom($this->_config->email->supportemail);
        $mail->addTo($configEmail->adminemail);
        $mail->setSubject('Community-ID error report');
        return $mail;
    }
开发者ID:sdgdsffdsfff,项目名称:auth-center,代码行数:51,代码来源:Error.php

示例8: HandleObjectCategories

 function HandleObjectCategories($objectCategoryIds)
 {
     global $prefs;
     $perspectivelib = TikiLib::lib('perspective');
     $current_object = current_object();
     if (!$current_object) {
         // only used on tiki objects
         return;
     }
     $descendants = $this->get_category_descendants($prefs['areas_root']);
     $objectPerspective = 0;
     if (!empty($objectCategoryIds)) {
         if (!isset($_SESSION['current_perspective'])) {
             unset($_SESSION['current_perspective']);
         }
         foreach ($objectCategoryIds as $categId) {
             // If category is inside $prefs['areas_root']
             if (in_array($categId, $descendants)) {
                 $area = $this->getAreaByCategId($categId);
                 if ($area) {
                     $objectPerspective = $area['perspectives'][0];
                     // use 1st persp
                     break;
                 }
             }
         }
         if ($objectPerspective && $objectPerspective != $_SESSION['current_perspective']) {
             $area = $this->getAreaByPerspId($_SESSION['current_perspective']);
             $objectArea = $this->getAreaByPerspId($objectPerspective);
             if ($area && !$area['share_common'] || $objectArea && $objectArea['exclusive']) {
                 $perspectivelib->set_perspective($objectPerspective, true);
                 Zend_OpenId::redirect(Zend_OpenId::selfUrl());
             }
         }
     }
     if ($objectPerspective < 1 && !empty($_SESSION['current_perspective'])) {
         // uncategorised objects
         $area = $this->getAreaByPerspId($_SESSION['current_perspective']);
         if ($area) {
             if (!$area['share_common']) {
                 $perspectivelib->set_perspective($objectPerspective, true);
                 Zend_OpenId::redirect(Zend_OpenId::selfUrl());
             }
         }
     }
 }
开发者ID:ameoba32,项目名称:tiki,代码行数:46,代码来源:binderlib.php

示例9: _makeVerifyParameters

 /**
  * Подготовить набор параметров для verify
  *
  * @return array
  */
 protected function _makeVerifyParameters(array $extraParams = array())
 {
     $_SERVER['SCRIPT_URI'] = 'http://localhost/index.php/auth/openid/verify';
     $expiresIn = TIME + 600;
     $this->storage->addDiscoveryInfo(self::ID, self::REAL_ID, self::SERVER, 1.1, $expiresIn);
     $this->storage->addAssociation(self::SERVER, self::HANDLE, "sha1", $secret = pack("H*", "8382aea922560ece833ba55fa53b7a975f597370"), $expiresIn);
     $params = array("openid_return_to" => $_SERVER['SCRIPT_URI'], "openid_assoc_handle" => self::HANDLE, "openid_claimed_id" => self::ID, "openid_identity" => self::REAL_ID, "openid_response_nonce" => "2007-08-14T12:52:33Z46c1a59124ffe", "openid_mode" => "id_res", "openid_signed" => "assoc_handle,return_to,claimed_id,identity,response_nonce,mode,signed");
     $signed = array($params["openid_signed"]);
     if ($extraParams) {
         $params = array_merge($params, $extraParams);
         // TODO: Фуууууу
         $extraParams2 = explode(',', str_replace('_', '.', implode(',', array_keys($extraParams))));
         $signed = array_merge($signed, $extraParams2);
     }
     $params["openid_signed"] = str_replace('openid.', '', implode(',', $signed));
     // Подписать данные
     $data = '';
     foreach (explode(',', $params['openid_signed']) as $key) {
         $data .= $key . ':' . $params['openid_' . strtr($key, '.', '_')] . "\n";
     }
     $params['openid_sig'] = base64_encode(\Zend_OpenId::hashHmac('sha1', $data, $secret));
     return $params;
 }
开发者ID:pycmam,项目名称:sfOpenAuthPlugin,代码行数:28,代码来源:BaseTestCase.php

示例10: absoluteUrl

 /**
  * Returns an absolute URL for the given one
  *
  * @param string $url absilute or relative URL
  * @return string
  */
 public static function absoluteUrl($url)
 {
     if (empty($url)) {
         return Zend_OpenId::selfUrl();
     } else {
         if (!preg_match('|^([^:]+)://|', $url)) {
             if (preg_match('|^([^:]+)://([^:@]*(?:[:][^@]*)?@)?([^/:@?#]*)(?:[:]([^/?#]*))?(/[^?]*)?((?:[?](?:[^#]*))?(?:#.*)?)$|', Zend_OpenId::selfUrl(), $reg)) {
                 $scheme = $reg[1];
                 $auth = $reg[2];
                 $host = $reg[3];
                 $port = $reg[4];
                 $path = $reg[5];
                 $query = $reg[6];
                 if ($url[0] == '/') {
                     return $scheme . '://' . $auth . $host . (empty($port) ? '' : ':' . $port) . $url;
                 } else {
                     $dir = dirname($path);
                     return $scheme . '://' . $auth . $host . (empty($port) ? '' : ':' . $port) . (strlen($dir) > 1 ? $dir : '') . '/' . $url;
                 }
             }
         }
     }
     return $url;
 }
开发者ID:smarcet,项目名称:openstackid,代码行数:30,代码来源:OpenIdUriHelper.php

示例11: realpath

$dir = realpath(__DIR__ . "/../../..");
set_include_path("{$dir}/incubator/library" . PATH_SEPARATOR . "{$dir}/library" . PATH_SEPARATOR . get_include_path());
/**
 * @see Zend_Auth
 */
require_once "Zend/Auth.php";
/**
 * @see Zend_Auth_Adapter_OpenId
 */
require_once "Zend/Auth/Adapter/OpenId.php";
$status = "";
$auth = Zend_Auth::getInstance();
if (isset($_POST['openid_action']) && $_POST['openid_action'] == "login" && !empty($_POST['openid_identifier']) || isset($_GET['openid_mode']) || isset($_POST['openid_mode'])) {
    $result = $auth->authenticate(new Zend_Auth_Adapter_OpenId(@$_POST['openid_identifier']));
    if ($result->isValid()) {
        Zend_OpenId::redirect(Zend_OpenId::selfURL());
    } else {
        $auth->clearIdentity();
        foreach ($result->getMessages() as $message) {
            $status .= "{$message}<br>\n";
        }
    }
} else {
    if ($auth->hasIdentity()) {
        if (isset($_POST['openid_action']) && $_POST['openid_action'] == "logout") {
            $auth->clearIdentity();
        } else {
            $status = "You are logged-in as " . $auth->getIdentity() . "<br>\n";
        }
    }
}
开发者ID:alab1001101,项目名称:zf2,代码行数:31,代码来源:test_auth.php

示例12: getUserWithUsername

 public function getUserWithUsername($username, $generateNewIfMissing = false, Zend_View $view = null)
 {
     $select = $this->select()->where('username=?', $username);
     $user = $this->fetchRow($select);
     $ldapOptions = Zend_Registry::get('config')->ldap;
     if ($ldapOptions->enabled) {
         $ldap = Monkeys_Ldap::getInstance();
         try {
             $ldapUserData = $ldap->get("cn={$username},{$ldapOptions->baseDn}");
         } catch (Exception $e) {
             if ($e->getCode() == Monkeys_Ldap::EXCEPTION_SEARCH) {
                 return false;
             }
             throw $e;
         }
         if ($user) {
             // this fields are always overridden from what comes from LDAP, because they might change
             $user->overrideWithLdapData($ldapUserData);
         } else {
             // user is registered in LDAP, but not in CID's db
             $user = $this->createRow();
             $user->registration_date = date('Y-m-d');
             $user->overrideWithLdapData($ldapUserData);
             if ($user->role != Users_Model_User::ROLE_ADMIN) {
                 preg_match('#(.*)/users/login/authenticate#', Zend_OpenId::selfURL(), $matches);
                 $user->generateOpenId($matches[1]);
             }
             if ($generateNewIfMissing) {
                 $user->save();
                 $profileId = $user->createDefaultProfile($view);
                 $user->generatePersonalInfo($ldapUserData, $profileId);
             }
         }
     }
     return $user;
 }
开发者ID:sdgdsffdsfff,项目名称:auth-center,代码行数:36,代码来源:Users.php

示例13: openId

 /**
  * handle all kinds of openId requests
  * 
  * @return void
  */
 public function openId()
 {
     Tinebase_Core::startCoreSession();
     $server = new Tinebase_OpenId_Provider(null, null, new Tinebase_OpenId_Provider_User_Tine20(), new Tinebase_OpenId_Provider_Storage());
     $server->setOpEndpoint(dirname(Zend_OpenId::selfUrl()) . '/index.php?method=Tinebase.openId');
     // handle openId login form
     if (isset($_POST['openid_action']) && $_POST['openid_action'] === 'login') {
         $server->login($_POST['openid_identifier'], $_POST['password'], $_POST['username']);
         unset($_GET['openid_action']);
         $this->_setJsonKeyCookie();
         Zend_OpenId::redirect(dirname(Zend_OpenId::selfUrl()) . '/index.php', $_GET);
         // display openId login form
     } else {
         if (isset($_GET['openid_action']) && $_GET['openid_action'] === 'login') {
             $view = new Zend_View();
             $view->setScriptPath('Tinebase/views');
             $view->openIdIdentity = $_GET['openid_identity'];
             $view->loginName = $_GET['openid_identity'];
             header('Content-Type: text/html; charset=utf-8');
             echo $view->render('openidLogin.php');
             // handle openId trust form
         } else {
             if (isset($_POST['openid_action']) && $_POST['openid_action'] === 'trust') {
                 if (isset($_POST['allow'])) {
                     if (isset($_POST['forever'])) {
                         $server->allowSite($server->getSiteRoot($_GET));
                     }
                     $server->respondToConsumer($_GET);
                 } else {
                     if (isset($_POST['deny'])) {
                         if (isset($_POST['forever'])) {
                             $server->denySite($server->getSiteRoot($_GET));
                         }
                         Zend_OpenId::redirect($_GET['openid_return_to'], array('openid.mode' => 'cancel'));
                     }
                 }
                 // display openId trust form
             } else {
                 if (isset($_GET['openid_action']) && $_GET['openid_action'] === 'trust') {
                     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
                         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " Display openId trust screen");
                     }
                     $view = new Zend_View();
                     $view->setScriptPath('Tinebase/views');
                     $view->openIdConsumer = $server->getSiteRoot($_GET);
                     $view->openIdIdentity = $server->getLoggedInUser();
                     header('Content-Type: text/html; charset=utf-8');
                     echo $view->render('openidTrust.php');
                     // handle all other openId requests
                 } else {
                     $result = $server->handle();
                     if (is_string($result)) {
                         echo $result;
                     } elseif ($result !== true) {
                         header('HTTP/1.0 403 Forbidden');
                         return;
                     }
                 }
             }
         }
     }
 }
开发者ID:hernot,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:67,代码来源:Http.php

示例14: testBtwoc

 /**
  * testing testBtwoc
  *
  */
 public function testBtwoc()
 {
     $this->assertSame( '00', bin2hex(Zend_OpenId::btwoc(pack('H*', '00'))) );
     $this->assertSame( '01', bin2hex(Zend_OpenId::btwoc(pack('H*', '01'))) );
     $this->assertSame( '7e', bin2hex(Zend_OpenId::btwoc(pack('H*', '7e'))) );
     $this->assertSame( '78', bin2hex(Zend_OpenId::btwoc(pack('H*', '78'))) );
     $this->assertSame( '0080', bin2hex(Zend_OpenId::btwoc(pack('H*', '80'))) );
     $this->assertSame( '0081', bin2hex(Zend_OpenId::btwoc(pack('H*', '81'))) );
     $this->assertSame( '00fe', bin2hex(Zend_OpenId::btwoc(pack('H*', 'fe'))) );
     $this->assertSame( '00ff', bin2hex(Zend_OpenId::btwoc(pack('H*', 'ff'))) );
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:15,代码来源:OpenIdTest.php

示例15: Zend_OpenId_Extension_Sreg

 if ($_POST['openid_action'] == 'trust') {
     if (isset($_GET['openid_return_to'])) {
         $sreg = new Zend_OpenId_Extension_Sreg();
         $sreg->parseResponse($_POST);
         if (isset($_POST['allow'])) {
             if (isset($_POST['forever'])) {
                 $server->allowSite($server->getSiteRoot($_GET), $sreg);
             }
             unset($_GET['openid_action']);
             $server->respondToConsumer($_GET, $sreg);
         } else {
             if (isset($_POST['deny'])) {
                 if (isset($_POST['forever'])) {
                     $server->denySite($server->getSiteRoot($_GET));
                 }
                 Zend_OpenId::redirect($_GET['openid_return_to'], array('openid.mode' => 'cancel'));
             }
         }
     } else {
         if (isset($_POST['allow'])) {
             $server->allowSite($_POST['site']);
             header('Location: ' . $_SERVER['PHP_SELF']);
             exit;
         } else {
             if (isset($_POST['deny'])) {
                 $server->denySite($_POST['site']);
                 header('Location: ' . $_SERVER['PHP_SELF']);
                 exit;
             } else {
                 if (isset($_POST['del'])) {
                     $server->delSite($_POST['site']);
开发者ID:alab1001101,项目名称:zf2,代码行数:31,代码来源:test_server.php


注:本文中的Zend_OpenId类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。