@@ -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 | } |
@@ -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 | '', |
@@ -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 | /** |
@@ -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; |
@@ -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 | } |
@@ -34,9 +34,9 @@ discard block |
||
34 | 34 | public function testEncryptEncryptsPlaintext() |
35 | 35 | { |
36 | 36 | $this->encryption->expects($this->once()) |
37 | - ->method('encrypt') |
|
38 | - ->with('The quick brown fox jumps over the lazy dog', $this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface')) |
|
39 | - ->will($this->returnValue('ThisIsACipherText')); |
|
37 | + ->method('encrypt') |
|
38 | + ->with('The quick brown fox jumps over the lazy dog', $this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface')) |
|
39 | + ->will($this->returnValue('ThisIsACipherText')); |
|
40 | 40 | |
41 | 41 | $ciphertext = $this->wrapper->encrypt('The quick brown fox jumps over the lazy dog', $this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface')); |
42 | 42 | |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | { |
51 | 51 | try { |
52 | 52 | $this->encryption->expects($this->once()) |
53 | - ->method('encrypt') |
|
54 | - ->with('The quick brown fox jumps over the lazy dog', $this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface')) |
|
55 | - ->will($this->throwException(new EnvironmentIsBrokenException())); |
|
53 | + ->method('encrypt') |
|
54 | + ->with('The quick brown fox jumps over the lazy dog', $this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface')) |
|
55 | + ->will($this->throwException(new EnvironmentIsBrokenException())); |
|
56 | 56 | } catch (EnvironmentIsBrokenException $e) { |
57 | 57 | $this->throwException(new CryptoException()); |
58 | 58 | } |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | public function testDecryptDecryptsCiphertext() |
64 | 64 | { |
65 | 65 | $this->encryption->expects($this->once()) |
66 | - ->method('decrypt') |
|
67 | - ->with('ThisIsACipherText', $this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface')) |
|
68 | - ->will($this->returnValue('The quick brown fox jumps over the lazy dog')); |
|
66 | + ->method('decrypt') |
|
67 | + ->with('ThisIsACipherText', $this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface')) |
|
68 | + ->will($this->returnValue('The quick brown fox jumps over the lazy dog')); |
|
69 | 69 | |
70 | 70 | $decryptedText = $this->wrapper->decrypt('ThisIsACipherText', $this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface')); |
71 | 71 | |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | { |
80 | 80 | try { |
81 | 81 | $this->encryption->expects($this->once()) |
82 | - ->method('decrypt') |
|
83 | - ->with('ThisIsACipherText', $this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface')) |
|
84 | - ->will($this->throwException(new BaseCryptoException())); |
|
82 | + ->method('decrypt') |
|
83 | + ->with('ThisIsACipherText', $this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface')) |
|
84 | + ->will($this->throwException(new BaseCryptoException())); |
|
85 | 85 | } catch (BaseCryptoException $e) { |
86 | 86 | $this->throwException(new CryptoException()); |
87 | 87 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | protected function setUp() |
93 | 93 | { |
94 | 94 | $this->encryption = $this->getMockBuilder('Mes\Security\CryptoBundle\EncryptionInterface') |
95 | - ->getMock(); |
|
95 | + ->getMock(); |
|
96 | 96 | $this->wrapper = new EncryptionWrapper($this->encryption); |
97 | 97 | } |
98 | 98 |
@@ -34,7 +34,7 @@ |
||
34 | 34 | $this->keyStorage->setKey($key); |
35 | 35 | |
36 | 36 | $this->assertInstanceOf('Defuse\Crypto\KeyProtectedByPassword', $this->keyStorage->getKey() |
37 | - ->getRawKey()); |
|
37 | + ->getRawKey()); |
|
38 | 38 | $this->assertSame($secret, $this->keyStorage->getKey() |
39 | 39 | ->getSecret()); |
40 | 40 | } |
@@ -36,9 +36,9 @@ discard block |
||
36 | 36 | public function testGenerateCreatesKey() |
37 | 37 | { |
38 | 38 | $this->keyManager->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->wrapper->generate(); |
44 | 44 | |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | { |
53 | 53 | try { |
54 | 54 | $this->keyManager->expects($this->once()) |
55 | - ->method('generate') |
|
56 | - ->with(null) |
|
57 | - ->will($this->throwException(new EnvironmentIsBrokenException())); |
|
55 | + ->method('generate') |
|
56 | + ->with(null) |
|
57 | + ->will($this->throwException(new EnvironmentIsBrokenException())); |
|
58 | 58 | } catch (EnvironmentIsBrokenException $ex) { |
59 | 59 | $this->throwException(new CryptoException()); |
60 | 60 | } |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | $secret = 'ThisIsASecretPassword'; |
69 | 69 | |
70 | 70 | $this->keyManager->expects($this->once()) |
71 | - ->method('generateFromAscii') |
|
72 | - ->with($key_encoded, $secret) |
|
73 | - ->will($this->returnValue($this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface'))); |
|
71 | + ->method('generateFromAscii') |
|
72 | + ->with($key_encoded, $secret) |
|
73 | + ->will($this->returnValue($this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface'))); |
|
74 | 74 | |
75 | 75 | $key = $this->wrapper->generateFromAscii($key_encoded, $secret); |
76 | 76 | |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | |
88 | 88 | try { |
89 | 89 | $this->keyManager->expects($this->once()) |
90 | - ->method('generateFromAscii') |
|
91 | - ->with($key_encoded, $secret) |
|
92 | - ->will($this->throwException(new BaseCryptoException())); |
|
90 | + ->method('generateFromAscii') |
|
91 | + ->with($key_encoded, $secret) |
|
92 | + ->will($this->throwException(new BaseCryptoException())); |
|
93 | 93 | } catch (CryptoException $ex) { |
94 | 94 | $this->throwException(new CryptoException()); |
95 | 95 | } |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | public function testGetKeyReadsKey() |
101 | 101 | { |
102 | 102 | $this->keyManager->expects($this->once()) |
103 | - ->method('getKey') |
|
104 | - ->will($this->returnValue($this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface'))); |
|
103 | + ->method('getKey') |
|
104 | + ->will($this->returnValue($this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface'))); |
|
105 | 105 | |
106 | 106 | $key = $this->wrapper->getKey(); |
107 | 107 | |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | public function testSetKeyStoresKey() |
112 | 112 | { |
113 | 113 | $this->keyManager->expects($this->once()) |
114 | - ->method('setKey') |
|
115 | - ->with($this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface')); |
|
114 | + ->method('setKey') |
|
115 | + ->with($this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface')); |
|
116 | 116 | |
117 | 117 | $this->wrapper->setKey($this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface')); |
118 | 118 | } |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | public function testSetSecretStoresSecret() |
121 | 121 | { |
122 | 122 | $this->keyManager->expects($this->once()) |
123 | - ->method('setSecret') |
|
124 | - ->with('ThisIsASecret'); |
|
123 | + ->method('setSecret') |
|
124 | + ->with('ThisIsASecret'); |
|
125 | 125 | |
126 | 126 | $this->wrapper->setSecret('ThisIsASecret'); |
127 | 127 | } |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | public function testGetSecretReadsSecret() |
130 | 130 | { |
131 | 131 | $this->keyManager->expects($this->once()) |
132 | - ->method('getSecret') |
|
133 | - ->will($this->returnValue('ThisIsYourSecret')); |
|
132 | + ->method('getSecret') |
|
133 | + ->will($this->returnValue('ThisIsYourSecret')); |
|
134 | 134 | |
135 | 135 | $secret = $this->wrapper->getSecret(); |
136 | 136 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | protected function setUp() |
141 | 141 | { |
142 | 142 | $this->keyManager = $this->getMockBuilder('\Mes\Security\CryptoBundle\KeyManagerInterface') |
143 | - ->getMock(); |
|
143 | + ->getMock(); |
|
144 | 144 | $this->wrapper = new KeyManagerWrapper($this->keyManager); |
145 | 145 | } |
146 | 146 |