PHP Класс Zend_OpenId

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.
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$exitOnRedirect Allows enable/disable stoping execution of PHP script after redirect()
$selfUrl Alternative request URL that can be used to override the default selfUrl() response

Открытые методы

Метод Описание
absoluteUrl ( string $url ) : string Returns an absolute URL for the given one
btwoc ( string $str ) : string Takes an arbitrary precision integer and returns its shortest big-endian two's complement representation.
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
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.
digest ( string $func, string $data ) : string Generates a hash value (message digest) according to given algorithm.
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'.
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.
normalize ( &$id ) : boolean Normalizes OpenID identifier that can be URL or XRI name.
normalizeUrl ( &$id ) : boolean Normalizes URL according to RFC 3986 to use it in comparison operations.
paramsToQuery ( array $params ) : string Converts variable/value pairs into URL encoded query string
randomBytes ( integer $len ) : string Produces string of random byte of given length.
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.
selfUrl ( ) : string Returns a full URL that was requested on current HTTP request.
setSelfUrl ( string $selfUrl = null ) : string Sets alternative request URL that can be used to override the default selfUrl() response
strlen ( string $str ) : integer Returns lenght of binary string in bytes

Защищенные методы

Метод Описание
bigNumToBin ( mixed $bn ) : string Converts internal ext/gmp or ext/bcmath big integer representation into binary string.
binToBigNum ( string $bin ) : mixed Converts binary representation into ext/gmp or ext/bcmath big integer representation.

Описание методов

absoluteUrl() публичный статический Метод

Returns an absolute URL for the given one
public static absoluteUrl ( string $url ) : string
$url string absilute or relative URL
Результат string

bigNumToBin() защищенный статический Метод

Converts internal ext/gmp or ext/bcmath big integer representation into binary string.
protected static bigNumToBin ( mixed $bn ) : string
$bn mixed big number
Результат string

binToBigNum() защищенный статический Метод

Converts binary representation into ext/gmp or ext/bcmath big integer representation.
protected static binToBigNum ( string $bin ) : mixed
$bin string binary representation of big number
Результат mixed

btwoc() публичный статический Метод

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.
public static btwoc ( string $str ) : string
$str string binary representation of arbitrary precision integer
Результат string big-endian signed representation

computeDhSecret() публичный статический Метод

Computes the shared secret from the private DH value $dh and the other party's public value in $pub_key
public static computeDhSecret ( string $pub_key, mixed $dh ) : string
$pub_key string other party's public value
$dh mixed Diffie-Hellman key
Результат string

createDhKey() публичный статический Метод

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.
public static createDhKey ( string $p, string $g, string $priv_key = null ) : mixed
$p string prime number in binary representation
$g string generator in binary representation
$priv_key string private key in binary representation
Результат mixed

digest() публичный статический Метод

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.
public static digest ( string $func, string $data ) : string
$func string digest algorithm
$data string data to sign
Результат string RAW digital signature

getDhKeyDetails() публичный статический Метод

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'.
public static getDhKeyDetails ( mixed $dh ) : array
$dh mixed Diffie-Hellman key
Результат array

hashHmac() публичный статический Метод

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.
public static hashHmac ( string $macFunc, string $data, string $secret ) : string
$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
Результат string RAW HMAC value

normalize() публичный статический Метод

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.
public static normalize ( &$id ) : boolean
Результат boolean

normalizeUrl() публичный статический Метод

The function gets URL argument by reference and modifies it. It returns true on success and false of failure.
public static normalizeUrl ( &$id ) : boolean
Результат boolean

paramsToQuery() публичный статический Метод

Converts variable/value pairs into URL encoded query string
public static paramsToQuery ( array $params ) : string
$params array variable/value pairs
Результат string URL encoded query string

randomBytes() публичный статический Метод

Produces string of random byte of given length.
public static randomBytes ( integer $len ) : string
$len integer length of requested string
Результат string RAW random binary string

redirect() публичный статический Метод

It may generate redirected request using GET or POST HTTP method. The function never returns.
public static redirect ( string $url, array $params = null, Zend_Controller_Response_Abstract $response = null, string $method = 'GET' )
$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')

selfUrl() публичный статический Метод

Returns a full URL that was requested on current HTTP request.
public static selfUrl ( ) : string
Результат string

setSelfUrl() публичный статический Метод

Sets alternative request URL that can be used to override the default selfUrl() response
public static setSelfUrl ( string $selfUrl = null ) : string
$selfUrl string the URL to be set
Результат string the old value of overriding URL

strlen() публичный статический Метод

Returns lenght of binary string in bytes
public static strlen ( string $str ) : integer
$str string
Результат integer the string lenght

Описание свойств

$exitOnRedirect публичное статическое свойство

Allows enable/disable stoping execution of PHP script after redirect()
public static $exitOnRedirect

$selfUrl публичное статическое свойство

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