Source for file Request.php
Documentation is available at Request.php
* @author Bill Shupp <hostmaster@shupp.org>
* @copyright 2009 Bill Shupp
* @license http://www.opensource.org/licenses/bsd-license.php FreeBSD
* @link http://pearopenid.googlecode.com
require_once 'Net/URL2.php';
require_once 'OpenID.php';
require_once 'OpenID/Auth/Exception.php';
require_once 'OpenID/Message.php';
require_once 'OpenID/Nonce.php';
* Creates an OpenID authorization request of type "checkid_setup" or
* // First perform discovery on the user supplied identifier
* $discover = new OpenID_Discover($identifier);
* // Optionally get association (from cache in this example)
* $opEndpointURL = array_shift($discover->services[0]->getURIs());
* $assocHandle = OpenID::getStore()->getAssociation($opEndpointURL)->assocHandle;
* // Now create the auth request object
* $auth = new OpenID_Auth_Request($discover, // OpenID_Discover object
* $returnTo, // openid.return_to
* $realm, // openid.realm
* $assocHandle); // openid.assoc_handle
* // Optionally add an extension
* $sreg = new OpenID_Extension_SREG11(OpenID_Extension::REQUEST);
* $sreg->set('required', 'email');
* $sreg->set('optional', 'nickname,gender,dob');
* // Add it to an existing instance of OpenID_Auth_Request
* $auth->addExtension($sreg);
* // Optionally make this a checkid_immediate request
* $auth->setMode(OpenID::MODE_CHECKID_IMMEDIATE);
* header('Location: ' . $auth->getAuthorizeURL());
* @author Bill Shupp <hostmaster@shupp.org>
* @copyright 2009 Bill Shupp
* @license http://www.opensource.org/licenses/bsd-license.php FreeBSD
* @link http://pearopenid.googlecode.com
* The normalized identifier
* The OP Endpoint we are communicating with
* @var OpenID_ServiceEndpoint
* Nonce class in case we are in 1.1 mode and need to embed it in the return_to
* Sets the basic information used in the message.
* @param OpenID_Discover $discover Discover object
* @param string $returnTo The return_to URL
* @param string $realm The realm
* @param string $assocHandle The optional association handle
if ($versionFromMap ==
OpenID::NS_2_0) {
$this->message->set('openid.ns', $versionFromMap);
$this->message->set('openid.return_to', $returnTo);
if (!empty($assocHandle)) {
$this->message->set('openid.assoc_handle', $assocHandle);
// Default to checkid_setup
* Adds an extension to the message.
* @param OpenID_Extension $extension Extension instance
* Sets the openid.mode parameter. Can be either "checkid_setup" or
* @param mixed $mode Value for 'openid.mode'
* @throws OpenID_Auth_Exception on an invalid mode
case OpenID::MODE_CHECKID_SETUP:
case OpenID::MODE_CHECKID_IMMEDIATE:
'Invalid openid.mode: ' .
$mode
* Gets the current openid.mode value
* Gets the auth request message in a URL format suitable for redirection. The
* decision about whether to use directed identity or not id done here.
* @return string The URL to redirect the User-Agent to
if ($version ==
OpenID::NS_2_0) {
if ($version ==
OpenID::NS_2_0) {
if ($version ==
OpenID::NS_1_1) {
$netURL =
new Net_URL2($url);
return $netURL->getURL();
* Sets the instance of OpenID_Nonce for use with 1.1 return_to nonces
* @param OpenID_Nonce $nonce Custom instance of OpenID_Nonce
public function setNonce(OpenID_Nonce $nonce)
* Gets the OpenID_Nonce instance if set, otherwise instantiates one.
* Adds a nonce to the openid.return_to URL parameter. Only used in OpenID 1.1
$nonce =
$this->getNonce()->createNonceAndStore();
$returnToURL =
new Net_URL2($this->message->get('openid.return_to'));
$returnToURL->setQueryVariable(OpenID_Nonce::RETURN_TO_NONCE,
$this->message->set('openid.return_to', $returnToURL->getURL());
$logMessage =
"Nonce: $nonce\n";
$logMessage =
'New ReturnTo: ' .
$returnToURL->getURL() .
"\n";
Documentation generated on Tue, 15 Dec 2009 19:00:58 -0800 by phpDocumentor 1.4.3