Completed
Pull Request — develop (#24)
by A.
03:37
created

SamlController::metadataAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
dl 0
loc 4
rs 10
c 2
b 0
f 1
cc 1
eloc 2
nc 1
nop 0
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 OpenConext\ProfileBundle\Controller;
20
21
use OpenConext\ProfileBundle\Transaction\StateHandler;
22
use Surfnet\SamlBundle\Http\XMLResponse;
23
use Surfnet\SamlBundle\Metadata\MetadataFactory;
24
use Symfony\Component\HttpFoundation\RedirectResponse;
25
use Symfony\Component\HttpFoundation\Request;
26
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
27
28
class SamlController
29
{
30
    /**
31
     * @var MetadataFactory
32
     */
33
    private $metadataFactory;
34
35
    /**
36
     * @var StateHandler
37
     */
38
    private $transactionStateHandler;
39
40
    /**
41
     * @param MetadataFactory $metadataFactory
42
     * @param StateHandler $transactionStateHandler
43
     */
44
    public function __construct(MetadataFactory $metadataFactory, StateHandler $transactionStateHandler)
45
    {
46
        $this->metadataFactory         = $metadataFactory;
47
        $this->transactionStateHandler = $transactionStateHandler;
48
    }
49
50
    public function consumeAssertionAction()
51
    {
52
        throw new BadRequestHttpException('Unexpected request sent to ACS');
53
    }
54
55
    public function retryTransactionAction(Request $request)
56
    {
57
        $this->transactionStateHandler->resetAttempts();
58
59
        return new RedirectResponse($request->query->get('return-url'));
60
    }
61
62
    /**
63
     * @return XMLResponse
64
     */
65
    public function metadataAction()
66
    {
67
        return new XMLResponse($this->metadataFactory->generate());
68
    }
69
}
70