import org.bouncycastle.cert.X509CertificateHolder;
import org.bouncycastle.openssl.PEMParser;
+import org.json.simple.JSONObject;
import java.io.*;
import java.security.KeyStore;
import java.security.cert.Certificate;
import java.security.cert.CertificateFactory;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
/**
* Custom KeyStore Loader
* Created by lhameury on 10/09/15.
*/
public class KeyStoreLoader {
+ private static List<StoreConfig> stores = new ArrayList<>();
- private static KeyStore ks;
-
- private static String store = "ADULLACT"; // Default
-
- public static String getStore() {
- return store;
+ public static List<StoreConfig> getInstance() {
+ return stores;
}
- public static void setStore(String store) {
- KeyStoreLoader.store = store;
- }
+ public static void setStores(JSONObject store) throws Exception {
+ for (Object o : store.entrySet()) {
+ Map.Entry entry = (Map.Entry) o;
- public static KeyStore getInstance() {
- if (ks == null) {
- try {
- ks = loadStore(store);
- } catch (Exception e) {
- e.printStackTrace();
- }
+ StoreConfig sc = loadStore((String) entry.getKey());
+ sc.setConfig((String) entry.getKey(), StoreConfig.Validity.valueOf((String) entry.getValue()));
+
+ stores.add(sc);
}
- return ks;
}
/**
* @return The RGS KeyStore
* @throws Exception
*/
- private static KeyStore loadStore(String store) throws Exception {
+ private static StoreConfig loadStore(String store) throws Exception {
//Création d'un keystore...
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
ks.load(null, null);
}
}
}
- return ks;
+ return new StoreConfig(ks);
}
}