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

RequestObjectEncryptionSource::prepend()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 3
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;
15
16
use OAuth2Framework\Bundle\Component\Component;
17
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
18
use Symfony\Component\DependencyInjection\ContainerBuilder;
19
20
class RequestObjectEncryptionSource implements Component
0 ignored issues
show
Bug introduced by
There is at least one abstract method in this class. Maybe declare it as abstract, or implement the remaining methods: build, load
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.authorization_request_object.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...
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(ArrayNodeDefinition $node, ArrayNodeDefinition $rootNode)
45
    {
46
        $node
47
            ->children()
48
                ->booleanNode('required')
49
                    ->info('If true, incoming request objects must be encrypted.')
50
                    ->defaultFalse()
51
                ->end()
52
                ->arrayNode('key_encryption_algorithms')
53
                    ->info('Supported key encryption algorithms.')
54
                    ->useAttributeAsKey('name')
55
                    ->scalarPrototype()->end()
56
                    ->treatNullLike([])
57
                ->end()
58
                ->arrayNode('content_encryption_algorithms')
59
                    ->info('Supported content encryption algorithms.')
60
                    ->useAttributeAsKey('name')
61
                    ->scalarPrototype()->end()
62
                    ->treatNullLike([])
63
                ->end()
64
            ->end();
65
    }
66
67
    /**
68
     * {@inheritdoc}
69
     */
70
    public function prepend(array $bundleConfig, string $path, ContainerBuilder $container)
71
    {
72
        parent::prepend($bundleConfig, $path, $container);
73
74
        Assertion::keyExists($bundleConfig['key_set'], 'encryption', 'The encryption key set must be enabled.');
75
        //ConfigurationHelper::addKeyset($container, 'authorization_request_object.key_set.encryption', '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...
76
    }
77
}
78