Completed
Pull Request — develop (#92)
by Boy
02:56
created

ProxyStateHandler::getRequestAuthContextClassRef()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/**
4
 * Copyright 2014 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\GatewayBundle\Saml\Proxy;
20
21
use Symfony\Component\HttpFoundation\Session\SessionInterface;
22
23
class ProxyStateHandler
24
{
25
    const SESSION_PATH = 'surfnet/gateway/request';
26
27
    /**
28
     * @var \Symfony\Component\HttpFoundation\Session\SessionInterface
29
     */
30
    private $session;
31
32
    /**
33
     * @param SessionInterface $session
34
     */
35
    public function __construct(SessionInterface $session)
36
    {
37
        $this->session = $session;
38
    }
39
40
    /**
41
     * @param string $originalRequestId
42
     * @return $this
43
     */
44
    public function setRequestId($originalRequestId)
45
    {
46
        $this->set('request_id', $originalRequestId);
47
48
        return $this;
49
    }
50
51
    /**
52
     * @return string|null
53
     */
54
    public function getRequestId()
55
    {
56
        return $this->get('request_id');
57
    }
58
59
    /**
60
     * @param string $serviceProvider
61
     * @return $this
62
     */
63
    public function setRequestServiceProvider($serviceProvider)
64
    {
65
        $this->set('service_provider', $serviceProvider);
66
67
        return $this;
68
    }
69
70
    /**
71
     * @return string|null
72
     */
73
    public function getRequestServiceProvider()
74
    {
75
        return $this->get('service_provider');
76
    }
77
78
    /**
79
     * @param string $relayState
80
     * @return $this
81
     */
82
    public function setRelayState($relayState)
83
    {
84
        $this->set('relay_state', $relayState);
85
86
        return $this;
87
    }
88
89
    /**
90
     * @return string|null
91
     */
92
    public function getRelayState()
93
    {
94
        return $this->get('relay_state');
95
    }
96
97
    /**
98
     * @param string $loa_identifier
99
     * @return $this
100
     */
101
    public function setRequiredLoaIdentifier($loa_identifier)
0 ignored issues
show
Coding Style Naming introduced by
The parameter $loa_identifier is not named in camelCase.

This check marks parameter names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
102
    {
103
        $this->set('loa_identifier', $loa_identifier);
104
105
        return $this;
106
    }
107
108
    /**
109
     * @return string|null
110
     */
111
    public function getRequiredLoaIdentifier()
112
    {
113
        return $this->get('loa_identifier');
114
    }
115
116
    /**
117
     * @param string $requestId
118
     * @return $this
119
     */
120
    public function setGatewayRequestId($requestId)
121
    {
122
        $this->set('gateway_request_id', $requestId);
123
124
        return $this;
125
    }
126
127
    /**
128
     * @return string|null
129
     */
130
    public function getGatewayRequestId()
131
    {
132
        return $this->get('gateway_request_id');
133
    }
134
135
    /**
136
     * @param string $assertionAsXmlString
137
     * @return $this
138
     */
139
    public function saveAssertion($assertionAsXmlString)
140
    {
141
        $this->set('response_assertion', $assertionAsXmlString);
142
143
        return $this;
144
    }
145
146
    /**
147
     * @return null|string
148
     */
149
    public function getAssertion()
150
    {
151
        return $this->get('response_assertion');
152
    }
153
154
    /**
155
     * @param $nameId
156
     * @return $this
157
     */
158
    public function saveIdentityNameId($nameId)
159
    {
160
        $this->set('name_id', $nameId);
161
162
        return $this;
163
    }
164
165
    /**
166
     * @return null|string
167
     */
168
    public function getIdentityNameId()
169
    {
170
        return $this->get('name_id');
171
    }
172
173
    /**
174
     * @param string $idpEntityId
175
     * @return $this
176
     */
177
    public function setAuthenticatingIdp($idpEntityId)
178
    {
179
        $this->set('authenticating_idp', $idpEntityId);
180
181
        return $this;
182
    }
183
184
    /**
185
     * @return null|string
186
     */
187
    public function getAuthenticatingIdp()
188
    {
189
        return $this->get('authenticating_idp');
190
    }
191
192
    /**
193
     * @param string|null $secondFactorId
194
     * @return $this
195
     */
196
    public function setSelectedSecondFactorId($secondFactorId)
197
    {
198
        $this->set('selected_second_factor', $secondFactorId);
199
200
        return $this;
201
    }
202
203
    /**
204
     * @return null|string
205
     */
206
    public function getSelectedSecondFactorId()
207
    {
208
        return $this->get('selected_second_factor');
209
    }
210
211
    /**
212
     * @param bool $verified
213
     * @return $this
214
     */
215
    public function setSecondFactorVerified($verified)
216
    {
217
        $this->set('selected_second_factor_verified', $verified);
218
219
        return $this;
220
    }
221
222
    /**
223
     * @return bool
224
     */
225
    public function isSecondFactorVerified()
226
    {
227
        return $this->get('selected_second_factor_verified') === true;
228
    }
229
230
    /**
231
     * @param string $key
232
     * @param mixed $value Any scalar
233
     */
234
    protected function set($key, $value)
235
    {
236
        $this->session->set(self::SESSION_PATH . $key, $value);
237
    }
238
239
    /**
240
     * @param string $key
241
     * @return mixed|null Any scalar
242
     */
243
    protected function get($key)
244
    {
245
        return $this->session->get(self::SESSION_PATH . $key);
246
    }
247
}
248