This repository has been archived by the owner on Apr 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathKeyFile.php
66 lines (59 loc) · 1.75 KB
/
KeyFile.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/*
* The MIT License (MIT)
*
* Copyright (c) 2014-2016 Spomky-Labs
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
namespace SpomkyLabs\JoseBundle\DependencyInjection\Source\JWKSource;
use SpomkyLabs\JoseBundle\DependencyInjection\Source\AbstractSource;
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
final class KeyFile extends AbstractSource implements JWKSourceInterface
{
/**
* {@inheritdoc}
*/
public function createDefinition(ContainerBuilder $container, array $config)
{
$definition = new Definition('Jose\Object\JWK');
$definition->setFactory([
new Reference('jose.factory.jwk'),
'createFromKeyFile',
]);
$definition->setArguments([
$config['path'],
$config['password'],
$config['additional_values'],
]);
return $definition;
}
/**
* {@inheritdoc}
*/
public function getKey()
{
return 'file';
}
/**
* {@inheritdoc}
*/
public function addConfiguration(NodeDefinition $node)
{
parent::addConfiguration($node);
$node
->children()
->scalarNode('path')->isRequired()->end()
->scalarNode('password')->defaultNull()->end()
->arrayNode('additional_values')
->defaultValue([])
->useAttributeAsKey('key')
->prototype('variable')->end()
->end()
->end();
}
}