Skip to content
Snippets Groups Projects
Commit 58933a61 authored by Felix Sidokhine's avatar Felix Sidokhine
Browse files

close to finishing the update model

parent 5bf7fd5a
No related branches found
No related tags found
No related merge requests found
package net.jami.jams.common.updater;
import java.security.PrivateKey;
import java.security.cert.X509Certificate;
import java.util.HashMap;
public interface AppUpdater {
......@@ -7,7 +9,7 @@ public interface AppUpdater {
HashMap<String,FileDescription> getLocalVersions();
HashMap<String,FileDescription> getRemoteVersions();
boolean getUpdateAvailable();
void setLicense();
void setLicense(X509Certificate certificate, PrivateKey privateKey);
void doUpdate();
}
......@@ -57,6 +57,8 @@ public class LicenseService {
licenseInformation = X509Utils.extractSubscriptionTypeFromCertificate(certificate);
log.info("Server is activated with valid license: {}", Server.activated.get());
log.info("License type: {}",licenseInformation.getType());
Server.appUpdater.setLicense(certificate,privateKey);
log.info("Successfully set license inside updater module!");
}
catch (Exception e){
log.error("A generic occurred while trying to load your license or your license could not be found");
......
......@@ -7,6 +7,8 @@ import net.jami.jams.common.updater.AppUpdater;
import net.jami.jams.common.updater.FileDescription;
import net.jami.jams.common.utils.VersioningUtils;
import java.security.PrivateKey;
import java.security.cert.X509Certificate;
import java.util.HashMap;
import java.util.Timer;
import java.util.concurrent.atomic.AtomicBoolean;
......@@ -19,7 +21,11 @@ public class JAMSUpdater implements AppUpdater {
public static final AtomicBoolean updateAvailable = new AtomicBoolean(false);
private final AtomicBoolean doUpdate;
private final UpdateCheckTask updateCheckTask = new UpdateCheckTask();
private final UpdateDownloader updateDownloader = new UpdateDownloader();
private final Timer timer = new Timer();
//These get written to from the server, so we set them to volatile for visibility purposes.
public volatile static X509Certificate certificate;
public volatile static PrivateKey privateKey;
public JAMSUpdater(AtomicBoolean doUpdate) {
this.doUpdate = doUpdate;
......@@ -42,19 +48,22 @@ public class JAMSUpdater implements AppUpdater {
}
@Override
public void setLicense() {
//Trigger reading the license from disk.
public void setLicense(X509Certificate certificate, PrivateKey privateKey) {
JAMSUpdater.certificate = certificate;
JAMSUpdater.privateKey = privateKey;
}
@Override
public void doUpdate() {
//Some logic here about replacing the existing files.
boolean res = updateDownloader.downloadFiles();
//Notify back up-stream to the launcher that we want the update to happen.
doUpdate.set(true);
synchronized (doUpdate){
doUpdate.notify();
if(res) {
doUpdate.set(true);
synchronized (doUpdate) {
doUpdate.notify();
}
}
else log.error("Could not perform update!");
}
}
......@@ -15,6 +15,11 @@ public class UpdateDownloader {
//TODO: Download the files and dump them into a tmp folder.
public boolean downloadFiles(){
try {
//Build the SSL context here, (this is fairly simple)
//Try to download the files and store the to /tmp
//Check file checksums.
return true;
}
catch (Exception e){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment