1
2
3
4
5
6
7
8
9
10
11 package org.mule.mule.security;
12
13 import org.mule.impl.security.SecretKeyEncryptionStrategy;
14 import org.mule.tck.AbstractMuleTestCase;
15
16 public class SecretKeyEncryptionStrategyTestCase extends AbstractMuleTestCase
17 {
18
19 public void testRoundTripEncryptionBlowfish() throws Exception
20 {
21 SecretKeyEncryptionStrategy ske = new SecretKeyEncryptionStrategy();
22 ske.setAlgorithm("Blowfish");
23 ske.setKey("shhhhh");
24 ske.initialise();
25
26 byte[] b = ske.encrypt("hello".getBytes(), null);
27
28 assertNotSame(new String(b), "hello");
29 String s = new String(ske.decrypt(b, null), "UTF-8");
30 assertEquals("hello", s);
31 }
32
33 public void testRoundTripEncryptionTripleDES() throws Exception
34 {
35 SecretKeyEncryptionStrategy ske = new SecretKeyEncryptionStrategy();
36 ske.setAlgorithm("TripleDES");
37 ske.setKey("shhhhh");
38
39 ske.initialise();
40
41 byte[] b = ske.encrypt("hello".getBytes(), null);
42
43 assertNotSame(new String(b), "hello");
44 String s = new String(ske.decrypt(b, null), "UTF-8");
45 assertEquals("hello", s);
46 }
47 }