@@ -74,8 +74,8 @@ discard block |
||
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
77 | - * @param $question |
|
78 | - * @param $default |
|
77 | + * @param string $question |
|
78 | + * @param string $default |
|
79 | 79 | * @param string $sep |
80 | 80 | * |
81 | 81 | * @return string |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | |
91 | 91 | /** |
92 | 92 | * @param \Symfony\Component\Console\Output\OutputInterface $output |
93 | - * @param $text |
|
93 | + * @param string $text |
|
94 | 94 | * @param string $style |
95 | 95 | */ |
96 | 96 | protected function writeSection(OutputInterface $output, $text, $style = 'bg=blue;fg=white') |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
112 | - * @param $text |
|
113 | - * @param $style |
|
112 | + * @param string $text |
|
113 | + * @param string $style |
|
114 | 114 | * |
115 | 115 | * @return string |
116 | 116 | */ |
@@ -99,7 +99,7 @@ |
||
99 | 99 | * @var FormatterHelper |
100 | 100 | */ |
101 | 101 | $formatter = $this->getHelperSet() |
102 | - ->get('formatter'); |
|
102 | + ->get('formatter'); |
|
103 | 103 | |
104 | 104 | $output->writeln(array( |
105 | 105 | '', |
@@ -44,7 +44,7 @@ |
||
44 | 44 | /** |
45 | 45 | * @param Key|KeyInterface $key |
46 | 46 | * |
47 | - * @return \Defuse\Crypto\Key|\Defuse\Crypto\KeyProtectedByPassword |
|
47 | + * @return \Defuse\Crypto\Key |
|
48 | 48 | */ |
49 | 49 | private function unlockKey(Key $key) |
50 | 50 | { |
@@ -49,6 +49,6 @@ |
||
49 | 49 | private function unlockKey(Key $key) |
50 | 50 | { |
51 | 51 | return $key->unlock() |
52 | - ->getRawKey(); |
|
52 | + ->getRawKey(); |
|
53 | 53 | } |
54 | 54 | } |
@@ -135,6 +135,9 @@ |
||
135 | 135 | $this->helper = null; |
136 | 136 | } |
137 | 137 | |
138 | + /** |
|
139 | + * @param string[] $input |
|
140 | + */ |
|
138 | 141 | private function getInputStream($input) |
139 | 142 | { |
140 | 143 | $stream = fopen('php://memory', 'r+', false); |
@@ -92,7 +92,7 @@ |
||
92 | 92 | |
93 | 93 | // rawKey is locked and become instance of \Defuse\Crypto\Key. |
94 | 94 | $this->rawKey = $this->getRawKey() |
95 | - ->unlockKey($this->getSecret()); |
|
95 | + ->unlockKey($this->getSecret()); |
|
96 | 96 | |
97 | 97 | return $this; |
98 | 98 | } |
@@ -26,13 +26,13 @@ |
||
26 | 26 | protected function configure() |
27 | 27 | { |
28 | 28 | $this->setName('mes:crypto:generate-secret') |
29 | - ->setDescription('Generates an authentication secret') |
|
30 | - ->setHelp(<<<'EOF' |
|
29 | + ->setDescription('Generates an authentication secret') |
|
30 | + ->setHelp(<<<'EOF' |
|
31 | 31 | The <info>%command.name%</info> generates an authentication secret. |
32 | 32 | |
33 | 33 | <info>%command.full_name%</info> |
34 | 34 | EOF |
35 | - ); |
|
35 | + ); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | $random = \bin2hex(random_bytes(20)); |
77 | 77 | $this->symfonyStyle->newLine(); |
78 | 78 | $question = new Question($this->getQuestion('Insert your authentication secret or use this one randomly generated', $random), $random); |
79 | - $question->setValidator(function ($secret) { |
|
79 | + $question->setValidator(function($secret) { |
|
80 | 80 | if (!ctype_print($secret)) { |
81 | 81 | throw new \RuntimeException(sprintf('The authentication secret is not printable', $secret)); |
82 | 82 | } |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | $dh->start(spl_object_hash($process), "Find {$options['dir']}", 'START'), |
207 | 207 | )); |
208 | 208 | |
209 | - $process->run(function ($type, $buffer) use ($process, $output, $dh) { |
|
209 | + $process->run(function($type, $buffer) use ($process, $output, $dh) { |
|
210 | 210 | $output->writeln($dh->progress(spl_object_hash($process), $buffer, Process::ERR === $type)); |
211 | 211 | }); |
212 | 212 |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | parent::initialize($input, $output); |
42 | 42 | |
43 | 43 | $this->helper = $this->getHelperSet() |
44 | - ->get('question'); |
|
44 | + ->get('question'); |
|
45 | 45 | |
46 | 46 | $this->symfonyStyle = $this->getStyle($input, $output); |
47 | 47 | } |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | protected function configure() |
50 | 50 | { |
51 | 51 | $this->setName('mes:crypto:generate-key') |
52 | - ->setDefinition($this->createDefinition()) |
|
53 | - ->setDescription('Generates an encoded key with or without authentication secret') |
|
54 | - ->setHelp(<<<'EOF' |
|
52 | + ->setDefinition($this->createDefinition()) |
|
53 | + ->setDescription('Generates an encoded key with or without authentication secret') |
|
54 | + ->setHelp(<<<'EOF' |
|
55 | 55 | The <info>%command.name%</info> generates an encoded key with or without authentication secret and optionally it saves the printable key and the secret in a ini format .crypto file. |
56 | 56 | |
57 | 57 | <info>%command.full_name%</info> |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | |
61 | 61 | <info>%command.full_name%</info> --dir /path/to/dir/key.crypto |
62 | 62 | EOF |
63 | - ); |
|
63 | + ); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | protected function interact(InputInterface $input, OutputInterface $output) |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | $this->writeSection($output, 'Generating key'.($secret ? ' with authentication secret' : '').($dir ? " in $dir" : '')); |
134 | 134 | |
135 | 135 | $encodedKey = $keyGenerator->generate($secret) |
136 | - ->getEncoded(); |
|
136 | + ->getEncoded(); |
|
137 | 137 | |
138 | 138 | $this->log($logger, "The encoded key has been generated with the following sequence:\n{$encodedKey}\n", LogLevel::INFO); |
139 | 139 | |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * @var DebugFormatterHelper |
198 | 198 | */ |
199 | 199 | $dh = $this->getHelperSet() |
200 | - ->get('debug_formatter'); |
|
200 | + ->get('debug_formatter'); |
|
201 | 201 | |
202 | 202 | $process = new Process("ls -la {$options['dir']} | grep \".crypto\""); |
203 | 203 |
@@ -125,27 +125,27 @@ discard block |
||
125 | 125 | |
126 | 126 | // Reads encoded key from configuration file if key is not external. |
127 | 127 | $rawKeyDefinition->setClass($defuseKey) |
128 | - ->setFactory(array( |
|
129 | - $defuseKey, |
|
130 | - 'loadFromAsciiSafeString', |
|
131 | - )); |
|
128 | + ->setFactory(array( |
|
129 | + $defuseKey, |
|
130 | + 'loadFromAsciiSafeString', |
|
131 | + )); |
|
132 | 132 | $rawKeyDefinition->setArguments(array( |
133 | 133 | $keyIsExternal ? $loadKey : $key, |
134 | 134 | )); |
135 | 135 | } else { |
136 | 136 | $rawKeyDefinition->setClass($defuseKey) |
137 | - ->setArguments($secretExists ? array($secretIsExternal ? $loadSecret : $secret) : array()) |
|
138 | - ->setFactory($secretExists ? array( |
|
139 | - 'Defuse\Crypto\KeyProtectedByPassword', |
|
140 | - 'createRandomPasswordProtectedKey', |
|
141 | - ) : array( |
|
142 | - 'Defuse\Crypto\Key', |
|
143 | - 'createNewRandomKey', |
|
144 | - )); |
|
137 | + ->setArguments($secretExists ? array($secretIsExternal ? $loadSecret : $secret) : array()) |
|
138 | + ->setFactory($secretExists ? array( |
|
139 | + 'Defuse\Crypto\KeyProtectedByPassword', |
|
140 | + 'createRandomPasswordProtectedKey', |
|
141 | + ) : array( |
|
142 | + 'Defuse\Crypto\Key', |
|
143 | + 'createNewRandomKey', |
|
144 | + )); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | $container->setDefinition('mes_crypto.raw_key', $rawKeyDefinition) |
148 | - ->setPublic(false); |
|
148 | + ->setPublic(false); |
|
149 | 149 | |
150 | 150 | // Key |
151 | 151 | $keyDefinition = new Definition('Mes\Security\CryptoBundle\Model\Key', array( |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | 'create', |
158 | 158 | )); |
159 | 159 | $container->setDefinition('mes_crypto.key', $keyDefinition) |
160 | - ->setPublic(false); |
|
160 | + ->setPublic(false); |
|
161 | 161 | |
162 | 162 | $keyManagerDefinition = $container->getDefinition('mes_crypto.key_manager_wrapper'); |
163 | 163 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | private function setCryptoLoaderResource(ContainerBuilder $container, $resource) |
193 | 193 | { |
194 | 194 | $container->getDefinition('mes_crypto.crypto_loader') |
195 | - ->replaceArgument(0, $resource); |
|
195 | + ->replaceArgument(0, $resource); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | /** |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | $rootNode = $treeBuilder->root('mes_crypto'); |
32 | 32 | |
33 | 33 | $rootNode |
34 | - ->children() |
|
34 | + ->children() |
|
35 | 35 | ->arrayNode('key') |
36 | 36 | ->addDefaultsIfNotSet() |
37 | 37 | ->children() |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | ->info('your_encryption_service_id. Default: Mes Encryption.') |
99 | 99 | ->defaultNull() |
100 | 100 | ->end() |
101 | - ->end() |
|
101 | + ->end() |
|
102 | 102 | ; |
103 | 103 | |
104 | 104 | return $treeBuilder; |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | ->info('Encoded key or path to .crypto file. If key is null, it generates a different random key for each request.') |
42 | 42 | ->beforeNormalization() |
43 | 43 | ->ifString() |
44 | - ->then(function ($v) { |
|
44 | + ->then(function($v) { |
|
45 | 45 | if (is_file($v) && is_readable($v)) { |
46 | 46 | return array('path' => $v); |
47 | 47 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | ->end() |
52 | 52 | ->validate() |
53 | 53 | ->ifArray() |
54 | - ->then(function ($v) { |
|
54 | + ->then(function($v) { |
|
55 | 55 | $path = $v['path']; |
56 | 56 | $key = $v['key']; |
57 | 57 |
@@ -36,9 +36,9 @@ discard block |
||
36 | 36 | public function testGenerateCreatesKey() |
37 | 37 | { |
38 | 38 | $this->keyGenerator->expects($this->once()) |
39 | - ->method('generate') |
|
40 | - ->with(null) |
|
41 | - ->will($this->returnValue($this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface'))); |
|
39 | + ->method('generate') |
|
40 | + ->with(null) |
|
41 | + ->will($this->returnValue($this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface'))); |
|
42 | 42 | |
43 | 43 | $key = $this->keyManager->generate(); |
44 | 44 | |
@@ -51,9 +51,9 @@ discard block |
||
51 | 51 | $secret = 'ThisIsASecretPassword'; |
52 | 52 | |
53 | 53 | $this->keyGenerator->expects($this->once()) |
54 | - ->method('generateFromAscii') |
|
55 | - ->with($key_encoded, $secret) |
|
56 | - ->will($this->returnValue($this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface'))); |
|
54 | + ->method('generateFromAscii') |
|
55 | + ->with($key_encoded, $secret) |
|
56 | + ->will($this->returnValue($this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface'))); |
|
57 | 57 | |
58 | 58 | $key = $this->keyManager->generateFromAscii($key_encoded, $secret); |
59 | 59 | |
@@ -63,16 +63,16 @@ discard block |
||
63 | 63 | public function testGetKeyReadsNotExistingKey() |
64 | 64 | { |
65 | 65 | $this->keyStorage->expects($this->once()) |
66 | - ->method('getKey') |
|
67 | - ->will($this->returnValue(null)); |
|
66 | + ->method('getKey') |
|
67 | + ->will($this->returnValue(null)); |
|
68 | 68 | |
69 | 69 | $this->keyGenerator->expects($this->once()) |
70 | - ->method('generate') |
|
71 | - ->with(null) |
|
72 | - ->will($this->returnValue($this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface'))); |
|
70 | + ->method('generate') |
|
71 | + ->with(null) |
|
72 | + ->will($this->returnValue($this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface'))); |
|
73 | 73 | |
74 | 74 | $this->keyStorage->expects($this->once()) |
75 | - ->method('setKey'); |
|
75 | + ->method('setKey'); |
|
76 | 76 | |
77 | 77 | $key = $this->keyManager->getKey(); |
78 | 78 | |
@@ -82,14 +82,14 @@ discard block |
||
82 | 82 | public function testGetKeyReadsExistingKey() |
83 | 83 | { |
84 | 84 | $this->keyStorage->expects($this->never()) |
85 | - ->method('setKey'); |
|
85 | + ->method('setKey'); |
|
86 | 86 | |
87 | 87 | $this->keyGenerator->expects($this->never()) |
88 | - ->method('generate'); |
|
88 | + ->method('generate'); |
|
89 | 89 | |
90 | 90 | $this->keyStorage->expects($this->once()) |
91 | - ->method('getKey') |
|
92 | - ->will($this->returnValue($this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface'))); |
|
91 | + ->method('getKey') |
|
92 | + ->will($this->returnValue($this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface'))); |
|
93 | 93 | |
94 | 94 | $key = $this->keyManager->getKey(); |
95 | 95 | |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | public function testSetKeyStoresKey() |
100 | 100 | { |
101 | 101 | $this->keyStorage->expects($this->once()) |
102 | - ->method('setKey') |
|
103 | - ->with($this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface')); |
|
102 | + ->method('setKey') |
|
103 | + ->with($this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface')); |
|
104 | 104 | |
105 | 105 | $this->keyManager->setKey($this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface')); |
106 | 106 | } |
@@ -115,10 +115,10 @@ discard block |
||
115 | 115 | protected function setUp() |
116 | 116 | { |
117 | 117 | $this->keyStorage = $this->getMockBuilder('Mes\Security\CryptoBundle\KeyStorage\KeyStorageInterface') |
118 | - ->getMock(); |
|
118 | + ->getMock(); |
|
119 | 119 | |
120 | 120 | $this->keyGenerator = $this->getMockBuilder('Mes\Security\CryptoBundle\KeyGenerator\KeyGeneratorInterface') |
121 | - ->getMock(); |
|
121 | + ->getMock(); |
|
122 | 122 | |
123 | 123 | $this->keyManager = new KeyManager($this->keyStorage, $this->keyGenerator); |
124 | 124 | } |