Changeset 34565 in osm
- Timestamp:
- 2018-08-18T20:35:07+02:00 (6 years ago)
- Location:
- applications/editors/josm/plugins/trustosm
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/trustosm/build.xml
r33869 r34565 5 5 <property name="commit.message" value="New plugin for digital signing osm data"/> 6 6 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 7 <property name="plugin.main.version" value="1 2840" />7 <property name="plugin.main.version" value="14153" /> 8 8 <property name="plugin.author" value="Christoph Wagner" /> 9 9 <property name="plugin.class" value="org.openstreetmap.josm.plugins.trustosm.TrustOSMplugin" /> -
applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/TrustOSMplugin.java
r33869 r34565 27 27 import javax.swing.JMenuItem; 28 28 29 import org.openstreetmap.josm.Main;30 29 import org.openstreetmap.josm.actions.ExtensionFileFilter; 30 import org.openstreetmap.josm.data.Preferences; 31 31 import org.openstreetmap.josm.gui.MainApplication; 32 32 import org.openstreetmap.josm.gui.MainMenu; … … 42 42 import org.openstreetmap.josm.plugins.trustosm.io.SigImporter; 43 43 import org.openstreetmap.josm.plugins.trustosm.util.TrustGPG; 44 import org.openstreetmap.josm.spi.preferences.Config; 44 45 import org.openstreetmap.josm.tools.Logging; 45 46 … … 65 66 super(info); 66 67 // check if the jarlibs are already extracted or not and extract them if not 67 /*if (! Main.pref.getBoolean("trustosm.jarLibsExtracted")) {68 Main.pref.put("trustosm.jarLibsExtracted", extractFiles("trustosm","lib"));69 Main.pref.put("trustosm.jarLibsExtracted", extractFiles("trustosm","resources"));68 /*if (!Config.getPref().getBoolean("trustosm.jarLibsExtracted")) { 69 Config.getPref().put("trustosm.jarLibsExtracted", extractFiles("trustosm","lib")); 70 Config.getPref().put("trustosm.jarLibsExtracted", extractFiles("trustosm","resources")); 70 71 }*/ 71 72 extractFiles("trustosm", "lib"); … … 161 162 String cmd = "sh -c sudo -S mv "+sysSecPath+"/local_policy.jar "+sysSecPath+"/local_policy.jar.restricted"; 162 163 /* String cmd2 = "sudo -S mv "+sysSecPath+"/US_export_policy.jar "+sysSecPath+"/US_export_policy.jar.restricted"; 163 String cmd3 = "sudo -S cp "+ Main.pref.getPluginsDirectory().getPath()+"/trustosm/jce/US_export_policy.jar "+sysSecPath;164 String cmd4 = "sudo -S cp "+ Main.pref.getPluginsDirectory().getPath()+"/trustosm/jce/local_policy.jar "+sysSecPath;164 String cmd3 = "sudo -S cp "+Config.getPref().getPluginsDirectory().getPath()+"/trustosm/jce/US_export_policy.jar "+sysSecPath; 165 String cmd4 = "sudo -S cp "+Config.getPref().getPluginsDirectory().getPath()+"/trustosm/jce/local_policy.jar "+sysSecPath; 165 166 166 167 … … 226 227 public static boolean extractFiles(String pluginname, String extractDir) { 227 228 if (extractDir == null) extractDir = "lib"; 228 String path = Main.pref.getPluginsDirectory().getPath();229 String path = Preferences.main().getPluginsDirectory().getPath(); 229 230 try (JarFile jar = new JarFile(path+"/"+pluginname+".jar")) { 230 231 Enumeration<JarEntry> entries = jar.entries(); … … 265 266 266 267 public static void setSettings() { 267 Map<String, String> prefs = Main.pref.getAllPrefix("trustosm.");268 Map<String, String> prefs = Preferences.main().getAllPrefix("trustosm."); 268 269 269 270 // if setting isn't present, we set a default 270 271 // This makes sense for example when we start the plugin for the first time 271 if (!prefs.containsKey("trustosm.gpg")) Main.pref.put("trustosm.gpg", "gpg");272 if (!prefs.containsKey("trustosm.gpg.separateHomedir")) Main.pref.putBoolean("trustosm.gpg.separateHomedir", true);272 if (!prefs.containsKey("trustosm.gpg")) Config.getPref().put("trustosm.gpg", "gpg"); 273 if (!prefs.containsKey("trustosm.gpg.separateHomedir")) Config.getPref().putBoolean("trustosm.gpg.separateHomedir", true); 273 274 } 274 275 … … 287 288 288 289 public static String getGpgPath() { 289 return Main.pref.getPluginsDirectory().getPath() + "/trustosm/gnupg/";290 return Preferences.main().getPluginsDirectory().getPath() + "/trustosm/gnupg/"; 290 291 } 291 292 } -
applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/actions/GetMissingDataAction.java
r33536 r34565 12 12 import javax.swing.JOptionPane; 13 13 14 import org.openstreetmap.josm.Main;15 14 import org.openstreetmap.josm.actions.JosmAction; 16 15 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 43 42 int itemCount = trustitems.size(); 44 43 if (missingCount == 0) { 45 JOptionPane.showMessageDialog(Main .parent, tr("{0} Signatures loaded. All referenced OSM objects found.", itemCount));44 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), tr("{0} Signatures loaded. All referenced OSM objects found.", itemCount)); 46 45 } else { 47 int n = JOptionPane.showOptionDialog(Main .parent,46 int n = JOptionPane.showOptionDialog(MainApplication.getMainFrame(), 48 47 tr("{0} of {1} OSM objects are referenced but not there.\nDo you want to load them from OSM-Server?", 49 48 missingCount, itemCount), -
applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/gui/dialogs/TrustDialog.java
r33536 r34565 493 493 content.setMaximumSize(new Dimension(600, 500)); 494 494 content.add(scroller); 495 JOptionPane.showMessageDialog(Main .parent,content, tr("Clearsigned Signature"), JOptionPane.PLAIN_MESSAGE);495 JOptionPane.showMessageDialog(MainApplication.getMainFrame(),content, tr("Clearsigned Signature"), JOptionPane.PLAIN_MESSAGE); 496 496 } 497 497 } -
applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/gui/dialogs/TrustPreferenceEditor.java
r33869 r34565 16 16 import javax.swing.JTabbedPane; 17 17 18 import org.openstreetmap.josm.Main;19 18 import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting; 20 19 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; 21 20 import org.openstreetmap.josm.plugins.trustosm.TrustOSMplugin; 21 import org.openstreetmap.josm.spi.preferences.Config; 22 22 import org.openstreetmap.josm.tools.GBC; 23 23 … … 50 50 gpgdirGroup.add(defaultHomedir); 51 51 52 if ( Main.pref.getBoolean("trustosm.gpg.separateHomedir")) {52 if (Config.getPref().getBoolean("trustosm.gpg.separateHomedir")) { 53 53 separateHomedir.setSelected(true); 54 54 } else … … 70 70 @Override 71 71 public boolean ok() { 72 Main.pref.putBoolean("trustosm.gpg.showSignedDeleted", showSignedDeleted.isSelected());73 Main.pref.putBoolean("trustosm.gpg.separateHomedir", separateHomedir.isSelected());72 Config.getPref().putBoolean("trustosm.gpg.showSignedDeleted", showSignedDeleted.isSelected()); 73 Config.getPref().putBoolean("trustosm.gpg.separateHomedir", separateHomedir.isSelected()); 74 74 return false; 75 75 } -
applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/gui/dialogs/TrustSignaturesDialog.java
r33536 r34565 21 21 import org.bouncycastle.openpgp.PGPSignature; 22 22 import org.jdesktop.swingx.JXTreeTable; 23 import org.openstreetmap.josm.Main;24 23 import org.openstreetmap.josm.data.osm.DefaultNameFormatter; 25 24 import org.openstreetmap.josm.data.osm.Node; 26 25 import org.openstreetmap.josm.gui.ExtendedDialog; 26 import org.openstreetmap.josm.gui.MainApplication; 27 27 import org.openstreetmap.josm.plugins.trustosm.TrustOSMplugin; 28 28 import org.openstreetmap.josm.plugins.trustosm.data.TrustNode; … … 99 99 scroller.setPreferredSize(new Dimension(700, 500)); 100 100 String[] buttons = {tr("Ok")}; 101 ExtendedDialog info = new ExtendedDialog(Main .parent, tr("Signature Info"), buttons, false);101 ExtendedDialog info = new ExtendedDialog(MainApplication.getMainFrame(), tr("Signature Info"), buttons, false); 102 102 info.setContent(scroller, false); 103 103 info.showDialog(); … … 164 164 165 165 p.add(createKeyButton(uid,pub.getKeyID())); 166 JOptionPane.showMessageDialog(Main .parent,p, tr("Key Signatures"), JOptionPane.PLAIN_MESSAGE);166 JOptionPane.showMessageDialog(MainApplication.getMainFrame(),p, tr("Key Signatures"), JOptionPane.PLAIN_MESSAGE); 167 167 } 168 168 -
applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/io/SigExporter.java
r33573 r34565 10 10 import javax.swing.JOptionPane; 11 11 12 import org.openstreetmap.josm.Main;13 12 import org.openstreetmap.josm.actions.ExtensionFileFilter; 13 import org.openstreetmap.josm.gui.MainApplication; 14 14 import org.openstreetmap.josm.gui.io.importexport.FileExporter; 15 15 import org.openstreetmap.josm.gui.layer.Layer; … … 42 42 } catch (IOException x) { 43 43 x.printStackTrace(); 44 JOptionPane.showMessageDialog(Main .parent, tr("Error while exporting {0}:\n{1}", fn, x.getMessage()),44 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), tr("Error while exporting {0}:\n{1}", fn, x.getMessage()), 45 45 tr("Error"), JOptionPane.ERROR_MESSAGE); 46 46 } -
applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/io/SigImporter.java
r33573 r34565 56 56 int itemCount = trustitems.size(); 57 57 if (missingCount == 0) { 58 JOptionPane.showMessageDialog(Main .parent, tr("{0} Signatures loaded. All referenced OSM objects found.",itemCount));58 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), tr("{0} Signatures loaded. All referenced OSM objects found.",itemCount)); 59 59 } else { 60 int n = JOptionPane.showOptionDialog(Main .parent,60 int n = JOptionPane.showOptionDialog(MainApplication.getMainFrame(), 61 61 tr("{0} of {1} OSM objects are referenced but not there.\nDo you want to load them from OSM-Server?",missingCount,itemCount), 62 62 tr("Load objects from server"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); 63 63 64 64 if (n == JOptionPane.YES_OPTION) { 65 Main.worker.submit(new DownloadSignedOsmDataTask(missingData, Main.main.getEditLayer()));65 Main.worker.submit(new DownloadSignedOsmDataTask(missingData, OsmDataManager.getInstance().getEditLayer())); 66 66 } 67 67 } -
applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/util/TrustAnalyzer.java
r32533 r34565 12 12 13 13 import org.bouncycastle.openpgp.PGPSignature; 14 import org.openstreetmap.josm.Main;15 14 import org.openstreetmap.josm.data.osm.Node; 16 15 import org.openstreetmap.josm.data.osm.Way; 16 import org.openstreetmap.josm.gui.MainApplication; 17 17 import org.openstreetmap.josm.plugins.trustosm.TrustOSMplugin; 18 18 import org.openstreetmap.josm.plugins.trustosm.data.TrustNode; … … 28 28 29 29 public static void showManipulationWarning() { 30 JOptionPane.showMessageDialog(Main .parent, tr("The Signature is broken!"), tr("Manipulation Warning"), JOptionPane.WARNING_MESSAGE);30 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), tr("The Signature is broken!"), tr("Manipulation Warning"), JOptionPane.WARNING_MESSAGE); 31 31 } 32 32 -
applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/util/TrustGPG.java
r33536 r34565 85 85 import org.bouncycastle.openpgp.operator.jcajce.JcePBESecretKeyEncryptorBuilder; 86 86 import org.bouncycastle.util.encoders.Hex; 87 import org.openstreetmap.josm. Main;87 import org.openstreetmap.josm.data.Preferences; 88 88 import org.openstreetmap.josm.data.osm.Node; 89 89 import org.openstreetmap.josm.data.osm.OsmPrimitive; 90 90 import org.openstreetmap.josm.data.osm.Way; 91 import org.openstreetmap.josm.gui.MainApplication; 91 92 import org.openstreetmap.josm.plugins.trustosm.data.TrustNode; 92 93 import org.openstreetmap.josm.plugins.trustosm.data.TrustOsmPrimitive; … … 158 159 Logging.error(e); 159 160 Logging.error("GPG Key Ring File could not be created in: "+ 160 Main.pref.getPluginsDirectory().getPath() + "/trustosm/gnupg/secring.gpg");161 Preferences.main().getPluginsDirectory().getPath() + "/trustosm/gnupg/secring.gpg"); 161 162 } 162 163 } … … 249 250 p.add(Box.createRigidArea(d)); 250 251 251 int n = JOptionPane.showOptionDialog(Main .parent, p, tr("Select a Key to sign"),252 int n = JOptionPane.showOptionDialog(MainApplication.getMainFrame(), p, tr("Select a Key to sign"), 252 253 JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, ImageProvider.get("keyring"), null, null); 253 254 … … 269 270 FileInputStream secIn; 270 271 try { 271 pubIn = new FileInputStream( Main.pref.getPluginsDirectory().getPath() + "/trustosm/gnupg/secring.gpg");272 secIn = new FileInputStream( Main.pref.getPluginsDirectory().getPath() + "/trustosm/gnupg/pubring.gpg");272 pubIn = new FileInputStream(Preferences.main().getPluginsDirectory().getPath() + "/trustosm/gnupg/secring.gpg"); 273 secIn = new FileInputStream(Preferences.main().getPluginsDirectory().getPath() + "/trustosm/gnupg/pubring.gpg"); 273 274 //pubIn = new FileInputStream("/tmp/secring.gpg"); 274 275 //secIn = new FileInputStream("/tmp/pubring.gpg"); … … 276 277 pgpPub = new BcPGPPublicKeyRingCollection(PGPUtil.getDecoderStream(secIn)); 277 278 } catch (FileNotFoundException e) { 278 System.err.println("No gpg files found in "+ Main.pref.getPluginsDirectory().getPath() + "/trustosm/gnupg/secring.gpg");279 System.err.println("No gpg files found in "+Preferences.main().getPluginsDirectory().getPath() + "/trustosm/gnupg/secring.gpg"); 279 280 pgpSec = null; 280 281 pgpPub = null; … … 284 285 285 286 public void writeGpgFiles() throws FileNotFoundException, IOException { 286 String path = Main.pref.getPluginsDirectory().getPath();287 String path = Preferences.main().getPluginsDirectory().getPath(); 287 288 try (FileOutputStream pubOut = new FileOutputStream(path + "/trustosm/gnupg/pubring.gpg"); 288 289 FileOutputStream secOut = new FileOutputStream(path + "/trustosm/gnupg/secring.gpg")) { … … 313 314 314 315 /*final JPasswordField passwordField = new JPasswordField(10); 315 JOptionPane.showMessageDialog(Main .parent, passwordField, "Enter password", JOptionPane.OK_OPTION, ImageProvider.get("lock"));316 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), passwordField, "Enter password", JOptionPane.OK_OPTION, ImageProvider.get("lock")); 316 317 password = passwordField.getPassword(); 317 318 */ … … 348 349 public void invalidIDWarning(OsmPrimitive osm) { 349 350 // CHECKSTYLE.OFF: LineLength 350 JOptionPane.showMessageDialog(Main .parent,351 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), 351 352 tr("The object with the ID \"{0}\" ({1}) is newly created.\nYou can not sign it, because the signature would lose the ID-Reference after uploading it to the OSM-server.", 352 353 osm.getUniqueId(), osm.toString()), … … 476 477 p.add(new JLabel(tr("meters")), GBC.eol()); 477 478 478 int n = JOptionPane.showOptionDialog(Main .parent, p, tr("Accuracy"),479 int n = JOptionPane.showOptionDialog(MainApplication.getMainFrame(), p, tr("Accuracy"), 479 480 JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); 480 481 … … 503 504 p.add(trusted, GBC.eol()); 504 505 505 int n = JOptionPane.showOptionDialog(Main .parent, p, tr("Which source did you use?"),506 int n = JOptionPane.showOptionDialog(MainApplication.getMainFrame(), p, tr("Which source did you use?"), 506 507 JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); 507 508 … … 699 700 // metaPanel.add(sp); 700 701 701 JOptionPane.showMessageDialog(Main .parent, p, tr("PGP-Key details"), JOptionPane.INFORMATION_MESSAGE);702 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), p, tr("PGP-Key details"), JOptionPane.INFORMATION_MESSAGE); 702 703 } 703 704 … … 706 707 707 708 JTextField userId = new JTextField(); 708 NameGenerator nameGen = new NameGenerator( Main.pref.getPluginsDirectory().getPath()+"/trustosm/resources/syllables.txt");709 NameGenerator nameGen = new NameGenerator(Preferences.main().getPluginsDirectory().getPath()+"/trustosm/resources/syllables.txt"); 709 710 userId.setText(nameGen.compose(3)); 710 711 … … 793 794 16, 6); //xPad, yPad 794 795 795 int n = JOptionPane.showOptionDialog(Main .parent, p, tr("Create a new signing key"),796 int n = JOptionPane.showOptionDialog(MainApplication.getMainFrame(), p, tr("Create a new signing key"), 796 797 JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); 797 798
Note:
See TracChangeset
for help on using the changeset viewer.