|
12 | 12 | */
|
13 | 13 | package org.codehaus.plexus.components.cipher;
|
14 | 14 |
|
| 15 | +import java.util.Set; |
| 16 | + |
15 | 17 | /**
|
16 | 18 | * @author Oleg Gusakov
|
17 | 19 | */
|
18 | 20 | public interface PlexusCipher {
|
| 21 | + |
| 22 | + /** |
| 23 | + * Returns the available cipher algorithms, never {@code null}. |
| 24 | + */ |
| 25 | + Set<String> availableCiphers(); |
| 26 | + |
19 | 27 | /**
|
20 |
| - * encrypt given string with the given passPhrase and encode it into base64 |
| 28 | + * Encrypt given string with the given alg and passPhrase and encode it into Base64 string. |
21 | 29 | *
|
22 |
| - * @param str string to encrypt |
23 |
| - * @param passPhrase pass phrase |
24 |
| - * @return encrypted str |
| 30 | + * @param alg cipher alg to use, never {@code null} |
| 31 | + * @param str string to encrypt, never {@code null} |
| 32 | + * @param passPhrase pass phrase, never {@code null} |
| 33 | + * @return encrypted str, never {@code null} |
25 | 34 | * @throws PlexusCipherException if encryption fails
|
26 | 35 | */
|
27 |
| - String encrypt(String str, String passPhrase) throws PlexusCipherException; |
| 36 | + String encrypt(String alg, String str, String passPhrase) throws PlexusCipherException; |
28 | 37 |
|
29 | 38 | /**
|
30 |
| - * encrypt given string with the given passPhrase, encode it into base64 and return result, wrapped into { } |
31 |
| - * decorations |
| 39 | + * Encrypt given string with the given alg and passPhrase and encode it into Base64 decorated string. |
32 | 40 | *
|
33 |
| - * @param str string to encrypt |
34 |
| - * @param passPhrase pass phrase |
35 |
| - * @return encrypted and decorated str |
| 41 | + * @param alg cipher alg to use, never {@code null} |
| 42 | + * @param str string to encrypt, never {@code null} |
| 43 | + * @param passPhrase pass phrase, never {@code null} |
| 44 | + * @return encrypted and decorated str, never {@code null} |
36 | 45 | * @throws PlexusCipherException if encryption fails
|
37 | 46 | */
|
38 |
| - String encryptAndDecorate(String str, String passPhrase) throws PlexusCipherException; |
| 47 | + String encryptAndDecorate(String alg, String str, String passPhrase) throws PlexusCipherException; |
39 | 48 |
|
40 | 49 | /**
|
41 |
| - * decrypt given base64 encrypted string |
| 50 | + * Decrypt given Base64 encoded string with the given alg and passPhrase and return resulting string. |
42 | 51 | *
|
43 |
| - * @param str base64 encoded string |
44 |
| - * @param passPhrase pass phrase |
45 |
| - * @return decrypted str |
46 |
| - * @throws PlexusCipherException if decryption fails |
| 52 | + * @param alg cipher alg to use, never {@code null} |
| 53 | + * @param str string to encrypt, never {@code null} |
| 54 | + * @param passPhrase pass phrase, never {@code null} |
| 55 | + * @return encrypted and decorated str, never {@code null} |
| 56 | + * @throws PlexusCipherException if encryption fails |
47 | 57 | */
|
48 |
| - String decrypt(String str, String passPhrase) throws PlexusCipherException; |
| 58 | + String decrypt(String alg, String str, String passPhrase) throws PlexusCipherException; |
49 | 59 |
|
50 | 60 | /**
|
51 |
| - * decrypt given base64 encoded encrypted string. If string is decorated, decrypt base64 encoded string inside |
52 |
| - * decorations |
| 61 | + * Decrypt given decorated Base64 encoded string with the given alg and passPhrase and return resulting string. |
53 | 62 | *
|
54 |
| - * @param str base64 encoded string |
55 |
| - * @param passPhrase pass phrase |
56 |
| - * @return decrypted decorated str |
57 |
| - * @throws PlexusCipherException if decryption fails |
| 63 | + * @param alg cipher alg to use, never {@code null} |
| 64 | + * @param str string to encrypt, never {@code null} |
| 65 | + * @param passPhrase pass phrase, never {@code null} |
| 66 | + * @return encrypted and decorated str, never {@code null} |
| 67 | + * @throws PlexusCipherException if encryption fails |
58 | 68 | */
|
59 |
| - String decryptDecorated(String str, String passPhrase) throws PlexusCipherException; |
| 69 | + String decryptDecorated(String alg, String str, String passPhrase) throws PlexusCipherException; |
60 | 70 |
|
61 | 71 | /**
|
62 |
| - * check if given string is decorated |
63 |
| - * |
64 |
| - * @param str string to check |
65 |
| - * @return true if string is encrypted |
| 72 | + * Check if given string is decorated. |
66 | 73 | */
|
67 | 74 | boolean isEncryptedString(String str);
|
68 | 75 |
|
69 | 76 | /**
|
70 |
| - * return string inside decorations |
| 77 | + * Remove decorations from string, if it was decorated. |
71 | 78 | *
|
72 |
| - * @param str decorated string |
73 |
| - * @return undecorated str |
74 |
| - * @throws PlexusCipherException if decryption fails |
| 79 | + * @throws PlexusCipherException is string is malformed |
75 | 80 | */
|
76 | 81 | String unDecorate(String str) throws PlexusCipherException;
|
77 | 82 |
|
78 | 83 | /**
|
79 |
| - * decorated given string with { and } |
80 |
| - * |
81 |
| - * @param str string to decorate |
82 |
| - * @return decorated str |
| 84 | + * Decorates given string. |
83 | 85 | */
|
84 | 86 | String decorate(String str);
|
85 | 87 | }
|
0 commit comments