forked from I2P_Developers/i2p.i2p
* Plugins:
- Fix plugin start button - Change signer prop to match docs - Tweaks
This commit is contained in:
@ -51,10 +51,15 @@ public class ConfigClientsHandler extends FormHandler {
|
|||||||
try {
|
try {
|
||||||
appnum = Integer.parseInt(app);
|
appnum = Integer.parseInt(app);
|
||||||
} catch (NumberFormatException nfe) {}
|
} catch (NumberFormatException nfe) {}
|
||||||
if (appnum >= 0)
|
if (appnum >= 0) {
|
||||||
startClient(appnum);
|
startClient(appnum);
|
||||||
else
|
} else {
|
||||||
startWebApp(app);
|
List<String> plugins = PluginStarter.getPlugins();
|
||||||
|
if (plugins.contains(app))
|
||||||
|
startPlugin(app);
|
||||||
|
else
|
||||||
|
startWebApp(app);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,10 +122,15 @@ public class ConfigClientsHandler extends FormHandler {
|
|||||||
try {
|
try {
|
||||||
appnum = Integer.parseInt(app);
|
appnum = Integer.parseInt(app);
|
||||||
} catch (NumberFormatException nfe) {}
|
} catch (NumberFormatException nfe) {}
|
||||||
if (appnum >= 0)
|
if (appnum >= 0) {
|
||||||
startClient(appnum);
|
startClient(appnum);
|
||||||
else
|
} else {
|
||||||
startWebApp(app);
|
List<String> plugins = PluginStarter.getPlugins();
|
||||||
|
if (plugins.contains(app))
|
||||||
|
startPlugin(app);
|
||||||
|
else
|
||||||
|
startWebApp(app);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
addFormError(_("Unsupported") + ' ' + _action + '.');
|
addFormError(_("Unsupported") + ' ' + _action + '.');
|
||||||
}
|
}
|
||||||
@ -315,4 +325,13 @@ public class ConfigClientsHandler extends FormHandler {
|
|||||||
} catch (InterruptedException ie) {}
|
} catch (InterruptedException ie) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void startPlugin(String app) {
|
||||||
|
try {
|
||||||
|
PluginStarter.startPlugin(_context, app);
|
||||||
|
addFormNotice(_("Started plugin {0}", app));
|
||||||
|
} catch (Throwable e) {
|
||||||
|
addFormError(_("Error starting plugin {0}", app) + ": " + e);
|
||||||
|
_log.error("Error starting plugin " + app, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,16 +86,20 @@ public class ConfigClientsHelper extends HelperBase {
|
|||||||
String app = name.substring(PluginStarter.PREFIX.length(), name.lastIndexOf(PluginStarter.ENABLED));
|
String app = name.substring(PluginStarter.PREFIX.length(), name.lastIndexOf(PluginStarter.ENABLED));
|
||||||
String val = props.getProperty(name);
|
String val = props.getProperty(name);
|
||||||
Properties appProps = PluginStarter.pluginProperties(_context, app);
|
Properties appProps = PluginStarter.pluginProperties(_context, app);
|
||||||
|
if (appProps.size() <= 0)
|
||||||
|
continue;
|
||||||
StringBuilder desc = new StringBuilder(256);
|
StringBuilder desc = new StringBuilder(256);
|
||||||
desc.append("<table border=\"0\">")
|
desc.append("<table border=\"0\">")
|
||||||
.append("<tr><td><b>").append(_("Version")).append("<td>").append(stripHTML(appProps, "version"))
|
.append("<tr><td><b>").append(_("Version")).append("<td>").append(stripHTML(appProps, "version"))
|
||||||
.append("<tr><td><b>")
|
.append("<tr><td><b>")
|
||||||
.append(_("Signed by")).append("<td>");
|
.append(_("Signed by")).append("<td>");
|
||||||
String s = stripHTML(appProps, "keyName");
|
String s = stripHTML(appProps, "signer");
|
||||||
if (s.indexOf("@") > 0)
|
if (s != null) {
|
||||||
desc.append("<a href=\"mailto:").append(s).append("\">").append(s).append("</a>");
|
if (s.indexOf("@") > 0)
|
||||||
else
|
desc.append("<a href=\"mailto:").append(s).append("\">").append(s).append("</a>");
|
||||||
desc.append(s);
|
else
|
||||||
|
desc.append(s);
|
||||||
|
}
|
||||||
s = stripHTML(appProps, "date");
|
s = stripHTML(appProps, "date");
|
||||||
if (s != null) {
|
if (s != null) {
|
||||||
long ms = 0;
|
long ms = 0;
|
||||||
|
@ -301,9 +301,9 @@ public class PluginStarter implements Runnable {
|
|||||||
for (String name : names) {
|
for (String name : names) {
|
||||||
Properties props = pluginProperties(ctx, name);
|
Properties props = pluginProperties(ctx, name);
|
||||||
String pubkey = props.getProperty("key");
|
String pubkey = props.getProperty("key");
|
||||||
String keyName = props.getProperty("keyName");
|
String signer = props.getProperty("signer");
|
||||||
if (pubkey != null && keyName != null && pubkey.length() == 172 && keyName.length() > 0)
|
if (pubkey != null && signer != null && pubkey.length() == 172 && signer.length() > 0)
|
||||||
rv.put(pubkey, keyName);
|
rv.put(pubkey, signer);
|
||||||
}
|
}
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -174,11 +174,11 @@ public class PluginUpdateHandler extends UpdateHandler {
|
|||||||
|
|
||||||
// ok, now we check sigs and deal with a bad sig
|
// ok, now we check sigs and deal with a bad sig
|
||||||
String pubkey = props.getProperty("key");
|
String pubkey = props.getProperty("key");
|
||||||
String keyName = props.getProperty("keyName");
|
String signer = props.getProperty("signer");
|
||||||
if (pubkey == null || keyName == null || pubkey.length() != 172 || keyName.length() <= 0) {
|
if (pubkey == null || signer == null || pubkey.length() != 172 || signer.length() <= 0) {
|
||||||
f.delete();
|
f.delete();
|
||||||
to.delete();
|
to.delete();
|
||||||
//updateStatus("<b>" + "Plugin contains an invalid key" + ' ' + pubkey + ' ' + keyName + "</b>");
|
//updateStatus("<b>" + "Plugin contains an invalid key" + ' ' + pubkey + ' ' + signer + "</b>");
|
||||||
updateStatus("<b>" + _("Plugin from {0} contains an invalid key", url) + "</b>");
|
updateStatus("<b>" + _("Plugin from {0} contains an invalid key", url) + "</b>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -193,9 +193,9 @@ public class PluginUpdateHandler extends UpdateHandler {
|
|||||||
|
|
||||||
if (up.haveKey(pubkey)) {
|
if (up.haveKey(pubkey)) {
|
||||||
// the key is already in the TrustedUpdate keyring
|
// the key is already in the TrustedUpdate keyring
|
||||||
// verify the sig and verify that it is signed by the keyName in the plugin.config file
|
// verify the sig and verify that it is signed by the signer in the plugin.config file
|
||||||
String signingKeyName = up.verifyAndGetSigner(f);
|
String signingKeyName = up.verifyAndGetSigner(f);
|
||||||
if (!keyName.equals(signingKeyName)) {
|
if (!signer.equals(signingKeyName)) {
|
||||||
f.delete();
|
f.delete();
|
||||||
to.delete();
|
to.delete();
|
||||||
updateStatus("<b>" + _("Plugin signature verification of {0} failed", url) + "</b>");
|
updateStatus("<b>" + _("Plugin signature verification of {0} failed", url) + "</b>");
|
||||||
@ -203,7 +203,7 @@ public class PluginUpdateHandler extends UpdateHandler {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// add to keyring...
|
// add to keyring...
|
||||||
if(!up.addKey(pubkey, keyName)) {
|
if(!up.addKey(pubkey, signer)) {
|
||||||
// bad or duplicate key
|
// bad or duplicate key
|
||||||
f.delete();
|
f.delete();
|
||||||
to.delete();
|
to.delete();
|
||||||
@ -211,9 +211,9 @@ public class PluginUpdateHandler extends UpdateHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// ...and try the verify again
|
// ...and try the verify again
|
||||||
// verify the sig and verify that it is signed by the keyName in the plugin.config file
|
// verify the sig and verify that it is signed by the signer in the plugin.config file
|
||||||
String signingKeyName = up.verifyAndGetSigner(f);
|
String signingKeyName = up.verifyAndGetSigner(f);
|
||||||
if (!keyName.equals(signingKeyName)) {
|
if (!signer.equals(signingKeyName)) {
|
||||||
f.delete();
|
f.delete();
|
||||||
to.delete();
|
to.delete();
|
||||||
updateStatus("<b>" + _("Plugin signature verification of {0} failed", url) + "</b>");
|
updateStatus("<b>" + _("Plugin signature verification of {0} failed", url) + "</b>");
|
||||||
@ -278,9 +278,9 @@ public class PluginUpdateHandler extends UpdateHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String oldPubkey = oldProps.getProperty("key");
|
String oldPubkey = oldProps.getProperty("key");
|
||||||
String oldKeyName = oldProps.getProperty("keyName");
|
String oldKeyName = oldProps.getProperty("signer");
|
||||||
String oldAppName = props.getProperty("name");
|
String oldAppName = props.getProperty("name");
|
||||||
if ((!pubkey.equals(oldPubkey)) || (!keyName.equals(oldKeyName)) || (!appName.equals(oldAppName))) {
|
if ((!pubkey.equals(oldPubkey)) || (!signer.equals(oldKeyName)) || (!appName.equals(oldAppName))) {
|
||||||
to.delete();
|
to.delete();
|
||||||
updateStatus("<b>" + _("Signature of downloaded plugin does not match installed plugin") + "</b>");
|
updateStatus("<b>" + _("Signature of downloaded plugin does not match installed plugin") + "</b>");
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user