|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Class AuthenticationKeyFinderCommand |
|
4
|
|
|
*/ |
|
5
|
|
|
|
|
6
|
|
|
namespace Graviton\SecurityBundle\Command; |
|
7
|
|
|
|
|
8
|
|
|
use Symfony\Component\Console\Command\Command; |
|
9
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
10
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
11
|
|
|
use Symfony\Component\Console\Logger\ConsoleLogger; |
|
12
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
13
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* @author List of contributors <https://github.com/libgraviton/graviton/graphs/contributors> |
|
17
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License |
|
18
|
|
|
* @link http://swisscom.ch |
|
19
|
|
|
*/ |
|
20
|
|
|
class AuthenticationKeyFinderCommand extends Command |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* @var array |
|
24
|
|
|
*/ |
|
25
|
|
|
private $strategies = array(); |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @param string $service add strategy services to show |
|
29
|
|
|
* |
|
30
|
|
|
* @return void |
|
31
|
|
|
*/ |
|
32
|
2 |
|
public function addService($service) |
|
33
|
|
|
{ |
|
34
|
2 |
|
$this->strategies[] = $service; |
|
35
|
2 |
|
$this->strategies = array_unique($this->strategies); |
|
36
|
2 |
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* {@inheritDoc} |
|
40
|
|
|
* |
|
41
|
|
|
* @return void |
|
42
|
|
|
*/ |
|
43
|
2 |
|
protected function configure() |
|
44
|
|
|
{ |
|
45
|
2 |
|
$this |
|
46
|
2 |
|
->setName('graviton:security:authenication:keyfinder:strategies') |
|
47
|
2 |
|
->setDescription('Shows a list of available keyfinder strategies.') |
|
48
|
2 |
|
->addOption( |
|
49
|
2 |
|
'list', |
|
50
|
2 |
|
'l', |
|
51
|
2 |
|
InputOption::VALUE_NONE, |
|
52
|
|
|
'If set, it will provide a list of available strategies.' |
|
53
|
2 |
|
); |
|
54
|
2 |
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* {@inheritDoc} |
|
58
|
|
|
* |
|
59
|
|
|
* @param InputInterface $input input from cli |
|
60
|
|
|
* @param OutputInterface $output output to cli |
|
61
|
|
|
* |
|
62
|
|
|
* @return void |
|
63
|
|
|
*/ |
|
64
|
2 |
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
65
|
|
|
{ |
|
66
|
2 |
|
$output->writeln('<info>Following strategies to extract an authentication key are available:</info>'); |
|
67
|
2 |
|
$output->writeln( |
|
68
|
|
|
"<info>\t* " . |
|
69
|
2 |
|
implode(PHP_EOL . "\t* ", $this->strategies) . |
|
70
|
|
|
"</info>" |
|
71
|
2 |
|
); |
|
72
|
2 |
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|