This repository was archived by the owner on Nov 24, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +15
-14
lines changed
main/java/org/codehaus/plexus/components/cipher
test/java/org/codehaus/plexus/components/cipher/internal Expand file tree Collapse file tree 5 files changed +15
-14
lines changed Original file line number Diff line number Diff line change 1616 * @author Oleg Gusakov
1717 */
1818public interface PlexusCipher {
19- String ENCRYPTED_STRING_DECORATION_START = "{" ;
20-
21- String ENCRYPTED_STRING_DECORATION_STOP = "}" ;
22-
2319 /**
2420 * encrypt given string with the given passPhrase and encode it into base64
2521 *
Original file line number Diff line number Diff line change 1010 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1111 * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
1212 */
13- package org .codehaus .plexus .components .cipher ;
13+ package org .codehaus .plexus .components .cipher . internal ;
1414
1515import javax .inject .Named ;
1616import javax .inject .Singleton ;
2222import java .util .regex .Matcher ;
2323import java .util .regex .Pattern ;
2424
25+ import org .codehaus .plexus .components .cipher .PlexusCipher ;
26+ import org .codehaus .plexus .components .cipher .PlexusCipherException ;
27+
2528/**
2629 * Default implementation of {@link PlexusCipher}. This class is thread safe.
2730 *
3134@ Named
3235public class DefaultPlexusCipher implements PlexusCipher {
3336 private static final Pattern ENCRYPTED_STRING_PATTERN = Pattern .compile (".*?[^\\ \\ ]?\\ {(.*?[^\\ \\ ])\\ }.*" );
37+ private static final String ENCRYPTED_STRING_DECORATION_START = "{" ;
38+ private static final String ENCRYPTED_STRING_DECORATION_STOP = "}" ;
3439
3540 private final PBECipher _cipher ;
3641
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ Licensed to the Apache Software Foundation (ASF) under one
1717under the License.
1818 */
1919
20- package org .codehaus .plexus .components .cipher ;
20+ package org .codehaus .plexus .components .cipher . internal ;
2121
2222import javax .crypto .Cipher ;
2323import javax .crypto .NoSuchPaddingException ;
@@ -36,6 +36,8 @@ Licensed to the Apache Software Foundation (ASF) under one
3636import java .security .spec .KeySpec ;
3737import java .util .Base64 ;
3838
39+ import org .codehaus .plexus .components .cipher .PlexusCipherException ;
40+
3941/**
4042 * This class is thread-safe.
4143 *
Original file line number Diff line number Diff line change 1010 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1111 * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
1212 */
13- package org .codehaus .plexus .components .cipher ;
13+ package org .codehaus .plexus .components .cipher . internal ;
1414
15+ import org .codehaus .plexus .components .cipher .PlexusCipher ;
16+ import org .codehaus .plexus .components .cipher .PlexusCipherException ;
1517import org .junit .jupiter .api .BeforeEach ;
1618import org .junit .jupiter .api .Disabled ;
1719import org .junit .jupiter .api .Test ;
@@ -154,18 +156,14 @@ void testDecrypt() {
154156 @ Test
155157 void testDecorate () {
156158 String res = pc .decorate ("aaa" );
157- assertEquals (
158- PlexusCipher .ENCRYPTED_STRING_DECORATION_START + "aaa" + PlexusCipher .ENCRYPTED_STRING_DECORATION_STOP ,
159- res ,
160- "Decoration failed" );
159+ assertEquals ("{aaa}" , res , "Decoration failed" );
161160 }
162161
163162 // -------------------------------------------------------------
164163
165164 @ Test
166165 void testUnDecorate () throws Exception {
167- String res = pc .unDecorate (
168- PlexusCipher .ENCRYPTED_STRING_DECORATION_START + "aaa" + PlexusCipher .ENCRYPTED_STRING_DECORATION_STOP );
166+ String res = pc .unDecorate ("{aaa}" );
169167 assertEquals ("aaa" , res , "Decoration failed" );
170168 }
171169
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ Licensed to the Apache Software Foundation (ASF) under one
1717under the License.
1818 */
1919
20- package org .codehaus .plexus .components .cipher ;
20+ package org .codehaus .plexus .components .cipher . internal ;
2121
2222import org .junit .jupiter .api .BeforeEach ;
2323import org .junit .jupiter .api .Test ;
You can’t perform that action at this time.
0 commit comments