Changeset 30744 in osm for applications/editors/josm
- Timestamp:
- 2014-10-19T03:40:37+02:00 (10 years ago)
- Location:
- applications/editors/josm/plugins/trustosm
- Files:
-
- 6 edited
- 4 moved
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/trustosm/build.xml
r30743 r30744 101 101 <attribute name="Plugin-Date" value="${version.entry.commit.date}"/> 102 102 <attribute name="Plugin-Description" value="Plugin to digital sign OSM-Data"/> 103 <attribute name="Plugin-Icon" value=" trustosm"/>104 < attribute name="Plugin-Link" value="..."/>103 <attribute name="Plugin-Icon" value="images/trustosm.png"/> 104 <!--<attribute name="Plugin-Link" value="..."/>--> 105 105 <attribute name="Plugin-Mainversion" value="${plugin.main.version}"/> 106 106 <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/> -
applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/data/TrustSignatures.java
r30742 r30744 127 127 if (textsigs.containsKey(plain)){ 128 128 List<PGPSignature> l = textsigs.get(plain); 129 ByteArrayOutputStream baos = new ByteArrayOutputStream(); 130 try (ArmoredOutputStream aOut = new ArmoredOutputStream(baos)) { 131 aOut.beginClearText(l.get(0).getHashAlgorithm()); 132 aOut.write(plain.getBytes(Charset.forName("UTF-8"))); 133 aOut.write('\n'); 134 aOut.endClearText(); 129 PGPSignature first = l.get(0); 130 if (first != null) { 131 ByteArrayOutputStream baos = new ByteArrayOutputStream(); 132 try (ArmoredOutputStream aOut = new ArmoredOutputStream(baos)) { 133 aOut.beginClearText(first.getHashAlgorithm()); 134 aOut.write(plain.getBytes(Charset.forName("UTF-8"))); 135 aOut.write('\n'); 136 aOut.endClearText(); 135 137 136 try (BCPGOutputStream bOut = new BCPGOutputStream(aOut)) { 137 for (PGPSignature sig : l) { 138 sig.encode(bOut); 138 try (BCPGOutputStream bOut = new BCPGOutputStream(aOut)) { 139 for (PGPSignature sig : l) { 140 sig.encode(bOut); 141 } 139 142 } 143 144 return baos.toString("UTF-8"); 145 146 } catch (Exception e) { 147 Main.error(e); 148 return "Error - read console Output"; 140 149 } 141 142 return baos.toString("UTF-8");143 144 } catch (Exception e) {145 Main.error(e);146 return "Error - read console Output";147 150 } 148 151 } -
applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/gui/KeyTreeTableModel.java
r30724 r30744 42 42 public KeyTreeTableModel(Collection<PGPSignature> sigs) { 43 43 root = new SignatureTreeNode(); 44 for (PGPSignature s : sigs){ 45 SignatureTreeNode sn = new SignatureTreeNode(s); 46 PGPPublicKey pub = TrustOSMplugin.gpg.getPublicKeyFromRing(s.getKeyID()); 47 Iterator<?> iter = pub.getSignatures(); 48 while (iter.hasNext()){ 49 PGPSignature ks = (PGPSignature)iter.next(); 50 sn.getChildren().add(new SignatureTreeNode(ks)); 44 for (PGPSignature s : sigs) { 45 if (s != null) { 46 SignatureTreeNode sn = new SignatureTreeNode(s); 47 PGPPublicKey pub = TrustOSMplugin.gpg.getPublicKeyFromRing(s.getKeyID()); 48 Iterator<?> iter = pub.getSignatures(); 49 while (iter.hasNext()){ 50 PGPSignature ks = (PGPSignature)iter.next(); 51 sn.getChildren().add(new SignatureTreeNode(ks)); 52 } 53 root.getChildren().add(sn); 51 54 } 52 root.getChildren().add(sn);53 55 } 54 56 } -
applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/gui/dialogs/TrustDialog.java
r30742 r30744 331 331 @Override 332 332 public void actionPerformed(ActionEvent e) { 333 for (OsmPrimitive osm : osmData) { 334 String id = TrustOsmPrimitive.createUniqueObjectIdentifier(osm); 335 if (TrustOSMplugin.signedItems.containsKey(id)) 336 TrustAnalyzer.checkEverything(TrustOSMplugin.signedItems.get(id)); 337 //checkedItems.put(osm, TrustOSMplugin.gpg.check(checkedItems.containsKey(osm)? checkedItems.get(osm) : new TrustOSMItem(osm))); 333 if (osmData != null) { 334 for (OsmPrimitive osm : osmData) { 335 String id = TrustOsmPrimitive.createUniqueObjectIdentifier(osm); 336 if (TrustOSMplugin.signedItems.containsKey(id)) 337 TrustAnalyzer.checkEverything(TrustOSMplugin.signedItems.get(id)); 338 //checkedItems.put(osm, TrustOSMplugin.gpg.check(checkedItems.containsKey(osm)? checkedItems.get(osm) : new TrustOSMItem(osm))); 339 } 338 340 } 339 341 updateTable(); … … 350 352 @Override 351 353 public void actionPerformed(ActionEvent e) { 352 for (int i : propertyTable.getSelectedRows()) { 353 String key = (String)propertyTable.getValueAt(i, 0); 354 for (OsmPrimitive osm : osmData) { 355 if (osm.keySet().contains(key)) { 356 String id = TrustOsmPrimitive.createUniqueObjectIdentifier(osm); 357 TrustOsmPrimitive trust = TrustOSMplugin.signedItems.containsKey(id)? TrustOSMplugin.signedItems.get(id) : TrustOsmPrimitive.createTrustOsmPrimitive(osm); 358 if (TrustOSMplugin.gpg.signTag(trust, key)) 359 TrustOSMplugin.signedItems.put(id, trust); 354 if (osmData != null) { 355 for (int i : propertyTable.getSelectedRows()) { 356 String key = (String)propertyTable.getValueAt(i, 0); 357 for (OsmPrimitive osm : osmData) { 358 if (osm.keySet().contains(key)) { 359 String id = TrustOsmPrimitive.createUniqueObjectIdentifier(osm); 360 TrustOsmPrimitive trust = TrustOSMplugin.signedItems.containsKey(id)? TrustOSMplugin.signedItems.get(id) : TrustOsmPrimitive.createTrustOsmPrimitive(osm); 361 if (TrustOSMplugin.gpg.signTag(trust, key)) 362 TrustOSMplugin.signedItems.put(id, trust); 363 } 360 364 } 361 365 } … … 421 425 @Override 422 426 public void actionPerformed(ActionEvent e) { 423 for (int i : propertyTable.getSelectedRows()) { 424 String key = (String)propertyTable.getValueAt(i, 0); 425 for (OsmPrimitive osm : osmData) { 426 String id = TrustOsmPrimitive.createUniqueObjectIdentifier(osm); 427 if (osm.keySet().contains(key) && TrustOSMplugin.signedItems.containsKey(id)) { 428 TrustSignaturesDialog.showSignaturesDialog(TrustOSMplugin.signedItems.get(id), key); 427 if (osmData != null) { 428 for (int i : propertyTable.getSelectedRows()) { 429 String key = (String)propertyTable.getValueAt(i, 0); 430 for (OsmPrimitive osm : osmData) { 431 String id = TrustOsmPrimitive.createUniqueObjectIdentifier(osm); 432 if (osm.keySet().contains(key) && TrustOSMplugin.signedItems.containsKey(id)) { 433 TrustSignaturesDialog.showSignaturesDialog(TrustOSMplugin.signedItems.get(id), key); 434 } 429 435 } 430 436 } … … 556 562 boolean sigsAvailable = false; 557 563 558 for (OsmPrimitive osm : osmData) { 559 String id = TrustOsmPrimitive.createUniqueObjectIdentifier(osm); 560 if (TrustOSMplugin.signedItems.containsKey(id)) { 561 trust = TrustOSMplugin.signedItems.get(id); 562 sigsAvailable = true; 563 /* 564 Map<String,String> tags = osm.getKeys(); 565 Map<String, TrustSignatures> signedTags = trust.getTagSigs(); 566 HashSet<String> removedKeys = new HashSet<String>(signedTags.keySet()); 567 removedKeys.removeAll(tags.keySet()); 568 for (String removedKey: removedKeys) { 569 TrustSignatures sigs = signedTags.get(removedKey); 570 sigs.setStatus( TrustSignatures.ITEM_REMOVED ); 571 String[] kv = TrustOsmPrimitive.generateTagsFromSigtext(sigs.getOnePlainText()); 572 tags.put(kv[0],kv[1]); 573 } 574 */ 575 } else { 576 trust = TrustOsmPrimitive.createTrustOsmPrimitive(osm); 577 sigsAvailable = false; 578 } 579 580 // trust = TrustOSMplugin.signedItems.containsKey(osm) ? TrustOSMplugin.signedItems.get(osm) : new TrustOSMItem(osm); 581 582 for (String key: osm.keySet()) { 583 String value = osm.get(key); 584 //keyCount.put(key, keyCount.containsKey(key) ? keyCount.get(key) + 1 : 1); 585 586 byte status = sigsAvailable && trust.getTagSigs().containsKey(key) ? trust.getTagSigs().get(key).getStatus() : TrustSignatures.SIG_UNKNOWN ; 587 Byte oldstatus = rowStatus.containsKey(key)? rowStatus.get(key) : new Byte(TrustSignatures.SIG_VALID); 588 Byte sigstatus = new Byte(status); 589 Byte newstatus; 590 if (sigstatus.equals(new Byte(TrustSignatures.SIG_BROKEN)) || oldstatus.equals(new Byte(TrustSignatures.SIG_BROKEN))) { 591 newstatus = new Byte(TrustSignatures.SIG_BROKEN); 592 } else if (sigstatus.equals(new Byte(TrustSignatures.SIG_UNKNOWN)) || oldstatus.equals(new Byte(TrustSignatures.SIG_UNKNOWN))) { 593 newstatus = new Byte(TrustSignatures.SIG_UNKNOWN); 594 } else newstatus = new Byte(TrustSignatures.SIG_VALID); 595 596 rowStatus.put(key, newstatus ); 597 if (valueCount.containsKey(key)) { 598 Map<String, Integer> v = valueCount.get(key); 599 v.put(value, v.containsKey(value)? v.get(value) + 1 : 1 ); 564 if (osmData != null) { 565 for (OsmPrimitive osm : osmData) { 566 String id = TrustOsmPrimitive.createUniqueObjectIdentifier(osm); 567 if (TrustOSMplugin.signedItems.containsKey(id)) { 568 trust = TrustOSMplugin.signedItems.get(id); 569 sigsAvailable = true; 570 /* 571 Map<String,String> tags = osm.getKeys(); 572 Map<String, TrustSignatures> signedTags = trust.getTagSigs(); 573 HashSet<String> removedKeys = new HashSet<String>(signedTags.keySet()); 574 removedKeys.removeAll(tags.keySet()); 575 for (String removedKey: removedKeys) { 576 TrustSignatures sigs = signedTags.get(removedKey); 577 sigs.setStatus( TrustSignatures.ITEM_REMOVED ); 578 String[] kv = TrustOsmPrimitive.generateTagsFromSigtext(sigs.getOnePlainText()); 579 tags.put(kv[0],kv[1]); 580 } 581 */ 600 582 } else { 601 TreeMap<String,Integer> v = new TreeMap<>(); 602 v.put(value, 1); 603 valueCount.put(key, v); 604 } 605 } 606 } 607 for (Entry<String, Map<String, Integer>> e : valueCount.entrySet()) { 608 int count=0; 609 for (Entry<String, Integer> e1: e.getValue().entrySet()) { 610 count+=e1.getValue(); 611 } 612 if (count < osmData.size()) { 613 e.getValue().put("", osmData.size()-count); 614 } 615 propertyData.addRow(new Object[]{e.getKey(), e.getValue()}); 616 } 617 618 619 boolean hasSelection = !osmData.isEmpty(); 583 trust = TrustOsmPrimitive.createTrustOsmPrimitive(osm); 584 sigsAvailable = false; 585 } 586 587 // trust = TrustOSMplugin.signedItems.containsKey(osm) ? TrustOSMplugin.signedItems.get(osm) : new TrustOSMItem(osm); 588 589 for (String key: osm.keySet()) { 590 String value = osm.get(key); 591 //keyCount.put(key, keyCount.containsKey(key) ? keyCount.get(key) + 1 : 1); 592 593 byte status = sigsAvailable && trust.getTagSigs().containsKey(key) ? trust.getTagSigs().get(key).getStatus() : TrustSignatures.SIG_UNKNOWN ; 594 Byte oldstatus = rowStatus.containsKey(key)? rowStatus.get(key) : new Byte(TrustSignatures.SIG_VALID); 595 Byte sigstatus = new Byte(status); 596 Byte newstatus; 597 if (sigstatus.equals(new Byte(TrustSignatures.SIG_BROKEN)) || oldstatus.equals(new Byte(TrustSignatures.SIG_BROKEN))) { 598 newstatus = new Byte(TrustSignatures.SIG_BROKEN); 599 } else if (sigstatus.equals(new Byte(TrustSignatures.SIG_UNKNOWN)) || oldstatus.equals(new Byte(TrustSignatures.SIG_UNKNOWN))) { 600 newstatus = new Byte(TrustSignatures.SIG_UNKNOWN); 601 } else newstatus = new Byte(TrustSignatures.SIG_VALID); 602 603 rowStatus.put(key, newstatus ); 604 if (valueCount.containsKey(key)) { 605 Map<String, Integer> v = valueCount.get(key); 606 v.put(value, v.containsKey(value)? v.get(value) + 1 : 1 ); 607 } else { 608 TreeMap<String,Integer> v = new TreeMap<>(); 609 v.put(value, 1); 610 valueCount.put(key, v); 611 } 612 } 613 } 614 for (Entry<String, Map<String, Integer>> e : valueCount.entrySet()) { 615 int count=0; 616 for (Entry<String, Integer> e1: e.getValue().entrySet()) { 617 count+=e1.getValue(); 618 } 619 if (count < osmData.size()) { 620 e.getValue().put("", osmData.size()-count); 621 } 622 propertyData.addRow(new Object[]{e.getKey(), e.getValue()}); 623 } 624 } 625 626 boolean hasSelection = osmData != null && !osmData.isEmpty(); 620 627 boolean hasTags = hasSelection && propertyData.getRowCount() > 0; 621 628 -
applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/gui/dialogs/TrustSignaturesDialog.java
r30724 r30744 89 89 } 90 90 }); 91 t.setLeafIcon(ImageProvider.get(" dialogs/sign"));92 t.setOpenIcon(ImageProvider.get(" dialogs/sign_color"));93 t.setClosedIcon(ImageProvider.get(" dialogs/sign_color"));91 t.setLeafIcon(ImageProvider.get("sign")); 92 t.setOpenIcon(ImageProvider.get("sign_color")); 93 t.setClosedIcon(ImageProvider.get("sign_color")); 94 94 t.expandAll(); 95 95 t.packAll(); -
applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/util/TrustGPG.java
r30742 r30744 136 136 generateKey(); 137 137 } catch (Exception e) { 138 System.err.println("GPG Key Ring File could not be created in: "+Main.pref.getPluginsDirectory().getPath() + "/trustosm/gnupg/secring.gpg"); 138 Main.error(e); 139 Main.error("GPG Key Ring File could not be created in: "+ 140 Main.pref.getPluginsDirectory().getPath() + "/trustosm/gnupg/secring.gpg"); 139 141 } 140 142 }
Note:
See TracChangeset
for help on using the changeset viewer.