1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Copyright 2015 SURFnet B.V. |
5
|
|
|
* |
6
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
7
|
|
|
* you may not use this file except in compliance with the License. |
8
|
|
|
* You may obtain a copy of the License at |
9
|
|
|
* |
10
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
11
|
|
|
* |
12
|
|
|
* Unless required by applicable law or agreed to in writing, software |
13
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
14
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15
|
|
|
* See the License for the specific language governing permissions and |
16
|
|
|
* limitations under the License. |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
namespace Surfnet\StepupRa\RaBundle\Service\U2f; |
20
|
|
|
|
21
|
|
|
use Surfnet\StepupU2fBundle\Dto\SignRequest; |
22
|
|
|
|
23
|
|
|
final class SignRequestCreationResult |
24
|
|
|
{ |
25
|
|
|
const STATUS_SUCCESS = 'SUCCESS'; |
26
|
|
|
const STATUS_UNKNOWN_KEY_HANDLE = 'UNKNOWN_KEY_HANDLE'; |
27
|
|
|
const STATUS_API_ERROR = 'API_ERROR'; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var string |
31
|
|
|
*/ |
32
|
|
|
private $status; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var SignRequest |
36
|
|
|
*/ |
37
|
|
|
private $signRequest; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @param SignRequest $signRequest |
41
|
|
|
* @return SignRequestCreationResult |
42
|
|
|
*/ |
43
|
|
|
public static function success(SignRequest $signRequest) |
44
|
|
|
{ |
45
|
|
|
$result = new self(self::STATUS_SUCCESS); |
46
|
|
|
$result->signRequest = $signRequest; |
47
|
|
|
|
48
|
|
|
return $result; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @return SignRequestCreationResult |
53
|
|
|
*/ |
54
|
|
|
public static function unknownKeyHandle() |
55
|
|
|
{ |
56
|
|
|
return new self(self::STATUS_UNKNOWN_KEY_HANDLE); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @return SignRequestCreationResult |
61
|
|
|
*/ |
62
|
|
|
public static function apiError() |
63
|
|
|
{ |
64
|
|
|
return new self(self::STATUS_API_ERROR); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
private function __construct($status) |
68
|
|
|
{ |
69
|
|
|
$this->status = $status; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @return bool |
74
|
|
|
*/ |
75
|
|
|
public function wasSuccessful() |
76
|
|
|
{ |
77
|
|
|
return $this->status === self::STATUS_SUCCESS; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @return mixed |
82
|
|
|
*/ |
83
|
|
|
public function getSignRequest() |
84
|
|
|
{ |
85
|
|
|
return $this->signRequest; |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|