Failed Conditions
Pull Request — master (#37)
by Florent
08:00 queued 03:46
created

IdTokenMetadataCompilerPass   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 18 4
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2017 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\Server\DependencyInjection\Compiler;
15
16
use OAuth2Framework\Bundle\Server\Service\MetadataBuilder;
17
use OAuth2Framework\Component\Server\Endpoint\UserInfo\UserInfo;
18
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
19
use Symfony\Component\DependencyInjection\ContainerBuilder;
20
use Symfony\Component\DependencyInjection\Reference;
21
22
final class IdTokenMetadataCompilerPass implements CompilerPassInterface
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function process(ContainerBuilder $container)
28
    {
29
        if (!$container->hasDefinition(MetadataBuilder::class)) {
30
            return;
31
        }
32
        $metadata = $container->getDefinition(MetadataBuilder::class);
33
34
        if ($container->hasDefinition(UserInfo::class)) {
35
            $metadata->addMethodCall('setUserinfo', [new Reference(UserInfo::class)]);
36
            $metadata->addMethodCall('addKeyValuePair', ['claims_supported', $container->getParameter('oauth2_server.openid_connect.claims_supported')]);
37
            $metadata->addMethodCall('addKeyValuePair', ['claims_locales_supported', $container->getParameter('oauth2_server.openid_connect.claims_locales_supported')]);
38
            $metadata->addMethodCall('addKeyValuePair', ['id_token_signing_alg_values_supported', $container->getParameter('oauth2_server.openid_connect.id_token.signature_algorithms')]);
39
            if (true === $container->getParameter('oauth2_server.openid_connect.id_token.encryption.enabled')) {
40
                $metadata->addMethodCall('addKeyValuePair', ['id_token_encryption_alg_values_supported', $container->getParameter('oauth2_server.openid_connect.id_token.encryption.key_encryption_algorithms')]);
41
                $metadata->addMethodCall('addKeyValuePair', ['id_token_encryption_enc_values_supported', $container->getParameter('oauth2_server.openid_connect.id_token.encryption.content_encryption_algorithms')]);
42
            }
43
        }
44
    }
45
}
46