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