1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Copyright 2017 SURFnet bv |
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\StepupGateway\SecondFactorOnlyBundle\Adfs\ValueObject; |
20
|
|
|
|
21
|
|
|
use Webmozart\Assert\Assert; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Helps with setting and asserting the correct state for an ADFS response. |
25
|
|
|
* |
26
|
|
|
* @package Surfnet\StepupGateway\SecondFactorOnlyBundle\Adfs\ValueObject |
27
|
|
|
*/ |
28
|
|
|
class Response |
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* @var string |
32
|
|
|
*/ |
33
|
|
|
private $authMethod; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var string |
37
|
|
|
*/ |
38
|
|
|
private $context; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Creates and validates an Adfs response value object |
42
|
|
|
* |
43
|
|
|
* @param string $authMethod |
44
|
|
|
* @param string $context |
45
|
|
|
* @return Response |
46
|
|
|
*/ |
47
|
|
|
public static function fromValues($authMethod, $context) |
48
|
|
|
{ |
49
|
|
|
Assert::stringNotEmpty($authMethod); |
50
|
|
|
Assert::stringNotEmpty($context); |
51
|
|
|
|
52
|
|
|
$response = new Response(); |
53
|
|
|
$response->authMethod = $authMethod; |
54
|
|
|
$response->context = $context; |
55
|
|
|
|
56
|
|
|
return $response; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @return mixed |
61
|
|
|
*/ |
62
|
|
|
public function getAuthMethod() |
63
|
|
|
{ |
64
|
|
|
return $this->authMethod; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @return mixed |
69
|
|
|
*/ |
70
|
|
|
public function getContext() |
71
|
|
|
{ |
72
|
|
|
return $this->context; |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|