Skip to content

Commit 0ef7b83

Browse files
authored
Merge pull request #3813 from ControlSystemStudio/CSSTUDIO-3638
Create directory for secure store if it does not exist
2 parents 3464ee8 + 342c9fd commit 0ef7b83

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

‎core/security/src/main/java/org/phoebus/security/store/FileBasedStore.java‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import java.io.File;
99
import java.io.FileInputStream;
1010
import java.io.FileOutputStream;
11+
import java.io.IOException;
1112
import java.security.KeyStore;
1213
import java.util.Collections;
1314
import java.util.List;
@@ -28,11 +29,10 @@ public class FileBasedStore implements Store<String, String> {
2829
private final SecretKeyFactory kf = SecretKeyFactory.getInstance("PBE");
2930
private final KeyStore store;
3031
private final File secure_file;
31-
private byte[] secureStoreByteArray;
3232
private final char[] store_pass;
3333
private final KeyStore.ProtectionParameter pp;
3434

35-
private static final Logger LOGGER = Logger.getLogger(SecureStore.class.getName());
35+
private static final Logger LOGGER = Logger.getLogger(FileBasedStore.class.getName());
3636

3737
/**
3838
* Create with default file in 'user' location
@@ -63,6 +63,14 @@ public FileBasedStore(final File secure_file) throws Exception {
6363
* @throws Exception on error
6464
*/
6565
public FileBasedStore(final File secure_file, final char[] store_pass) throws Exception {
66+
67+
File secureFileDir = secure_file.getParentFile();
68+
if (!secureFileDir.exists()) {
69+
if(!secureFileDir.mkdirs()){
70+
throw new IOException("Cannot create directory for secure store");
71+
}
72+
}
73+
6674
this.secure_file = secure_file;
6775
this.store_pass = store_pass;
6876

0 commit comments

Comments
 (0)