Failed Conditions
Push — ng ( e90992...13fb6e )
by Florent
17:32
created

getNodeDefinition()   B

Complexity

Conditions 3
Paths 1

Size

Total Lines 32
Code Lines 27

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 32
rs 8.8571
c 0
b 0
f 0
cc 3
eloc 27
nc 1
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\Bundle\DependencyInjection\Component\TokenEndpointAuthMethod;
15
16
use OAuth2Framework\Bundle\DependencyInjection\Component\Component;
17
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
18
use Symfony\Component\DependencyInjection\ContainerBuilder;
19
20
final class ClientAssertionJwtTokenEndpointAuthMethodEncryptionSupportSource implements Component
0 ignored issues
show
Bug introduced by
There is one abstract method load in this class; you could implement it, or declare this class as abstract.
Loading history...
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    protected function continueLoading(string $path, ContainerBuilder $container, array $config)
26
    {
27
        foreach (['required', 'key_encryption_algorithms', 'content_encryption_algorithms'] as $k) {
28
            $container->setParameter($path.'.'.$k, $config[$k]);
29
        }
30
        //$container->setAlias($path.'.key_set', 'jose.key_set.oauth2_server.token_endpoint_auth_method.client_assertion_jwt.encryption.key_set');
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function name(): string
37
    {
38
        return 'encryption';
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function getNodeDefinition(NodeDefinition $node)
45
    {
46
47
        $node
48
            ->validate()
49
                ->ifTrue(function ($config) {
50
                    return true === $config['enabled'] && empty($config['key_encryption_algorithms']);
51
                })
52
                ->thenInvalid('At least one key encryption algorithm must be set.')
53
            ->end()
54
            ->validate()
55
                ->ifTrue(function ($config) {
56
                    return true === $config['enabled'] && empty($config['content_encryption_algorithms']);
57
                })
58
                ->thenInvalid('At least one content encryption algorithm must be set.')
59
            ->end()
60
            ->children()
61
                ->booleanNode('required')->defaultFalse()->end()
62
                ->arrayNode('key_encryption_algorithms')
63
                    ->info('Supported key encryption algorithms.')
64
                    ->useAttributeAsKey('name')
65
                    ->prototype('scalar')->end()
66
                    ->treatNullLike([])
67
                ->end()
68
                ->arrayNode('content_encryption_algorithms')
69
                    ->info('Supported content encryption algorithms.')
70
                    ->useAttributeAsKey('name')
71
                    ->prototype('scalar')->end()
72
                    ->treatNullLike([])
73
                ->end()
74
            ->end();
75
    }
76
77
    /**
78
     * {@inheritdoc}
79
     */
80
    public function prepend(array $bundleConfig, string $path, ContainerBuilder $container)
81
    {
82
        parent::prepend($bundleConfig, $path, $container);
83
84
        Assertion::keyExists($bundleConfig['key_set'], 'encryption', 'The encryption key set must be enabled.');
85
        //ConfigurationHelper::addKeyset($container, 'oauth2_server.token_endpoint_auth_method.client_assertion_jwt.encryption.key_set', 'jwkset', ['value' => $bundleConfig['key_set']['encryption']]);
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
86
    }
87
}
88