Skip to content
Snippets Groups Projects
Commit 493534ef authored by Matyáš Latner's avatar Matyáš Latner
Browse files

#17 Jar SSL connection fix -> SSL keystore loaded to external storage

parent e84267ee
Branches
Tags
No related merge requests found
......@@ -139,6 +139,30 @@ public abstract class TablexiaAbstractFileManager extends AssetManager {
}
}
public enum KeystoreStorageType implements StorageType {
INTERNAL(RootStorageType.INTERNAL, KeystoreStorageType.KEYSTORE_DIRECTORY),
EXTERNAL(RootStorageType.EXTERNAL, KeystoreStorageType.KEYSTORE_DIRECTORY);
public static final String KEYSTORE_DIRECTORY = "keystore/";
private String storagePath;
private FileHandleResolver resolver;
KeystoreStorageType(RootStorageType rootStorageType, String assetsPath) {
this.storagePath = rootStorageType.getStoragePath() + assetsPath;
this.resolver = rootStorageType.getResolver();
}
public String getStoragePath() {
return storagePath;
}
public FileHandleResolver getResolver() {
return resolver;
}
}
public static FileHandle getFileStoragePathFileHandle(StorageType storageType, String additionalPath) {
return storageType.getResolver().resolve(storageType.getStoragePath() + additionalPath);
}
......
......@@ -35,10 +35,12 @@ import cz.nic.tablexia.util.Log;
*/
public class ZipAssetLoader extends TablexiaDataManager<Void> implements IApplicationLoader {
public static final TablexiaAbstractFileManager.RootStorageType ZIP_FILES_STORAGE_TYPE = TablexiaAbstractFileManager.RootStorageType.INTERNAL;
public static final TablexiaAbstractFileManager.StorageType ZIP_FILES_STORAGE_TYPE = TablexiaAbstractFileManager.DownloadStorageType.EXTERNAL;
public static final String ZIP_FILE_EXTENSION = ".zip";
private static final String TABLEXIA_ASSETS_DOWNLOAD_BASE_PATH = "https://www.tablexia.cz/static/assets/";
private static final int TABLEXIA_ASSETS_DOWNLOAD_TIMEOUT = 2500;
private static final String TABLEXIA_TRUST_KEYSTORE_NAME = "tablexiaTrustKeystore";
private static final String TABLEXIA_TRUST_KEYSTORE_PASSWORD = "tablexia";
private static final Object LOCK = new Object();
......@@ -125,8 +127,12 @@ public class ZipAssetLoader extends TablexiaDataManager<Void> implements IApplic
}
private void prepareKeyStore() {
System.setProperty("javax.net.ssl.trustStore", TablexiaAbstractFileManager.getFileStoragePath(TablexiaAbstractFileManager.RootStorageType.INTERNAL, "keystore/tablexiaTrustKeystore"));
System.setProperty("javax.net.ssl.trustStorePassword", "tablexia");
FileHandle keystoreExternal = TablexiaAbstractFileManager.getFileStoragePathFileHandle(TablexiaAbstractFileManager.KeystoreStorageType.EXTERNAL, TABLEXIA_TRUST_KEYSTORE_NAME);
FileHandle keystoreInternal = TablexiaAbstractFileManager.getFileStoragePathFileHandle(TablexiaAbstractFileManager.KeystoreStorageType.INTERNAL, TABLEXIA_TRUST_KEYSTORE_NAME);
keystoreExternal.write(keystoreInternal.read(), false);
System.setProperty("javax.net.ssl.trustStore", keystoreExternal.file().getAbsolutePath());
System.setProperty("javax.net.ssl.trustStorePassword", TABLEXIA_TRUST_KEYSTORE_PASSWORD);
}
public void download(final String fileName) {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment