| @@ 23-71 (lines=49) @@ | ||
| 20 | ||
| 21 | use Surfnet\StepupGateway\U2fVerificationBundle\Exception\InvalidArgumentException; |
|
| 22 | ||
| 23 | final class KeyHandle |
|
| 24 | { |
|
| 25 | /** |
|
| 26 | * @var string |
|
| 27 | */ |
|
| 28 | private $keyHandle; |
|
| 29 | ||
| 30 | /** |
|
| 31 | * @param string $keyHandle |
|
| 32 | */ |
|
| 33 | public function __construct($keyHandle) |
|
| 34 | { |
|
| 35 | if (!is_string($keyHandle)) { |
|
| 36 | throw InvalidArgumentException::invalidType('string', 'keyHandle', $keyHandle); |
|
| 37 | } |
|
| 38 | ||
| 39 | if ($keyHandle === '') { |
|
| 40 | throw new InvalidArgumentException('Invalid Argument, parameter "keyHandle" may not be an empty string'); |
|
| 41 | } |
|
| 42 | ||
| 43 | $this->keyHandle = $keyHandle; |
|
| 44 | } |
|
| 45 | ||
| 46 | /** |
|
| 47 | * @param KeyHandle $otherKeyHandle |
|
| 48 | * @return bool |
|
| 49 | */ |
|
| 50 | public function equals(KeyHandle $otherKeyHandle) |
|
| 51 | { |
|
| 52 | return $this->keyHandle === $otherKeyHandle->keyHandle; |
|
| 53 | } |
|
| 54 | ||
| 55 | /** |
|
| 56 | * @return string |
|
| 57 | */ |
|
| 58 | public function getKeyHandle() |
|
| 59 | { |
|
| 60 | return $this->keyHandle; |
|
| 61 | } |
|
| 62 | ||
| 63 | /** |
|
| 64 | * @return string |
|
| 65 | */ |
|
| 66 | public function __toString() |
|
| 67 | { |
|
| 68 | // Doctrine needs to be able to convert identifier fields to strings. |
|
| 69 | return $this->keyHandle; |
|
| 70 | } |
|
| 71 | } |
|
| 72 | ||
| @@ 23-62 (lines=40) @@ | ||
| 20 | ||
| 21 | use Surfnet\StepupGateway\U2fVerificationBundle\Exception\InvalidArgumentException; |
|
| 22 | ||
| 23 | final class PublicKey |
|
| 24 | { |
|
| 25 | /** |
|
| 26 | * @var string |
|
| 27 | */ |
|
| 28 | private $publicKey; |
|
| 29 | ||
| 30 | /** |
|
| 31 | * @param string $publicKey |
|
| 32 | */ |
|
| 33 | public function __construct($publicKey) |
|
| 34 | { |
|
| 35 | if (!is_string($publicKey)) { |
|
| 36 | throw InvalidArgumentException::invalidType('string', 'publicKey', $publicKey); |
|
| 37 | } |
|
| 38 | ||
| 39 | if ($publicKey === '') { |
|
| 40 | throw new InvalidArgumentException('Invalid Argument, parameter "publicKey" may not be an empty string'); |
|
| 41 | } |
|
| 42 | ||
| 43 | $this->publicKey = $publicKey; |
|
| 44 | } |
|
| 45 | ||
| 46 | /** |
|
| 47 | * @param PublicKey $otherPublicKey |
|
| 48 | * @return bool |
|
| 49 | */ |
|
| 50 | public function equals(PublicKey $otherPublicKey) |
|
| 51 | { |
|
| 52 | return $this->publicKey === $otherPublicKey->publicKey; |
|
| 53 | } |
|
| 54 | ||
| 55 | /** |
|
| 56 | * @return string |
|
| 57 | */ |
|
| 58 | public function getPublicKey() |
|
| 59 | { |
|
| 60 | return $this->publicKey; |
|
| 61 | } |
|
| 62 | } |
|
| 63 | ||