Abstract Class yii\authclient\signature\BaseMethod
Inheritance | yii\authclient\signature\BaseMethod » yii\base\Object |
---|---|
Subclasses | yii\authclient\signature\HmacSha1, yii\authclient\signature\PlainText, yii\authclient\signature\RsaSha1 |
Available since extension's version | 2.0 |
Source Code | https://github.com/yiisoft/yii2-authclient/blob/master/signature/BaseMethod.php |
BaseMethod is a base class for the OAuth signature methods.
Public Methods
Method | Description | Defined By |
---|---|---|
generateSignature() | Generates OAuth request signature. | yii\authclient\signature\BaseMethod |
getName() | Return the canonical name of the Signature Method. | yii\authclient\signature\BaseMethod |
verify() | Verifies given OAuth request. | yii\authclient\signature\BaseMethod |
Method Details
Generates OAuth request signature.
public abstract string generateSignature ( $baseString, $key ) | ||
$baseString | string |
Signature base string. |
$key | string |
Signature key. |
return | string |
Signature string. |
---|
abstract public function generateSignature($baseString, $key);
Return the canonical name of the Signature Method.
public abstract string getName ( ) | ||
return | string |
Method name. |
---|
abstract public function getName();
Verifies given OAuth request.
public boolean verify ( $signature, $baseString, $key ) | ||
$signature | string |
Signature to be verified. |
$baseString | string |
Signature base string. |
$key | string |
Signature key. |
return | boolean |
Success. |
---|
public function verify($signature, $baseString, $key)
{
$expectedSignature = $this->generateSignature($baseString, $key);
if (empty($signature) || empty($expectedSignature)) {
return false;
}
return (strcmp($expectedSignature, $signature) === 0);
}