Completed
Push — feature/implement-state-handli... ( bd5ae0 )
by Michiel
01:52
created

ServiceProviderController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Surfnet\StepupGateway\Behat\Controller;
4
5
use Exception;
6
use RuntimeException;
7
use SAML2\HTTPPost;
8
use SAML2\HTTPRedirect;
9
use SAML2\Response as SAMLResponse;
10
use Surfnet\SamlBundle\Http\XMLResponse;
11
use Symfony\Component\HttpFoundation\Request;
12
13
class ServiceProviderController
14
{
15
    public function __construct()
16
    {
17
    }
18
19
    /**
20
     * Simply dumps the SAMLResponse XML
21
     * @param Request $request
22
     */
23
    public function acsAction(Request $request)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
24
    {
25
        libxml_disable_entity_loader(true);
26
        try {
27
            $httpPostBinding = new HTTPPost();
28
            $message = $httpPostBinding->receive();
29
        } catch (Exception $e1) {
30
            try {
31
                $httpRedirectBinding = new HTTPRedirect();
32
                $message = $httpRedirectBinding->receive();
33
            } catch (Exception $e2) {
34
                throw new RuntimeException('Unable to retrieve SAML message?', 1, $e1);
35
            }
36
        }
37
38
        if (!$message instanceof SAMLResponse) {
39
            throw new RuntimeException(sprintf('Unrecognized message type received: "%s"', get_class($message)));
40
        }
41
42
        $xml = base64_decode($request->get('SAMLResponse'));
43
        return XMLResponse::create($xml);
44
    }
45
46
}
47