Index: applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/TrustOSMplugin.java
===================================================================
--- applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/TrustOSMplugin.java	(revision 25266)
+++ applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/TrustOSMplugin.java	(revision 25269)
@@ -29,7 +29,7 @@
 import org.openstreetmap.josm.plugins.PluginInformation;
 import org.openstreetmap.josm.plugins.trustosm.actions.ExportSigsAction;
-import org.openstreetmap.josm.plugins.trustosm.data.TrustOSMItem;
+import org.openstreetmap.josm.plugins.trustosm.data.TrustOsmPrimitive;
 import org.openstreetmap.josm.plugins.trustosm.gui.dialogs.TrustDialog;
-import org.openstreetmap.josm.plugins.trustosm.gui.preferences.TrustPreferenceEditor;
+import org.openstreetmap.josm.plugins.trustosm.gui.dialogs.TrustPreferenceEditor;
 import org.openstreetmap.josm.plugins.trustosm.io.SigExporter;
 import org.openstreetmap.josm.plugins.trustosm.io.SigImporter;
@@ -46,5 +46,5 @@
 
 	/** A global list with all OSM-Ids and corresponding TrustOSMItems */
-	public static final Map<String, TrustOSMItem> signedItems = new HashMap<String, TrustOSMItem>();
+	public static final Map<String, TrustOsmPrimitive> signedItems = new HashMap<String, TrustOsmPrimitive>();
 
 	/**
@@ -56,7 +56,12 @@
 		// init the plugin
 		super(info);
+		// check if the jarlibs are already extracted or not and extract them if not
+		if (!Main.pref.getBoolean("trustosm.jarLibsExtracted")) {
+			Main.pref.put("trustosm.jarLibsExtracted", extractFiles("trustosm","lib"));
+			Main.pref.put("trustosm.jarLibsExtracted", extractFiles("trustosm","resources"));
+		}
+
 		refreshMenu();
 		checkForUnrestrictedPolicyFiles();
-		extractFiles("trustosm","lib");
 		// register new SigImporter and SigExporter
 		ExtensionFileFilter.importers.add(new SigImporter());
@@ -89,6 +94,6 @@
 			c.doFinal(data);
 		} catch (Exception e) {
-			e.printStackTrace();
-			System.err.println("It seems that the Unrestricted Policy Files are not available in this JVM. So high level crypto is not allowed. Problems may occure.");
+			//e.printStackTrace();
+			System.err.println("Warning: It seems that the Unrestricted Policy Files are not available in this JVM. So high level crypto is not allowed. Problems may occure.");
 			//extractFiles("trustosm","jce");
 			installUnrestrictedPolicyFiles();
@@ -208,5 +213,5 @@
 	}
 
-	public static void extractFiles(String pluginname, String extractDir) {
+	public static boolean extractFiles(String pluginname, String extractDir) {
 		try {
 			if (extractDir == null) extractDir = "lib";
@@ -232,8 +237,9 @@
 				}
 			}
+			return true;
 
 		} catch (IOException e) {
 			e.printStackTrace();
-
+			return false;
 		}
 
Index: applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/actions/GetMissingDataAction.java
===================================================================
--- applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/actions/GetMissingDataAction.java	(revision 25266)
+++ applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/actions/GetMissingDataAction.java	(revision 25269)
@@ -15,5 +15,5 @@
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.plugins.trustosm.TrustOSMplugin;
-import org.openstreetmap.josm.plugins.trustosm.data.TrustOSMItem;
+import org.openstreetmap.josm.plugins.trustosm.data.TrustOsmPrimitive;
 import org.openstreetmap.josm.plugins.trustosm.gui.DownloadSignedOsmDataTask;
 import org.openstreetmap.josm.tools.Shortcut;
@@ -35,5 +35,5 @@
 	public boolean downloadMissing() {
 		Collection<OsmPrimitive> missingData = new HashSet<OsmPrimitive>();
-		Map<String,TrustOSMItem> trustitems = TrustOSMplugin.signedItems;
+		Map<String,TrustOsmPrimitive> trustitems = TrustOSMplugin.signedItems;
 		getMissing(trustitems, missingData);
 
@@ -54,8 +54,8 @@
 	}
 
-	public void getMissing(Map<String,TrustOSMItem> trustitems, Collection<OsmPrimitive> missingData) {
+	public void getMissing(Map<String,TrustOsmPrimitive> trustitems, Collection<OsmPrimitive> missingData) {
 		Collection<OsmPrimitive> presentData = getCurrentDataSet().allPrimitives();
-		for (TrustOSMItem t : trustitems.values()) {
-			OsmPrimitive osm = t.getOsmItem();
+		for (TrustOsmPrimitive t : trustitems.values()) {
+			OsmPrimitive osm = t.getOsmPrimitive();
 			if (!presentData.contains(osm))
 				missingData.add(osm);
Index: applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/data/TrustOSMItem.java
===================================================================
--- applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/data/TrustOSMItem.java	(revision 25266)
+++ 	(revision )
@@ -1,89 +1,0 @@
-package org.openstreetmap.josm.plugins.trustosm.data;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.bouncycastle.openpgp.PGPSignature;
-import org.openstreetmap.josm.data.osm.Node;
-import org.openstreetmap.josm.data.osm.OsmPrimitive;
-import org.openstreetmap.josm.plugins.trustosm.util.TrustGPG;
-
-public class TrustOSMItem {
-
-	private OsmPrimitive osm;
-	private final Map<String, TrustSignatures> keySig = new HashMap<String, TrustSignatures>();
-	private final Map<Node, TrustSignatures> geomSig = new HashMap<Node, TrustSignatures>();
-
-	public TrustOSMItem(OsmPrimitive osmItem) {
-		this.osm = osmItem;
-
-		/*for (String key: osm.keySet()) {
-			keySig.put(key, new TrustSignatures());
-		}*/
-	}
-
-	public OsmPrimitive getOsmItem() {
-		return osm;
-	}
-
-	public void setOsmItem(OsmPrimitive osmItem) {
-		this.osm = osmItem;
-	}
-
-	public void storeAllTagSigs(Map<String, TrustSignatures> sigs){
-		keySig.putAll(sigs);
-	}
-
-	public void storeTagSig(String key, PGPSignature sig) {
-		if (keySig.containsKey(key)) {
-			keySig.get(key).addSignature(sig, TrustGPG.generateTagSigtext(osm, key));
-			return;
-		} else if (osm.keySet().contains(key)) {
-			keySig.put(key, new TrustSignatures(sig, TrustGPG.generateTagSigtext(osm, key), TrustSignatures.SIG_VALID));
-		}
-	}
-
-	public void storeNodeSig(Node node, PGPSignature sig) {
-		if (geomSig.containsKey(node)) {
-			geomSig.get(node).addSignature(sig, TrustGPG.generateNodeSigtext(osm, node));
-		} else {
-			geomSig.put(node, new TrustSignatures(sig, TrustGPG.generateNodeSigtext(osm, node), TrustSignatures.SIG_VALID));
-		}
-	}
-
-	public Map<Node, TrustSignatures> getGeomSigs() {
-		return geomSig;
-	}
-
-	public TrustSignatures getSigsOnNode(Node node) {
-		return geomSig.get(node);
-	}
-
-	public Map<String, TrustSignatures> getTagSigs() {
-		return keySig;
-	}
-
-	public TrustSignatures getSigsOnKey(String key) {
-		return keySig.get(key);
-	}
-
-	public void updateTagSigStatus(String key, byte status) {
-		if (keySig.containsKey(key)) {
-			keySig.get(key).setStatus(status);
-		} else if (osm.keySet().contains(key)) {
-			TrustSignatures tsigs = new TrustSignatures();
-			tsigs.setStatus(status);
-			keySig.put(key, tsigs);
-		}
-	}
-
-	public void updateNodeSigStatus(Node node, byte status) {
-		if (geomSig.containsKey(node)) {
-			geomSig.get(node).setStatus(status);
-		} else {
-			TrustSignatures tsigs = new TrustSignatures();
-			tsigs.setStatus(status);
-			geomSig.put(node, tsigs);
-		}
-	}
-}
Index: applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/data/TrustSignatures.java
===================================================================
--- applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/data/TrustSignatures.java	(revision 25266)
+++ applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/data/TrustSignatures.java	(revision 25269)
@@ -25,7 +25,13 @@
 	private final Map<String, List<PGPSignature>> textsigs = new HashMap<String, List<PGPSignature>>();
 	private byte status;
+	private double reputation;
 
 	public TrustSignatures() {
 		this.status = SIG_UNKNOWN;
+	}
+
+	public TrustSignatures(PGPSignature signature, String sigtext, byte status) {
+		this.status = status;
+		addSignature(signature, sigtext);
 	}
 
@@ -40,7 +46,10 @@
 	}
 
-	public TrustSignatures(PGPSignature signature, String sigtext, byte status) {
-		this.status = status;
-		addSignature(signature, sigtext);
+	public void setReputation(double r) {
+		reputation = r;
+	}
+
+	public double getReputation() {
+		return reputation;
 	}
 
@@ -97,4 +106,10 @@
 	}
 	 */
+	public String getOnePlainText() {
+		Set<String> texts = getAllPlainTexts();
+		if (texts.isEmpty()) return "";
+		else return texts.iterator().next();
+	}
+
 	public Set<String> getAllPlainTexts() {
 		return textsigs.keySet();
Index: applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/gui/DownloadSignedOsmDataTask.java
===================================================================
--- applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/gui/DownloadSignedOsmDataTask.java	(revision 25266)
+++ applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/gui/DownloadSignedOsmDataTask.java	(revision 25269)
@@ -20,5 +20,5 @@
 import org.openstreetmap.josm.io.OsmTransferException;
 import org.openstreetmap.josm.plugins.trustosm.TrustOSMplugin;
-import org.openstreetmap.josm.plugins.trustosm.data.TrustOSMItem;
+import org.openstreetmap.josm.plugins.trustosm.data.TrustOsmPrimitive;
 import org.xml.sax.SAXException;
 
@@ -112,8 +112,8 @@
 
 	public boolean updateReferences(DataSet ds) {
-		for (TrustOSMItem t : TrustOSMplugin.signedItems.values()) {
-			OsmPrimitive osm = ds.getPrimitiveById(t.getOsmItem().getPrimitiveId());
+		for (TrustOsmPrimitive t : TrustOSMplugin.signedItems.values()) {
+			OsmPrimitive osm = ds.getPrimitiveById(t.getOsmPrimitive().getPrimitiveId());
 			if (osm != null) {
-				t.setOsmItem(osm);
+				t.setOsmPrimitive(osm);
 				return true;
 			} else {
Index: applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/gui/KeyTreeTableModel.java
===================================================================
--- applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/gui/KeyTreeTableModel.java	(revision 25266)
+++ applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/gui/KeyTreeTableModel.java	(revision 25269)
@@ -21,6 +21,7 @@
 
 	public static String convPGPSignatureToString(PGPSignature s) {
+		if (s==null) return null;
 		PGPSignatureSubpacketVector sv = s.getHashedSubPackets();
-		if (sv.hasSubpacket(SignatureSubpacketTags.SIGNER_USER_ID))
+		if (sv != null && sv.hasSubpacket(SignatureSubpacketTags.SIGNER_USER_ID))
 			return sv.getSignerUserID();
 
@@ -30,4 +31,5 @@
 			if (i.hasNext())
 				return (String)i.next();
+
 		}
 		return tr("unknown");
@@ -35,5 +37,5 @@
 
 	private final SignatureTreeNode root;
-	private final String[] allTitle = {tr("UID"),tr("KeyID"),tr("OSM-Cert"),tr("Signed")};
+	private final String[] allTitle = {tr("UID"),tr("KeyID"),tr("OSM-Info"),tr("Signed")};
 	private final List<String> columns = new ArrayList<String>(Arrays.asList(allTitle));
 
Index: applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/gui/dialogs/TrustDialog.java
===================================================================
--- applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/gui/dialogs/TrustDialog.java	(revision 25266)
+++ applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/gui/dialogs/TrustDialog.java	(revision 25269)
@@ -4,16 +4,22 @@
 import static org.openstreetmap.josm.tools.I18n.tr;
 
+import java.awt.BasicStroke;
 import java.awt.BorderLayout;
 import java.awt.Color;
 import java.awt.Component;
 import java.awt.Font;
+import java.awt.Graphics2D;
 import java.awt.GridLayout;
+import java.awt.Point;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
 import java.awt.event.KeyEvent;
+import java.awt.geom.GeneralPath;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -27,4 +33,6 @@
 import javax.swing.JTable;
 import javax.swing.JTree;
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.TreeSelectionListener;
 import javax.swing.table.DefaultTableCellRenderer;
 import javax.swing.table.DefaultTableModel;
@@ -35,4 +43,6 @@
 import javax.swing.tree.TreePath;
 
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.data.Bounds;
 import org.openstreetmap.josm.data.SelectionChangedListener;
 import org.openstreetmap.josm.data.osm.DataSet;
@@ -42,14 +52,21 @@
 import org.openstreetmap.josm.data.osm.Relation;
 import org.openstreetmap.josm.data.osm.Way;
+import org.openstreetmap.josm.data.osm.WaySegment;
+import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors;
 import org.openstreetmap.josm.gui.DefaultNameFormatter;
+import org.openstreetmap.josm.gui.MapView;
 import org.openstreetmap.josm.gui.SideButton;
 import org.openstreetmap.josm.gui.dialogs.ToggleDialog;
+import org.openstreetmap.josm.gui.layer.MapViewPaintable;
 import org.openstreetmap.josm.plugins.trustosm.TrustOSMplugin;
-import org.openstreetmap.josm.plugins.trustosm.data.TrustOSMItem;
+import org.openstreetmap.josm.plugins.trustosm.data.TrustNode;
+import org.openstreetmap.josm.plugins.trustosm.data.TrustOsmPrimitive;
 import org.openstreetmap.josm.plugins.trustosm.data.TrustSignatures;
+import org.openstreetmap.josm.plugins.trustosm.data.TrustWay;
+import org.openstreetmap.josm.plugins.trustosm.util.TrustAnalyzer;
 import org.openstreetmap.josm.tools.ImageProvider;
 import org.openstreetmap.josm.tools.Shortcut;
 
-public class TrustDialog extends ToggleDialog implements ActionListener, SelectionChangedListener {
+public class TrustDialog extends ToggleDialog implements ActionListener, SelectionChangedListener, MapViewPaintable {
 
 	/**
@@ -84,5 +101,11 @@
 	private Collection<? extends OsmPrimitive> osmData;
 
+
+	private final List<WaySegment> selectedSegments = new ArrayList<WaySegment>();
+	private final List<OsmPrimitive> selectedPrimitives = new ArrayList<OsmPrimitive>();
+
+	/** The JTree for showing the geometry */
 	private final JTree geomTree;
+
 
 	/**
@@ -122,4 +145,40 @@
 	};
 
+	/** The JTable for members of a relation */
+	private final DefaultTableModel memberData = new DefaultTableModel() {
+
+		/**
+		 * 
+		 */
+		private static final long serialVersionUID = 1L;
+		@Override public boolean isCellEditable(int row, int column) {
+			return false;
+		}
+		@Override public Class<?> getColumnClass(int columnIndex) {
+			return String.class;
+		}
+	};
+	private final JTable memberTable = new JTable(memberData) {
+		/**
+		 * 
+		 */
+		private static final long serialVersionUID = 1L;
+
+		@Override
+		public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
+			Component c = super.prepareRenderer(renderer, row, column);
+			Byte stat = rowStatus.get(getModel().getValueAt(row, 0));
+			if (!isRowSelected(row))
+				switch (stat.byteValue()) {
+				case -2: c.setBackground( BGCOLOR_REMOVED_ITEM ); break;
+				case -1: c.setBackground( BGCOLOR_BROKEN_SIG ); break;
+				case 1: c.setBackground( BGCOLOR_VALID_SIG ); break;
+				default: c.setBackground( BGCOLOR_NO_SIG ); break;
+				}
+			return c;
+		}
+	};
+
+
 	/**
 	 * Constructor
@@ -130,4 +189,5 @@
 						KeyEvent.VK_T, Shortcut.GROUP_LAYER, Shortcut.SHIFT_DEFAULT), 150);
 
+		Main.map.mapView.addTemporaryLayer(this);
 
 		// setting up the properties table
@@ -186,16 +246,36 @@
 				DefaultMutableTreeNode node = (DefaultMutableTreeNode)value;
 				if (node.isRoot()) return this;
-				OsmPrimitive osm = (OsmPrimitive) node.getUserObject();
-				setIcon(ImageProvider.get(OsmPrimitiveType.from(osm)));
-				setText(osm.getDisplayName(DefaultNameFormatter.getInstance()));
-
-				if (osm instanceof Node) {
-					Node osmNode = (Node) osm;
-					if (((DefaultMutableTreeNode) node.getParent()).getUserObject() instanceof Way) {
-						osm = (OsmPrimitive) ((DefaultMutableTreeNode) node.getParent()).getUserObject();
-					}
+				setBackgroundNonSelectionColor( BGCOLOR_NO_SIG );
+				Object o = node.getUserObject();
+				if (o instanceof OsmPrimitive){
+					OsmPrimitive osm = (OsmPrimitive) o;
+					setIcon(ImageProvider.get(OsmPrimitiveType.from(osm)));
+					setText(osm.getDisplayName(DefaultNameFormatter.getInstance()));
+
+
+					if (osm instanceof Node) {
+						Node osmNode = (Node) osm;
+						TrustSignatures sigs;
+						String id = TrustOsmPrimitive.createUniqueObjectIdentifier(osm);
+						if (TrustOSMplugin.signedItems.containsKey(id) && (sigs = ((TrustNode)TrustOSMplugin.signedItems.get(id)).getNodeSigs()) != null) {
+							byte stat = sigs.getStatus();
+							switch (stat) {
+							case -2: setBackgroundNonSelectionColor( BGCOLOR_REMOVED_ITEM ); break;
+							case -1: setBackgroundNonSelectionColor( BGCOLOR_BROKEN_SIG ); break;
+							case 1: setBackgroundNonSelectionColor( BGCOLOR_VALID_SIG ); break;
+							default: setBackgroundNonSelectionColor( BGCOLOR_NO_SIG ); break;
+							}
+						}
+					} else if (osm instanceof Way) {
+						//setBackgroundNonSelectionColor( BGCOLOR_NO_SIG );
+					}
+
+				} else if (o instanceof WaySegment){
+					WaySegment seg = (WaySegment) o;
+					setIcon(ImageProvider.get("mapmode/addsegment"));
+					setText(seg.getFirstNode().getDisplayName(DefaultNameFormatter.getInstance()) + " ----- " + seg.getSecondNode().getDisplayName(DefaultNameFormatter.getInstance()));
 					TrustSignatures sigs;
-					String id = String.valueOf(osm.getUniqueId());
-					if (TrustOSMplugin.signedItems.containsKey(id) && (sigs = TrustOSMplugin.signedItems.get(id).getSigsOnNode(osmNode)) != null) {
+					String id = TrustOsmPrimitive.createUniqueObjectIdentifier(seg.way);
+					if (TrustOSMplugin.signedItems.containsKey(id) && (sigs = ((TrustWay)TrustOSMplugin.signedItems.get(id)).getSigsOnSegment(seg)) != null) {
 						byte stat = sigs.getStatus();
 						switch (stat) {
@@ -205,9 +285,5 @@
 						default: setBackgroundNonSelectionColor( BGCOLOR_NO_SIG ); break;
 						}
-					} else {
-						setBackgroundNonSelectionColor( BGCOLOR_NO_SIG );
-					}
-				} else if (osm instanceof Way) {
-					setBackgroundNonSelectionColor( BGCOLOR_NO_SIG );
+					}
 				}
 				return this;
@@ -217,6 +293,56 @@
 		});
 
-
-
+		geomTree.addTreeSelectionListener(new TreeSelectionListener() {
+			public void valueChanged(TreeSelectionEvent e) {
+				// unhighlight everything
+				for (OsmPrimitive p : selectedPrimitives) {
+					p.setHighlighted(false);
+				}
+				selectedPrimitives.clear();
+				selectedSegments.clear();
+				if (geomTree.getSelectionPaths()!=null)
+					for (TreePath tp : geomTree.getSelectionPaths()) {
+						Object o = ((DefaultMutableTreeNode) tp.getLastPathComponent()).getUserObject();
+						if (o instanceof WaySegment) {
+							selectedSegments.add((WaySegment) o);
+						} else if (o instanceof OsmPrimitive) {
+							OsmPrimitive highlight = (OsmPrimitive) o;
+							highlight.setHighlighted(true);
+							selectedPrimitives.add(highlight);
+						}
+					}
+				Main.map.mapView.repaint();
+			}
+		});
+
+		propertyTable.addFocusListener(new FocusListener(){
+
+			@Override
+			public void focusGained(FocusEvent fe) {
+				geomTree.clearSelection();
+
+			}
+
+			@Override
+			public void focusLost(FocusEvent fe) {
+
+			}
+
+		});
+
+		geomTree.addFocusListener(new FocusListener(){
+
+			@Override
+			public void focusGained(FocusEvent fe) {
+				propertyTable.clearSelection();
+
+			}
+
+			@Override
+			public void focusLost(FocusEvent fe) {
+
+			}
+
+		});
 
 		JPanel dataPanel = new JPanel();
@@ -253,7 +379,7 @@
 		if (actionCommand.equals("Check")) {
 			for (OsmPrimitive osm : osmData) {
-				String id = String.valueOf(osm.getUniqueId());
+				String id = TrustOsmPrimitive.createUniqueObjectIdentifier(osm);
 				if (TrustOSMplugin.signedItems.containsKey(id))
-					TrustOSMplugin.gpg.checkAll(TrustOSMplugin.signedItems.get(id));
+					TrustAnalyzer.checkEverything(TrustOSMplugin.signedItems.get(id));
 				//checkedItems.put(osm, TrustOSMplugin.gpg.check(checkedItems.containsKey(osm)? checkedItems.get(osm) : new TrustOSMItem(osm)));
 			}
@@ -265,6 +391,8 @@
 				for (OsmPrimitive osm : osmData) {
 					if (osm.keySet().contains(key)) {
-						String id = String.valueOf(osm.getUniqueId());
-						TrustOSMplugin.signedItems.put(id, TrustOSMplugin.gpg.signTag(TrustOSMplugin.signedItems.containsKey(id)? TrustOSMplugin.signedItems.get(id) : new TrustOSMItem(osm), key));
+						String id = TrustOsmPrimitive.createUniqueObjectIdentifier(osm);
+						TrustOsmPrimitive trust = TrustOSMplugin.signedItems.containsKey(id)? TrustOSMplugin.signedItems.get(id) : TrustOsmPrimitive.createTrustOsmPrimitive(osm);
+						if (TrustOSMplugin.gpg.signTag(trust, key))
+							TrustOSMplugin.signedItems.put(id, trust);
 					}
 				}
@@ -272,19 +400,47 @@
 			if (geomTree.getSelectionPaths()!=null)
 				for (TreePath tp : geomTree.getSelectionPaths()) {
-					OsmPrimitive osm = (OsmPrimitive) ((DefaultMutableTreeNode) tp.getLastPathComponent()).getUserObject();
-					String id = String.valueOf(osm.getUniqueId());
-					if (osm instanceof Node) {
+					Object o = ((DefaultMutableTreeNode) tp.getLastPathComponent()).getUserObject();
+					if (o instanceof OsmPrimitive) {
+						OsmPrimitive osm = (OsmPrimitive) o;
+						String id = TrustOsmPrimitive.createUniqueObjectIdentifier(osm);
+						if (osm instanceof Node) {
+							Node osmNode = ((Node) osm);
+							TrustNode trust = TrustOSMplugin.signedItems.containsKey(id)? (TrustNode) TrustOSMplugin.signedItems.get(id) : new TrustNode(osmNode);
+							trust.storeNodeSig(TrustOSMplugin.gpg.signNode(osmNode));
+							TrustOSMplugin.signedItems.put(id, trust);
+
+
+							/*						TreePath parentPath = tp.getParentPath();
+							if (geomTree.isPathSelected(parentPath)) return;
+
+							Node osmNode = ((Node) osm);
+							if (((DefaultMutableTreeNode) parentPath.getLastPathComponent()).getUserObject() instanceof Way) {
+								osm = (OsmPrimitive) ((DefaultMutableTreeNode) parentPath.getLastPathComponent()).getUserObject();
+								id = String.valueOf(osm.getUniqueId());
+							}
+							TrustOsmPrimitive trust = TrustOSMplugin.signedItems.containsKey(id)? TrustOSMplugin.signedItems.get(id) : TrustOsmPrimitive.createTrustOsmPrimitive(osm);
+							trust.storeNodeSig(osmNode, TrustOSMplugin.gpg.signNode(osm,osmNode));
+							TrustOSMplugin.signedItems.put(id, trust);
+							 */
+						} else if (osm instanceof Way) {
+							TrustOSMplugin.signedItems.put(id, TrustOSMplugin.gpg.signWay(TrustOSMplugin.signedItems.containsKey(id)? (TrustWay)TrustOSMplugin.signedItems.get(id) : new TrustWay(osm)));
+							/*Way osmWay = ((Way) osm);
+							TrustWay trust = TrustOSMplugin.signedItems.containsKey(id)? (TrustWay) TrustOSMplugin.signedItems.get(id) : new TrustWay(osmWay);
+							trust.storeSegmentSig(TrustOSMplugin.gpg.signWay(osmWay));
+							TrustOSMplugin.signedItems.put(id, trust);
+							 */
+						}
+					} else if (o instanceof WaySegment) {
 						TreePath parentPath = tp.getParentPath();
 						if (geomTree.isPathSelected(parentPath)) return;
-
-						Node osmNode = ((Node) osm);
-						if (((DefaultMutableTreeNode) parentPath.getLastPathComponent()).getUserObject() instanceof Way) {
-							osm = (OsmPrimitive) ((DefaultMutableTreeNode) parentPath.getLastPathComponent()).getUserObject();
-						}
-						TrustOSMItem trust = TrustOSMplugin.signedItems.containsKey(id)? TrustOSMplugin.signedItems.get(id) : new TrustOSMItem(osm);
-						trust.storeNodeSig(osmNode, TrustOSMplugin.gpg.signNode(osm,osmNode));
+						WaySegment seg = (WaySegment) o;
+						List<Node> nodes = new ArrayList<Node>();
+						nodes.add(seg.getFirstNode());
+						nodes.add(seg.getSecondNode());
+						Way w = seg.way;
+						String id = TrustOsmPrimitive.createUniqueObjectIdentifier(w);
+						TrustWay trust = TrustOSMplugin.signedItems.containsKey(id)? (TrustWay) TrustOSMplugin.signedItems.get(id) : new TrustWay(w);
+						trust.storeSegmentSig(nodes,TrustOSMplugin.gpg.signSegment(trust,nodes));
 						TrustOSMplugin.signedItems.put(id, trust);
-					} else if (osm instanceof Way) {
-						TrustOSMplugin.signedItems.put(id, TrustOSMplugin.gpg.signGeometry(TrustOSMplugin.signedItems.containsKey(id)? TrustOSMplugin.signedItems.get(id) : new TrustOSMItem(osm)));
 					}
 				}
@@ -295,5 +451,5 @@
 				String key = (String)propertyTable.getValueAt(i, 0);
 				for (OsmPrimitive osm : osmData) {
-					String id = String.valueOf(osm.getUniqueId());
+					String id = TrustOsmPrimitive.createUniqueObjectIdentifier(osm);
 					if (osm.keySet().contains(key) && TrustOSMplugin.signedItems.containsKey(id)) {
 						TrustSignaturesDialog.showSignaturesDialog(TrustOSMplugin.signedItems.get(id), key);
@@ -301,4 +457,29 @@
 				}
 			}
+			if (geomTree.getSelectionPaths()!=null)
+				for (TreePath tp : geomTree.getSelectionPaths()) {
+					Object o = ((DefaultMutableTreeNode) tp.getLastPathComponent()).getUserObject();
+					if (o instanceof OsmPrimitive) {
+						OsmPrimitive osm = (OsmPrimitive) o;
+						String id = TrustOsmPrimitive.createUniqueObjectIdentifier(osm);
+						if (osm instanceof Node) {
+							if (TrustOSMplugin.signedItems.containsKey(id)) {
+								TrustSignaturesDialog.showSignaturesDialog((TrustNode) TrustOSMplugin.signedItems.get(id));
+							}
+						} else if (osm instanceof Way) {
+							//TrustOSMplugin.signedItems.put(id, TrustOSMplugin.gpg.signGeometry(TrustOSMplugin.signedItems.containsKey(id)? TrustOSMplugin.signedItems.get(id) : new TrustOSMItem(osm)));
+						}
+					} else if (o instanceof WaySegment) {
+						WaySegment seg = (WaySegment) o;
+						String id = TrustOsmPrimitive.createUniqueObjectIdentifier(seg.way);
+						if (TrustOSMplugin.signedItems.containsKey(id)) {
+							List<Node> nodes = new ArrayList<Node>();
+							nodes.add(seg.getFirstNode());
+							nodes.add(seg.getSecondNode());
+							TrustSignaturesDialog.showSignaturesDialog((TrustWay) TrustOSMplugin.signedItems.get(id),nodes);
+						}
+					}
+				}
+
 		}
 	}
@@ -336,4 +517,12 @@
 	}
 	 */
+	public static List<WaySegment> generateSegmentListFromWay(Way w) {
+		List<WaySegment> segList = new ArrayList<WaySegment>();
+		for (int i = 0; i < w.getNodesCount()-1; i++) {
+			segList.add(new WaySegment(w,i));
+		}
+		return segList;
+	}
+
 	private DefaultTreeModel createTree(){
 		DefaultMutableTreeNode root = new DefaultMutableTreeNode();
@@ -341,8 +530,15 @@
 		if (osmData!=null)
 			for (OsmPrimitive osm : osmData) {
-				String id = String.valueOf(osm.getUniqueId());
+				//String id = TrustOsmPrimitive.createUniqueObjectIdentifier(osm);
 				if(osm instanceof Node) {
 					root.add(new DefaultMutableTreeNode(osm));
 				} else if(osm instanceof Way) {
+					wayNode = new DefaultMutableTreeNode(osm);
+					List<WaySegment> presentSegments = TrustDialog.generateSegmentListFromWay(((Way)osm));
+					for (WaySegment seg : presentSegments ) {
+						wayNode.add(new DefaultMutableTreeNode(seg));
+					}
+
+					/*
 					wayNode = new DefaultMutableTreeNode(osm);
 					List<Node> presentNodes = ((Way)osm).getNodes();
@@ -353,5 +549,5 @@
 
 					if (TrustOSMplugin.signedItems.containsKey(id)) {
-						TrustOSMItem trust = TrustOSMplugin.signedItems.get(id);
+						TrustOsmPrimitive trust = TrustOSMplugin.signedItems.get(id);
 						HashSet<Node> signedNodes = new HashSet<Node>(trust.getGeomSigs().keySet());
 						signedNodes.removeAll(presentNodes);
@@ -364,4 +560,5 @@
 						}
 					}
+					 */
 					root.add(wayNode);
 				} else if(osm instanceof Relation) {
@@ -381,5 +578,5 @@
 		Map<String, Map<String, Integer>> valueCount = new TreeMap<String, Map<String, Integer>>();
 
-		TrustOSMItem trust;
+		TrustOsmPrimitive trust;
 
 		valueCount.clear();
@@ -388,5 +585,5 @@
 
 		for (OsmPrimitive osm : osmData) {
-			String id = String.valueOf(osm.getUniqueId());
+			String id = TrustOsmPrimitive.createUniqueObjectIdentifier(osm);
 			if (TrustOSMplugin.signedItems.containsKey(id)) {
 				trust = TrustOSMplugin.signedItems.get(id);
@@ -403,5 +600,5 @@
 
 			} else {
-				trust = new TrustOSMItem(osm);
+				trust = TrustOsmPrimitive.createTrustOsmPrimitive(osm);
 				sigsAvailable = false;
 			}
@@ -464,3 +661,29 @@
 	}
 
+	@Override
+	public void paint(Graphics2D g, MapView mv, Bounds bbox) {
+		// if there are no Segments to highlight - return
+		if (selectedSegments.isEmpty()) return;
+
+		// sanity checks
+		if (Main.map.mapView == null) return;
+
+
+		Graphics2D g2 = g;
+		g2.setColor(PaintColors.HIGHLIGHT.get());
+		g2.setStroke(new BasicStroke(3, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
+
+		// highlight all selected WaySegments
+		for (WaySegment seg : selectedSegments) {
+			GeneralPath b = new GeneralPath();
+			Point p1=mv.getPoint(seg.getFirstNode());
+			Point p2=mv.getPoint(seg.getSecondNode());
+
+			b.moveTo(p1.x,p1.y); b.lineTo(p2.x, p2.y);
+
+			g2.draw(b);
+		}
+		g2.setStroke(new BasicStroke(1));
+	}
+
 }
Index: applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/gui/dialogs/TrustSignaturesDialog.java
===================================================================
--- applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/gui/dialogs/TrustSignaturesDialog.java	(revision 25266)
+++ applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/gui/dialogs/TrustSignaturesDialog.java	(revision 25269)
@@ -3,18 +3,12 @@
 import static org.openstreetmap.josm.tools.I18n.tr;
 
-import java.awt.Component;
 import java.awt.Dimension;
 import java.awt.GridBagLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
 import java.text.SimpleDateFormat;
-import java.util.Collection;
-import java.util.Iterator;
 import java.util.List;
 
 import javax.swing.Box;
-import javax.swing.JButton;
 import javax.swing.JLabel;
 import javax.swing.JOptionPane;
@@ -22,21 +16,18 @@
 import javax.swing.JScrollPane;
 import javax.swing.JTextArea;
-import javax.swing.JTree;
-import javax.swing.tree.DefaultMutableTreeNode;
-import javax.swing.tree.DefaultTreeCellRenderer;
-import javax.swing.tree.DefaultTreeModel;
 import javax.swing.tree.TreePath;
 
-import org.bouncycastle.bcpg.SignatureSubpacketTags;
-import org.bouncycastle.bcpg.sig.NotationData;
 import org.bouncycastle.openpgp.PGPPublicKey;
 import org.bouncycastle.openpgp.PGPSignature;
-import org.bouncycastle.openpgp.PGPSignatureSubpacketVector;
 import org.jdesktop.swingx.JXTreeTable;
 import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.gui.DefaultNameFormatter;
 import org.openstreetmap.josm.gui.ExtendedDialog;
 import org.openstreetmap.josm.plugins.trustosm.TrustOSMplugin;
-import org.openstreetmap.josm.plugins.trustosm.data.TrustOSMItem;
+import org.openstreetmap.josm.plugins.trustosm.data.TrustNode;
+import org.openstreetmap.josm.plugins.trustosm.data.TrustOsmPrimitive;
 import org.openstreetmap.josm.plugins.trustosm.data.TrustSignatures;
+import org.openstreetmap.josm.plugins.trustosm.data.TrustWay;
 import org.openstreetmap.josm.plugins.trustosm.gui.KeyTreeTableModel;
 import org.openstreetmap.josm.plugins.trustosm.gui.KeyTreeTableModel.SignatureTreeNode;
@@ -49,91 +40,114 @@
 public class TrustSignaturesDialog {
 
-	public static void showSignaturesDialog(TrustOSMItem trust, String key) {
+
+	private static String createLabel(String plain, int type) {
+		if (type == 0) {
+			String[] kv = TrustOsmPrimitive.generateTagsFromSigtext(plain);
+			return tr("Signed key value pair was: {0}={1}", kv[0],kv[1]);
+		} else if (type == 1) {
+			Node node = TrustNode.generateNodeFromSigtext(plain);
+			//return tr("Signed node was: {0}", node.getDisplayName(DefaultNameFormatter.getInstance()));
+			return "ID:"+node.getUniqueId()+" ("+node.getCoor().toString() + ")";
+		} else if (type == 2) {
+			List<Node> nodes = TrustWay.generateSegmentFromSigtext(plain);
+			return "From:"+nodes.get(0).getUniqueId()+", To:"+nodes.get(nodes.size()-1).getUniqueId();
+		}
+		return "No known type";
+	}
+
+	private static void showDialog(TrustSignatures sigs, String label, int type) {
+		JPanel p = new JPanel(new GridBagLayout());
+		p.add(new JLabel(label),GBC.eol());
+
+		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd:hh.mm.ss");
+
+		for (String plain : sigs.getAllPlainTexts()) {
+			JTextArea sigtext = new JTextArea(sigs.getArmoredFulltextSignatureAll(plain));
+			sigtext.setEditable(false);
+			JPanel textcontent = new JPanel();
+			textcontent.add(sigtext);
+
+			p.add(new JCollapsiblePanel(createLabel(plain, type),textcontent),GBC.eol());
+
+			List<PGPSignature> siglist = sigs.getSignaturesByPlaintext(plain);
+			JPanel signerPanel = new JPanel(new GridBagLayout());
+			//signerPanel.add(createSignerTree(siglist));
+			KeyTreeTableModel km = new KeyTreeTableModel(siglist);
+			final JXTreeTable t = new JXTreeTable( km );
+			//t.setHorizontalScrollEnabled(true);
+			//t.setRootVisible(false);
+			t.addMouseListener(new MouseAdapter() {
+				@Override
+				public void mouseClicked(MouseEvent e) {
+					if (e.getClickCount() == 2) {
+						TreePath selPath = t.getPathForLocation(e.getX(), e.getY());
+						if (selPath == null)
+							return;
+						SignatureTreeNode sn = (SignatureTreeNode)selPath.getLastPathComponent();
+						PGPPublicKey pub = TrustOSMplugin.gpg.getPublicKeyFromRing(sn.getSignature().getKeyID());
+						TrustGPG.showKeyDetails(pub);
+					}
+				}
+			});
+			t.setLeafIcon(ImageProvider.get("dialogs/sign"));
+			t.setOpenIcon(ImageProvider.get("dialogs/sign_color"));
+			t.setClosedIcon(ImageProvider.get("dialogs/sign_color"));
+			t.expandAll();
+			t.packAll();
+			t.collapseAll();
+			signerPanel.add(new JScrollPane(t));
+
+
+			//			JTreeTable tt = new JTreeTable();
+
+			/*				for (PGPSignature s : siglist) {
+				signerPanel.add(createKeyButton(tr("Signature created at {0} by User {1}",formatter.format(s.getCreationTime()),s.getHashedSubPackets().getSignerUserID()),s.getKeyID()),GBC.eol());
+				//signerPanel.add(new JLabel(tr("Signature created at {0} by User {1}",formatter.format(s.getCreationTime()),s.getHashedSubPackets().getSignerUserID())),GBC.eol());
+			}*/
+
+			p.add(new JCollapsiblePanel(tr("{0} Signatures found.", siglist.size()),signerPanel),GBC.eol().insets(20,0,0,0));
+		}
+		p.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.BOTH));
+		JScrollPane scroller = new JScrollPane(p);
+		//JPanel content = new JPanel();
+		scroller.setPreferredSize(new Dimension(700,500));
+		//content.add(scroller);
+		//JOptionPane.showMessageDialog(Main.parent,scroller, tr("Clearsigned Signature"), JOptionPane.PLAIN_MESSAGE);
+		String[] buttons = {tr("Ok")};
+		ExtendedDialog info = new ExtendedDialog(Main.parent, tr("Signature Info"),buttons,false);
+		info.setContent(scroller,false);
+		info.showDialog();
+	}
+
+
+	public static void showSignaturesDialog(TrustNode trust) {
+		TrustSignatures sigs;
+		if ((sigs = trust.getNodeSigs()) == null) {
+			JOptionPane.showMessageDialog(null,tr("Sorry, there are no Signatures for the selected Node."), tr("No Signature found"), JOptionPane.WARNING_MESSAGE);
+		} else {
+			String nodename = ((Node)trust.getOsmPrimitive()).getDisplayName(DefaultNameFormatter.getInstance());
+			showDialog(sigs, tr("Selected node was:\n{0}",nodename),1);
+		}
+	}
+
+	public static void showSignaturesDialog(TrustOsmPrimitive trust, String key) {
 		TrustSignatures sigs;
 		if ((sigs = trust.getSigsOnKey(key)) == null) {
 			JOptionPane.showMessageDialog(null,tr("Sorry, there are no Signatures for the selected Attribute."), tr("No Signature found"), JOptionPane.WARNING_MESSAGE);
 		} else {
-			JPanel p = new JPanel(new GridBagLayout());
-			p.add(new JLabel(tr("Selected key value pair was:\n{0}={1}",key,trust.getOsmItem().get(key))),GBC.eol());
-
-			SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd:hh.mm.ss");
-
-			for (String plain : sigs.getAllPlainTexts()) {
-				JTextArea sigtext = new JTextArea(sigs.getArmoredFulltextSignatureAll(plain));
-				sigtext.setEditable(false);
-				JPanel textcontent = new JPanel();
-				textcontent.add(sigtext);
-				String[] kv = TrustGPG.generateTagsFromSigtext(plain);
-				p.add(new JCollapsiblePanel(tr("Signed key value pair was: {0}={1}", kv[0],kv[1]),textcontent),GBC.eol());
-
-				List<PGPSignature> siglist = sigs.getSignaturesByPlaintext(plain);
-				JPanel signerPanel = new JPanel(new GridBagLayout());
-				//signerPanel.add(createSignerTree(siglist));
-				KeyTreeTableModel km = new KeyTreeTableModel(siglist);
-				final JXTreeTable t = new JXTreeTable( km );
-				//t.setHorizontalScrollEnabled(true);
-				//t.setRootVisible(false);
-				t.addMouseListener(new MouseAdapter() {
-					@Override
-					public void mouseClicked(MouseEvent e) {
-						if (e.getClickCount() == 2) {
-							TreePath selPath = t.getPathForLocation(e.getX(), e.getY());
-							if (selPath == null)
-								return;
-							SignatureTreeNode sn = (SignatureTreeNode)selPath.getLastPathComponent();
-							PGPPublicKey pub = TrustOSMplugin.gpg.getPublicKeyFromRing(sn.getSignature().getKeyID());
-							TrustGPG.showKeyDetails(pub);
-						}
-					}
-				});
-				t.setLeafIcon(ImageProvider.get("dialogs/sign"));
-				t.setOpenIcon(ImageProvider.get("dialogs/sign_color"));
-				t.setClosedIcon(ImageProvider.get("dialogs/sign_color"));
-				t.expandAll();
-				t.packAll();
-				t.collapseAll();
-				signerPanel.add(new JScrollPane(t));
-
-
-				//			JTreeTable tt = new JTreeTable();
-
-				/*				for (PGPSignature s : siglist) {
-					signerPanel.add(createKeyButton(tr("Signature created at {0} by User {1}",formatter.format(s.getCreationTime()),s.getHashedSubPackets().getSignerUserID()),s.getKeyID()),GBC.eol());
-					//signerPanel.add(new JLabel(tr("Signature created at {0} by User {1}",formatter.format(s.getCreationTime()),s.getHashedSubPackets().getSignerUserID())),GBC.eol());
-				}*/
-
-				p.add(new JCollapsiblePanel(tr("{0} Signatures found.", siglist.size()),signerPanel),GBC.eol().insets(20,0,0,0));
-			}
-
-			/*
-
-			for (PGPSignature s : sigs.getSignatures()) {
-				JTextArea sigtext = new JTextArea(sigs.getArmoredFulltextSignature(s));
-				sigtext.setEditable(false);
-				sigtext.setAlignmentX(Component.LEFT_ALIGNMENT);
-				p.add(sigtext);
-				JLabel siginfo = new JLabel(tr("Signature created at {0} by User {1}",formatter.format(s.getCreationTime()),s.getHashedSubPackets().getSignerUserID()));
-				siginfo.setAlignmentX(Component.LEFT_ALIGNMENT);
-				p.add(siginfo);
-				p.add(Box.createRigidArea(d));
-			}
-			 */
-
-
-			p.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.BOTH));
-			JScrollPane scroller = new JScrollPane(p);
-			//JPanel content = new JPanel();
-			scroller.setPreferredSize(new Dimension(700,500));
-			//content.add(scroller);
-			//JOptionPane.showMessageDialog(Main.parent,scroller, tr("Clearsigned Signature"), JOptionPane.PLAIN_MESSAGE);
-			String[] buttons = {tr("Ok")};
-			ExtendedDialog info = new ExtendedDialog(Main.parent, tr("Signature Info"),buttons,false);
-			info.setContent(scroller,false);
-			info.showDialog();
-			//info.setBounds(200, 200, 300, 200);
-			//info.setVisible(true);
-		}
-	}
-
+			showDialog(sigs, tr("Selected key value pair was:\n{0}={1}",key,trust.getOsmPrimitive().get(key)), 0);
+		}
+	}
+
+	public static void showSignaturesDialog(TrustWay trust, List<Node> nodes) {
+		TrustSignatures sigs;
+		if ((sigs = trust.getSigsOnSegment(nodes)) == null) {
+			JOptionPane.showMessageDialog(null,tr("Sorry, there are no Signatures for the selected Segment."), tr("No Signature found"), JOptionPane.WARNING_MESSAGE);
+		} else {
+			showDialog(sigs, tr("Selected WaySegment was:"), 2);
+		}
+	}
+
+	/*
 	public static JButton createKeyButton(String label,final long keyID) {
 		JButton detailsButton = new JButton(label);
@@ -232,5 +246,5 @@
 	}
 
-
+	 */
 
 }
Index: applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/io/SigExporter.java
===================================================================
--- applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/io/SigExporter.java	(revision 25266)
+++ applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/io/SigExporter.java	(revision 25269)
@@ -24,5 +24,5 @@
 
 	public SigExporter() {
-		super(new ExtensionFileFilter("toxm,xml", "tosm", tr("Signature Files") + " (*.tosm *.xml)"));
+		super(new ExtensionFileFilter("txml,xml", "txml", tr("Signature Files") + " (*.txml *.xml)"));
 	}
 
Index: applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/io/SigImporter.java
===================================================================
--- applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/io/SigImporter.java	(revision 25266)
+++ applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/io/SigImporter.java	(revision 25269)
@@ -20,10 +20,10 @@
 import org.openstreetmap.josm.plugins.trustosm.TrustOSMplugin;
 import org.openstreetmap.josm.plugins.trustosm.actions.GetMissingDataAction;
-import org.openstreetmap.josm.plugins.trustosm.data.TrustOSMItem;
+import org.openstreetmap.josm.plugins.trustosm.data.TrustOsmPrimitive;
 
 public class SigImporter extends FileImporter {
 
 	public SigImporter() {
-		super(new ExtensionFileFilter("tosm,xml", "tosm", tr("OSM Signature Files") + " (*.tosm *.xml)"));
+		super(new ExtensionFileFilter("txml,xml", "txml", tr("OSM Signature Files") + " (*.txml *.xml)"));
 	}
 
@@ -49,5 +49,5 @@
 		}
 		//		Set<OsmPrimitive> missingData = new HashSet<OsmPrimitive>();
-		Map<String,TrustOSMItem> trustitems = SigReader.parseSignatureXML(in, NullProgressMonitor.INSTANCE);
+		Map<String,TrustOsmPrimitive> trustitems = SigReader.parseSignatureXML(in, NullProgressMonitor.INSTANCE);
 
 		/*
Index: applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/io/SigReader.java
===================================================================
--- applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/io/SigReader.java	(revision 25266)
+++ applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/io/SigReader.java	(revision 25269)
@@ -10,4 +10,5 @@
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -24,4 +25,5 @@
 import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
 import org.openstreetmap.josm.data.osm.Relation;
+import org.openstreetmap.josm.data.osm.RelationMember;
 import org.openstreetmap.josm.data.osm.Way;
 import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
@@ -30,6 +32,9 @@
 import org.openstreetmap.josm.io.OsmDataParsingException;
 import org.openstreetmap.josm.io.UTFInputStreamReader;
-import org.openstreetmap.josm.plugins.trustosm.data.TrustOSMItem;
+import org.openstreetmap.josm.plugins.trustosm.data.TrustNode;
+import org.openstreetmap.josm.plugins.trustosm.data.TrustOsmPrimitive;
+import org.openstreetmap.josm.plugins.trustosm.data.TrustRelation;
 import org.openstreetmap.josm.plugins.trustosm.data.TrustSignatures;
+import org.openstreetmap.josm.plugins.trustosm.data.TrustWay;
 import org.openstreetmap.josm.tools.CheckParameterUtil;
 import org.xml.sax.Attributes;
@@ -42,8 +47,8 @@
 public class SigReader {
 
-	private final Map<String,TrustOSMItem> trustitems = new HashMap<String,TrustOSMItem>();
+	private final Map<String,TrustOsmPrimitive> trustitems = new HashMap<String,TrustOsmPrimitive>();
 	private final Set<OsmPrimitive> missingData = new HashSet<OsmPrimitive>();
 
-	public Map<String,TrustOSMItem> getTrustItems() {
+	public Map<String,TrustOsmPrimitive> getTrustItems() {
 		return trustitems;
 	}
@@ -68,11 +73,7 @@
 		 * The current TrustOSMItem to be read.
 		 */
-		private TrustOSMItem trust;
-
-		/**
-		 * Signatures of geometry and tags.
-		 */
-		private final Map<String, TrustSignatures> keySig = new HashMap<String, TrustSignatures>();
-		private final Map<String, TrustSignatures> nodeSig = new HashMap<String, TrustSignatures>();
+		private TrustOsmPrimitive trust;
+
+
 		/**
 		 * The current Signatures.
@@ -87,7 +88,7 @@
 
 			try {
-				if (qName.equals("trustitem")) {
+				if (qName.equals("trustnode") || qName.equals("trustway") || qName.equals("trustrelation")) {
 					if (atts == null) {
-						throwException(tr("Missing mandatory attribute ''{0}'' of XML element {1}.", "osmid", "trustitem"));
+						throwException(tr("Missing mandatory attribute ''{0}'' of XML element {1}.", "osmid", qName));
 					}
 
@@ -100,9 +101,7 @@
 					long uid = Long.parseLong(osmid);
 
-					String osmtype = atts.getValue("type");
-					if (osmtype == null){
-						throwException(tr("Missing mandatory attribute ''{0}''.", "type"));
-					}
-					OsmPrimitiveType t = OsmPrimitiveType.fromApiTypeName(osmtype);
+					OsmPrimitiveType t = OsmPrimitiveType.NODE;
+					if (qName.equals("trustway")) t = OsmPrimitiveType.WAY;
+					else if (qName.equals("trustrelation")) t = OsmPrimitiveType.RELATION;
 
 					// search corresponding OsmPrimitive
@@ -116,25 +115,8 @@
 						missingData.add(osm);
 					}
-					trust = new TrustOSMItem(osm);
-				} else if (qName.equals("key")) {
-					if (atts == null) {
-						throwException(tr("Missing mandatory attribute ''{0}'' of XML element {1}.", "k", "key"));
-					}
-					String key = atts.getValue("k");
-					if (key == null || key.equals("")){
-						throwException(tr("Missing mandatory attribute ''{0}''.", "k"));
-					}
+					trust = TrustOsmPrimitive.createTrustOsmPrimitive(osm);
+
+				} else if (qName.equals("key") || qName.equals("node") || qName.equals("segment") || qName.equals("member")) {
 					tsigs = new TrustSignatures();
-					keySig.put(key, tsigs);
-				} else if (qName.equals("node")) {
-					if (atts == null) {
-						throwException(tr("Missing mandatory attribute ''{0}'' of XML element {1}.", "id", "node"));
-					}
-					String key = atts.getValue("id");
-					if (key == null || key.equals("")){
-						throwException(tr("Missing mandatory attribute ''{0}''.", "id"));
-					}
-					tsigs = new TrustSignatures();
-					nodeSig.put(key, tsigs);
 				} else if (qName.equals("openpgp")) {
 					tmpbuf = new StringBuffer();
@@ -146,8 +128,6 @@
 
 		@Override public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
-			if (qName.equals("trustitem")) {
-				trust.storeAllTagSigs(keySig);
-				//trust.storeAllNodeSigs;
-				trustitems.put(String.valueOf(trust.getOsmItem().getUniqueId()), trust);
+			if (qName.equals("trustnode") || qName.equals("trustway") || qName.equals("trustrelation")) {
+				trustitems.put(TrustOsmPrimitive.createUniqueObjectIdentifier(trust.getOsmPrimitive()), trust);
 			} else if (qName.equals("openpgp")) {
 				// System.out.println(tmpbuf.toString());
@@ -157,4 +137,15 @@
 					throw new OsmDataParsingException(tr("Could not parse OpenPGP message."),e).rememberLocation(locator);
 				}
+			} else if (qName.equals("key")) {
+				String[] kv = TrustOsmPrimitive.generateTagsFromSigtext(tsigs.getOnePlainText());
+				trust.setTagRatings(kv[0], tsigs);
+			} else if (qName.equals("node")) {
+				((TrustNode)trust).setNodeRatings(tsigs);
+			} else if (qName.equals("segment")) {
+				List<Node> nodes = TrustWay.generateSegmentFromSigtext(tsigs.getOnePlainText());
+				((TrustWay)trust).setSegmentRatings(nodes,tsigs);
+			} else if (qName.equals("member")) {
+				RelationMember member = TrustRelation.generateRelationMemberFromSigtext(tsigs.getOnePlainText());
+				((TrustRelation)trust).setMemberRating(TrustOsmPrimitive.createUniqueObjectIdentifier(member.getMember()), tsigs);
 			}
 		}
@@ -165,5 +156,4 @@
 
 		public void parseOpenPGP(String clearsigned) throws IOException {
-			System.out.println("Clearsignedtext vorher:\n"+clearsigned);
 
 			// handle different newline characters and match them all to \n
@@ -188,5 +178,4 @@
 			plain = plain.substring(0, plain.length()-1);
 
-			System.out.println("Plaintext:\n"+plain+"--------- hier is zu ende");
 			PGPSignatureList siglist = (PGPSignatureList)pgpFact.nextObject();
 			for (int i=0; i<siglist.size();i++) {
@@ -211,5 +200,5 @@
 	 * @throws IllegalArgumentException thrown if source is null
 	 */
-	public static Map<String,TrustOSMItem> parseSignatureXML(InputStream source, ProgressMonitor progressMonitor) throws IllegalDataException {
+	public static Map<String,TrustOsmPrimitive> parseSignatureXML(InputStream source, ProgressMonitor progressMonitor) throws IllegalDataException {
 		if (progressMonitor == null) {
 			progressMonitor = NullProgressMonitor.INSTANCE;
Index: applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/io/SigWriter.java
===================================================================
--- applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/io/SigWriter.java	(revision 25266)
+++ applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/io/SigWriter.java	(revision 25269)
@@ -7,11 +7,16 @@
 import java.io.UnsupportedEncodingException;
 import java.util.Collection;
+import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.io.XmlWriter;
-import org.openstreetmap.josm.plugins.trustosm.data.TrustOSMItem;
+import org.openstreetmap.josm.plugins.trustosm.data.TrustNode;
+import org.openstreetmap.josm.plugins.trustosm.data.TrustOsmPrimitive;
+import org.openstreetmap.josm.plugins.trustosm.data.TrustRelation;
 import org.openstreetmap.josm.plugins.trustosm.data.TrustSignatures;
+import org.openstreetmap.josm.plugins.trustosm.data.TrustWay;
 
 public class SigWriter extends XmlWriter {
@@ -27,5 +32,5 @@
 	}
 
-	public void write(Collection<TrustOSMItem> items) {
+	public void write(Collection<TrustOsmPrimitive> items) {
 		writeHeader();
 		indent = "  ";
@@ -37,15 +42,21 @@
 	private void writeDTD() {
 		out.println("<!DOCTYPE trustXML [");
-		out.println("  <!ELEMENT trustcollection (trustitem)*>");
-		out.println("  <!ATTLIST trustcollection version CDATA #IMPLIED creator CDATA #IMPLIED >");
-		out.println("  <!ELEMENT trustitem (signatures)*>");
-		out.println("  <!ATTLIST trustitem osmid CDATA #REQUIRED type CDATA #REQUIRED >");
-		out.println("  <!ELEMENT signatures (tags|geometry)*>");
-		out.println("  <!ELEMENT tags (key)*>");
-		out.println("  <!ELEMENT key (openpgp)*>");
-		out.println("  <!ATTLIST key k CDATA #REQUIRED >");
-		out.println("  <!ELEMENT geometry (node)*>");
-		out.println("  <!ELEMENT node (openpgp)*>");
-		out.println("  <!ATTLIST node id CDATA #REQUIRED >");
+		out.println("  <!ELEMENT trustXML (trustnode|trustway|trustrelation)*>");
+		out.println("  <!ATTLIST trustXML version CDATA #IMPLIED creator CDATA #IMPLIED >");
+		out.println("  <!ELEMENT trustnode (tags?,node?)>");
+		out.println("  <!ELEMENT trustway (tags?,segmentlist?)>");
+		out.println("  <!ELEMENT trustrelation (tags?,memberlist?)>");
+		out.println("  <!ATTLIST trustnode osmid CDATA #IMPLIED >");
+		out.println("  <!ATTLIST trustway osmid CDATA #IMPLIED >");
+		out.println("  <!ATTLIST trustrelation osmid CDATA #IMPLIED >");
+		out.println("  <!ELEMENT tags (key)+>");
+		out.println("  <!ELEMENT key (openpgp)+>");
+		out.println("  <!ATTLIST key k CDATA #IMPLIED >");
+		out.println("  <!ELEMENT node (openpgp)>");
+		//		out.println("  <!ATTLIST node id CDATA #REQUIRED >");
+		out.println("  <!ELEMENT segmentlist (segment)*>");
+		out.println("  <!ELEMENT segment (openpgp)+>");
+		out.println("  <!ELEMENT memberlist (member)*>");
+		out.println("  <!ELEMENT member (openpgp)+>");
 		out.println("  <!ELEMENT openpgp (#PCDATA)*>");
 		out.println("]>");
@@ -55,9 +66,9 @@
 		out.println("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>");
 		writeDTD();
-		out.println("<trustcollection version=\"0.1\" creator=\"JOSM Signature export\">");
+		out.println("<trustXML version=\"0.1\" creator=\"JOSM Signature export\">");
 	}
 
 	private void writeFooter() {
-		out.println("</trustcollection>");
+		out.println("</trustXML>");
 	}
 
@@ -69,37 +80,79 @@
 	}
 
-	private void writeItems(Collection<TrustOSMItem> items) {
-		Map<String, TrustSignatures> tagsigs;
-		Map<Node, TrustSignatures> nodesigs;
-
-		for (TrustOSMItem item : items){
-			OsmPrimitive osm = item.getOsmItem();
-
-			openAtt("trustitem", "osmid=\""+String.valueOf(osm.getUniqueId())+"\" type=\""+osm.getType().getAPIName()+"\"");
-			openln("signatures");
-
-			tagsigs = item.getTagSigs();
-			openln("tags");
-			for (String key : tagsigs.keySet()) {
-				openAtt("key","k=\""+key+"\"");
-
-				writeSigs(tagsigs.get(key));
-
-				closeln("key");
+	private void writeTags(TrustOsmPrimitive trust) {
+		Map<String, TrustSignatures> tagsigs = trust.getTagSigs();
+		Set<String> signedKeys = tagsigs.keySet();
+		if (signedKeys.isEmpty()) return;
+		openln("tags");
+		for (String key : signedKeys) {
+			openAtt("key","k=\""+key+"\"");
+
+			writeSigs(tagsigs.get(key));
+
+			closeln("key");
+		}
+		closeln("tags");
+	}
+
+	private void writeNode(TrustNode tn) {
+		TrustSignatures tsigs = tn.getNodeSigs();
+		if (tsigs == null) return;
+		openln("node");
+		writeSigs(tsigs);
+		closeln("node");
+	}
+
+	private void writeSegments(TrustWay tw) {
+		Map<List<Node>, TrustSignatures> segmentSig = tw.getSegmentSigs();
+		Set<List<Node>> signedSegments = segmentSig.keySet();
+		if (signedSegments.isEmpty()) return;
+		openln("segmentlist");
+		for (List<Node> segment : signedSegments) {
+			openln("segment");
+			writeSigs(segmentSig.get(segment));
+			closeln("segment");
+		}
+		closeln("segmentlist");
+	}
+
+	private void writeMembers(TrustRelation tr) {
+		Map<String, TrustSignatures> memberSig = tr.getMemberSigs();
+		Set<String> signedMembers = memberSig.keySet();
+		if (signedMembers.isEmpty()) return;
+		openln("memberlist");
+		for (String member : signedMembers) {
+			openln("member");
+			writeSigs(memberSig.get(member));
+			closeln("member");
+		}
+		closeln("memberlist");
+	}
+
+	private void writeItems(Collection<TrustOsmPrimitive> items) {
+
+		for (TrustOsmPrimitive trust : items){
+			OsmPrimitive osm = trust.getOsmPrimitive();
+			if (trust instanceof TrustNode) {
+				TrustNode tn = (TrustNode) trust;
+				openAtt("trustnode", "osmid=\""+String.valueOf(osm.getUniqueId())+"\"");
+				writeTags(tn);
+				writeNode(tn);
+				closeln("trustnode");
+			} else if (trust instanceof TrustWay) {
+				TrustWay tw = (TrustWay) trust;
+				openAtt("trustway", "osmid=\""+String.valueOf(osm.getUniqueId())+"\"");
+				writeTags(tw);
+				writeSegments(tw);
+				closeln("trustway");
+			} else if (trust instanceof TrustRelation) {
+				TrustRelation tr = (TrustRelation) trust;
+				openAtt("trustrelation", "osmid=\""+String.valueOf(osm.getUniqueId())+"\"");
+				writeTags(tr);
+				writeMembers(tr);
+				closeln("trustrelation");
 			}
-			closeln("tags");
-
-			nodesigs = item.getGeomSigs();
-			openln("geometry");
-			for (Node node : nodesigs.keySet()) {
-				openAtt("node","id=\""+String.valueOf(node.getUniqueId())+"\"");
-
-				writeSigs(nodesigs.get(node));
-
-				closeln("node");
-			}
-			closeln("geometry");
-			closeln("signatures");
-			closeln("trustitem");
+
+			//			openAtt("trustitem", "osmid=\""+String.valueOf(osm.getUniqueId())+"\" type=\""+osm.getType().getAPIName()+"\"");
+
 		}
 	}
Index: applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/util/TrustGPG.java
===================================================================
--- applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/util/TrustGPG.java	(revision 25266)
+++ applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/util/TrustGPG.java	(revision 25269)
@@ -5,4 +5,5 @@
 import java.awt.Component;
 import java.awt.Dimension;
+import java.awt.GridBagLayout;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
@@ -20,12 +21,14 @@
 import java.security.SecureRandom;
 import java.security.Security;
+import java.text.NumberFormat;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
-import java.util.HashMap;
 import java.util.Iterator;
-import java.util.Map;
+import java.util.List;
 import java.util.Random;
 import java.util.Vector;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import javax.swing.Box;
@@ -36,4 +39,5 @@
 import javax.swing.JComponent;
 import javax.swing.JDialog;
+import javax.swing.JFormattedTextField;
 import javax.swing.JLabel;
 import javax.swing.JOptionPane;
@@ -43,6 +47,5 @@
 import javax.swing.SpringLayout;
 
-import org.bouncycastle.bcpg.ArmoredOutputStream;
-import org.bouncycastle.bcpg.BCPGOutputStream;
+import org.bouncycastle.bcpg.sig.NotationData;
 import org.bouncycastle.jce.provider.BouncyCastleProvider;
 import org.bouncycastle.openpgp.PGPEncryptedData;
@@ -64,16 +67,12 @@
 import org.bouncycastle.util.encoders.Hex;
 import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.data.coor.CoordinateFormat;
-import org.openstreetmap.josm.data.coor.LatLon;
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
-import org.openstreetmap.josm.data.osm.Relation;
 import org.openstreetmap.josm.data.osm.Way;
-import org.openstreetmap.josm.plugins.trustosm.data.TrustOSMItem;
-import org.openstreetmap.josm.plugins.trustosm.data.TrustSignatures;
+import org.openstreetmap.josm.plugins.trustosm.data.TrustNode;
+import org.openstreetmap.josm.plugins.trustosm.data.TrustOsmPrimitive;
+import org.openstreetmap.josm.plugins.trustosm.data.TrustWay;
+import org.openstreetmap.josm.tools.GBC;
 import org.openstreetmap.josm.tools.ImageProvider;
-
-import tools.NameGenerator;
-import tools.SpringUtilities;
 
 import com.toedter.calendar.JDateChooser;
@@ -88,5 +87,7 @@
 	private static int digest = PGPUtil.SHA1;
 	private PGPSecretKey pgpSecKey;
-	public boolean keepkey = true;
+	public boolean keepkey = false;
+
+	public static final String NOTATION_DATA_KEY = "trustosm@openstreetmap.org";
 
 	public TrustGPG() {
@@ -130,9 +131,17 @@
 	private void readSecretKey() {
 
+		// if there is no KeyRingCollection we have to create a new one
+		if (pgpSec == null) {
+			try {
+				generateKey();
+			} catch (Exception e) {
+				System.err.println("GPG Key Ring File could not be created in: "+Main.pref.getPluginsDirectory().getPath() + "/trustosm/gnupg/secring.gpg");
+			}
+		}
 		//
 		// we just loop through the collection till we find a key suitable for encryption, in the real
 		// world you would probably want to be a bit smarter about this.
 		//
-		if (keepkey && pgpSecKey != null) return;
+		if (keepkey) return;
 
 		final ArrayList<PGPSecretKey> sigKeys = new ArrayList<PGPSecretKey>();
@@ -243,4 +252,6 @@
 				pgpSecKey = sigKeys.get(keyBox.getSelectedIndex());
 			}
+		} else {
+			pgpSecKey = null;
 		}
 		//String selection = (String) JOptionPane.showInputDialog(null, tr("Select a Key to sign"),tr("Secret Key Choice"), JOptionPane.OK_CANCEL_OPTION, null, keys, keys[0]);
@@ -263,8 +274,6 @@
 		} catch (FileNotFoundException e) {
 			System.err.println("No gpg files found in "+Main.pref.getPluginsDirectory().getPath() + "/trustosm/gnupg/secring.gpg");
-			System.err.println("Creating new...");
 			pgpSec = null;
 			pgpPub = null;
-			generateKey();
 		}
 
@@ -282,22 +291,5 @@
 	}
 
-	public static String[] generateTagsFromSigtext(String sigtext) {
-		String[] keyValue = sigtext.substring(sigtext.indexOf('\n')).split("=");
-		return keyValue;
-	}
-
-	public static String generateTagSigtext(OsmPrimitive osm, String key) {
-		String sigtext = "ID=" + osm.getUniqueId() + "\n";
-		sigtext += key + "=" + osm.get(key);
-		return sigtext;
-	}
-
-	public static String generateNodeSigtext(OsmPrimitive osm, Node node) {
-		LatLon point = node.getCoor();
-		String sigtext = "ID=" + osm.getUniqueId() + "\n";
-		sigtext += "Lat:" + point.latToString(CoordinateFormat.DECIMAL_DEGREES) + "\n";
-		sigtext += "Lon:" + point.lonToString(CoordinateFormat.DECIMAL_DEGREES);
-		return sigtext;
-	}
+
 
 	public void getPasswordfromUser() {
@@ -325,7 +317,7 @@
 		 */
 	}
-
-	public void checkTag(TrustOSMItem trust, String key) {
-		String sigtext = generateTagSigtext(trust.getOsmItem(),key);
+	/*
+	public void checkTag(TrustOsmPrimitive trust, String key) {
+		String sigtext = TrustOsmPrimitive.generateTagSigtext(trust.getOsmPrimitive(),key);
 		TrustSignatures sigs;
 		if ((sigs = trust.getSigsOnKey(key))!=null)
@@ -335,15 +327,8 @@
 	}
 
-	public void checkNode(TrustOSMItem trust, Node node) {
-		String sigtext = generateNodeSigtext(trust.getOsmItem(),node);
-		TrustSignatures sigs;
-		if ((sigs = trust.getSigsOnNode(node))!=null)
-			for (PGPSignature sig : sigs.getSignatures()) {
-				trust.updateNodeSigStatus(node, verify(sigtext,sig)? TrustSignatures.SIG_VALID : TrustSignatures.SIG_BROKEN);
-			}
-	}
-
-	public void checkAll(TrustOSMItem trust) {
-		OsmPrimitive osm = trust.getOsmItem();
+
+
+	/*	public void checkAll(TrustOsmPrimitive trust) {
+		OsmPrimitive osm = trust.getOsmPrimitive();
 		for (String key : osm.keySet()) {
 			checkTag(trust, key);
@@ -351,23 +336,25 @@
 
 		if(osm instanceof Node) {
-			checkNode(trust, (Node)osm);
+			checkNode((TrustNode) trust);
 		} else if(osm instanceof Way) {
-			Iterator<Node> iter = ((Way)osm).getNodes().iterator();
+			/*			Iterator<Node> iter = ((Way)osm).getNodes().iterator();
 			while (iter.hasNext()) {
 				checkNode(trust, iter.next());
-			}
+			}/
 		} else if(osm instanceof Relation) {
 
 		}
 	}
+	 */
 
 	public void invalidIDWarning(OsmPrimitive osm) {
 		JOptionPane.showMessageDialog(Main.parent, 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.",osm.getUniqueId(),osm.toString()), tr("Signing canceled!"), JOptionPane.ERROR_MESSAGE);
 	}
-
-	public TrustOSMItem signGeometry(TrustOSMItem trust) {
+	/*
+	public TrustOsmPrimitive signGeometry(TrustOsmPrimitive trust) {
+		PGPSignatureSubpacketGenerator spGen = chooseAccuracy();
 		PGPSignature s;
 		Node node;
-		OsmPrimitive osm = trust.getOsmItem();
+		OsmPrimitive osm = trust.getOsmPrimitive();
 		if (osm.isNew()) {
 			invalidIDWarning(osm);
@@ -375,12 +362,12 @@
 		}
 		if(osm instanceof Node) {
-			s = signNode(osm,(Node)osm);
-			if (s != null) trust.storeNodeSig((Node)osm, s);
+			s = signNode(osm,(Node)osm, spGen);
+			if (s != null) ((TrustNode)trust).storeNodeSig(s);
 		} else if(osm instanceof Way) {
 			Iterator<Node> iter = ((Way)osm).getNodes().iterator();
 			while (iter.hasNext()) {
 				node = iter.next();
-				s = signNode(osm,node);
-				if (s != null) trust.storeNodeSig(node, s);
+				s = signNode(osm,node,spGen);
+				if (s != null) ((TrustNode)trust).storeNodeSig(s);
 			}
 		} else if(osm instanceof Relation) {
@@ -388,31 +375,153 @@
 		}
 		return trust;
-	}
-
-	public PGPSignature signNode(OsmPrimitive osm, Node node) {
+	}*/
+
+	public TrustWay signWay(TrustWay trust) {
+		PGPSignature s;
+		Way w = (Way) trust.getOsmPrimitive();
+		if (w.isNew()) {
+			invalidIDWarning(w);
+			return trust;
+		}
+		/*
+		List<Node> nodes = w.getNodes();
+		s = signSegment(trust,nodes);
+		if (s != null) trust.storeSegmentSig(nodes,s);
+		 */
+		List<Node> wayNodes = w.getNodes();
+		for (int i=0; i<wayNodes.size()-1; i++) {
+			List<Node> nodes = new ArrayList<Node>();
+			nodes.add(wayNodes.get(i));
+			nodes.add(wayNodes.get(i+1));
+			s = signSegment(trust,nodes);
+			if (s != null) trust.storeSegmentSig(nodes,s);
+		}
+
+		return trust;
+	}
+
+	public PGPSignature signSegment(TrustWay trust, List<Node> nodes) {
+		Way w = (Way) trust.getOsmPrimitive();
+		if (w.isNew()) {
+			invalidIDWarning(w);
+			return null;
+		}
+		String tosign = TrustWay.generateSegmentSigtext(trust,nodes);
+		PGPSignatureSubpacketGenerator spGen = chooseAccuracy();
+		return sign(tosign,spGen);
+	}
+
+	public PGPSignature signNode(Node node) {
+		PGPSignatureSubpacketGenerator  spGen = chooseAccuracy();
+		return signNode(node,spGen);
+	}
+
+	public PGPSignature signNode(Node node, PGPSignatureSubpacketGenerator spGen) {
+		if (node.isNew()) {
+			invalidIDWarning(node);
+			return null;
+		}
+		String tosign = TrustNode.generateNodeSigtext(node);
+		return sign(tosign,spGen);
+	}
+
+	public boolean signTag(TrustOsmPrimitive trust, String key) {
+		OsmPrimitive osm = trust.getOsmPrimitive();
 		if (osm.isNew()) {
 			invalidIDWarning(osm);
-			return null;
-		}
-		String tosign = generateNodeSigtext(osm,node);
-		return sign(tosign);
-	}
-
-	public TrustOSMItem signTag(TrustOSMItem trust, String key) {
-		OsmPrimitive osm = trust.getOsmItem();
-		if (osm.isNew()) {
-			invalidIDWarning(osm);
-			return trust;
+			return false;
 		}
 		PGPSignature s;
-		String tosign = generateTagSigtext(osm,key);
-		s = sign(tosign);
-		if (s != null)
+		String tosign = TrustOsmPrimitive.generateTagSigtext(osm,key);
+		//s = sign(tosign);
+		s = sign(tosign,chooseInformationSource());
+		if (s != null) {
 			trust.storeTagSig(key, s);
-		return trust;
+			return true;
+		}
+		return false;
+	}
+
+	/**
+	 * Search in a given Signature for Tolerance information.
+	 * @param sig
+	 * @return found tolerance as double or 0 if no Tolerance is given
+	 */
+
+	public static double searchTolerance(PGPSignature sig) {
+		/** Take the first NotationData packet that seems to have Tolerance information */
+		for (NotationData nd : sig.getHashedSubPackets().getNotationDataOccurences()){
+			if (nd.getNotationName().equals(TrustGPG.NOTATION_DATA_KEY)) {
+				String notation = nd.getNotationValue();
+				Pattern p = Pattern.compile("^Tolerance:(\\d*\\.?\\d*)m");
+				Matcher m = p.matcher(notation);
+				if (m.matches()) { // we found a valid Tolerance
+					return Double.parseDouble(m.group(1));
+				}
+			}
+		}
+		return 0;
+	}
+
+	public PGPSignatureSubpacketGenerator chooseAccuracy() {
+		PGPSignatureSubpacketGenerator  spGen = new PGPSignatureSubpacketGenerator();
+		JPanel p = new JPanel(new GridBagLayout());
+		p.add(new JLabel(tr("Please give a tolerance in meters")),GBC.eol());
+
+		JFormattedTextField meters = new JFormattedTextField(NumberFormat.getNumberInstance());
+		meters.setValue(new Double(10));
+		meters.setColumns(5);
+
+		p.add(meters,GBC.std());
+		p.add(new JLabel(tr("meters")),GBC.eol());
+
+		int n = JOptionPane.showOptionDialog(Main.parent, p, tr("Accuracy"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
+
+		if (n == JOptionPane.OK_OPTION) {
+			spGen.setNotationData(false, true, TrustGPG.NOTATION_DATA_KEY, "Tolerance:"+meters.getValue()+"m");
+			return spGen;
+		}
+		return null;
+	}
+
+	public PGPSignatureSubpacketGenerator chooseInformationSource() {
+		PGPSignatureSubpacketGenerator  spGen = new PGPSignatureSubpacketGenerator();
+		JPanel p = new JPanel(new GridBagLayout());
+		p.add(new JLabel(tr("Select as much as you like:")),GBC.eol());
+
+		JCheckBox survey = new JCheckBox(tr("Survey"));
+		p.add(survey,GBC.eol());
+
+		JCheckBox aerial = new JCheckBox(tr("Aerial Photography"));
+		p.add(aerial,GBC.eol());
+
+		JCheckBox web = new JCheckBox(tr("Web Recherche"));
+		p.add(web,GBC.eol());
+
+		JCheckBox trusted = new JCheckBox(tr("Trusted persons told me"));
+		p.add(trusted,GBC.eol());
+
+		int n = JOptionPane.showOptionDialog(Main.parent, p, tr("Which source did you use?"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
+
+		if (n == JOptionPane.OK_OPTION) {
+			String sources = "Sources:";
+			if (survey.isSelected()) sources += ":survey";
+			if (aerial.isSelected()) sources += ":aerial";
+			if (web.isSelected()) sources += ":web";
+			if (trusted.isSelected()) sources += ":trusted";
+			spGen.setNotationData(false, true, TrustGPG.NOTATION_DATA_KEY, sources);
+			return spGen;
+		}
+		return null;
 	}
 
 	public PGPSignature sign(String tosign) {
-
+		PGPSignatureSubpacketGenerator  spGen = new PGPSignatureSubpacketGenerator();
+		return sign(tosign,spGen);
+	}
+
+	public PGPSignature sign(String tosign, PGPSignatureSubpacketGenerator spGen) {
+
+		if (spGen == null) return null;
 		PGPSignature sig;
 		try{
@@ -428,19 +537,18 @@
 			PGPSignatureGenerator sGen = new PGPSignatureGenerator(pgpSecKey.getPublicKey().getAlgorithm(), digest, "BC");
 			sGen.initSign(PGPSignature.CANONICAL_TEXT_DOCUMENT, pgpPrivKey);
+
 			Iterator it = pgpSecKey.getPublicKey().getUserIDs();
-			if (it.hasNext())
-			{
-				PGPSignatureSubpacketGenerator  spGen = new PGPSignatureSubpacketGenerator();
-
+			if (it.hasNext()) {
 				spGen.setSignerUserID(false, (String)it.next());
-				sGen.setHashedSubpackets(spGen.generate());
-			}
+			}
+			sGen.setHashedSubpackets(spGen.generate());
 			sGen.update(tosign.getBytes(Charset.forName("UTF-8")));
 			sig = sGen.generate();
+			//System.out.println(new String(sGen.generateOnePassVersion(false).getEncoded(),Charset.forName("UTF-8")));
 			//writeSignatureToFile(sig, tosign, new FileOutputStream("/tmp/sigtest.asc"));
 			//sig.encode(new BCPGOutputStream(new ArmoredOutputStream(new FileOutputStream("/tmp/sigtest.asc"))));
 			return sig;
 		}catch (Exception e){//Catch exception if any
-			System.err.println("Error: " + e.getMessage());
+			System.err.println("PGP Signing Error: " + e.getMessage());
 		}
 
@@ -471,5 +579,5 @@
 			return sig.verify();
 		}catch (Exception e){//Catch exception if any
-			System.err.println("Error: " + e.getMessage());
+			System.err.println("PGP Verification Error: " + e.getMessage());
 		}
 		return false;
@@ -477,29 +585,29 @@
 
 
-	public static void writeSignatureToFile(PGPSignature sig, String clearText, FileOutputStream fout) throws Exception {
-		ArmoredOutputStream aOut = new ArmoredOutputStream(fout);
-		aOut.beginClearText(digest);
-		aOut.write(clearText.getBytes(Charset.forName("UTF-8")));
-		aOut.write('\n');
-		aOut.endClearText();
-
-		BCPGOutputStream bOut = new BCPGOutputStream(aOut);
-		sig.encode(bOut);
-		aOut.close();
-		bOut.close();
-	}
-
-	public Map<String, String> getKeyValueFromSignature(PGPSignature sig) {
-		Map<String, String> tags = new HashMap<String, String>();
-		try {
-			String sigtext = new String(sig.getEncoded(), Charset.forName("UTF-8"));
-			String[] kv = generateTagsFromSigtext(sigtext);
-			tags.put(kv[0],kv[1]);
-		} catch (IOException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
-		return tags;
-	}
+	//	public static void writeSignatureToFile(PGPSignature sig, String clearText, FileOutputStream fout) throws Exception {
+	//		ArmoredOutputStream aOut = new ArmoredOutputStream(fout);
+	//		aOut.beginClearText(digest);
+	//		aOut.write(clearText.getBytes(Charset.forName("UTF-8")));
+	//		aOut.write('\n');
+	//		aOut.endClearText();
+	//
+	//		BCPGOutputStream bOut = new BCPGOutputStream(aOut);
+	//		sig.encode(bOut);
+	//		aOut.close();
+	//		bOut.close();
+	//	}
+	//
+	//	public Map<String, String> getKeyValueFromSignature(PGPSignature sig) {
+	//		Map<String, String> tags = new HashMap<String, String>();
+	//		try {
+	//			String sigtext = new String(sig.getEncoded(), Charset.forName("UTF-8"));
+	//			String[] kv = TrustOsmPrimitive.generateTagsFromSigtext(sigtext);
+	//			tags.put(kv[0],kv[1]);
+	//		} catch (IOException e) {
+	//			// TODO Auto-generated catch block
+	//			e.printStackTrace();
+	//		}
+	//		return tags;
+	//	}
 
 	public static void showKeyDetails(PGPPublicKey key) {
@@ -738,5 +846,5 @@
 
 
-		//writeGpgFiles();
+		writeGpgFiles();
 
 		return secRing.getSecretKey();
