Completed
Pull Request — master (#24)
by Florent
06:28 queued 03:25
created

PublicJWKSet::getKeySet()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * The MIT License (MIT)
5
 *
6
 * Copyright (c) 2014-2016 Spomky-Labs
7
 *
8
 * This software may be modified and distributed under the terms
9
 * of the MIT license.  See the LICENSE file for details.
10
 */
11
12
namespace SpomkyLabs\JoseBundle\DependencyInjection\Source\JWKSetSource;
13
14
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Definition;
17
use Symfony\Component\DependencyInjection\Reference;
18
19
class PublicJWKSet implements JWKSetSourceInterface
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function create(ContainerBuilder $container, $id, array $config)
25
    {
26
        $definition = new Definition('Jose\Object\JWKSet');
27
        $definition->setFactory([
28
            new Reference('jose.factory.jwk'),
29
            'createPublicKeySet',
30
        ]);
31
        $definition->setArguments([new Reference($config['id'])]);
32
33
        $definition->setPublic($config['is_public']);
34
        $container->setDefinition($id, $definition);
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function getKeySet()
41
    {
42
        return 'public_jwkset';
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function addConfiguration(NodeDefinition $node)
49
    {
50
        $node
51
            ->children()
52
                ->booleanNode('is_public')
53
                    ->info('If true, the service will be public, else private.')
54
                    ->defaultTrue()
55
                ->end()
56
                ->scalarNode('id')
57
                    ->info('ID of the JWKSet to use.')
58
                    ->isRequired()
59
                ->end()
60
            ->end();
61
    }
62
}
63