Failed Conditions
Push — master ( 4152cd...12bde0 )
by Florent
08:02
created

IdTokenMetadataCompilerPass::process()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.2
c 0
b 0
f 0
cc 4
eloc 11
nc 3
nop 1
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\ServerBundle\Component\OpenIdConnect\Compiler;
15
16
use OAuth2Framework\ServerBundle\Service\MetadataBuilder;
17
use OAuth2Framework\Component\OpenIdConnect\UserInfo\UserInfo;
18
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
19
use Symfony\Component\DependencyInjection\ContainerBuilder;
20
use Symfony\Component\DependencyInjection\Reference;
21
22
class IdTokenMetadataCompilerPass implements CompilerPassInterface
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function process(ContainerBuilder $container)
28
    {
29
        if (!$container->hasDefinition(MetadataBuilder::class) || !$container->hasDefinition(UserInfo::class)) {
30
            return;
31
        }
32
        $metadata = $container->getDefinition(MetadataBuilder::class);
33
34
        $metadata->addMethodCall('setUserinfo', [new Reference(UserInfo::class)]);
35
        $metadata->addMethodCall('addKeyValuePair', ['claim_types_supported', ['normal', 'aggregated', 'distributed']]);
36
        $metadata->addMethodCall('addKeyValuePair', ['claims_parameter_supported', true]);
37
        $metadata->addMethodCall('addKeyValuePair', ['id_token_signing_alg_values_supported', $container->getParameter('oauth2_server.openid_connect.id_token.signature_algorithms')]);
38
        if (true === $container->getParameter('oauth2_server.openid_connect.id_token.encryption.enabled')) {
39
            $metadata->addMethodCall('addKeyValuePair', ['id_token_encryption_alg_values_supported', $container->getParameter('oauth2_server.openid_connect.id_token.encryption.key_encryption_algorithms')]);
40
            $metadata->addMethodCall('addKeyValuePair', ['id_token_encryption_enc_values_supported', $container->getParameter('oauth2_server.openid_connect.id_token.encryption.content_encryption_algorithms')]);
41
        }
42
    }
43
}
44