Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Keppler2018-11-17 05:06:14 -0500
committerMichael Keppler2018-12-02 03:56:19 -0500
commit6b4d96fd291200eeb512c3a3de349b4388cbf568 (patch)
treeb20d8014c36f617670c06c3e2e75ce0b8421e2b3 /org.eclipse.egit.core.test/src
parent4b9a3331c1c314cbaa0f99db660710ea61aed881 (diff)
downloadegit-6b4d96fd291200eeb512c3a3de349b4388cbf568.tar.gz
egit-6b4d96fd291200eeb512c3a3de349b4388cbf568.tar.xz
egit-6b4d96fd291200eeb512c3a3de349b4388cbf568.zip
Clear password of crypto API after usage
The (internally cloned) password of a key spec needs to be cleared after usage. For this unit test this is not really relevant. However, we don't want someone to copy/paste our code into a real security relevant project without having the clearPassword(). Found with Cognicrypt plugin. Change-Id: Ic92a65ca14fc0d528049ba0534d73c4715597ffa Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
Diffstat (limited to 'org.eclipse.egit.core.test/src')
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/securestorage/EGitSecureStoreTest.java9
1 files changed, 6 insertions, 3 deletions
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/securestorage/EGitSecureStoreTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/securestorage/EGitSecureStoreTest.java
index 823207596..1b0987bdb 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/securestorage/EGitSecureStoreTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/securestorage/EGitSecureStoreTest.java
@@ -39,6 +39,8 @@ public class EGitSecureStoreTest {
EGitSecureStore store;
+ private PBEKeySpec keySpec;
+
@Before
public void setUp() throws Exception {
setupNewSecureStore();
@@ -48,6 +50,7 @@ public class EGitSecureStoreTest {
@After
public void tearDown() throws Exception {
secureStoreForTest.flush();
+ keySpec.clearPassword();
}
@Test
@@ -201,9 +204,9 @@ public class EGitSecureStoreTest {
private void setupNewSecureStore() throws IOException,
MalformedURLException {
- HashMap<String, Object> options = new HashMap<String, Object>();
- options.put(IProviderHints.DEFAULT_PASSWORD, new PBEKeySpec(
- "masterpass".toCharArray()));
+ HashMap<String, Object> options = new HashMap<>();
+ keySpec = new PBEKeySpec("masterpass".toCharArray());
+ options.put(IProviderHints.DEFAULT_PASSWORD, keySpec);
String secureStorePath = ResourcesPlugin.getWorkspace().getRoot()
.getLocation().append("testSecureStore").toOSString();
File file = new File(secureStorePath);

Back to the top