Changeset 34565 in osm


Ignore:
Timestamp:
2018-08-18T20:35:07+02:00 (6 years ago)
Author:
donvip
Message:

update to JOSM 14153

Location:
applications/editors/josm/plugins/trustosm
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/trustosm/build.xml

    r33869 r34565  
    55    <property name="commit.message" value="New plugin for digital signing osm data"/>
    66    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    7     <property name="plugin.main.version" value="12840" />
     7    <property name="plugin.main.version" value="14153" />
    88    <property name="plugin.author" value="Christoph Wagner" />
    99    <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  
    2727import javax.swing.JMenuItem;
    2828
    29 import org.openstreetmap.josm.Main;
    3029import org.openstreetmap.josm.actions.ExtensionFileFilter;
     30import org.openstreetmap.josm.data.Preferences;
    3131import org.openstreetmap.josm.gui.MainApplication;
    3232import org.openstreetmap.josm.gui.MainMenu;
     
    4242import org.openstreetmap.josm.plugins.trustosm.io.SigImporter;
    4343import org.openstreetmap.josm.plugins.trustosm.util.TrustGPG;
     44import org.openstreetmap.josm.spi.preferences.Config;
    4445import org.openstreetmap.josm.tools.Logging;
    4546
     
    6566        super(info);
    6667        // 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"));
    7071        }*/
    7172        extractFiles("trustosm", "lib");
     
    161162        String cmd = "sh -c sudo -S mv "+sysSecPath+"/local_policy.jar "+sysSecPath+"/local_policy.jar.restricted";
    162163        /*        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;
    165166
    166167
     
    226227    public static boolean extractFiles(String pluginname, String extractDir) {
    227228        if (extractDir == null) extractDir = "lib";
    228         String path = Main.pref.getPluginsDirectory().getPath();
     229        String path = Preferences.main().getPluginsDirectory().getPath();
    229230        try (JarFile jar = new JarFile(path+"/"+pluginname+".jar")) {
    230231            Enumeration<JarEntry> entries = jar.entries();
     
    265266
    266267    public static void setSettings() {
    267         Map<String, String> prefs = Main.pref.getAllPrefix("trustosm.");
     268        Map<String, String> prefs = Preferences.main().getAllPrefix("trustosm.");
    268269
    269270        // if setting isn't present, we set a default
    270271        // 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);
    273274    }
    274275
     
    287288
    288289    public static String getGpgPath() {
    289         return Main.pref.getPluginsDirectory().getPath() + "/trustosm/gnupg/";
     290        return Preferences.main().getPluginsDirectory().getPath() + "/trustosm/gnupg/";
    290291    }
    291292}
  • applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/actions/GetMissingDataAction.java

    r33536 r34565  
    1212import javax.swing.JOptionPane;
    1313
    14 import org.openstreetmap.josm.Main;
    1514import org.openstreetmap.josm.actions.JosmAction;
    1615import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    4342        int itemCount = trustitems.size();
    4443        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));
    4645        } else {
    47             int n = JOptionPane.showOptionDialog(Main.parent,
     46            int n = JOptionPane.showOptionDialog(MainApplication.getMainFrame(),
    4847                    tr("{0} of {1} OSM objects are referenced but not there.\nDo you want to load them from OSM-Server?",
    4948                            missingCount, itemCount),
  • applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/gui/dialogs/TrustDialog.java

    r33536 r34565  
    493493            content.setMaximumSize(new Dimension(600, 500));
    494494            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);
    496496        }
    497497    }
  • applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/gui/dialogs/TrustPreferenceEditor.java

    r33869 r34565  
    1616import javax.swing.JTabbedPane;
    1717
    18 import org.openstreetmap.josm.Main;
    1918import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
    2019import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    2120import org.openstreetmap.josm.plugins.trustosm.TrustOSMplugin;
     21import org.openstreetmap.josm.spi.preferences.Config;
    2222import org.openstreetmap.josm.tools.GBC;
    2323
     
    5050        gpgdirGroup.add(defaultHomedir);
    5151
    52         if (Main.pref.getBoolean("trustosm.gpg.separateHomedir")) {
     52        if (Config.getPref().getBoolean("trustosm.gpg.separateHomedir")) {
    5353            separateHomedir.setSelected(true);
    5454        } else
     
    7070    @Override
    7171    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());
    7474        return false;
    7575    }
  • applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/gui/dialogs/TrustSignaturesDialog.java

    r33536 r34565  
    2121import org.bouncycastle.openpgp.PGPSignature;
    2222import org.jdesktop.swingx.JXTreeTable;
    23 import org.openstreetmap.josm.Main;
    2423import org.openstreetmap.josm.data.osm.DefaultNameFormatter;
    2524import org.openstreetmap.josm.data.osm.Node;
    2625import org.openstreetmap.josm.gui.ExtendedDialog;
     26import org.openstreetmap.josm.gui.MainApplication;
    2727import org.openstreetmap.josm.plugins.trustosm.TrustOSMplugin;
    2828import org.openstreetmap.josm.plugins.trustosm.data.TrustNode;
     
    9999        scroller.setPreferredSize(new Dimension(700, 500));
    100100        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);
    102102        info.setContent(scroller, false);
    103103        info.showDialog();
     
    164164
    165165        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);
    167167    }
    168168
  • applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/io/SigExporter.java

    r33573 r34565  
    1010import javax.swing.JOptionPane;
    1111
    12 import org.openstreetmap.josm.Main;
    1312import org.openstreetmap.josm.actions.ExtensionFileFilter;
     13import org.openstreetmap.josm.gui.MainApplication;
    1414import org.openstreetmap.josm.gui.io.importexport.FileExporter;
    1515import org.openstreetmap.josm.gui.layer.Layer;
     
    4242        } catch (IOException x) {
    4343            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()),
    4545                    tr("Error"), JOptionPane.ERROR_MESSAGE);
    4646        }
  • applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/io/SigImporter.java

    r33573 r34565  
    5656        int itemCount = trustitems.size();
    5757        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));
    5959        } else {
    60             int n = JOptionPane.showOptionDialog(Main.parent,
     60            int n = JOptionPane.showOptionDialog(MainApplication.getMainFrame(),
    6161            tr("{0} of {1} OSM objects are referenced but not there.\nDo you want to load them from OSM-Server?",missingCount,itemCount),
    6262            tr("Load objects from server"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
    6363
    6464            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()));
    6666            }
    6767        }
  • applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/util/TrustAnalyzer.java

    r32533 r34565  
    1212
    1313import org.bouncycastle.openpgp.PGPSignature;
    14 import org.openstreetmap.josm.Main;
    1514import org.openstreetmap.josm.data.osm.Node;
    1615import org.openstreetmap.josm.data.osm.Way;
     16import org.openstreetmap.josm.gui.MainApplication;
    1717import org.openstreetmap.josm.plugins.trustosm.TrustOSMplugin;
    1818import org.openstreetmap.josm.plugins.trustosm.data.TrustNode;
     
    2828
    2929    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);
    3131    }
    3232
  • applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/util/TrustGPG.java

    r33536 r34565  
    8585import org.bouncycastle.openpgp.operator.jcajce.JcePBESecretKeyEncryptorBuilder;
    8686import org.bouncycastle.util.encoders.Hex;
    87 import org.openstreetmap.josm.Main;
     87import org.openstreetmap.josm.data.Preferences;
    8888import org.openstreetmap.josm.data.osm.Node;
    8989import org.openstreetmap.josm.data.osm.OsmPrimitive;
    9090import org.openstreetmap.josm.data.osm.Way;
     91import org.openstreetmap.josm.gui.MainApplication;
    9192import org.openstreetmap.josm.plugins.trustosm.data.TrustNode;
    9293import org.openstreetmap.josm.plugins.trustosm.data.TrustOsmPrimitive;
     
    158159                Logging.error(e);
    159160                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");
    161162            }
    162163        }
     
    249250        p.add(Box.createRigidArea(d));
    250251
    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"),
    252253                JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, ImageProvider.get("keyring"), null, null);
    253254
     
    269270        FileInputStream secIn;
    270271        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");
    273274            //pubIn = new FileInputStream("/tmp/secring.gpg");
    274275            //secIn = new FileInputStream("/tmp/pubring.gpg");
     
    276277            pgpPub = new BcPGPPublicKeyRingCollection(PGPUtil.getDecoderStream(secIn));
    277278        } 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");
    279280            pgpSec = null;
    280281            pgpPub = null;
     
    284285
    285286    public void writeGpgFiles() throws FileNotFoundException, IOException {
    286         String path = Main.pref.getPluginsDirectory().getPath();
     287        String path = Preferences.main().getPluginsDirectory().getPath();
    287288        try (FileOutputStream pubOut = new FileOutputStream(path + "/trustosm/gnupg/pubring.gpg");
    288289                FileOutputStream secOut = new FileOutputStream(path + "/trustosm/gnupg/secring.gpg")) {
     
    313314
    314315        /*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"));
    316317        password = passwordField.getPassword();
    317318         */
     
    348349    public void invalidIDWarning(OsmPrimitive osm) {
    349350        // CHECKSTYLE.OFF: LineLength
    350         JOptionPane.showMessageDialog(Main.parent,
     351        JOptionPane.showMessageDialog(MainApplication.getMainFrame(),
    351352                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.",
    352353                        osm.getUniqueId(), osm.toString()),
     
    476477        p.add(new JLabel(tr("meters")), GBC.eol());
    477478
    478         int n = JOptionPane.showOptionDialog(Main.parent, p, tr("Accuracy"),
     479        int n = JOptionPane.showOptionDialog(MainApplication.getMainFrame(), p, tr("Accuracy"),
    479480                JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
    480481
     
    503504        p.add(trusted, GBC.eol());
    504505
    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?"),
    506507                JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
    507508
     
    699700        //        metaPanel.add(sp);
    700701
    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);
    702703    }
    703704
     
    706707
    707708        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");
    709710        userId.setText(nameGen.compose(3));
    710711
     
    793794                16, 6);      //xPad, yPad
    794795
    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"),
    796797                JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
    797798
Note: See TracChangeset for help on using the changeset viewer.