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.
파일 보기 프로젝트 열기: kimai/kimai 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$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