Source for file Request.php
Documentation is available at Request.php
* OpenID_Association_Request
* @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 'OpenID.php';
require_once 'OpenID/Association/Exception.php';
require_once 'OpenID/Association.php';
require_once 'OpenID/Message.php';
require_once 'OpenID/Association/DiffieHellman.php';
* OpenID_Association_Request
* Request object for establishing OpenID Associations.
* @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
* OpenID provider endpoint URL
* Contains contents of the association request
* Version of OpenID in use. This determines which algorithms we can use.
* The association request response in array format
* Optional instance of Crypt_DiffieHellman
* @var Crypt_DiffieHellman
* OpenID_Association_DiffieHellman instance
* @var OpenID_Association_DiffieHellman
* Sets the arguments passed in, as well as creates the request message.
* @param string $opEndpointURL URL of OP Endpoint
* @param string $version Version of OpenID in use
* @param Crypt_DiffieHellman $cdh Custom Crypt_DiffieHellman
Crypt_DiffieHellman $cdh =
null)
throw
new OpenID_Association_Exception(
if (OpenID::$versionMap[$version] ==
OpenID::NS_2_0) {
$this->message->set('openid.assoc_type', self::ASSOC_TYPE_HMAC_SHA256);
$this->message->set('openid.session_type', self::SESSION_TYPE_DH_SHA256);
$this->message->set('openid.assoc_type', self::ASSOC_TYPE_HMAC_SHA1);
$this->message->set('openid.session_type', self::SESSION_TYPE_DH_SHA1);
* Sends the association request. Loops over errors and adapts to
* 'unsupported-type' responses.
* @return mixed OpenID_Association on success, false on failure
* @see buildAssociation()
* @see sendAssociationRequest()
// Easier to operate on array format here
if (isset
($response['assoc_handle'])) {
if (isset
($response['mode'])
&&
$response['mode'] ==
OpenID::MODE_ERROR
&& isset
($response['error_code'])
&&
$response['error_code'] ==
'unsupported-type') {
if (isset
($response['assoc_type'])) {
if (isset
($response['session_type'])) {
* Build the OpenID_Association class based on the association response
* @param array $response Association response in array format
* @return OpenID_Association
$params['created'] =
time();
$params['expiresIn'] =
$response['expires_in'];
$params['assocHandle'] =
$response['assoc_handle'];
if (!isset
($response['mac_key'])) {
'Missing mac_key in association response'
$params['sharedSecret'] =
$response['mac_key'];
$this->getDH()->getSharedSecret($response, $params);
* Actually sends the assocition request to the OP Endpoing URL.
if ($this->message->get('openid.session_type')
==
self::SESSION_TYPE_NO_ENCRYPTION) {
$this->message->delete('openid.dh_consumer_public');
$this->message->delete('openid.dh_modulus');
$this->message->delete('openid.dh_gen');
* Gets the last association response
* Initialize the diffie-hellman parameters for the association request.
* Gets an instance of OpenID_Association_DiffieHellman. If one is not already
* instanciated, a new one is returned.
* @return OpenID_Association_DiffieHellman
protected function getDH()
* Sets he association type for the request. Can be sha1 or sha256.
* @param string $type sha1 or sha256
* @throws OpenID_Association_Exception on invalid type
case self::ASSOC_TYPE_HMAC_SHA1:
case self::ASSOC_TYPE_HMAC_SHA256:
$this->message->set('openid.assoc_type', $type);
* Gets the current association type
return $this->message->get('openid.assoc_type');
* Sets the session type. Can be sha1, sha256, or no-encryption
* @param string $type sha1, sha256, or no-encryption
* @throws OpenID_Association_Exception on invalid type, or if you set
* no-encryption for an OP URL that doesn't support HTTPS
case self::SESSION_TYPE_NO_ENCRYPTION:
// Make sure we're using SSL
'Un-encrypted sessions require HTTPS'
$this->message->set('openid.session_type',
self::SESSION_TYPE_NO_ENCRYPTION);
case self::SESSION_TYPE_DH_SHA1:
case self::SESSION_TYPE_DH_SHA256:
$this->message->set('openid.session_type', $type);
* Gets the current session type
* @return string Current session type (sha1, sha256, or no-encryption)
return $this->message->get('openid.session_type');
* Gets the OP Endpoint URL
* @return string OP Endpoint URL
Documentation generated on Tue, 15 Dec 2009 19:00:58 -0800 by phpDocumentor 1.4.3