API Documentation

OpenId.php

Includes Classes 
category
Zend
copyright
Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
license
http://framework.zend.com/license/new-bsd New BSD License
package
Zend_OpenId
version
$Id: OpenId.php 22655 2010-07-22 18:47:20Z mabe $
Classes
Zend_OpenId

Description

Zend Framework

LICENSE

This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.

Zend_OpenId

category
Zend
copyright
Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
license
http://framework.zend.com/license/new-bsd New BSD License
package
Zend_OpenId
Constants
DH_P
DH_G
NS_2_0
Properties
$exitOnRedirect
$selfUrl
Methods
setSelfUrl
selfUrl
absoluteUrl
paramsToQuery
normalizeUrl
normalize
redirect
randomBytes
digest
hashHmac
binToBigNum
bigNumToBin
createDhKey
getDhKeyDetails
computeDhSecret
btwoc
strlen

Description

Static class that contains common utility functions for {@link Zend_OpenId_Consumer} and {@link Zend_OpenId_Provider}.

This class implements common utility functions that are used by both Consumer and Provider. They include functions for Diffie-Hellman keys generation and exchange, URL normalization, HTTP redirection and some others.

Constants

DH_P

 DH_P = 'dcf93a0b883972ec0e19989ac5a2ce310e1d37717e8d9571bb7623731866e61ef75a2e27898b057f9891c2e27a639c3f29b60814581cd3b2ca3986d2683705577d45c2e7e52dc81c7a171876e5cea74b1448bfdfaf18828efd2519f14e45e3826634af1949e5b535cc829a483b8a76223e5d490a257f05bdff16f2fb22c583ab'

Default Diffie-Hellman key generator (1024 bit)

Details

value
dcf93a0b883972ec0e19989ac5a2ce310e1d37717e8d9571bb7623731866e61ef75a2e27898b057f9891c2e27a639c3f29b60814581cd3b2ca3986d2683705577d45c2e7e52dc81c7a171876e5cea74b1448bfdfaf18828efd2519f14e45e3826634af1949e5b535cc829a483b8a76223e5d490a257f05bdff16f2fb22c583ab

DH_G

 DH_G = '02'

Default Diffie-Hellman prime number (should be 2 or 5)

Details

value
02

NS_2_0

 NS_2_0 = 'http://specs.openid.net/auth/2.0'

OpenID 2.0 namespace. All OpenID 2.0 messages MUST contain variable openid.ns with its value.

Details

value
http://specs.openid.net/auth/2.0

Properties

$exitOnRedirect

 $exitOnRedirect = 'true'

Allows enable/disable stoping execution of PHP script after redirect()

Details

visibility
public
default
true
final
false
static
true

$selfUrl

 $selfUrl = 'null'

Alternative request URL that can be used to override the default selfUrl() response

Details

visibility
public
default
null
final
false
static
true

Methods

absoluteUrl

absoluteUrl( string $url ) : string

Returns an absolute URL for the given one

Arguments
$url
string
absilute or relative URL
Output
string
Details
visibility
public
final
false
static
true

bigNumToBin

bigNumToBin( mixed $bn ) : string

Converts internal ext/gmp or ext/bcmath big integer representation into binary string.

Arguments
$bn
mixed
big number
Output
string
Details
visibility
protected
final
false
static
true
throws

binToBigNum

binToBigNum( string $bin ) : mixed

Converts binary representation into ext/gmp or ext/bcmath big integer representation.

Arguments
$bin
string
binary representation of big number
Output
mixed
Details
visibility
protected
final
false
static
true
throws

btwoc

btwoc( string $str ) : string

Takes an arbitrary precision integer and returns its shortest big-endian two's complement representation.

Arbitrary precision integers MUST be encoded as big-endian signed two's complement binary strings. Henceforth, "btwoc" is a function that takes an arbitrary precision integer and returns its shortest big-endian two's complement representation. All integers that are used with Diffie-Hellman Key Exchange are positive. This means that the left-most bit of the two's complement representation MUST be zero. If it is not, implementations MUST add a zero byte at the front of the string.

Arguments
$str
string
binary representation of arbitrary precision integer
Output
string
big-endian signed representation
Details
visibility
public
final
false
static
true

computeDhSecret

computeDhSecret( string $pub_key, mixed $dh ) : string

Computes the shared secret from the private DH value $dh and the other party's public value in $pub_key

Arguments
$pub_key
string
other party's public value
$dh
mixed
Diffie-Hellman key
Output
string
Details
visibility
public
final
false
static
true
throws

createDhKey

createDhKey( string $p, string $g, string $priv_key = null ) : mixed

Performs the first step of a Diffie-Hellman key exchange by generating private and public DH values based on given prime number $p and generator $g. Both sides of key exchange MUST have the same prime number and generator. In this case they will able to create a random shared secret that is never send from one to the other.

Arguments
$p
string
prime number in binary representation
$g
string
generator in binary representation
$priv_key
string
private key in binary representation
Output
mixed
Details
visibility
public
final
false
static
true

digest

digest( string $func, string $data ) : string

Generates a hash value (message digest) according to given algorithm.

It returns RAW binary string.

This is a wrapper function that uses one of available internal function dependent on given PHP configuration. It may use various functions from ext/openssl, ext/hash, ext/mhash or ext/standard.

Arguments
$func
string
digest algorithm
$data
string
data to sign
Output
string
RAW digital signature
Details
visibility
public
final
false
static
true
throws

getDhKeyDetails

getDhKeyDetails( mixed $dh ) : array

Returns an associative array with Diffie-Hellman key components in binary representation. The array includes original prime number 'p' and generator 'g', random private key 'priv_key' and corresponding public key 'pub_key'.

Arguments
$dh
mixed
Diffie-Hellman key
Output
array
Details
visibility
public
final
false
static
true

hashHmac

hashHmac( string $macFunc, string $data, string $secret ) : string

Generates a keyed hash value using the HMAC method. It uses ext/hash if available or user-level PHP implementation, that is not significantly slower.

Arguments
$macFunc
string
name of selected hashing algorithm (sha1, sha256)
$data
string
data to sign
$secret
string
shared secret key used for generating the HMAC variant of the message digest
Output
string
RAW HMAC value
Details
visibility
public
final
false
static
true

normalize

normalize( string $id ) : bool

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.

Arguments
$id
string
&$id identifier to be normalized
Output
bool
Details
visibility
public
final
false
static
true

normalizeUrl

normalizeUrl( string $id ) : bool

Normalizes URL according to RFC 3986 to use it in comparison operations.

The function gets URL argument by reference and modifies it. It returns true on success and false of failure.

Arguments
$id
string
&$id url to be normalized
Output
bool
Details
visibility
public
final
false
static
true

paramsToQuery

paramsToQuery( array $params ) : string

Converts variable/value pairs into URL encoded query string

Arguments
$params
array
variable/value pairs
Output
string
URL encoded query string
Details
visibility
public
final
false
static
true

randomBytes

randomBytes( integer $len ) : string

Produces string of random byte of given length.

Arguments
$len
integer
length of requested string
Output
string
RAW random binary string
Details
visibility
public
final
false
static
true

redirect

redirect( string $url, array $params = null, Zend_Controller_Response_Abstract $response = null, string $method = GET ) :

Performs a HTTP redirection to specified URL with additional data.

It may generate redirected request using GET or POST HTTP method. The function never returns.

Arguments
$url
string
URL to redirect to
$params
array
additional variable/value pairs to send
$response
Zend_Controller_Response_Abstract
$method
string
redirection method ('GET' or 'POST')
Details
visibility
public
final
false
static
true

selfUrl

selfUrl( ) : string

Returns a full URL that was requested on current HTTP request.

Output
string
Details
visibility
public
final
false
static
true

setSelfUrl

setSelfUrl( string $selfUrl = null ) : string

Sets alternative request URL that can be used to override the default selfUrl() response

Arguments
$selfUrl
string
the URL to be set
Output
string
the old value of overriding URL
Details
visibility
public
final
false
static
true

strlen

strlen( string $str ) : int

Returns lenght of binary string in bytes

Arguments
$str
string
Output
int
the string lenght
Details
visibility
public
final
false
static
true
Documentation was generated by DocBlox.