1 package org.apache.turbine.services.crypto;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 /***
23 * This interface describes the various Crypto Algorithms that are
24 * handed out by the Crypto Service.
25 *
26 * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
27 * @version $Id: CryptoAlgorithm.java 534527 2007-05-02 16:10:59Z tv $
28 */
29 public interface CryptoAlgorithm
30 {
31 /***
32 * Allows the user to set a salt value whenever the
33 * algorithm is used. Setting a new salt should invalidate
34 * all internal state of this object.
35 * <p>
36 * Algorithms that do not use a salt are allowed to ignore
37 * this parameter.
38 * <p>
39 * Algorithms must be able to deal with the null value as salt.
40 * They should treat it as "use a random salt".
41 *
42 * @param salt The salt value
43 */
44 void setSeed(String salt);
45
46 /***
47 * Performs the actual encryption.
48 *
49 * @param value The value to be encrypted
50 * @return The encrypted value
51 * @throws Exception various errors from the underlying ciphers.
52 * The caller should catch them and report accordingly.
53 */
54 String encrypt(String value)
55 throws Exception;
56
57 /***
58 * Algorithms that perform multiple ciphers get told
59 * with setCipher, which cipher to use. This should be
60 * called before any other method call.
61 *
62 * If called after any call to encrypt or setSeed, the
63 * CryptoAlgorithm may choose to ignore this or to reset
64 * and use the new cipher.
65 *
66 * If any other call is used before this, the algorithm
67 * should use a default cipher and not throw an error.
68 *
69 * @param cipher The cipher to use.
70 */
71 void setCipher(String cipher);
72
73 }