Failed Conditions
Push — ng ( 29d837...4fff42 )
by Florent
03:48
created

RequestObjectCompilerPass   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 24
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B process() 0 18 5
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2018 Spomky-Labs
9
 *
10
 * This software may be modified and distributed under the terms
11
 * of the MIT license.  See the LICENSE file for details.
12
 */
13
14
namespace OAuth2Framework\Bundle\Component\Endpoint\Authorization\Compiler;
15
16
use OAuth2Framework\Component\AuthorizationEndpoint\AuthorizationRequestLoader;
17
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
18
use Symfony\Component\DependencyInjection\ContainerBuilder;
19
use Symfony\Component\DependencyInjection\Reference;
20
21
class RequestObjectCompilerPass implements CompilerPassInterface
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function process(ContainerBuilder $container)
27
    {
28
        if (!$container->hasDefinition('jose.jws_loader.request_object') || !$container->hasDefinition(AuthorizationRequestLoader::class)) {
29
            return;
30
        }
31
32
        $metadata = $container->getDefinition(AuthorizationRequestLoader::class);
33
        $metadata->addMethodCall('enableRequestObjectSupport', [new Reference('jose.jws_loader.request_object'), new Reference('jose.claim_checker.request_object'), []]); //FIXME
34
        if (true === $container->getParameter('oauth2_server.endpoint.authorization.request_object.encryption.enabled')) {
35
            $required = $container->getParameter('oauth2_server.endpoint.authorization.request_object.encryption.required');
36
            $metadata->addMethodCall('enableEncryptedRequestObjectSupport', [new Reference('jose.jwe_loader.request_object'), new Reference('jose.key_set.oauth2_server.key_set.encryption'), $required]);
37
        }
38
39
        if (true === $container->getParameter('oauth2_server.endpoint.authorization.request_object.reference.enabled')) {
40
            $uriRegistration = $container->getParameter('oauth2_server.endpoint.authorization.request_object.reference.uris_registration_required');
41
            $metadata->addMethodCall('enableRequestObjectReferenceSupport', [new Reference('oauth2_server.http.client'), $uriRegistration]);
42
        }
43
    }
44
}
45