Index: applications/editors/josm/plugins/trustosm/.classpath
===================================================================
--- applications/editors/josm/plugins/trustosm/.classpath	(revision 30724)
+++ applications/editors/josm/plugins/trustosm/.classpath	(revision 30724)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="lib" path="lib/bcpg-jdk16-145.jar"/>
+	<classpathentry kind="lib" path="lib/bcprov-jdk16-145.jar"/>
+	<classpathentry kind="lib" path="lib/jcalendar-1.3.3.jar"/>
+	<classpathentry kind="lib" path="lib/looks-2.0.1.jar"/>
+	<classpathentry kind="lib" path="lib/stax-utils.jar"/>
+	<classpathentry kind="lib" path="lib/swingx-core-1.6.2.jar"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/JOSM"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
Index: applications/editors/josm/plugins/trustosm/.project
===================================================================
--- applications/editors/josm/plugins/trustosm/.project	(revision 30724)
+++ applications/editors/josm/plugins/trustosm/.project	(revision 30724)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>JOSM-trustosm</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>
Index: applications/editors/josm/plugins/trustosm/.settings/org.eclipse.core.resources.prefs
===================================================================
--- applications/editors/josm/plugins/trustosm/.settings/org.eclipse.core.resources.prefs	(revision 30724)
+++ applications/editors/josm/plugins/trustosm/.settings/org.eclipse.core.resources.prefs	(revision 30724)
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/src=UTF-8
Index: applications/editors/josm/plugins/trustosm/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- applications/editors/josm/plugins/trustosm/.settings/org.eclipse.jdt.core.prefs	(revision 30724)
+++ applications/editors/josm/plugins/trustosm/.settings/org.eclipse.jdt.core.prefs	(revision 30724)
@@ -0,0 +1,100 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled
+org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
+org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
+org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
+org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
+org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
+org.eclipse.jdt.core.compiler.problem.deadCode=warning
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
+org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
+org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
+org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
+org.eclipse.jdt.core.compiler.problem.nullReference=warning
+org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
+org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
+org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.7
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 30723)
+++ applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/TrustOSMplugin.java	(revision 30724)
@@ -38,248 +38,245 @@
 public class TrustOSMplugin extends Plugin {
 
-	static JMenu gpgJMenu;
-
-	private TrustDialog trustDialog;
-
-	/** Use a TrustGPGPreparer to sign or validate signatures */
-	public static TrustGPG gpg;
-
-	/** A global list with all OSM-Ids and corresponding TrustOSMItems */
-	public static final Map<String, TrustOsmPrimitive> signedItems = new HashMap<String, TrustOsmPrimitive>();
-
-	/**
-	 * Will be invoked by JOSM to bootstrap the plugin
-	 *
-	 * @param info  information about the plugin and its local installation
-	 */
-	public TrustOSMplugin(PluginInformation info) {
-		// 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();
-		// register new SigImporter and SigExporter
-		ExtensionFileFilter.importers.add(new SigImporter());
-		ExtensionFileFilter.exporters.add(new SigExporter());
-
-		gpg = new TrustGPG();
-		setSettings();
-		File gpgDir = new File(getGpgPath());
-		if (!gpgDir.exists())
-			gpgDir.mkdirs();
-
-	}
-
-	public static void checkForUnrestrictedPolicyFiles() {
-		byte[] data = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 };
-
-		// create a cipher and attempt to encrypt the data block with our key
-		try{
-			Cipher c = Cipher.getInstance("AES");
-			// create a 192 bit secret key from raw bytes
-
-			SecretKey key192 = new SecretKeySpec(new byte[] { 0x00, 0x01, 0x02,
-					0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c,
-					0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
-					0x17 }, "AES");
-
-			// now try encrypting with the larger key
-
-			c.init(Cipher.ENCRYPT_MODE, key192);
-			c.doFinal(data);
-		} catch (Exception e) {
-			//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();
-		}
-	}
-
-	public static boolean installUnrestrictedPolicyFiles() {
-		/*
-		String[] cmd = new String[3];
-		cmd[0] = "sudo";
-		cmd[1] = "-S";
-		cmd[2] = "/tmp/skript.sh";
-
-		try
-		{
-			Process p = Runtime.getRuntime().exec(cmd);
-			OutputStream os = p.getOutputStream();
-			Writer writer = new OutputStreamWriter(os);
-
-			JPasswordField passwordField = new JPasswordField(10);
-			JOptionPane.showMessageDialog(null, passwordField, "Enter password", JOptionPane.OK_OPTION);
-			String password = passwordField.getPassword().toString();
-
-			writer.write(password + "\n");
-			writer.close();
-			InputStream in = p.getInputStream();
-			BufferedReader reader = new BufferedReader(new InputStreamReader(in));
-			String satz = reader.readLine();
-			while (satz != null)
-			{
-				System.out.println(satz);
-				satz = reader.readLine();
-			}
-			int rc = p.waitFor();
-		}
-		catch (Exception e)
-		{
-			System.out.println(e.toString());
-		}
-
-		/*
-
-		Process	p;
-		int exitCode;
-		String stdout,stderr;
-		String sysSecPath = System.getProperty("java.home")+"/lib/security";
-		File localPolicy = new File(sysSecPath+"/local_policy.jar");
-		if (!localPolicy.exists()) {
-			System.err.println("No local_policy.jar file found in "+sysSecPath+"\n Is this the right java directory?");
-			return false;
-		}
-
-
-		String cmd = "sh -c sudo -S mv "+sysSecPath+"/local_policy.jar "+sysSecPath+"/local_policy.jar.restricted";
-		/*		String cmd2 = "sudo -S mv "+sysSecPath+"/US_export_policy.jar "+sysSecPath+"/US_export_policy.jar.restricted";
-		String cmd3 = "sudo -S cp "+Main.pref.getPluginsDirectory().getPath()+"/trustosm/jce/US_export_policy.jar "+sysSecPath;
-		String cmd4 = "sudo -S cp "+Main.pref.getPluginsDirectory().getPath()+"/trustosm/jce/local_policy.jar "+sysSecPath;
-
-
-		//System.out.println (cmd);
-
-		try
-		{
-			p = Runtime.getRuntime().exec(cmd);
-		}
-		catch(IOException io)
-		{
-			System.err.println ("io Error" + io.getMessage ());
-			return false;
-		}
-
-		JPasswordField passwordField = new JPasswordField(10);
-		JOptionPane.showMessageDialog(null, passwordField, "Enter password", JOptionPane.OK_OPTION);
-		String password = passwordField.getPassword().toString();
-
-		if (password != null)
-		{
-			BufferedWriter out = new BufferedWriter(new OutputStreamWriter(p.getOutputStream()));
-			try
-			{
-				out.write(password);
-				out.close();
-			}
-			catch(IOException io)
-			{
-				System.err.println("Exception at write! " + io.getMessage ());
-				return false;
-			}
-		}
-
-		try
-		{
-			exitCode = p.exitValue ();
-			if (exitCode==0) {
-				System.err.println("Everything seems to be ok.");
-			} else {
-				System.err.println("Exit code was not 0.");
-				StringBuffer buf = new StringBuffer();
-				InputStream errIn = p.getErrorStream();
-				int read;
-				while ((read = errIn.read()) != -1) {
-					buf.append(read);
-				}
-				System.err.println(buf.toString());
-			}
-		}
-		catch (IllegalThreadStateException itse)
-		{
-			return false;
-		} catch (IOException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
-
-		 */
-		return false;
-	}
-
-	public static boolean extractFiles(String pluginname, String extractDir) {
-		try {
-			if (extractDir == null) extractDir = "lib";
-			JarFile jar = new JarFile(Main.pref.getPluginsDirectory().getPath()+"/"+pluginname+".jar");
-			Enumeration<JarEntry> entries = jar.entries();
-			InputStream is;
-			FileOutputStream fos;
-			File file;
-			while (entries.hasMoreElements()) {
-				JarEntry entry = entries.nextElement();
-				String name = entry.getName();
-				if (name.startsWith(extractDir+"/") && !entry.isDirectory()) {
-					System.out.println(Main.pref.getPluginsDirectory().getPath()+"/"+pluginname+"/"+name);
-					file = new File(Main.pref.getPluginsDirectory().getPath()+"/"+pluginname+"/"+name);
-					file.getParentFile().mkdirs();
-					is = jar.getInputStream(entry);
-					fos = new FileOutputStream(file);
-					while (is.available() > 0) {  // write contents of 'is' to 'fos'
-						fos.write(is.read());
-					}
-					fos.close();
-					is.close();
-				}
-			}
-			return true;
-
-		} catch (IOException e) {
-			e.printStackTrace();
-			return false;
-		}
-
-	}
-
-	public static void refreshMenu() {
-		MainMenu menu = Main.main.menu;
-
-		if (gpgJMenu == null) {
-			gpgJMenu = menu.addMenu(marktr("GPG"), KeyEvent.VK_B, menu.getDefaultMenuPos(), ht("/Plugin/TrustOSM"));
-			gpgJMenu.add(new JMenuItem(new ExportSigsAction()));
-		}
-
-	}
-
-	public static void setSettings() {
-		Map<String,String> prefs = Main.pref.getAllPrefix("trustosm.");
-
-		// if setting isn't present, we set a default
-		// This makes sense for example when we start the plugin for the first time
-		if (!prefs.containsKey("trustosm.gpg")) Main.pref.put("trustosm.gpg", "gpg");
-		if (!prefs.containsKey("trustosm.gpg.separateHomedir")) Main.pref.put("trustosm.gpg.separateHomedir", true);
-	}
-
-
-	@Override
-	public PreferenceSetting getPreferenceSetting() {
-		return new TrustPreferenceEditor();
-	}
-
-	@Override
-	public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
-		if (oldFrame==null && newFrame!=null) {
-			trustDialog = new TrustDialog();
-			newFrame.addToggleDialog(trustDialog);
-		}
-	}
-
-	public static String getGpgPath() {
-		return Main.pref.getPluginsDirectory().getPath() + "/trustosm/gnupg/";
-	}
-
+    static JMenu gpgJMenu;
+
+    private TrustDialog trustDialog;
+
+    /** Use a TrustGPGPreparer to sign or validate signatures */
+    public static TrustGPG gpg;
+
+    /** A global list with all OSM-Ids and corresponding TrustOSMItems */
+    public static final Map<String, TrustOsmPrimitive> signedItems = new HashMap<>();
+
+    /**
+     * Will be invoked by JOSM to bootstrap the plugin
+     *
+     * @param info  information about the plugin and its local installation
+     */
+    public TrustOSMplugin(PluginInformation info) {
+        // 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();
+        // register new SigImporter and SigExporter
+        ExtensionFileFilter.importers.add(new SigImporter());
+        ExtensionFileFilter.exporters.add(new SigExporter());
+
+        gpg = new TrustGPG();
+        setSettings();
+        File gpgDir = new File(getGpgPath());
+        if (!gpgDir.exists())
+            gpgDir.mkdirs();
+
+    }
+
+    public static void checkForUnrestrictedPolicyFiles() {
+        byte[] data = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 };
+
+        // create a cipher and attempt to encrypt the data block with our key
+        try{
+            Cipher c = Cipher.getInstance("AES");
+            // create a 192 bit secret key from raw bytes
+
+            SecretKey key192 = new SecretKeySpec(new byte[] { 0x00, 0x01, 0x02,
+                    0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c,
+                    0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
+                    0x17 }, "AES");
+
+            // now try encrypting with the larger key
+
+            c.init(Cipher.ENCRYPT_MODE, key192);
+            c.doFinal(data);
+        } catch (Exception e) {
+            //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();
+        }
+    }
+
+    public static boolean installUnrestrictedPolicyFiles() {
+        /*
+        String[] cmd = new String[3];
+        cmd[0] = "sudo";
+        cmd[1] = "-S";
+        cmd[2] = "/tmp/skript.sh";
+
+        try
+        {
+            Process p = Runtime.getRuntime().exec(cmd);
+            OutputStream os = p.getOutputStream();
+            Writer writer = new OutputStreamWriter(os);
+
+            JPasswordField passwordField = new JPasswordField(10);
+            JOptionPane.showMessageDialog(null, passwordField, "Enter password", JOptionPane.OK_OPTION);
+            String password = passwordField.getPassword().toString();
+
+            writer.write(password + "\n");
+            writer.close();
+            InputStream in = p.getInputStream();
+            BufferedReader reader = new BufferedReader(new InputStreamReader(in));
+            String satz = reader.readLine();
+            while (satz != null)
+            {
+                System.out.println(satz);
+                satz = reader.readLine();
+            }
+            int rc = p.waitFor();
+        }
+        catch (Exception e)
+        {
+            System.out.println(e.toString());
+        }
+
+        /*
+
+        Process    p;
+        int exitCode;
+        String stdout,stderr;
+        String sysSecPath = System.getProperty("java.home")+"/lib/security";
+        File localPolicy = new File(sysSecPath+"/local_policy.jar");
+        if (!localPolicy.exists()) {
+            System.err.println("No local_policy.jar file found in "+sysSecPath+"\n Is this the right java directory?");
+            return false;
+        }
+
+
+        String cmd = "sh -c sudo -S mv "+sysSecPath+"/local_policy.jar "+sysSecPath+"/local_policy.jar.restricted";
+        /*        String cmd2 = "sudo -S mv "+sysSecPath+"/US_export_policy.jar "+sysSecPath+"/US_export_policy.jar.restricted";
+        String cmd3 = "sudo -S cp "+Main.pref.getPluginsDirectory().getPath()+"/trustosm/jce/US_export_policy.jar "+sysSecPath;
+        String cmd4 = "sudo -S cp "+Main.pref.getPluginsDirectory().getPath()+"/trustosm/jce/local_policy.jar "+sysSecPath;
+
+
+        //System.out.println (cmd);
+
+        try
+        {
+            p = Runtime.getRuntime().exec(cmd);
+        }
+        catch(IOException io)
+        {
+            System.err.println ("io Error" + io.getMessage ());
+            return false;
+        }
+
+        JPasswordField passwordField = new JPasswordField(10);
+        JOptionPane.showMessageDialog(null, passwordField, "Enter password", JOptionPane.OK_OPTION);
+        String password = passwordField.getPassword().toString();
+
+        if (password != null)
+        {
+            BufferedWriter out = new BufferedWriter(new OutputStreamWriter(p.getOutputStream()));
+            try
+            {
+                out.write(password);
+                out.close();
+            }
+            catch(IOException io)
+            {
+                System.err.println("Exception at write! " + io.getMessage ());
+                return false;
+            }
+        }
+
+        try
+        {
+            exitCode = p.exitValue ();
+            if (exitCode==0) {
+                System.err.println("Everything seems to be ok.");
+            } else {
+                System.err.println("Exit code was not 0.");
+                StringBuffer buf = new StringBuffer();
+                InputStream errIn = p.getErrorStream();
+                int read;
+                while ((read = errIn.read()) != -1) {
+                    buf.append(read);
+                }
+                System.err.println(buf.toString());
+            }
+        }
+        catch (IllegalThreadStateException itse)
+        {
+            return false;
+        } catch (IOException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+
+         */
+        return false;
+    }
+
+    public static boolean extractFiles(String pluginname, String extractDir) {
+        if (extractDir == null) extractDir = "lib";
+        String path = Main.pref.getPluginsDirectory().getPath();
+        try (JarFile jar = new JarFile(path+"/"+pluginname+".jar")) {
+            Enumeration<JarEntry> entries = jar.entries();
+            InputStream is;
+            FileOutputStream fos;
+            File file;
+            while (entries.hasMoreElements()) {
+                JarEntry entry = entries.nextElement();
+                String name = entry.getName();
+                if (name.startsWith(extractDir+"/") && !entry.isDirectory()) {
+                    file = new File(path+"/"+pluginname+"/"+name);
+                    file.getParentFile().mkdirs();
+                    is = jar.getInputStream(entry);
+                    fos = new FileOutputStream(file);
+                    while (is.available() > 0) {  // write contents of 'is' to 'fos'
+                        fos.write(is.read());
+                    }
+                    fos.close();
+                    is.close();
+                }
+            }
+            return true;
+
+        } catch (IOException e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+
+    public static void refreshMenu() {
+        MainMenu menu = Main.main.menu;
+
+        if (gpgJMenu == null) {
+            gpgJMenu = menu.addMenu(marktr("GPG"), KeyEvent.VK_B, menu.getDefaultMenuPos(), ht("/Plugin/TrustOSM"));
+            gpgJMenu.add(new JMenuItem(new ExportSigsAction()));
+        }
+
+    }
+
+    public static void setSettings() {
+        Map<String,String> prefs = Main.pref.getAllPrefix("trustosm.");
+
+        // if setting isn't present, we set a default
+        // This makes sense for example when we start the plugin for the first time
+        if (!prefs.containsKey("trustosm.gpg")) Main.pref.put("trustosm.gpg", "gpg");
+        if (!prefs.containsKey("trustosm.gpg.separateHomedir")) Main.pref.put("trustosm.gpg.separateHomedir", true);
+    }
+
+
+    @Override
+    public PreferenceSetting getPreferenceSetting() {
+        return new TrustPreferenceEditor();
+    }
+
+    @Override
+    public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
+        if (oldFrame==null && newFrame!=null) {
+            trustDialog = new TrustDialog();
+            newFrame.addToggleDialog(trustDialog);
+        }
+    }
+
+    public static String getGpgPath() {
+        return Main.pref.getPluginsDirectory().getPath() + "/trustosm/gnupg/";
+    }
 }
Index: applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/actions/ExportSigsAction.java
===================================================================
--- applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/actions/ExportSigsAction.java	(revision 30723)
+++ applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/actions/ExportSigsAction.java	(revision 30724)
@@ -15,33 +15,33 @@
 public class ExportSigsAction extends DiskAccessAction {
 
-	public ExportSigsAction() {
-		super(tr("Export sigs..."), "exportsigs", tr("Export all signatures to XML file."),
-				Shortcut.registerShortcut("file:exportsigs", tr("Export sigs to XML..."), KeyEvent.VK_X, Shortcut.ALT_CTRL));
-	}
+    public ExportSigsAction() {
+        super(tr("Export sigs..."), "exportsigs", tr("Export all signatures to XML file."),
+                Shortcut.registerShortcut("file:exportsigs", tr("Export sigs to XML..."), KeyEvent.VK_X, Shortcut.ALT_CTRL));
+    }
 
-	public ExportSigsAction(String name, String iconName, String tooltip, Shortcut shortcut) {
-		super(name, iconName, tooltip, shortcut);
-	}
+    public ExportSigsAction(String name, String iconName, String tooltip, Shortcut shortcut) {
+        super(name, iconName, tooltip, shortcut);
+    }
 
-	@Override
-	public void actionPerformed(ActionEvent e) {
-		if (!isEnabled())
-			return;
-		doSave();
-	}
+    @Override
+    public void actionPerformed(ActionEvent e) {
+        if (!isEnabled())
+            return;
+        doSave();
+    }
 
-	public boolean doSave() {
-		File f = createAndOpenSaveFileChooser(tr("Save Signatures file"), "tosm");
-		if (f == null)
-			return false;
-		SigExporter exporter = new SigExporter();
-		try {
-			exporter.exportData(f, null);
-		} catch (IOException e) {
-			e.printStackTrace();
-			return false;
-		}
-		return true;
-	}
+    public boolean doSave() {
+        File f = createAndOpenSaveFileChooser(tr("Save Signatures file"), "tosm");
+        if (f == null)
+            return false;
+        SigExporter exporter = new SigExporter();
+        try {
+            exporter.exportData(f, null);
+        } catch (IOException e) {
+            e.printStackTrace();
+            return false;
+        }
+        return true;
+    }
 
 }
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 30723)
+++ applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/actions/GetMissingDataAction.java	(revision 30724)
@@ -21,45 +21,45 @@
 public class GetMissingDataAction extends JosmAction {
 
-	public GetMissingDataAction() {
-		super(tr("Download OSM"),"getmissing",tr("Get all referenced but not actually present OSM objects from OSM server."),
-				Shortcut.registerShortcut("gpg:download", tr("Download referenced osm objects..."), KeyEvent.VK_T, Shortcut.CTRL),true);
-	}
+    public GetMissingDataAction() {
+        super(tr("Download OSM"),"getmissing",tr("Get all referenced but not actually present OSM objects from OSM server."),
+                Shortcut.registerShortcut("gpg:download", tr("Download referenced osm objects..."), KeyEvent.VK_T, Shortcut.CTRL),true);
+    }
 
-	@Override
-	public void actionPerformed(ActionEvent arg0) {
-		if (!isEnabled())
-			return;
-		downloadMissing();
-	}
+    @Override
+    public void actionPerformed(ActionEvent arg0) {
+        if (!isEnabled())
+            return;
+        downloadMissing();
+    }
 
-	public boolean downloadMissing() {
-		Collection<OsmPrimitive> missingData = new HashSet<OsmPrimitive>();
-		Map<String,TrustOsmPrimitive> trustitems = TrustOSMplugin.signedItems;
-		getMissing(trustitems, missingData);
+    public boolean downloadMissing() {
+        Collection<OsmPrimitive> missingData = new HashSet<>();
+        Map<String,TrustOsmPrimitive> trustitems = TrustOSMplugin.signedItems;
+        getMissing(trustitems, missingData);
 
-		int missingCount = missingData.size();
-		int itemCount = trustitems.size();
-		if (missingCount == 0) {
-			JOptionPane.showMessageDialog(Main.parent, tr("{0} Signatures loaded. All referenced OSM objects found.",itemCount));
-		} else {
-			int n = JOptionPane.showOptionDialog(Main.parent, tr("{0} of {1} OSM objects are referenced but not there.\nDo you want to load them from OSM-Server?",missingCount,itemCount), tr("Load objects from server"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
+        int missingCount = missingData.size();
+        int itemCount = trustitems.size();
+        if (missingCount == 0) {
+            JOptionPane.showMessageDialog(Main.parent, tr("{0} Signatures loaded. All referenced OSM objects found.",itemCount));
+        } else {
+            int n = JOptionPane.showOptionDialog(Main.parent, tr("{0} of {1} OSM objects are referenced but not there.\nDo you want to load them from OSM-Server?",missingCount,itemCount), tr("Load objects from server"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
 
-			if (n == JOptionPane.YES_OPTION) {
-				Main.worker.submit(new DownloadSignedOsmDataTask(missingData, Main.main.getEditLayer()));
-				return true;
-			}
-		}
+            if (n == JOptionPane.YES_OPTION) {
+                Main.worker.submit(new DownloadSignedOsmDataTask(missingData, Main.main.getEditLayer()));
+                return true;
+            }
+        }
 
-		return false;
-	}
+        return false;
+    }
 
-	public void getMissing(Map<String,TrustOsmPrimitive> trustitems, Collection<OsmPrimitive> missingData) {
-		Collection<OsmPrimitive> presentData = Main.main.getCurrentDataSet().allPrimitives();
-		for (TrustOsmPrimitive t : trustitems.values()) {
-			OsmPrimitive osm = t.getOsmPrimitive();
-			if (!presentData.contains(osm))
-				missingData.add(osm);
-		}
-	}
+    public void getMissing(Map<String,TrustOsmPrimitive> trustitems, Collection<OsmPrimitive> missingData) {
+        Collection<OsmPrimitive> presentData = Main.main.getCurrentDataSet().allPrimitives();
+        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/TrustNode.java
===================================================================
--- applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/data/TrustNode.java	(revision 30723)
+++ applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/data/TrustNode.java	(revision 30724)
@@ -13,53 +13,53 @@
 
 
-	public static Node generateNodeFromSigtext(String sigtext) {
-		Pattern p = Pattern.compile("^(\\d*)\\((\\d*\\.?\\d*),(\\d*\\.?\\d*)\\)");
-		Matcher m = p.matcher(sigtext);
-		if (m.matches()) {
-			Node node = new Node(Long.parseLong(m.group(1)));
-			node.setCoor(new LatLon(Double.parseDouble(m.group(2)),Double.parseDouble(m.group(3))));
-			return node;
-		}
-		return null;
-	}
+    public static Node generateNodeFromSigtext(String sigtext) {
+        Pattern p = Pattern.compile("^(\\d*)\\((\\d*\\.?\\d*),(\\d*\\.?\\d*)\\)");
+        Matcher m = p.matcher(sigtext);
+        if (m.matches()) {
+            Node node = new Node(Long.parseLong(m.group(1)));
+            node.setCoor(new LatLon(Double.parseDouble(m.group(2)),Double.parseDouble(m.group(3))));
+            return node;
+        }
+        return null;
+    }
 
-	public static String generateNodeSigtext(Node node) {
-		LatLon point = node.getCoor();
-		String sigtext = node.getUniqueId() + "(";
-		sigtext += point.latToString(CoordinateFormat.DECIMAL_DEGREES) + ",";
-		sigtext += point.lonToString(CoordinateFormat.DECIMAL_DEGREES) + ")";
-		return sigtext;
-	}
+    public static String generateNodeSigtext(Node node) {
+        LatLon point = node.getCoor();
+        String sigtext = node.getUniqueId() + "(";
+        sigtext += point.latToString(CoordinateFormat.DECIMAL_DEGREES) + ",";
+        sigtext += point.lonToString(CoordinateFormat.DECIMAL_DEGREES) + ")";
+        return sigtext;
+    }
 
-	private TrustSignatures ratings;
+    private TrustSignatures ratings;
 
-	public TrustNode(Node osmItem) {
-		super(osmItem);
-	}
+    public TrustNode(Node osmItem) {
+        super(osmItem);
+    }
 
-	@Override
-	public void setOsmPrimitive(OsmPrimitive osmItem) {
-		if(osmItem instanceof Node) {
-			osm = osmItem;
-		} else {
-			System.err.println("Error while creating TrustNode: OsmPrimitive "+osmItem.getUniqueId()+" is not a Node!");
-		}
-	}
+    @Override
+    public void setOsmPrimitive(OsmPrimitive osmItem) {
+        if(osmItem instanceof Node) {
+            osm = osmItem;
+        } else {
+            System.err.println("Error while creating TrustNode: OsmPrimitive "+osmItem.getUniqueId()+" is not a Node!");
+        }
+    }
 
-	public void storeNodeSig(PGPSignature sig) {
-		if (ratings == null) {
-			ratings = new TrustSignatures(sig, TrustNode.generateNodeSigtext((Node) osm), TrustSignatures.SIG_VALID);
-		} else {
-			ratings.addSignature(sig, TrustNode.generateNodeSigtext((Node) osm));
-		}
-	}
+    public void storeNodeSig(PGPSignature sig) {
+        if (ratings == null) {
+            ratings = new TrustSignatures(sig, TrustNode.generateNodeSigtext((Node) osm), TrustSignatures.SIG_VALID);
+        } else {
+            ratings.addSignature(sig, TrustNode.generateNodeSigtext((Node) osm));
+        }
+    }
 
-	public void setNodeRatings(TrustSignatures ratings) {
-		this.ratings =ratings;
-	}
+    public void setNodeRatings(TrustSignatures ratings) {
+        this.ratings =ratings;
+    }
 
-	public TrustSignatures getNodeSigs() {
-		return ratings;
-	}
+    public TrustSignatures getNodeSigs() {
+        return ratings;
+    }
 
 }
Index: applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/data/TrustOsmPrimitive.java
===================================================================
--- applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/data/TrustOsmPrimitive.java	(revision 30723)
+++ applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/data/TrustOsmPrimitive.java	(revision 30724)
@@ -13,116 +13,116 @@
 abstract public class TrustOsmPrimitive {
 
-	public static String createUniqueObjectIdentifier(OsmPrimitive osm) {
-		String id = "";
-		if(osm instanceof Node) {
-			id = "n";
-		} else if(osm instanceof Way) {
-			id = "w";
-		} else if(osm instanceof Relation) {
-			id = "r";
-		}
-		id += osm.getUniqueId();
-		return id;
-	}
+    public static String createUniqueObjectIdentifier(OsmPrimitive osm) {
+        String id = "";
+        if(osm instanceof Node) {
+            id = "n";
+        } else if(osm instanceof Way) {
+            id = "w";
+        } else if(osm instanceof Relation) {
+            id = "r";
+        }
+        id += osm.getUniqueId();
+        return id;
+    }
 
-	public static OsmPrimitive createOsmPrimitiveFromUniqueObjectIdentifier(String oid) {
-		char type = oid.charAt(0);
-		long id = Long.parseLong(oid.substring(1));
-		switch (type) {
-		case 'n': return new Node(id);
-		case 'w': return new Way(id);
-		case 'r': return new Relation(id);
-		}
-		return null;
-	}
+    public static OsmPrimitive createOsmPrimitiveFromUniqueObjectIdentifier(String oid) {
+        char type = oid.charAt(0);
+        long id = Long.parseLong(oid.substring(1));
+        switch (type) {
+        case 'n': return new Node(id);
+        case 'w': return new Way(id);
+        case 'r': return new Relation(id);
+        }
+        return null;
+    }
 
-	public static TrustOsmPrimitive createTrustOsmPrimitive(OsmPrimitive osm) {
-		if(osm instanceof Node) {
-			return new TrustNode((Node) osm);
-		} else if(osm instanceof Way) {
-			return new TrustWay(osm);
-		} else if(osm instanceof Relation) {
-			return new TrustRelation(osm);
-		}
-		return null;
-	}
+    public static TrustOsmPrimitive createTrustOsmPrimitive(OsmPrimitive osm) {
+        if(osm instanceof Node) {
+            return new TrustNode((Node) osm);
+        } else if(osm instanceof Way) {
+            return new TrustWay(osm);
+        } else if(osm instanceof Relation) {
+            return new TrustRelation(osm);
+        }
+        return null;
+    }
 
-	protected OsmPrimitive osm;
-	private final Map<String, TrustSignatures> keySig = new HashMap<String, TrustSignatures>();
+    protected OsmPrimitive osm;
+    private final Map<String, TrustSignatures> keySig = new HashMap<>();
 
-	public TrustOsmPrimitive(OsmPrimitive osmItem) {
-		setOsmPrimitive(osmItem);
-	}
+    public TrustOsmPrimitive(OsmPrimitive osmItem) {
+        setOsmPrimitive(osmItem);
+    }
 
-	public OsmPrimitive getOsmPrimitive() {
-		return osm;
-	}
+    public OsmPrimitive getOsmPrimitive() {
+        return osm;
+    }
 
-	public abstract void setOsmPrimitive(OsmPrimitive osmItem);
+    public abstract void setOsmPrimitive(OsmPrimitive osmItem);
 
 
-	public static String[] generateTagsFromSigtext(String sigtext) {
-		String[] keyValue = sigtext.substring(sigtext.indexOf('\n')+1).split("=");
-		return keyValue;
-	}
+    public static String[] generateTagsFromSigtext(String sigtext) {
+        String[] keyValue = sigtext.substring(sigtext.indexOf('\n')+1).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 generateTagSigtext(OsmPrimitive osm, String key) {
+        String sigtext = "ID=" + osm.getUniqueId() + "\n";
+        sigtext += key + "=" + osm.get(key);
+        return sigtext;
+    }
 
-	public void storeTagSig(String key, PGPSignature sig) {
-		if (keySig.containsKey(key)) {
-			keySig.get(key).addSignature(sig, TrustOsmPrimitive.generateTagSigtext(osm, key));
-			return;
-		} else if (osm.keySet().contains(key)) {
-			keySig.put(key, new TrustSignatures(sig, TrustOsmPrimitive.generateTagSigtext(osm, key), TrustSignatures.SIG_VALID));
-		}
-	}
+    public void storeTagSig(String key, PGPSignature sig) {
+        if (keySig.containsKey(key)) {
+            keySig.get(key).addSignature(sig, TrustOsmPrimitive.generateTagSigtext(osm, key));
+            return;
+        } else if (osm.keySet().contains(key)) {
+            keySig.put(key, new TrustSignatures(sig, TrustOsmPrimitive.generateTagSigtext(osm, key), TrustSignatures.SIG_VALID));
+        }
+    }
 
-	public void setTagRatings(String key, TrustSignatures tsigs) {
-		keySig.put(key, tsigs);
-	}
+    public void setTagRatings(String key, TrustSignatures tsigs) {
+        keySig.put(key, tsigs);
+    }
 
-	/*
-	public Map<Node, TrustSignatures> getGeomSigs() {
-		return geomSig;
-	}
+    /*
+    public Map<Node, TrustSignatures> getGeomSigs() {
+        return geomSig;
+    }
 
-	public TrustSignatures getSigsOnNode(Node node) {
-		return geomSig.get(node);
-	}*/
+    public TrustSignatures getSigsOnNode(Node node) {
+        return geomSig.get(node);
+    }*/
 
-	public Set<String> getSignedKeys() {
-		return keySig.keySet();
-	}
+    public Set<String> getSignedKeys() {
+        return keySig.keySet();
+    }
 
-	public Map<String, TrustSignatures> getTagSigs() {
-		return keySig;
-	}
+    public Map<String, TrustSignatures> getTagSigs() {
+        return keySig;
+    }
 
-	public TrustSignatures getSigsOnKey(String key) {
-		return keySig.get(key);
-	}
+    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);
-		}
-	}*/
+    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/TrustRelation.java
===================================================================
--- applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/data/TrustRelation.java	(revision 30723)
+++ applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/data/TrustRelation.java	(revision 30724)
@@ -15,62 +15,62 @@
 
 
-	public static RelationMember generateRelationMemberFromSigtext(String sigtext) {
-		Pattern p = Pattern.compile("^RelID=(\\w*)\n(\\d*),(.*)");
-		Matcher m = p.matcher(sigtext);
-		if (m.matches()) {
-			OsmPrimitive osm = createOsmPrimitiveFromUniqueObjectIdentifier(m.group(2));
-			return new RelationMember(m.group(3),osm);
-		}
-		return null;
-	}
+    public static RelationMember generateRelationMemberFromSigtext(String sigtext) {
+        Pattern p = Pattern.compile("^RelID=(\\w*)\n(\\d*),(.*)");
+        Matcher m = p.matcher(sigtext);
+        if (m.matches()) {
+            OsmPrimitive osm = createOsmPrimitiveFromUniqueObjectIdentifier(m.group(2));
+            return new RelationMember(m.group(3),osm);
+        }
+        return null;
+    }
 
-	public static String generateRelationMemberSigtext(TrustRelation trust, String memID) {
-		Relation r = (Relation)trust.getOsmPrimitive();
-		List<RelationMember> members = r.getMembers();
-		RelationMember member = null;
-		for (RelationMember m : members) {
-			if (TrustOsmPrimitive.createUniqueObjectIdentifier(m.getMember()).equals(memID)) {
-				member = m;
-				break;
-			}
-		}
-		if (member == null) return "";
-		String sigtext = "RelID=" + r.getUniqueId() + "\n";
-		sigtext += TrustOsmPrimitive.createUniqueObjectIdentifier(member.getMember())+","+member.getRole();
-		return sigtext;
-	}
+    public static String generateRelationMemberSigtext(TrustRelation trust, String memID) {
+        Relation r = (Relation)trust.getOsmPrimitive();
+        List<RelationMember> members = r.getMembers();
+        RelationMember member = null;
+        for (RelationMember m : members) {
+            if (TrustOsmPrimitive.createUniqueObjectIdentifier(m.getMember()).equals(memID)) {
+                member = m;
+                break;
+            }
+        }
+        if (member == null) return "";
+        String sigtext = "RelID=" + r.getUniqueId() + "\n";
+        sigtext += TrustOsmPrimitive.createUniqueObjectIdentifier(member.getMember())+","+member.getRole();
+        return sigtext;
+    }
 
-	private final Map<String, TrustSignatures> memberSig = new HashMap<String, TrustSignatures>();
+    private final Map<String, TrustSignatures> memberSig = new HashMap<>();
 
-	public TrustRelation(OsmPrimitive osmItem) {
-		super(osmItem);
-	}
+    public TrustRelation(OsmPrimitive osmItem) {
+        super(osmItem);
+    }
 
-	@Override
-	public void setOsmPrimitive(OsmPrimitive osmItem) {
-		if(osmItem instanceof Relation) {
-			osm = osmItem;
-		} else {
-			System.err.println("Error while creating TrustRelation: OsmPrimitive "+osmItem.getUniqueId()+" is not a Relation!");
-		}
-	}
+    @Override
+    public void setOsmPrimitive(OsmPrimitive osmItem) {
+        if(osmItem instanceof Relation) {
+            osm = osmItem;
+        } else {
+            System.err.println("Error while creating TrustRelation: OsmPrimitive "+osmItem.getUniqueId()+" is not a Relation!");
+        }
+    }
 
 
-	public void storeMemberSig(String memID, PGPSignature sig) {
-		if (memberSig.containsKey(memID)) {
-			memberSig.get(memID).addSignature(sig, TrustRelation.generateRelationMemberSigtext(this, memID));
-			return;
-		} else {
-			memberSig.put(memID, new TrustSignatures(sig, TrustRelation.generateRelationMemberSigtext(this, memID), TrustSignatures.SIG_VALID));
-		}
-	}
+    public void storeMemberSig(String memID, PGPSignature sig) {
+        if (memberSig.containsKey(memID)) {
+            memberSig.get(memID).addSignature(sig, TrustRelation.generateRelationMemberSigtext(this, memID));
+            return;
+        } else {
+            memberSig.put(memID, new TrustSignatures(sig, TrustRelation.generateRelationMemberSigtext(this, memID), TrustSignatures.SIG_VALID));
+        }
+    }
 
-	public void setMemberRating(String memID, TrustSignatures tsigs) {
-		memberSig.put(memID, tsigs);
-	}
+    public void setMemberRating(String memID, TrustSignatures tsigs) {
+        memberSig.put(memID, tsigs);
+    }
 
-	public Map<String, TrustSignatures> getMemberSigs() {
-		return memberSig;
-	}
+    public Map<String, TrustSignatures> getMemberSigs() {
+        return memberSig;
+    }
 
 }
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 30723)
+++ applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/data/TrustSignatures.java	(revision 30724)
@@ -16,161 +16,161 @@
 public class TrustSignatures {
 
-	public final static byte SIG_UNKNOWN = 0;
-	public final static byte SIG_VALID = 1;
-	public final static byte SIG_BROKEN = -1;
-	public final static byte ITEM_REMOVED = -2;
+    public final static byte SIG_UNKNOWN = 0;
+    public final static byte SIG_VALID = 1;
+    public final static byte SIG_BROKEN = -1;
+    public final static byte ITEM_REMOVED = -2;
 
-	//private final Vector<PGPSignature> signatures = new Vector<PGPSignature>();
-	//	private final HashMap<PGPSignature, String> signatureTextMap = new HashMap<PGPSignature, String>();
-	private final Map<String, List<PGPSignature>> textsigs = new HashMap<String, List<PGPSignature>>();
-	private byte status;
-	private double reputation;
+    //private final Vector<PGPSignature> signatures = new Vector<PGPSignature>();
+    //    private final HashMap<PGPSignature, String> signatureTextMap = new HashMap<PGPSignature, String>();
+    private final Map<String, List<PGPSignature>> textsigs = new HashMap<>();
+    private byte status;
+    private double reputation;
 
-	public TrustSignatures() {
-		this.status = SIG_UNKNOWN;
-	}
+    public TrustSignatures() {
+        this.status = SIG_UNKNOWN;
+    }
 
-	public TrustSignatures(PGPSignature signature, String sigtext, byte status) {
-		this.status = status;
-		addSignature(signature, sigtext);
-	}
+    public TrustSignatures(PGPSignature signature, String sigtext, byte status) {
+        this.status = status;
+        addSignature(signature, sigtext);
+    }
 
-	public int countSigs() {
-		//		return signatures.size();
-		//return signatureTextMap.size();
-		int count = 0;
-		for (List<PGPSignature> siglist : textsigs.values()) {
-			count += siglist.size();
-		}
-		return count;
-	}
+    public int countSigs() {
+        //        return signatures.size();
+        //return signatureTextMap.size();
+        int count = 0;
+        for (List<PGPSignature> siglist : textsigs.values()) {
+            count += siglist.size();
+        }
+        return count;
+    }
 
-	public void setReputation(double r) {
-		reputation = r;
-	}
+    public void setReputation(double r) {
+        reputation = r;
+    }
 
-	public double getReputation() {
-		return reputation;
-	}
+    public double getReputation() {
+        return reputation;
+    }
 
-	public void setStatus(byte status) {
-		this.status = status;
-	}
+    public void setStatus(byte status) {
+        this.status = status;
+    }
 
-	public byte getStatus() {
-		return status;
-	}
+    public byte getStatus() {
+        return status;
+    }
 
-	/*	public void setSignatures(Vector<PGPSignature> signatures) {
-		this.signatures.addAll(signatures);
-	}
-	 */
-	public Vector<PGPSignature> getSignatures() {
-		//		return signatures;
-		Vector<PGPSignature> sigs = new Vector<PGPSignature>();
-		for (List<PGPSignature> siglist : textsigs.values()) {
-			sigs.addAll(siglist);
-		}
-		return sigs;
-	}
+    /*    public void setSignatures(Vector<PGPSignature> signatures) {
+        this.signatures.addAll(signatures);
+    }
+     */
+    public Vector<PGPSignature> getSignatures() {
+        //        return signatures;
+        Vector<PGPSignature> sigs = new Vector<>();
+        for (List<PGPSignature> siglist : textsigs.values()) {
+            sigs.addAll(siglist);
+        }
+        return sigs;
+    }
 
-	public Map<String, List<PGPSignature>> getSignaturesWithText() {
-		//		return signatures;
-		return textsigs;
-	}
+    public Map<String, List<PGPSignature>> getSignaturesWithText() {
+        //        return signatures;
+        return textsigs;
+    }
 
-	public List<PGPSignature> getSignaturesByPlaintext(String plain) {
-		return textsigs.get(plain);
-	}
+    public List<PGPSignature> getSignaturesByPlaintext(String plain) {
+        return textsigs.get(plain);
+    }
 
-	public void addSignature(PGPSignature signature, String sigtext) {
-		//		signatures.add(signature);
-		//signatureTextMap.put(signature, sigtext);
-		if (textsigs.containsKey(sigtext)) {
-			textsigs.get(sigtext).add(signature);
-		} else {
-			List<PGPSignature> l = new ArrayList<PGPSignature>();
-			l.add(signature);
-			textsigs.put(sigtext, l);
-		}
-	}
+    public void addSignature(PGPSignature signature, String sigtext) {
+        //        signatures.add(signature);
+        //signatureTextMap.put(signature, sigtext);
+        if (textsigs.containsKey(sigtext)) {
+            textsigs.get(sigtext).add(signature);
+        } else {
+            List<PGPSignature> l = new ArrayList<>();
+            l.add(signature);
+            textsigs.put(sigtext, l);
+        }
+    }
 
-	/*	public void addSignatures(List<PGPSignature> signatures, String sigtext) {
-		textsigs.get(sigtext).addAll(signatures);
-	}
-	 */
+    /*    public void addSignatures(List<PGPSignature> signatures, String sigtext) {
+        textsigs.get(sigtext).addAll(signatures);
+    }
+     */
 
-	/*
-	public PGPSignature getLatestSignature() {
-		return signatures.lastElement();
-	}
-	 */
-	public String getOnePlainText() {
-		Set<String> texts = getAllPlainTexts();
-		if (texts.isEmpty()) return "";
-		else return texts.iterator().next();
-	}
+    /*
+    public PGPSignature getLatestSignature() {
+        return signatures.lastElement();
+    }
+     */
+    public String getOnePlainText() {
+        Set<String> texts = getAllPlainTexts();
+        if (texts.isEmpty()) return "";
+        else return texts.iterator().next();
+    }
 
-	public Set<String> getAllPlainTexts() {
-		return textsigs.keySet();
-	}
+    public Set<String> getAllPlainTexts() {
+        return textsigs.keySet();
+    }
 
-	public String getSigtext(PGPSignature signature) {
-		for (String sigtext : textsigs.keySet()) {
-			if (textsigs.get(sigtext).contains(signature)) return sigtext;
-		}
-		return "";
-	}
+    public String getSigtext(PGPSignature signature) {
+        for (String sigtext : textsigs.keySet()) {
+            if (textsigs.get(sigtext).contains(signature)) return sigtext;
+        }
+        return "";
+    }
 
-	public String getArmoredFulltextSignatureAll(String plain) {
-		if (textsigs.containsKey(plain)){
-			List<PGPSignature> l = textsigs.get(plain);
-			try {
-				ByteArrayOutputStream baos = new ByteArrayOutputStream();
-				ArmoredOutputStream aOut = new ArmoredOutputStream(baos);
-				aOut.beginClearText(l.get(0).getHashAlgorithm());
-				aOut.write(plain.getBytes(Charset.forName("UTF-8")));
-				aOut.write('\n');
-				aOut.endClearText();
+    public String getArmoredFulltextSignatureAll(String plain) {
+        if (textsigs.containsKey(plain)){
+            List<PGPSignature> l = textsigs.get(plain);
+            try {
+                ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                ArmoredOutputStream aOut = new ArmoredOutputStream(baos);
+                aOut.beginClearText(l.get(0).getHashAlgorithm());
+                aOut.write(plain.getBytes(Charset.forName("UTF-8")));
+                aOut.write('\n');
+                aOut.endClearText();
 
-				BCPGOutputStream bOut = new BCPGOutputStream(aOut);
-				for (PGPSignature sig : l) {
-					sig.encode(bOut);
-				}
+                BCPGOutputStream bOut = new BCPGOutputStream(aOut);
+                for (PGPSignature sig : l) {
+                    sig.encode(bOut);
+                }
 
-				bOut.close();
-				aOut.close();
+                bOut.close();
+                aOut.close();
 
-				return baos.toString("UTF-8");
+                return baos.toString("UTF-8");
 
-			} catch (Exception e) {
-				e.printStackTrace();
-				return "Error - read console Output";
-			}
-		}
-		return "No sigs available";
-	}
+            } catch (Exception e) {
+                e.printStackTrace();
+                return "Error - read console Output";
+            }
+        }
+        return "No sigs available";
+    }
 
-	public String getArmoredFulltextSignature(PGPSignature sig) {
-		try {
-			ByteArrayOutputStream baos = new ByteArrayOutputStream();
-			ArmoredOutputStream aOut = new ArmoredOutputStream(baos);
-			aOut.beginClearText(sig.getHashAlgorithm());
-			aOut.write(getSigtext(sig).getBytes(Charset.forName("UTF-8")));
-			aOut.write('\n');
-			aOut.endClearText();
+    public String getArmoredFulltextSignature(PGPSignature sig) {
+        try {
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            ArmoredOutputStream aOut = new ArmoredOutputStream(baos);
+            aOut.beginClearText(sig.getHashAlgorithm());
+            aOut.write(getSigtext(sig).getBytes(Charset.forName("UTF-8")));
+            aOut.write('\n');
+            aOut.endClearText();
 
-			BCPGOutputStream bOut = new BCPGOutputStream(aOut);
-			sig.encode(bOut);
-			bOut.close();
-			aOut.close();
+            BCPGOutputStream bOut = new BCPGOutputStream(aOut);
+            sig.encode(bOut);
+            bOut.close();
+            aOut.close();
 
 
-			return baos.toString("UTF-8");
-		} catch (Exception e) {
-			e.printStackTrace();
-			return "Error - read console Output";
-		}
-	}
+            return baos.toString("UTF-8");
+        } catch (Exception e) {
+            e.printStackTrace();
+            return "Error - read console Output";
+        }
+    }
 
 }
Index: applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/data/TrustWay.java
===================================================================
--- applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/data/TrustWay.java	(revision 30723)
+++ applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/data/TrustWay.java	(revision 30724)
@@ -14,74 +14,74 @@
 public class TrustWay extends TrustOsmPrimitive {
 
-	/*
-	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;
-	}
-	 */
+    /*
+    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;
+    }
+     */
 
-	public static List<Node> generateSegmentFromSigtext(String sigtext) {
-		String[] lines = sigtext.split("\n");
-		List<Node> nodes = new ArrayList<Node>();
-		for (int i=1; i<lines.length; i++){
-			nodes.add(TrustNode.generateNodeFromSigtext(lines[i]));
-		}
-		return nodes;
-	}
+    public static List<Node> generateSegmentFromSigtext(String sigtext) {
+        String[] lines = sigtext.split("\n");
+        List<Node> nodes = new ArrayList<>();
+        for (int i=1; i<lines.length; i++){
+            nodes.add(TrustNode.generateNodeFromSigtext(lines[i]));
+        }
+        return nodes;
+    }
 
-	public static String generateSegmentSigtext(TrustWay trust, List<Node> nodes) {
-		String sigtext = "WayID=" + trust.getOsmPrimitive().getUniqueId();
-		for (Node n : nodes) {
-			sigtext += "\n" + TrustNode.generateNodeSigtext(n);
-		}
-		return sigtext;
-	}
+    public static String generateSegmentSigtext(TrustWay trust, List<Node> nodes) {
+        String sigtext = "WayID=" + trust.getOsmPrimitive().getUniqueId();
+        for (Node n : nodes) {
+            sigtext += "\n" + TrustNode.generateNodeSigtext(n);
+        }
+        return sigtext;
+    }
 
 
-	private final Map<List<Node>, TrustSignatures> segmentSig = new HashMap<List<Node>, TrustSignatures>();
+    private final Map<List<Node>, TrustSignatures> segmentSig = new HashMap<>();
 
-	public TrustWay(OsmPrimitive osmItem) {
-		super(osmItem);
-	}
+    public TrustWay(OsmPrimitive osmItem) {
+        super(osmItem);
+    }
 
-	@Override
-	public void setOsmPrimitive(OsmPrimitive osmItem) {
-		if(osmItem instanceof Way) {
-			osm = osmItem;
-		} else {
-			System.err.println("Error while creating TrustWay: OsmPrimitive "+osmItem.getUniqueId()+" is not a Way!");
-		}
-	}
+    @Override
+    public void setOsmPrimitive(OsmPrimitive osmItem) {
+        if(osmItem instanceof Way) {
+            osm = osmItem;
+        } else {
+            System.err.println("Error while creating TrustWay: OsmPrimitive "+osmItem.getUniqueId()+" is not a Way!");
+        }
+    }
 
 
-	public void storeSegmentSig(List<Node> nodes, PGPSignature sig) {
-		if (segmentSig.containsKey(nodes)) {
-			segmentSig.get(nodes).addSignature(sig, TrustWay.generateSegmentSigtext(this,nodes));
-		} else {
-			segmentSig.put(nodes, new TrustSignatures(sig, TrustWay.generateSegmentSigtext(this,nodes), TrustSignatures.SIG_VALID));
-		}
-	}
+    public void storeSegmentSig(List<Node> nodes, PGPSignature sig) {
+        if (segmentSig.containsKey(nodes)) {
+            segmentSig.get(nodes).addSignature(sig, TrustWay.generateSegmentSigtext(this,nodes));
+        } else {
+            segmentSig.put(nodes, new TrustSignatures(sig, TrustWay.generateSegmentSigtext(this,nodes), TrustSignatures.SIG_VALID));
+        }
+    }
 
-	public void setSegmentRatings(List<Node> nodes, TrustSignatures tsigs) {
-		segmentSig.put(nodes, tsigs);
-	}
+    public void setSegmentRatings(List<Node> nodes, TrustSignatures tsigs) {
+        segmentSig.put(nodes, tsigs);
+    }
 
-	public Map<List<Node>, TrustSignatures> getSegmentSigs() {
-		return segmentSig;
-	}
+    public Map<List<Node>, TrustSignatures> getSegmentSigs() {
+        return segmentSig;
+    }
 
-	public TrustSignatures getSigsOnSegment(WaySegment seg) {
-		List<Node> nodes = new ArrayList<Node>();
-		nodes.add(seg.getFirstNode());
-		nodes.add(seg.getSecondNode());
-		return getSigsOnSegment(nodes);
-	}
+    public TrustSignatures getSigsOnSegment(WaySegment seg) {
+        List<Node> nodes = new ArrayList<>();
+        nodes.add(seg.getFirstNode());
+        nodes.add(seg.getSecondNode());
+        return getSigsOnSegment(nodes);
+    }
 
-	public TrustSignatures getSigsOnSegment(List<Node> nodes) {
-		return segmentSig.get(nodes);
-	}
+    public TrustSignatures getSigsOnSegment(List<Node> nodes) {
+        return segmentSig.get(nodes);
+    }
 
 }
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 30723)
+++ applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/gui/DownloadSignedOsmDataTask.java	(revision 30724)
@@ -25,102 +25,102 @@
 public class DownloadSignedOsmDataTask  extends PleaseWaitRunnable {
 
-	private boolean canceled;
-	private Exception lastException;
-	private final Collection<OsmPrimitive> missing;
-	private final OsmDataLayer curLayer;
-	private MultiFetchServerObjectReader objectReader;
+    private boolean canceled;
+    private Exception lastException;
+    private final Collection<OsmPrimitive> missing;
+    private final OsmDataLayer curLayer;
+    private MultiFetchServerObjectReader objectReader;
 
-	/**
-	 * Download the given OSMPrimitives to the given layer
-	 * 
-	 */
-	public DownloadSignedOsmDataTask(Collection<OsmPrimitive> missing, OsmDataLayer curLayer) {
-		super(tr("Download signed data"));
-		this.missing = missing;
-		this.curLayer = curLayer;
-	}
+    /**
+     * Download the given OSMPrimitives to the given layer
+     * 
+     */
+    public DownloadSignedOsmDataTask(Collection<OsmPrimitive> missing, OsmDataLayer curLayer) {
+        super(tr("Download signed data"));
+        this.missing = missing;
+        this.curLayer = curLayer;
+    }
 
 
-	@Override
-	protected void cancel() {
-		canceled = true;
-		synchronized(this) {
-			if (objectReader != null) {
-				objectReader.cancel();
-			}
-		}
-	}
+    @Override
+    protected void cancel() {
+        canceled = true;
+        synchronized(this) {
+            if (objectReader != null) {
+                objectReader.cancel();
+            }
+        }
+    }
 
-	@Override
-	protected void finish() {
-		Main.map.repaint();
-		if (canceled)
-			return;
-		if (lastException != null) {
-			ExceptionDialogUtil.explainException(lastException);
-		}
-	}
+    @Override
+    protected void finish() {
+        Main.map.repaint();
+        if (canceled)
+            return;
+        if (lastException != null) {
+            ExceptionDialogUtil.explainException(lastException);
+        }
+    }
 
-	protected String buildDownloadFeedbackMessage() {
-		return trn("Downloading {0} incomplete child of relation ''{1}''",
-				"Downloading {0} incomplete children of relation ''{1}''",
-				missing.size(),
-				missing.size(),
-				"Wurst"
-		);
-	}
+    protected String buildDownloadFeedbackMessage() {
+        return trn("Downloading {0} incomplete child of relation ''{1}''",
+                "Downloading {0} incomplete children of relation ''{1}''",
+                missing.size(),
+                missing.size(),
+                "Wurst"
+        );
+    }
 
-	@Override
-	protected void realRun() throws SAXException, IOException, OsmTransferException {
-		try {
-			synchronized (this) {
-				if (canceled) return;
-				objectReader = new MultiFetchServerObjectReader();
-			}
-			objectReader.append(missing);
-			progressMonitor.indeterminateSubTask(
-					buildDownloadFeedbackMessage()
-			);
-			final DataSet dataSet = objectReader.parseOsm(progressMonitor
-					.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false));
-			if (dataSet == null)
-				return;
-			synchronized (this) {
-				if (canceled) return;
-				objectReader = null;
-			}
+    @Override
+    protected void realRun() throws SAXException, IOException, OsmTransferException {
+        try {
+            synchronized (this) {
+                if (canceled) return;
+                objectReader = new MultiFetchServerObjectReader();
+            }
+            objectReader.append(missing);
+            progressMonitor.indeterminateSubTask(
+                    buildDownloadFeedbackMessage()
+            );
+            final DataSet dataSet = objectReader.parseOsm(progressMonitor
+                    .createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false));
+            if (dataSet == null)
+                return;
+            synchronized (this) {
+                if (canceled) return;
+                objectReader = null;
+            }
 
-			SwingUtilities.invokeLater(
-					new Runnable() {
-						public void run() {
-							curLayer.mergeFrom(dataSet);
-							curLayer.onPostDownloadFromServer();
-							AutoScaleAction.zoomTo(dataSet.allPrimitives());
-							updateReferences(dataSet);
-						}
-					}
-			);
+            SwingUtilities.invokeLater(
+                    new Runnable() {
+                        public void run() {
+                            curLayer.mergeFrom(dataSet);
+                            curLayer.onPostDownloadFromServer();
+                            AutoScaleAction.zoomTo(dataSet.allPrimitives());
+                            updateReferences(dataSet);
+                        }
+                    }
+            );
 
-		} catch (Exception e) {
-			if (canceled) {
-				System.out.println(tr("Warning: Ignoring exception because task was canceled. Exception: {0}", e.toString()));
-				return;
-			}
-			lastException = e;
-		}
-	}
+        } catch (Exception e) {
+            if (canceled) {
+                System.out.println(tr("Warning: Ignoring exception because task was canceled. Exception: {0}", e.toString()));
+                return;
+            }
+            lastException = e;
+        }
+    }
 
-	public boolean updateReferences(DataSet ds) {
-		for (TrustOsmPrimitive t : TrustOSMplugin.signedItems.values()) {
-			OsmPrimitive osm = ds.getPrimitiveById(t.getOsmPrimitive().getPrimitiveId());
-			if (osm != null) {
-				t.setOsmPrimitive(osm);
-				return true;
-			} else {
-				System.out.println("No item found");
-			}
-		}
-		return false;
-	}
+    public boolean updateReferences(DataSet ds) {
+        for (TrustOsmPrimitive t : TrustOSMplugin.signedItems.values()) {
+            OsmPrimitive osm = ds.getPrimitiveById(t.getOsmPrimitive().getPrimitiveId());
+            if (osm != null) {
+                t.setOsmPrimitive(osm);
+                return true;
+            } else {
+                System.out.println("No item found");
+            }
+        }
+        return false;
+    }
 
 }
Index: applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/gui/KeyGenerationTask.java
===================================================================
--- applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/gui/KeyGenerationTask.java	(revision 30723)
+++ applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/gui/KeyGenerationTask.java	(revision 30724)
@@ -12,72 +12,72 @@
 public class KeyGenerationTask extends PleaseWaitRunnable {
 
-	private boolean canceled;
-	private Exception lastException;
+    private boolean canceled;
+    private Exception lastException;
 
-	public KeyGenerationTask() {
-		super(tr("Generating new Keypair.\nCollecting randomness..."));
-	}
+    public KeyGenerationTask() {
+        super(tr("Generating new Keypair.\nCollecting randomness..."));
+    }
 
-	@Override
-	protected void cancel() {
-		canceled = true;
-		synchronized(this) {
-			/*		if (objectReader != null) {
-				objectReader.cancel();
-			}*/
-		}
-	}
+    @Override
+    protected void cancel() {
+        canceled = true;
+        synchronized(this) {
+            /*        if (objectReader != null) {
+                objectReader.cancel();
+            }*/
+        }
+    }
 
-	@Override
-	protected void finish() {
-		if (canceled)
-			return;
-		if (lastException != null) {
-			ExceptionDialogUtil.explainException(lastException);
-		}
+    @Override
+    protected void finish() {
+        if (canceled)
+            return;
+        if (lastException != null) {
+            ExceptionDialogUtil.explainException(lastException);
+        }
 
-	}
+    }
 
-	@Override
-	protected void realRun() throws SAXException, IOException,
-	OsmTransferException {
-		try {
-			/*			synchronized (this) {
-				if (canceled) return;
-				objectReader = new MultiFetchServerObjectReader();
-			}
-			objectReader.append(missing);
-			progressMonitor.indeterminateSubTask(
-					buildDownloadFeedbackMessage()
-			);
-			final DataSet dataSet = objectReader.parseOsm(progressMonitor
-					.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false));
-			if (dataSet == null)
-				return;
-			synchronized (this) {
-				if (canceled) return;
-				objectReader = null;
-			}
+    @Override
+    protected void realRun() throws SAXException, IOException,
+    OsmTransferException {
+        try {
+            /*            synchronized (this) {
+                if (canceled) return;
+                objectReader = new MultiFetchServerObjectReader();
+            }
+            objectReader.append(missing);
+            progressMonitor.indeterminateSubTask(
+                    buildDownloadFeedbackMessage()
+            );
+            final DataSet dataSet = objectReader.parseOsm(progressMonitor
+                    .createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false));
+            if (dataSet == null)
+                return;
+            synchronized (this) {
+                if (canceled) return;
+                objectReader = null;
+            }
 
-			SwingUtilities.invokeLater(
-					new Runnable() {
-						public void run() {
-							curLayer.mergeFrom(dataSet);
-							curLayer.onPostDownloadFromServer();
-							AutoScaleAction.zoomTo(dataSet.allPrimitives());
-						}
-					}
-			);
-			 */
-		} catch (Exception e) {
-			if (canceled) {
-				System.out.println(tr("Warning: Ignoring exception because task was canceled. Exception: {0}", e
-						.toString()));
-				return;
-			}
-			lastException = e;
-		}
+            SwingUtilities.invokeLater(
+                    new Runnable() {
+                        public void run() {
+                            curLayer.mergeFrom(dataSet);
+                            curLayer.onPostDownloadFromServer();
+                            AutoScaleAction.zoomTo(dataSet.allPrimitives());
+                        }
+                    }
+            );
+             */
+        } catch (Exception e) {
+            if (canceled) {
+                System.out.println(tr("Warning: Ignoring exception because task was canceled. Exception: {0}", e
+                        .toString()));
+                return;
+            }
+            lastException = e;
+        }
 
-	}
+    }
 
 }
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 30723)
+++ applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/gui/KeyTreeTableModel.java	(revision 30724)
@@ -20,134 +20,134 @@
 public class KeyTreeTableModel extends AbstractTreeTableModel {
 
-	public static String convPGPSignatureToString(PGPSignature s) {
-		if (s==null) return null;
-		PGPSignatureSubpacketVector sv = s.getHashedSubPackets();
-		if (sv != null && sv.hasSubpacket(SignatureSubpacketTags.SIGNER_USER_ID))
-			return sv.getSignerUserID();
+    public static String convPGPSignatureToString(PGPSignature s) {
+        if (s==null) return null;
+        PGPSignatureSubpacketVector sv = s.getHashedSubPackets();
+        if (sv != null && sv.hasSubpacket(SignatureSubpacketTags.SIGNER_USER_ID))
+            return sv.getSignerUserID();
 
-		PGPPublicKey pub = TrustOSMplugin.gpg.getPublicKeyFromRing(s.getKeyID());
-		if (pub != null){
-			Iterator i = pub.getUserIDs();
-			if (i.hasNext())
-				return (String)i.next();
+        PGPPublicKey pub = TrustOSMplugin.gpg.getPublicKeyFromRing(s.getKeyID());
+        if (pub != null){
+            Iterator<?> i = pub.getUserIDs();
+            if (i.hasNext())
+                return (String)i.next();
 
-		}
-		return tr("unknown");
-	}
+        }
+        return tr("unknown");
+    }
 
-	private final SignatureTreeNode root;
-	private final String[] allTitle = {tr("UID"),tr("KeyID"),tr("OSM-Info"),tr("Signed")};
-	private final List<String> columns = new ArrayList<String>(Arrays.asList(allTitle));
+    private final SignatureTreeNode root;
+    private final String[] allTitle = {tr("UID"),tr("KeyID"),tr("OSM-Info"),tr("Signed")};
+    private final List<String> columns = new ArrayList<>(Arrays.asList(allTitle));
 
-	public KeyTreeTableModel(Collection<PGPSignature> sigs) {
-		root = new SignatureTreeNode();
-		for (PGPSignature s : sigs){
-			SignatureTreeNode sn = new SignatureTreeNode(s);
-			PGPPublicKey pub = TrustOSMplugin.gpg.getPublicKeyFromRing(s.getKeyID());
-			Iterator iter = pub.getSignatures();
-			while (iter.hasNext()){
-				PGPSignature ks = (PGPSignature)iter.next();
-				sn.getChildren().add(new SignatureTreeNode(ks));
-			}
-			root.getChildren().add(sn);
-		}
-	}
+    public KeyTreeTableModel(Collection<PGPSignature> sigs) {
+        root = new SignatureTreeNode();
+        for (PGPSignature s : sigs){
+            SignatureTreeNode sn = new SignatureTreeNode(s);
+            PGPPublicKey pub = TrustOSMplugin.gpg.getPublicKeyFromRing(s.getKeyID());
+            Iterator<?> iter = pub.getSignatures();
+            while (iter.hasNext()){
+                PGPSignature ks = (PGPSignature)iter.next();
+                sn.getChildren().add(new SignatureTreeNode(ks));
+            }
+            root.getChildren().add(sn);
+        }
+    }
 
-	@Override
-	public int getColumnCount() {
-		return columns.size();
-	}
+    @Override
+    public int getColumnCount() {
+        return columns.size();
+    }
 
-	@Override
-	public String getColumnName( int column ) {
-		String title = columns.get(column);
-		if (title != null)
-			return title;
-		return tr("Unknown");
-	}
+    @Override
+    public String getColumnName( int column ) {
+        String title = columns.get(column);
+        if (title != null)
+            return title;
+        return tr("Unknown");
+    }
 
 
-	@Override
-	public Object getValueAt(Object node, int column) {
-		SignatureTreeNode signode = ( SignatureTreeNode )node;
-		String title = columns.get(column);
-		if (title != null){
-			if (title.equals(allTitle[0]))
-				return signode.getUID();
-			if (title.equals(allTitle[1]))
-				return signode.getKeyID();
-			if (title.equals(allTitle[2]))
-				return signode.getOsmCertificate();
-			if (title.equals(allTitle[3]))
-				return signode.getSignatureDate();
-		}
-		return tr("Unknown");
+    @Override
+    public Object getValueAt(Object node, int column) {
+        SignatureTreeNode signode = ( SignatureTreeNode )node;
+        String title = columns.get(column);
+        if (title != null){
+            if (title.equals(allTitle[0]))
+                return signode.getUID();
+            if (title.equals(allTitle[1]))
+                return signode.getKeyID();
+            if (title.equals(allTitle[2]))
+                return signode.getOsmCertificate();
+            if (title.equals(allTitle[3]))
+                return signode.getSignatureDate();
+        }
+        return tr("Unknown");
 
-	}
+    }
 
-	@Override
-	public Object getChild(Object node, int index) {
-		SignatureTreeNode signode = ( SignatureTreeNode )node;
-		return signode.getChildren().get( index );
-	}
+    @Override
+    public Object getChild(Object node, int index) {
+        SignatureTreeNode signode = ( SignatureTreeNode )node;
+        return signode.getChildren().get( index );
+    }
 
-	@Override
-	public int getChildCount(Object node) {
-		SignatureTreeNode signode = ( SignatureTreeNode )node;
-		return signode.getChildren().size();
-	}
+    @Override
+    public int getChildCount(Object node) {
+        SignatureTreeNode signode = ( SignatureTreeNode )node;
+        return signode.getChildren().size();
+    }
 
-	@Override
-	public int getIndexOfChild( Object parent, Object child ) {
-		SignatureTreeNode signode = ( SignatureTreeNode )parent;
-		for( int i=0; i>signode.getChildren().size(); i++ ) {
-			if( signode.getChildren().get( i ) == child )
-				return i;
-		}
-		return 0;
-	}
+    @Override
+    public int getIndexOfChild( Object parent, Object child ) {
+        SignatureTreeNode signode = ( SignatureTreeNode )parent;
+        for( int i=0; i>signode.getChildren().size(); i++ ) {
+            if( signode.getChildren().get( i ) == child )
+                return i;
+        }
+        return 0;
+    }
 
-	@Override
-	public Object getRoot() {
-		return root;
-	}
+    @Override
+    public Object getRoot() {
+        return root;
+    }
 
 
-	public class SignatureTreeNode {
-		private PGPSignature s;
-		private final List<SignatureTreeNode> children = new ArrayList<SignatureTreeNode>();
-		private final SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd:hh.mm.ss");
-		public SignatureTreeNode() {
-		}
+    public class SignatureTreeNode {
+        private PGPSignature s;
+        private final List<SignatureTreeNode> children = new ArrayList<>();
+        private final SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd:hh.mm.ss");
+        public SignatureTreeNode() {
+        }
 
-		public SignatureTreeNode(PGPSignature s) {
-			this.s = s;
-		}
+        public SignatureTreeNode(PGPSignature s) {
+            this.s = s;
+        }
 
-		public PGPSignature getSignature(){
-			return s;
-		}
-		public String getUID() {
-			return convPGPSignatureToString(s);
-		}
-		public String getKeyID() {
-			return "0x"+Long.toHexString(s.getKeyID()).substring(8).toUpperCase();
-		}
-		public String getOsmCertificate() {
-			String cert = "";
-			for (NotationData nd : s.getHashedSubPackets().getNotationDataOccurences()){
-				if (nd.getNotationName().equals("trustosm@openstreetmap.org")) {
-					cert += nd.getNotationValue();
-				}
-			}
-			return cert;
-		}
-		public String getSignatureDate() {
-			return formatter.format(s.getCreationTime());
-		}
-		public List<SignatureTreeNode> getChildren() {
-			return children;
-		}
+        public PGPSignature getSignature(){
+            return s;
+        }
+        public String getUID() {
+            return convPGPSignatureToString(s);
+        }
+        public String getKeyID() {
+            return "0x"+Long.toHexString(s.getKeyID()).substring(8).toUpperCase();
+        }
+        public String getOsmCertificate() {
+            String cert = "";
+            for (NotationData nd : s.getHashedSubPackets().getNotationDataOccurences()){
+                if (nd.getNotationName().equals("trustosm@openstreetmap.org")) {
+                    cert += nd.getNotationValue();
+                }
+            }
+            return cert;
+        }
+        public String getSignatureDate() {
+            return formatter.format(s.getCreationTime());
+        }
+        public List<SignatureTreeNode> getChildren() {
+            return children;
+        }
 
-	}
+    }
 }
Index: applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/gui/dialogs/JCollapsiblePanel.java
===================================================================
--- applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/gui/dialogs/JCollapsiblePanel.java	(revision 30723)
+++ applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/gui/dialogs/JCollapsiblePanel.java	(revision 30724)
@@ -14,52 +14,52 @@
 public class JCollapsiblePanel extends JPanel {
 
-	private boolean expanded;
-	JPanel contentPanel_;
-	HeaderPanel headerPanel_;
+    private boolean expanded;
+    JPanel contentPanel_;
+    HeaderPanel headerPanel_;
 
-	private class HeaderPanel extends JPanel {
-		JLabel title;
+    private class HeaderPanel extends JPanel {
+        JLabel title;
 
-		public HeaderPanel(String text) {
+        public HeaderPanel(String text) {
 
-			setLayout(new GridBagLayout());
-			title = new JLabel(text,ImageProvider.get("misc", "minimized"),SwingConstants.LEADING);
-			add(title,GBC.eol());
+            setLayout(new GridBagLayout());
+            title = new JLabel(text,ImageProvider.get("misc", "minimized"),SwingConstants.LEADING);
+            add(title,GBC.eol());
 
 
-			addMouseListener(
-					new MouseAdapter() {
-						@Override
-						public void mouseClicked(MouseEvent e) {
-							expanded = !expanded;
+            addMouseListener(
+                    new MouseAdapter() {
+                        @Override
+                        public void mouseClicked(MouseEvent e) {
+                            expanded = !expanded;
 
-							if (contentPanel_.isShowing()) {
-								contentPanel_.setVisible(false);
-								title.setIcon(ImageProvider.get("misc", "minimized"));
-							}
-							else {
-								contentPanel_.setVisible(true);
-								title.setIcon(ImageProvider.get("misc", "normal"));
-							}
-							validate();
+                            if (contentPanel_.isShowing()) {
+                                contentPanel_.setVisible(false);
+                                title.setIcon(ImageProvider.get("misc", "minimized"));
+                            }
+                            else {
+                                contentPanel_.setVisible(true);
+                                title.setIcon(ImageProvider.get("misc", "normal"));
+                            }
+                            validate();
 
-							headerPanel_.repaint();
-						}
-					}
-			);
+                            headerPanel_.repaint();
+                        }
+                    }
+            );
 
-		}
+        }
 
-	}
+    }
 
-	public JCollapsiblePanel(String text, JPanel panel) {
-		super(new GridBagLayout());
-		expanded = false;
-		headerPanel_ = new HeaderPanel(text);
-		contentPanel_ = panel;
-		add(headerPanel_, GBC.eol());
-		add(contentPanel_, GBC.eol());
-		contentPanel_.setVisible(false);
-	}
+    public JCollapsiblePanel(String text, JPanel panel) {
+        super(new GridBagLayout());
+        expanded = false;
+        headerPanel_ = new HeaderPanel(text);
+        contentPanel_ = panel;
+        add(headerPanel_, GBC.eol());
+        add(contentPanel_, GBC.eol());
+        contentPanel_.setVisible(false);
+    }
 
 }
Index: applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/gui/dialogs/KeySignaturesDialog.java
===================================================================
--- applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/gui/dialogs/KeySignaturesDialog.java	(revision 30723)
+++ applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/gui/dialogs/KeySignaturesDialog.java	(revision 30724)
@@ -22,126 +22,126 @@
 public class KeySignaturesDialog extends JPanel {
 
-	protected boolean isCollapsed;
+    protected boolean isCollapsed;
 
-	protected TitleBar titleBar;
+    protected TitleBar titleBar;
 
-	/** the label in the title bar which shows whether the toggle dialog is expanded or collapsed */
-	private JLabel lblMinimized;
+    /** the label in the title bar which shows whether the toggle dialog is expanded or collapsed */
+    private JLabel lblMinimized;
 
 
-	public KeySignaturesDialog(PGPPublicKey key) {
-		super(new BorderLayout());
+    public KeySignaturesDialog(PGPPublicKey key) {
+        super(new BorderLayout());
 
-		String userid = "Unknown";
-		Iterator iter = key.getUserIDs();
-		if (iter.hasNext()) {
-			userid = (String)iter.next();
-		}
+        String userid = "Unknown";
+        Iterator<?> iter = key.getUserIDs();
+        if (iter.hasNext()) {
+            userid = (String)iter.next();
+        }
 
-		isCollapsed = false;
+        isCollapsed = false;
 
-		titleBar = new TitleBar(userid);
-		add(titleBar, BorderLayout.NORTH);
-		add(createKeySigPanel(key));
+        titleBar = new TitleBar(userid);
+        add(titleBar, BorderLayout.NORTH);
+        add(createKeySigPanel(key));
 
-	}
+    }
 
-	public static JPanel createKeySigPanel(PGPPublicKey key) {
-		JPanel p = new JPanel();
-		p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS));
-		Iterator iter = key.getSignatures();
-		while (iter.hasNext()) {
-			PGPSignature sig = (PGPSignature)iter.next();
-			String uid = "0x"+Long.toHexString(sig.getKeyID()).substring(8).toUpperCase();
-			p.add(new JLabel(uid));
-		}
-		return p;
-	}
+    public static JPanel createKeySigPanel(PGPPublicKey key) {
+        JPanel p = new JPanel();
+        p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS));
+        Iterator<?> iter = key.getSignatures();
+        while (iter.hasNext()) {
+            PGPSignature sig = (PGPSignature)iter.next();
+            String uid = "0x"+Long.toHexString(sig.getKeyID()).substring(8).toUpperCase();
+            p.add(new JLabel(uid));
+        }
+        return p;
+    }
 
-	/**
-	 * Collapses the toggle dialog to the title bar only
-	 *
-	 */
-	public void collapse() {
-		if (!isCollapsed) {
-			//setContentVisible(false);
-			isCollapsed = true;
-			setPreferredSize(new Dimension(0,20));
-			setMaximumSize(new Dimension(Integer.MAX_VALUE,20));
-			setMinimumSize(new Dimension(Integer.MAX_VALUE,20));
-			lblMinimized.setIcon(ImageProvider.get("misc", "minimized"));
-		}
-		else throw new IllegalStateException();
-	}
+    /**
+     * Collapses the toggle dialog to the title bar only
+     *
+     */
+    public void collapse() {
+        if (!isCollapsed) {
+            //setContentVisible(false);
+            isCollapsed = true;
+            setPreferredSize(new Dimension(0,20));
+            setMaximumSize(new Dimension(Integer.MAX_VALUE,20));
+            setMinimumSize(new Dimension(Integer.MAX_VALUE,20));
+            lblMinimized.setIcon(ImageProvider.get("misc", "minimized"));
+        }
+        else throw new IllegalStateException();
+    }
 
-	/**
-	 * Expands the toggle dialog
-	 */
-	protected void expand() {
-		if (isCollapsed) {
-			//		setContentVisible(true);
-			isCollapsed = false;
-			setPreferredSize(new Dimension(0,200));
-			setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
-			lblMinimized.setIcon(ImageProvider.get("misc", "normal"));
-		}
-		else throw new IllegalStateException();
-	}
+    /**
+     * Expands the toggle dialog
+     */
+    protected void expand() {
+        if (isCollapsed) {
+            //        setContentVisible(true);
+            isCollapsed = false;
+            setPreferredSize(new Dimension(0,200));
+            setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
+            lblMinimized.setIcon(ImageProvider.get("misc", "normal"));
+        }
+        else throw new IllegalStateException();
+    }
 
-	/**
-	 * Sets the visibility of all components in this toggle dialog, except the title bar
-	 *
-	 * @param visible true, if the components should be visible; false otherwise
-	 */
-	protected void setContentVisible(boolean visible) {
-		Component comps[] = getComponents();
-		for(int i=0; i<comps.length; i++) {
-			if(comps[i] != titleBar) {
-				comps[i].setVisible(visible);
-			}
-		}
-	}
+    /**
+     * Sets the visibility of all components in this toggle dialog, except the title bar
+     *
+     * @param visible true, if the components should be visible; false otherwise
+     */
+    protected void setContentVisible(boolean visible) {
+        Component comps[] = getComponents();
+        for(int i=0; i<comps.length; i++) {
+            if(comps[i] != titleBar) {
+                comps[i].setVisible(visible);
+            }
+        }
+    }
 
-	/**
-	 * The title bar displayed in docked mode
-	 *
-	 */
-	protected class TitleBar extends JPanel {
-		final private JLabel lblTitle;
+    /**
+     * The title bar displayed in docked mode
+     *
+     */
+    protected class TitleBar extends JPanel {
+        final private JLabel lblTitle;
 
-		public TitleBar(String toggleDialogName) {
-			setLayout(new GridBagLayout());
-			lblMinimized = new JLabel(ImageProvider.get("misc", "minimized"));
-			add(lblMinimized);
+        public TitleBar(String toggleDialogName) {
+            setLayout(new GridBagLayout());
+            lblMinimized = new JLabel(ImageProvider.get("misc", "minimized"));
+            add(lblMinimized);
 
-			lblTitle = new JLabel(toggleDialogName);
-			add(lblTitle, GBC.std().fill(GBC.HORIZONTAL));
+            lblTitle = new JLabel(toggleDialogName);
+            add(lblTitle, GBC.std().fill(GBC.HORIZONTAL));
 
-			addMouseListener(
-					new MouseAdapter() {
-						@Override
-						public void mouseClicked(MouseEvent e) {
-							// toggleExpandedState
-							if (isCollapsed) {
-								expand();
-							} else {
-								collapse();
-							}
-						}
-					}
-			);
+            addMouseListener(
+                    new MouseAdapter() {
+                        @Override
+                        public void mouseClicked(MouseEvent e) {
+                            // toggleExpandedState
+                            if (isCollapsed) {
+                                expand();
+                            } else {
+                                collapse();
+                            }
+                        }
+                    }
+            );
 
-			setToolTipText(tr("Click to minimize/maximize the panel content"));
-			setTitle(toggleDialogName);
-		}
+            setToolTipText(tr("Click to minimize/maximize the panel content"));
+            setTitle(toggleDialogName);
+        }
 
-		public void setTitle(String title) {
-			lblTitle.setText(title);
-		}
+        public void setTitle(String title) {
+            lblTitle.setText(title);
+        }
 
-		public String getTitle() {
-			return lblTitle.getText();
-		}
-	}
+        public String getTitle() {
+            return lblTitle.getText();
+        }
+    }
 
 }
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 30723)
+++ applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/gui/dialogs/TrustDialog.java	(revision 30724)
@@ -70,614 +70,614 @@
 public class TrustDialog extends ToggleDialog implements ActionListener, SelectionChangedListener, MapViewPaintable {
 
-	/**
-	 * 
-	 */
-	private static final long serialVersionUID = -3324984194315776740L;
-
-
-	public final static Color BGCOLOR_NO_SIG = new Color(234, 234, 234);
-	//	public final static Color BGCOLOR_VALID_SIG = new Color(235,255,177);
-	public final static Color BGCOLOR_VALID_SIG = new Color(74,245,106);
-	public final static Color BGCOLOR_BROKEN_SIG = new Color(255, 197, 197);
-	public final static Color BGCOLOR_REMOVED_ITEM = new Color(255, 100, 100);
-	public final static Color BGCOLOR_UPDATED_ITEM = new Color(249,221,95);
-
-
-	/** Use a TrustGPGPreparer to sign or validate signatures */
-	//private final TrustGPGPreparer gpg;
-
-	/** The check signatures button */
-	private final SideButton checkButton;
-
-	/** The sign button */
-	private final SideButton signButton;
-
-	/** The show sigs button */
-	private final SideButton showButton;
-
-	private final Map<String, Byte> rowStatus = new HashMap<String, Byte>();
-
-	/** The selected osmData */
-	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;
-
-
-	/**
-	 * The property data.
-	 */
-	private final DefaultTableModel propertyData = new DefaultTableModel() {
-		/**
-		 * 
-		 */
-		private static final long serialVersionUID = -1252801283184909691L;
-		@Override public boolean isCellEditable(int row, int column) {
-			return false;
-		}
-		@Override public Class<?> getColumnClass(int columnIndex) {
-			return String.class;
-		}
-	};
-	private final JTable propertyTable = new JTable(propertyData) {
-		/**
-		 * 
-		 */
-		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;
-		}
-	};
-
-	/** 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
-	 */
-	public TrustDialog() {
-		super(tr("Object signatures"), "trustosm", tr("Open object signing window."),
-				Shortcut.registerShortcut("subwindow:trustosm", tr("Toggle: {0}", tr("Object signatures")),
-						KeyEvent.VK_T, Shortcut.ALT_CTRL), 150);
-
-		Main.map.mapView.addTemporaryLayer(this);
-
-		// setting up the properties table
-		propertyData.setColumnIdentifiers(new String[]{tr("Key"),tr("Value")});
-
-		// copy and paste from org.openstreetmap.josm.gui.dialogs.properties.PropertiesDialog
-
-		propertyTable.getColumnModel().getColumn(1).setCellRenderer(new DefaultTableCellRenderer(){
-			/**
-			 * 
-			 */
-			private static final long serialVersionUID = 8003207668070727861L;
-
-			@Override
-			public Component getTableCellRendererComponent(JTable table, Object value,
-					boolean isSelected, boolean hasFocus, int row, int column) {
-				Component c = super.getTableCellRendererComponent(table, value, isSelected, false, row, column);
-				if (c instanceof JLabel) {
-					String str = null;
-					if (value instanceof String) {
-						str = (String) value;
-					} else if (value instanceof Map<?, ?>) {
-						Map<?, ?> v = (Map<?, ?>) value;
-						if (v.size() != 1) {
-							str=tr("<different>");
-							c.setFont(c.getFont().deriveFont(Font.ITALIC));
-						} else {
-							final Map.Entry<?, ?> entry = v.entrySet().iterator().next();
-							str = (String) entry.getKey();
-						}
-					}
-					((JLabel)c).setText(str);
-				}
-				return c;
-			}
-		});
-
-		geomTree = new JTree( createTree() );
-
-		geomTree.setBackground( BGCOLOR_NO_SIG );
-		geomTree.setRootVisible(false);
-		geomTree.setCellRenderer(new DefaultTreeCellRenderer(){
-
-			/**
-			 * 
-			 */
-			private static final long serialVersionUID = -3070210847060314196L;
-
-			@Override
-			public Component getTreeCellRendererComponent(JTree tree, Object value,
-					boolean selected, boolean expanded, boolean leaf, int row,
-					boolean hasFocus)
-			{
-				super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
-
-				DefaultMutableTreeNode node = (DefaultMutableTreeNode)value;
-				if (node.isRoot()) return this;
-				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 = TrustOsmPrimitive.createUniqueObjectIdentifier(seg.way);
-					if (TrustOSMplugin.signedItems.containsKey(id) && (sigs = ((TrustWay)TrustOSMplugin.signedItems.get(id)).getSigsOnSegment(seg)) != 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;
-						}
-					}
-				}
-				return this;
-			}
-
-
-		});
-
-		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();
-		dataPanel.setLayout(new BoxLayout(dataPanel, BoxLayout.PAGE_AXIS));
-		propertyTable.setAlignmentX(LEFT_ALIGNMENT);
-		dataPanel.add(propertyTable);
-		geomTree.setAlignmentX(LEFT_ALIGNMENT);
-		dataPanel.add(geomTree);
-
-		checkButton = new SideButton(marktr("Check"), "checksignatures", "TrustOSM",
-				tr("Check all available signatures for selected object."), this);
-		signButton = new SideButton(marktr("Sign"), "sign", "TrustOSM",
-				tr("Digital sign selected Tags, if you believe they are correct."), this);
-		showButton = new SideButton(marktr("Show"), "showsig", "TrustOSM",
-				tr("Show all available signatures for selected attribute."), this);
-
-		createLayout(dataPanel, true, Arrays.asList(new SideButton[] {
-			checkButton, signButton, showButton
-		}));
-		DataSet.addSelectionListener(this);
-	}
-
-	@Override
-	public void actionPerformed(ActionEvent e) {
-		String actionCommand = e.getActionCommand();
-		if (actionCommand.equals("Check")) {
-			for (OsmPrimitive osm : osmData) {
-				String id = TrustOsmPrimitive.createUniqueObjectIdentifier(osm);
-				if (TrustOSMplugin.signedItems.containsKey(id))
-					TrustAnalyzer.checkEverything(TrustOSMplugin.signedItems.get(id));
-				//checkedItems.put(osm, TrustOSMplugin.gpg.check(checkedItems.containsKey(osm)? checkedItems.get(osm) : new TrustOSMItem(osm)));
-			}
-			updateTable();
-			geomTree.repaint();
-		} else if (actionCommand.equals("Sign")) {
-			for (int i : propertyTable.getSelectedRows()) {
-				String key = (String)propertyTable.getValueAt(i, 0);
-				for (OsmPrimitive osm : osmData) {
-					if (osm.keySet().contains(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);
-					}
-				}
-			}
-			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) {
-							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;
-						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);
-					}
-				}
-			updateTable();
-			geomTree.repaint();
-		} else if (actionCommand.equals("Show")) {
-			for (int i : propertyTable.getSelectedRows()) {
-				String key = (String)propertyTable.getValueAt(i, 0);
-				for (OsmPrimitive osm : osmData) {
-					String id = TrustOsmPrimitive.createUniqueObjectIdentifier(osm);
-					if (osm.keySet().contains(key) && TrustOSMplugin.signedItems.containsKey(id)) {
-						TrustSignaturesDialog.showSignaturesDialog(TrustOSMplugin.signedItems.get(id), key);
-					}
-				}
-			}
-			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);
-						}
-					}
-				}
-
-		}
-	}
-	/*
-	public void showSignaturesDialog(TrustOSMItem 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();
-			p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS));
-			Dimension d = new Dimension(0,20);
-			JLabel head = new JLabel(tr("Selected key value pair was:\n{0}={1}",key,trust.getOsmItem().get(key)));
-			head.setAlignmentX(LEFT_ALIGNMENT);
-			p.add(head);
-			p.add(Box.createRigidArea(d));
-			SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd:hh.mm.ss");
-			for (PGPSignature s : sigs.getSignatures()) {
-				JTextArea sigtext = new JTextArea(sigs.getArmoredFulltextSignature(s));
-				sigtext.setEditable(false);
-				sigtext.setAlignmentX(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(LEFT_ALIGNMENT);
-				p.add(siginfo);
-				p.add(Box.createRigidArea(d));
-			}
-
-			JScrollPane scroller = new JScrollPane(p);
-			JPanel content = new JPanel();
-			content.setMaximumSize(new Dimension(600,500));
-			content.add(scroller);
-			JOptionPane.showMessageDialog(Main.parent,content, tr("Clearsigned Signature"), JOptionPane.PLAIN_MESSAGE);
-		}
-	}
-	 */
-	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();
-		DefaultMutableTreeNode wayNode;
-		if (osmData!=null)
-			for (OsmPrimitive osm : osmData) {
-				//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();
-					Iterator<Node> iter = presentNodes.iterator();
-					while (iter.hasNext()) {
-						wayNode.add(new DefaultMutableTreeNode(iter.next()));
-					}
-
-					if (TrustOSMplugin.signedItems.containsKey(id)) {
-						TrustOsmPrimitive trust = TrustOSMplugin.signedItems.get(id);
-						HashSet<Node> signedNodes = new HashSet<Node>(trust.getGeomSigs().keySet());
-						signedNodes.removeAll(presentNodes);
-						iter = signedNodes.iterator();
-						Node removedNode;
-						while (iter.hasNext()) {
-							removedNode = iter.next();
-							trust.updateNodeSigStatus(removedNode, TrustSignatures.ITEM_REMOVED);
-							wayNode.add(new DefaultMutableTreeNode(removedNode));
-						}
-					}
-					 */
-					root.add(wayNode);
-				} else if(osm instanceof Relation) {
-
-				}
-
-			}
-
-		return new DefaultTreeModel(root);
-
-	}
-
-	public void updateTable() {
-		// re-load property data
-		propertyData.setRowCount(0);
-
-		Map<String, Map<String, Integer>> valueCount = new TreeMap<String, Map<String, Integer>>();
-
-		TrustOsmPrimitive trust;
-
-		valueCount.clear();
-		rowStatus.clear();
-		boolean sigsAvailable = false;
-
-		for (OsmPrimitive osm : osmData) {
-			String id = TrustOsmPrimitive.createUniqueObjectIdentifier(osm);
-			if (TrustOSMplugin.signedItems.containsKey(id)) {
-				trust = TrustOSMplugin.signedItems.get(id);
-				sigsAvailable = true;
-				/*
-				Map<String,String> tags = osm.getKeys();
-				Map<String, TrustSignatures>  signedTags = trust.getTagSigs();
-				HashSet<String> removedKeys = new HashSet<String>(signedTags.keySet());
-				removedKeys.removeAll(tags.keySet());
-				for (String removedKey: removedKeys) {
-					TrustSignatures sigs = signedTags.get(removedKey);
-					sigs.setStatus( TrustSignatures.ITEM_REMOVED );
-					String[] kv = TrustOsmPrimitive.generateTagsFromSigtext(sigs.getOnePlainText());
-					tags.put(kv[0],kv[1]);
-				}
-				 */
-			} else {
-				trust = TrustOsmPrimitive.createTrustOsmPrimitive(osm);
-				sigsAvailable = false;
-			}
-
-			//		trust = TrustOSMplugin.signedItems.containsKey(osm) ? TrustOSMplugin.signedItems.get(osm) : new TrustOSMItem(osm);
-
-			for (String key: osm.keySet()) {
-				String value = osm.get(key);
-				//keyCount.put(key, keyCount.containsKey(key) ? keyCount.get(key) + 1 : 1);
-
-				byte status = sigsAvailable && trust.getTagSigs().containsKey(key) ? trust.getTagSigs().get(key).getStatus() : TrustSignatures.SIG_UNKNOWN ;
-				Byte oldstatus = rowStatus.containsKey(key)? rowStatus.get(key) : new Byte(TrustSignatures.SIG_VALID);
-				Byte sigstatus = new Byte(status);
-				Byte newstatus;
-				if (sigstatus.equals(new Byte(TrustSignatures.SIG_BROKEN)) || oldstatus.equals(new Byte(TrustSignatures.SIG_BROKEN))) {
-					newstatus = new Byte(TrustSignatures.SIG_BROKEN);
-				} else if (sigstatus.equals(new Byte(TrustSignatures.SIG_UNKNOWN)) || oldstatus.equals(new Byte(TrustSignatures.SIG_UNKNOWN))) {
-					newstatus = new Byte(TrustSignatures.SIG_UNKNOWN);
-				} else newstatus = new Byte(TrustSignatures.SIG_VALID);
-
-				rowStatus.put(key, newstatus );
-				if (valueCount.containsKey(key)) {
-					Map<String, Integer> v = valueCount.get(key);
-					v.put(value, v.containsKey(value)? v.get(value) + 1 : 1 );
-				} else {
-					TreeMap<String,Integer> v = new TreeMap<String, Integer>();
-					v.put(value, 1);
-					valueCount.put(key, v);
-				}
-			}
-		}
-		for (Entry<String, Map<String, Integer>> e : valueCount.entrySet()) {
-			int count=0;
-			for (Entry<String, Integer> e1: e.getValue().entrySet()) {
-				count+=e1.getValue();
-			}
-			if (count < osmData.size()) {
-				e.getValue().put("", osmData.size()-count);
-			}
-			propertyData.addRow(new Object[]{e.getKey(), e.getValue()});
-		}
-
-
-		boolean hasSelection = !osmData.isEmpty();
-		boolean hasTags = hasSelection && propertyData.getRowCount() > 0;
-
-		propertyTable.setVisible(hasTags);
-		propertyTable.getTableHeader().setVisible(hasTags);
-	}
-
-	@Override
-	public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) {
-		this.osmData = newSelection;
-
-		if (!isVisible())
-			return;
-		geomTree.setModel(createTree());
-		updateTable();
-		//		signButton.setEnabled(newSelection.size() == 1);
-	}
-
-	@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));
-	}
+    /**
+     * 
+     */
+    private static final long serialVersionUID = -3324984194315776740L;
+
+
+    public final static Color BGCOLOR_NO_SIG = new Color(234, 234, 234);
+    //    public final static Color BGCOLOR_VALID_SIG = new Color(235,255,177);
+    public final static Color BGCOLOR_VALID_SIG = new Color(74,245,106);
+    public final static Color BGCOLOR_BROKEN_SIG = new Color(255, 197, 197);
+    public final static Color BGCOLOR_REMOVED_ITEM = new Color(255, 100, 100);
+    public final static Color BGCOLOR_UPDATED_ITEM = new Color(249,221,95);
+
+
+    /** Use a TrustGPGPreparer to sign or validate signatures */
+    //private final TrustGPGPreparer gpg;
+
+    /** The check signatures button */
+    private final SideButton checkButton;
+
+    /** The sign button */
+    private final SideButton signButton;
+
+    /** The show sigs button */
+    private final SideButton showButton;
+
+    private final Map<String, Byte> rowStatus = new HashMap<>();
+
+    /** The selected osmData */
+    private Collection<? extends OsmPrimitive> osmData;
+
+
+    private final List<WaySegment> selectedSegments = new ArrayList<>();
+    private final List<OsmPrimitive> selectedPrimitives = new ArrayList<>();
+
+    /** The JTree for showing the geometry */
+    private final JTree geomTree;
+
+
+    /**
+     * The property data.
+     */
+    private final DefaultTableModel propertyData = new DefaultTableModel() {
+        /**
+         * 
+         */
+        private static final long serialVersionUID = -1252801283184909691L;
+        @Override public boolean isCellEditable(int row, int column) {
+            return false;
+        }
+        @Override public Class<?> getColumnClass(int columnIndex) {
+            return String.class;
+        }
+    };
+    private final JTable propertyTable = new JTable(propertyData) {
+        /**
+         * 
+         */
+        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;
+        }
+    };
+
+    /** 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
+     */
+    public TrustDialog() {
+        super(tr("Object signatures"), "trustosm", tr("Open object signing window."),
+                Shortcut.registerShortcut("subwindow:trustosm", tr("Toggle: {0}", tr("Object signatures")),
+                        KeyEvent.VK_T, Shortcut.ALT_CTRL), 150);
+
+        Main.map.mapView.addTemporaryLayer(this);
+
+        // setting up the properties table
+        propertyData.setColumnIdentifiers(new String[]{tr("Key"),tr("Value")});
+
+        // copy and paste from org.openstreetmap.josm.gui.dialogs.properties.PropertiesDialog
+
+        propertyTable.getColumnModel().getColumn(1).setCellRenderer(new DefaultTableCellRenderer(){
+            /**
+             * 
+             */
+            private static final long serialVersionUID = 8003207668070727861L;
+
+            @Override
+            public Component getTableCellRendererComponent(JTable table, Object value,
+                    boolean isSelected, boolean hasFocus, int row, int column) {
+                Component c = super.getTableCellRendererComponent(table, value, isSelected, false, row, column);
+                if (c instanceof JLabel) {
+                    String str = null;
+                    if (value instanceof String) {
+                        str = (String) value;
+                    } else if (value instanceof Map<?, ?>) {
+                        Map<?, ?> v = (Map<?, ?>) value;
+                        if (v.size() != 1) {
+                            str=tr("<different>");
+                            c.setFont(c.getFont().deriveFont(Font.ITALIC));
+                        } else {
+                            final Map.Entry<?, ?> entry = v.entrySet().iterator().next();
+                            str = (String) entry.getKey();
+                        }
+                    }
+                    ((JLabel)c).setText(str);
+                }
+                return c;
+            }
+        });
+
+        geomTree = new JTree( createTree() );
+
+        geomTree.setBackground( BGCOLOR_NO_SIG );
+        geomTree.setRootVisible(false);
+        geomTree.setCellRenderer(new DefaultTreeCellRenderer(){
+
+            /**
+             * 
+             */
+            private static final long serialVersionUID = -3070210847060314196L;
+
+            @Override
+            public Component getTreeCellRendererComponent(JTree tree, Object value,
+                    boolean selected, boolean expanded, boolean leaf, int row,
+                    boolean hasFocus)
+            {
+                super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
+
+                DefaultMutableTreeNode node = (DefaultMutableTreeNode)value;
+                if (node.isRoot()) return this;
+                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 = TrustOsmPrimitive.createUniqueObjectIdentifier(seg.way);
+                    if (TrustOSMplugin.signedItems.containsKey(id) && (sigs = ((TrustWay)TrustOSMplugin.signedItems.get(id)).getSigsOnSegment(seg)) != 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;
+                        }
+                    }
+                }
+                return this;
+            }
+
+
+        });
+
+        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();
+        dataPanel.setLayout(new BoxLayout(dataPanel, BoxLayout.PAGE_AXIS));
+        propertyTable.setAlignmentX(LEFT_ALIGNMENT);
+        dataPanel.add(propertyTable);
+        geomTree.setAlignmentX(LEFT_ALIGNMENT);
+        dataPanel.add(geomTree);
+
+        checkButton = new SideButton(marktr("Check"), "checksignatures", "TrustOSM",
+                tr("Check all available signatures for selected object."), this);
+        signButton = new SideButton(marktr("Sign"), "sign", "TrustOSM",
+                tr("Digital sign selected Tags, if you believe they are correct."), this);
+        showButton = new SideButton(marktr("Show"), "showsig", "TrustOSM",
+                tr("Show all available signatures for selected attribute."), this);
+
+        createLayout(dataPanel, true, Arrays.asList(new SideButton[] {
+            checkButton, signButton, showButton
+        }));
+        DataSet.addSelectionListener(this);
+    }
+
+    @Override
+    public void actionPerformed(ActionEvent e) {
+        String actionCommand = e.getActionCommand();
+        if (actionCommand.equals("Check")) {
+            for (OsmPrimitive osm : osmData) {
+                String id = TrustOsmPrimitive.createUniqueObjectIdentifier(osm);
+                if (TrustOSMplugin.signedItems.containsKey(id))
+                    TrustAnalyzer.checkEverything(TrustOSMplugin.signedItems.get(id));
+                //checkedItems.put(osm, TrustOSMplugin.gpg.check(checkedItems.containsKey(osm)? checkedItems.get(osm) : new TrustOSMItem(osm)));
+            }
+            updateTable();
+            geomTree.repaint();
+        } else if (actionCommand.equals("Sign")) {
+            for (int i : propertyTable.getSelectedRows()) {
+                String key = (String)propertyTable.getValueAt(i, 0);
+                for (OsmPrimitive osm : osmData) {
+                    if (osm.keySet().contains(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);
+                    }
+                }
+            }
+            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) {
+                            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;
+                        WaySegment seg = (WaySegment) o;
+                        List<Node> nodes = new ArrayList<>();
+                        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);
+                    }
+                }
+            updateTable();
+            geomTree.repaint();
+        } else if (actionCommand.equals("Show")) {
+            for (int i : propertyTable.getSelectedRows()) {
+                String key = (String)propertyTable.getValueAt(i, 0);
+                for (OsmPrimitive osm : osmData) {
+                    String id = TrustOsmPrimitive.createUniqueObjectIdentifier(osm);
+                    if (osm.keySet().contains(key) && TrustOSMplugin.signedItems.containsKey(id)) {
+                        TrustSignaturesDialog.showSignaturesDialog(TrustOSMplugin.signedItems.get(id), key);
+                    }
+                }
+            }
+            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<>();
+                            nodes.add(seg.getFirstNode());
+                            nodes.add(seg.getSecondNode());
+                            TrustSignaturesDialog.showSignaturesDialog((TrustWay) TrustOSMplugin.signedItems.get(id),nodes);
+                        }
+                    }
+                }
+
+        }
+    }
+    /*
+    public void showSignaturesDialog(TrustOSMItem 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();
+            p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS));
+            Dimension d = new Dimension(0,20);
+            JLabel head = new JLabel(tr("Selected key value pair was:\n{0}={1}",key,trust.getOsmItem().get(key)));
+            head.setAlignmentX(LEFT_ALIGNMENT);
+            p.add(head);
+            p.add(Box.createRigidArea(d));
+            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd:hh.mm.ss");
+            for (PGPSignature s : sigs.getSignatures()) {
+                JTextArea sigtext = new JTextArea(sigs.getArmoredFulltextSignature(s));
+                sigtext.setEditable(false);
+                sigtext.setAlignmentX(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(LEFT_ALIGNMENT);
+                p.add(siginfo);
+                p.add(Box.createRigidArea(d));
+            }
+
+            JScrollPane scroller = new JScrollPane(p);
+            JPanel content = new JPanel();
+            content.setMaximumSize(new Dimension(600,500));
+            content.add(scroller);
+            JOptionPane.showMessageDialog(Main.parent,content, tr("Clearsigned Signature"), JOptionPane.PLAIN_MESSAGE);
+        }
+    }
+     */
+    public static List<WaySegment> generateSegmentListFromWay(Way w) {
+        List<WaySegment> segList = new ArrayList<>();
+        for (int i = 0; i < w.getNodesCount()-1; i++) {
+            segList.add(new WaySegment(w,i));
+        }
+        return segList;
+    }
+
+    private DefaultTreeModel createTree(){
+        DefaultMutableTreeNode root = new DefaultMutableTreeNode();
+        DefaultMutableTreeNode wayNode;
+        if (osmData!=null)
+            for (OsmPrimitive osm : osmData) {
+                //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();
+                    Iterator<Node> iter = presentNodes.iterator();
+                    while (iter.hasNext()) {
+                        wayNode.add(new DefaultMutableTreeNode(iter.next()));
+                    }
+
+                    if (TrustOSMplugin.signedItems.containsKey(id)) {
+                        TrustOsmPrimitive trust = TrustOSMplugin.signedItems.get(id);
+                        HashSet<Node> signedNodes = new HashSet<Node>(trust.getGeomSigs().keySet());
+                        signedNodes.removeAll(presentNodes);
+                        iter = signedNodes.iterator();
+                        Node removedNode;
+                        while (iter.hasNext()) {
+                            removedNode = iter.next();
+                            trust.updateNodeSigStatus(removedNode, TrustSignatures.ITEM_REMOVED);
+                            wayNode.add(new DefaultMutableTreeNode(removedNode));
+                        }
+                    }
+                     */
+                    root.add(wayNode);
+                } else if(osm instanceof Relation) {
+
+                }
+
+            }
+
+        return new DefaultTreeModel(root);
+
+    }
+
+    public void updateTable() {
+        // re-load property data
+        propertyData.setRowCount(0);
+
+        Map<String, Map<String, Integer>> valueCount = new TreeMap<>();
+
+        TrustOsmPrimitive trust;
+
+        valueCount.clear();
+        rowStatus.clear();
+        boolean sigsAvailable = false;
+
+        for (OsmPrimitive osm : osmData) {
+            String id = TrustOsmPrimitive.createUniqueObjectIdentifier(osm);
+            if (TrustOSMplugin.signedItems.containsKey(id)) {
+                trust = TrustOSMplugin.signedItems.get(id);
+                sigsAvailable = true;
+                /*
+                Map<String,String> tags = osm.getKeys();
+                Map<String, TrustSignatures>  signedTags = trust.getTagSigs();
+                HashSet<String> removedKeys = new HashSet<String>(signedTags.keySet());
+                removedKeys.removeAll(tags.keySet());
+                for (String removedKey: removedKeys) {
+                    TrustSignatures sigs = signedTags.get(removedKey);
+                    sigs.setStatus( TrustSignatures.ITEM_REMOVED );
+                    String[] kv = TrustOsmPrimitive.generateTagsFromSigtext(sigs.getOnePlainText());
+                    tags.put(kv[0],kv[1]);
+                }
+                 */
+            } else {
+                trust = TrustOsmPrimitive.createTrustOsmPrimitive(osm);
+                sigsAvailable = false;
+            }
+
+            //        trust = TrustOSMplugin.signedItems.containsKey(osm) ? TrustOSMplugin.signedItems.get(osm) : new TrustOSMItem(osm);
+
+            for (String key: osm.keySet()) {
+                String value = osm.get(key);
+                //keyCount.put(key, keyCount.containsKey(key) ? keyCount.get(key) + 1 : 1);
+
+                byte status = sigsAvailable && trust.getTagSigs().containsKey(key) ? trust.getTagSigs().get(key).getStatus() : TrustSignatures.SIG_UNKNOWN ;
+                Byte oldstatus = rowStatus.containsKey(key)? rowStatus.get(key) : new Byte(TrustSignatures.SIG_VALID);
+                Byte sigstatus = new Byte(status);
+                Byte newstatus;
+                if (sigstatus.equals(new Byte(TrustSignatures.SIG_BROKEN)) || oldstatus.equals(new Byte(TrustSignatures.SIG_BROKEN))) {
+                    newstatus = new Byte(TrustSignatures.SIG_BROKEN);
+                } else if (sigstatus.equals(new Byte(TrustSignatures.SIG_UNKNOWN)) || oldstatus.equals(new Byte(TrustSignatures.SIG_UNKNOWN))) {
+                    newstatus = new Byte(TrustSignatures.SIG_UNKNOWN);
+                } else newstatus = new Byte(TrustSignatures.SIG_VALID);
+
+                rowStatus.put(key, newstatus );
+                if (valueCount.containsKey(key)) {
+                    Map<String, Integer> v = valueCount.get(key);
+                    v.put(value, v.containsKey(value)? v.get(value) + 1 : 1 );
+                } else {
+                    TreeMap<String,Integer> v = new TreeMap<>();
+                    v.put(value, 1);
+                    valueCount.put(key, v);
+                }
+            }
+        }
+        for (Entry<String, Map<String, Integer>> e : valueCount.entrySet()) {
+            int count=0;
+            for (Entry<String, Integer> e1: e.getValue().entrySet()) {
+                count+=e1.getValue();
+            }
+            if (count < osmData.size()) {
+                e.getValue().put("", osmData.size()-count);
+            }
+            propertyData.addRow(new Object[]{e.getKey(), e.getValue()});
+        }
+
+
+        boolean hasSelection = !osmData.isEmpty();
+        boolean hasTags = hasSelection && propertyData.getRowCount() > 0;
+
+        propertyTable.setVisible(hasTags);
+        propertyTable.getTableHeader().setVisible(hasTags);
+    }
+
+    @Override
+    public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) {
+        this.osmData = newSelection;
+
+        if (!isVisible())
+            return;
+        geomTree.setModel(createTree());
+        updateTable();
+        //        signButton.setEnabled(newSelection.size() == 1);
+    }
+
+    @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/TrustPreferenceEditor.java
===================================================================
--- applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/gui/dialogs/TrustPreferenceEditor.java	(revision 30723)
+++ applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/gui/dialogs/TrustPreferenceEditor.java	(revision 30724)
@@ -23,53 +23,53 @@
 public class TrustPreferenceEditor implements PreferenceSetting {
 
-	private final JCheckBox showSignedDeleted = new JCheckBox(tr("Show deleted tags and notes if they were signed before"));
-	private final JRadioButton defaultHomedir = new JRadioButton(tr("Use default (and maybe existing) GnuPG directory ({0}) to store new keys and configs.", "~/.gnupg"));
-	private final JRadioButton separateHomedir = new JRadioButton(tr("Use separate GnuPG directory ({0}) to store new keys and configs.", TrustOSMplugin.getGpgPath()));
+    private final JCheckBox showSignedDeleted = new JCheckBox(tr("Show deleted tags and notes if they were signed before"));
+    private final JRadioButton defaultHomedir = new JRadioButton(tr("Use default (and maybe existing) GnuPG directory ({0}) to store new keys and configs.", "~/.gnupg"));
+    private final JRadioButton separateHomedir = new JRadioButton(tr("Use separate GnuPG directory ({0}) to store new keys and configs.", TrustOSMplugin.getGpgPath()));
 
-	@Override
-	public void addGui(final PreferenceTabbedPane gui) {
-		// TODO Auto-generated method stub
-		JPanel p = gui.createPreferenceTab("trustosm", tr("Trust OSM Settings"), tr("Change GPG and privacy settings of the trustosm plugin."));
-		JTabbedPane tabs = new JTabbedPane();
-		p.add(tabs, GBC.eol().fill(GBC.BOTH));
+    @Override
+    public void addGui(final PreferenceTabbedPane gui) {
+        // TODO Auto-generated method stub
+        JPanel p = gui.createPreferenceTab("trustosm", tr("Trust OSM Settings"), tr("Change GPG and privacy settings of the trustosm plugin."));
+        JTabbedPane tabs = new JTabbedPane();
+        p.add(tabs, GBC.eol().fill(GBC.BOTH));
 
 
-		JPanel gpgsettings = new JPanel(new GridBagLayout());
+        JPanel gpgsettings = new JPanel(new GridBagLayout());
 
-		gpgsettings.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
+        gpgsettings.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
 
-		gpgsettings.add(new JLabel(tr("Use separate GnuPG configuration directory?")), GBC.eol().insets(20,0,0,0));
-		ButtonGroup gpgdirGroup = new ButtonGroup();
-		gpgdirGroup.add(separateHomedir);
-		gpgdirGroup.add(defaultHomedir);
+        gpgsettings.add(new JLabel(tr("Use separate GnuPG configuration directory?")), GBC.eol().insets(20,0,0,0));
+        ButtonGroup gpgdirGroup = new ButtonGroup();
+        gpgdirGroup.add(separateHomedir);
+        gpgdirGroup.add(defaultHomedir);
 
-		if (Main.pref.getBoolean("trustosm.gpg.separateHomedir")) {
-			separateHomedir.setSelected(true);
-		} else
-			defaultHomedir.setSelected(true);
+        if (Main.pref.getBoolean("trustosm.gpg.separateHomedir")) {
+            separateHomedir.setSelected(true);
+        } else
+            defaultHomedir.setSelected(true);
 
-		gpgsettings.add(separateHomedir, GBC.eol().insets(40,0,0,0));
-		gpgsettings.add(defaultHomedir, GBC.eol().insets(40,0,0,0));
+        gpgsettings.add(separateHomedir, GBC.eol().insets(40,0,0,0));
+        gpgsettings.add(defaultHomedir, GBC.eol().insets(40,0,0,0));
 
 
-		gpgsettings.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.BOTH));
-		JScrollPane scrollpane = new JScrollPane(gpgsettings);
-		scrollpane.setBorder(BorderFactory.createEmptyBorder( 0, 0, 0, 0 ));
-		tabs.add(tr("GnuPG"), scrollpane);
+        gpgsettings.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.BOTH));
+        JScrollPane scrollpane = new JScrollPane(gpgsettings);
+        scrollpane.setBorder(BorderFactory.createEmptyBorder( 0, 0, 0, 0 ));
+        tabs.add(tr("GnuPG"), scrollpane);
 
 
-		JPanel dialogsettings = new JPanel(new GridBagLayout());
-		tabs.add(tr("Dialog"), dialogsettings);
-		dialogsettings.add(showSignedDeleted, GBC.eol().fill(GBC.HORIZONTAL).insets(20,0,0,5));
+        JPanel dialogsettings = new JPanel(new GridBagLayout());
+        tabs.add(tr("Dialog"), dialogsettings);
+        dialogsettings.add(showSignedDeleted, GBC.eol().fill(GBC.HORIZONTAL).insets(20,0,0,5));
 
-	}
+    }
 
-	@Override
-	public boolean ok() {
-		Main.pref.put("trustosm.gpg.showSignedDeleted", showSignedDeleted.isSelected());
-		Main.pref.put("trustosm.gpg.separateHomedir", separateHomedir.isSelected());
-		//		TrustOSMplugin.gpg.refreshGpg();
-		return false;
-	}
+    @Override
+    public boolean ok() {
+        Main.pref.put("trustosm.gpg.showSignedDeleted", showSignedDeleted.isSelected());
+        Main.pref.put("trustosm.gpg.separateHomedir", separateHomedir.isSelected());
+        //        TrustOSMplugin.gpg.refreshGpg();
+        return false;
+    }
 
 
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 30723)
+++ applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/gui/dialogs/TrustSignaturesDialog.java	(revision 30724)
@@ -7,5 +7,4 @@
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
-import java.text.SimpleDateFormat;
 import java.util.List;
 
@@ -41,210 +40,210 @@
 
 
-	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 {
-			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);
-		detailsButton.addActionListener(new ActionListener() {
-
-			public void actionPerformed(ActionEvent e)
-			{
-				showKeySignaturesDialog(keyID);
-			}
-		});
-		return detailsButton;
-	}
-
-	public static void showKeySignaturesDialog(long keyID) {
-		PGPPublicKey pub = TrustOSMplugin.gpg.getPublicKeyFromRing(keyID);
-		JPanel p = new JPanel(new GridBagLayout());
-
-		Iterator sigIt = pub.getSignatures();
-		while (sigIt.hasNext()) {
-			PGPSignature s = (PGPSignature)sigIt.next();
-			p.add(createKeyButton(s.getHashedSubPackets().getSignerUserID(),pub.getKeyID()));
-		}
-
-		String uid = String.valueOf(pub.getKeyID());
-		Iterator i = pub.getUserIDs();
-		if (i.hasNext())
-			uid = (String)i.next();
-
-		p.add(createKeyButton(uid,pub.getKeyID()));
-		JOptionPane.showMessageDialog(Main.parent,p, tr("Key Signatures"), JOptionPane.PLAIN_MESSAGE);
-	}
-
-
-	public static String convPGPSignatureToString(PGPSignature s) {
-		PGPSignatureSubpacketVector sv = s.getHashedSubPackets();
-		if (sv.hasSubpacket(SignatureSubpacketTags.SIGNER_USER_ID))
-			return sv.getSignerUserID();
-
-		PGPPublicKey pub = TrustOSMplugin.gpg.getPublicKeyFromRing(s.getKeyID());
-		if (pub != null){
-			Iterator i = pub.getUserIDs();
-			if (i.hasNext())
-				return (String)i.next();
-		}
-		return tr("unknown");
-	}
-
-	public static JTree createSignerTree(Collection<PGPSignature> sigs) {
-		DefaultMutableTreeNode root = new DefaultMutableTreeNode();
-		for (PGPSignature s : sigs){
-			DefaultMutableTreeNode sn = new DefaultMutableTreeNode(s);
-			PGPPublicKey pub = TrustOSMplugin.gpg.getPublicKeyFromRing(s.getKeyID());
-			Iterator iter = pub.getSignatures();
-			while (iter.hasNext()){
-				PGPSignature ks = (PGPSignature)iter.next();
-				sn.add(new DefaultMutableTreeNode(ks));
-			}
-			root.add(sn);
-		}
-
-
-		JTree t = new JTree(new DefaultTreeModel(root));
-		t.setRootVisible(false);
-		t.setBackground(TrustDialog.BGCOLOR_NO_SIG);
-		t.setCellRenderer(new DefaultTreeCellRenderer(){
-
-			@Override
-			public Component getTreeCellRendererComponent(JTree tree, Object value,
-					boolean selected, boolean expanded, boolean leaf, int row,
-					boolean hasFocus)
-			{
-				super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
-
-				DefaultMutableTreeNode node = (DefaultMutableTreeNode)value;
-				if (node.isRoot()) return this;
-				PGPSignature s = (PGPSignature) node.getUserObject();
-				setIcon(ImageProvider.get("dialogs/sign"));
-				setText(convPGPSignatureToString(s));
-				PGPSignatureSubpacketVector sv = s.getHashedSubPackets();
-				setBackgroundNonSelectionColor(TrustDialog.BGCOLOR_NO_SIG);
-				if (sv.hasSubpacket(SignatureSubpacketTags.NOTATION_DATA)) {
-					for (NotationData nd : sv.getNotationDataOccurences()){
-						System.out.println(nd.getNotationName()+"="+nd.getNotationValue());
-						if (nd.getNotationName().equals("trustosm@openstreetmap.org")) {
-							setBackgroundNonSelectionColor(TrustDialog.BGCOLOR_VALID_SIG);
-							setToolTipText(tr("Key certified for OSM-Usage with comment:{0}",nd.getNotationValue()));
-						}
-					}
-				}
-				return this;
-			}
-
-
-		});
-		return t;
-	}
-
-	 */
+    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 {
+            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);
+        detailsButton.addActionListener(new ActionListener() {
+
+            public void actionPerformed(ActionEvent e)
+            {
+                showKeySignaturesDialog(keyID);
+            }
+        });
+        return detailsButton;
+    }
+
+    public static void showKeySignaturesDialog(long keyID) {
+        PGPPublicKey pub = TrustOSMplugin.gpg.getPublicKeyFromRing(keyID);
+        JPanel p = new JPanel(new GridBagLayout());
+
+        Iterator sigIt = pub.getSignatures();
+        while (sigIt.hasNext()) {
+            PGPSignature s = (PGPSignature)sigIt.next();
+            p.add(createKeyButton(s.getHashedSubPackets().getSignerUserID(),pub.getKeyID()));
+        }
+
+        String uid = String.valueOf(pub.getKeyID());
+        Iterator i = pub.getUserIDs();
+        if (i.hasNext())
+            uid = (String)i.next();
+
+        p.add(createKeyButton(uid,pub.getKeyID()));
+        JOptionPane.showMessageDialog(Main.parent,p, tr("Key Signatures"), JOptionPane.PLAIN_MESSAGE);
+    }
+
+
+    public static String convPGPSignatureToString(PGPSignature s) {
+        PGPSignatureSubpacketVector sv = s.getHashedSubPackets();
+        if (sv.hasSubpacket(SignatureSubpacketTags.SIGNER_USER_ID))
+            return sv.getSignerUserID();
+
+        PGPPublicKey pub = TrustOSMplugin.gpg.getPublicKeyFromRing(s.getKeyID());
+        if (pub != null){
+            Iterator i = pub.getUserIDs();
+            if (i.hasNext())
+                return (String)i.next();
+        }
+        return tr("unknown");
+    }
+
+    public static JTree createSignerTree(Collection<PGPSignature> sigs) {
+        DefaultMutableTreeNode root = new DefaultMutableTreeNode();
+        for (PGPSignature s : sigs){
+            DefaultMutableTreeNode sn = new DefaultMutableTreeNode(s);
+            PGPPublicKey pub = TrustOSMplugin.gpg.getPublicKeyFromRing(s.getKeyID());
+            Iterator iter = pub.getSignatures();
+            while (iter.hasNext()){
+                PGPSignature ks = (PGPSignature)iter.next();
+                sn.add(new DefaultMutableTreeNode(ks));
+            }
+            root.add(sn);
+        }
+
+
+        JTree t = new JTree(new DefaultTreeModel(root));
+        t.setRootVisible(false);
+        t.setBackground(TrustDialog.BGCOLOR_NO_SIG);
+        t.setCellRenderer(new DefaultTreeCellRenderer(){
+
+            @Override
+            public Component getTreeCellRendererComponent(JTree tree, Object value,
+                    boolean selected, boolean expanded, boolean leaf, int row,
+                    boolean hasFocus)
+            {
+                super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
+
+                DefaultMutableTreeNode node = (DefaultMutableTreeNode)value;
+                if (node.isRoot()) return this;
+                PGPSignature s = (PGPSignature) node.getUserObject();
+                setIcon(ImageProvider.get("dialogs/sign"));
+                setText(convPGPSignatureToString(s));
+                PGPSignatureSubpacketVector sv = s.getHashedSubPackets();
+                setBackgroundNonSelectionColor(TrustDialog.BGCOLOR_NO_SIG);
+                if (sv.hasSubpacket(SignatureSubpacketTags.NOTATION_DATA)) {
+                    for (NotationData nd : sv.getNotationDataOccurences()){
+                        System.out.println(nd.getNotationName()+"="+nd.getNotationValue());
+                        if (nd.getNotationName().equals("trustosm@openstreetmap.org")) {
+                            setBackgroundNonSelectionColor(TrustDialog.BGCOLOR_VALID_SIG);
+                            setToolTipText(tr("Key certified for OSM-Usage with comment:{0}",nd.getNotationValue()));
+                        }
+                    }
+                }
+                return this;
+            }
+
+
+        });
+        return t;
+    }
+
+     */
 
 }
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 30723)
+++ applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/io/SigExporter.java	(revision 30724)
@@ -18,33 +18,31 @@
 public class SigExporter extends FileExporter {
 
-	public SigExporter(ExtensionFileFilter filter) {
-		super(filter);
-		// TODO Auto-generated constructor stub
-	}
+    public SigExporter(ExtensionFileFilter filter) {
+        super(filter);
+        // TODO Auto-generated constructor stub
+    }
 
-	public SigExporter() {
-		super(new ExtensionFileFilter("txml,xml", "txml", tr("Signature Files") + " (*.txml *.xml)"));
-	}
+    public SigExporter() {
+        super(new ExtensionFileFilter("txml,xml", "txml", tr("Signature Files") + " (*.txml *.xml)"));
+    }
 
-	@Override
-	public void exportData(File file, Layer layer) throws IOException {
-		CheckParameterUtil.ensureParameterNotNull(file, "file");
+    @Override
+    public void exportData(File file, Layer layer) throws IOException {
+        CheckParameterUtil.ensureParameterNotNull(file, "file");
 
-		String fn = file.getPath();
-		if (fn.indexOf('.') == -1) {
-			fn += ".tosm";
-			file = new File(fn);
-		}
-		try {
-			FileOutputStream fo = new FileOutputStream(file);
-			new SigWriter(fo).write(TrustOSMplugin.signedItems.values());
-			fo.flush();
-			fo.close();
-		} catch (IOException x) {
-			x.printStackTrace();
-			JOptionPane.showMessageDialog(Main.parent, tr("Error while exporting {0}:\n{1}", fn, x.getMessage()),
-					tr("Error"), JOptionPane.ERROR_MESSAGE);
-		}
-	}
+        String fn = file.getPath();
+        if (fn.indexOf('.') == -1) {
+            fn += ".tosm";
+            file = new File(fn);
+        }
+        try (FileOutputStream fo = new FileOutputStream(file)) {
+            new SigWriter(fo).write(TrustOSMplugin.signedItems.values());
+            fo.flush();
+        } catch (IOException x) {
+            x.printStackTrace();
+            JOptionPane.showMessageDialog(Main.parent, tr("Error while exporting {0}:\n{1}", fn, x.getMessage()),
+                    tr("Error"), JOptionPane.ERROR_MESSAGE);
+        }
+    }
 
 }
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 30723)
+++ applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/io/SigImporter.java	(revision 30724)
@@ -24,48 +24,48 @@
 public class SigImporter extends FileImporter {
 
-	public SigImporter() {
-		super(new ExtensionFileFilter("txml,xml", "txml", tr("OSM Signature Files") + " (*.txml *.xml)"));
-	}
+    public SigImporter() {
+        super(new ExtensionFileFilter("txml,xml", "txml", tr("OSM Signature Files") + " (*.txml *.xml)"));
+    }
 
-	public SigImporter(ExtensionFileFilter filter) {
-		super(filter);
-	}
+    public SigImporter(ExtensionFileFilter filter) {
+        super(filter);
+    }
 
-	@Override public void importData(File file, ProgressMonitor progressMonitor) throws IOException, IllegalDataException {
-		try {
-			FileInputStream in = new FileInputStream(file);
-			importData(in, file);
-		} catch (FileNotFoundException e) {
-			e.printStackTrace();
-			throw new IOException(tr("File ''{0}'' does not exist.", file.getName()));
-		}
-	}
+    @Override public void importData(File file, ProgressMonitor progressMonitor) throws IOException, IllegalDataException {
+        try {
+            FileInputStream in = new FileInputStream(file);
+            importData(in, file);
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+            throw new IOException(tr("File ''{0}'' does not exist.", file.getName()));
+        }
+    }
 
-	protected void importData(InputStream in, File associatedFile) throws IllegalDataException {
-		if (!Main.main.hasEditLayer()) {
-			DataSet dataSet = new DataSet();
-			final OsmDataLayer layer = new OsmDataLayer(dataSet, associatedFile.getName(), associatedFile);
-			Main.main.addLayer(layer);
-		}
-		//		Set<OsmPrimitive> missingData = new HashSet<OsmPrimitive>();
-		Map<String,TrustOsmPrimitive> trustitems = SigReader.parseSignatureXML(in, NullProgressMonitor.INSTANCE);
-		System.out.println(trustitems.size());
-		/*
-		int missingCount = missingData.size();
-		int itemCount = trustitems.size();
-		if (missingCount == 0) {
-			JOptionPane.showMessageDialog(Main.parent, tr("{0} Signatures loaded. All referenced OSM objects found.",itemCount));
-		} else {
-			int n = JOptionPane.showOptionDialog(Main.parent, tr("{0} of {1} OSM objects are referenced but not there.\nDo you want to load them from OSM-Server?",missingCount,itemCount), tr("Load objects from server"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
+    protected void importData(InputStream in, File associatedFile) throws IllegalDataException {
+        if (!Main.main.hasEditLayer()) {
+            DataSet dataSet = new DataSet();
+            final OsmDataLayer layer = new OsmDataLayer(dataSet, associatedFile.getName(), associatedFile);
+            Main.main.addLayer(layer);
+        }
+        //        Set<OsmPrimitive> missingData = new HashSet<OsmPrimitive>();
+        Map<String,TrustOsmPrimitive> trustitems = SigReader.parseSignatureXML(in, NullProgressMonitor.INSTANCE);
+        System.out.println(trustitems.size());
+        /*
+        int missingCount = missingData.size();
+        int itemCount = trustitems.size();
+        if (missingCount == 0) {
+            JOptionPane.showMessageDialog(Main.parent, tr("{0} Signatures loaded. All referenced OSM objects found.",itemCount));
+        } else {
+            int n = JOptionPane.showOptionDialog(Main.parent, tr("{0} of {1} OSM objects are referenced but not there.\nDo you want to load them from OSM-Server?",missingCount,itemCount), tr("Load objects from server"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
 
-			if (n == JOptionPane.YES_OPTION) {
-				Main.worker.submit(new DownloadSignedOsmDataTask(missingData, Main.main.getEditLayer()));
-			}
-		}
-		 */
-		TrustOSMplugin.signedItems.putAll(trustitems);
-		new GetMissingDataAction().downloadMissing();
-		//TrustOSMplugin.signedItems.putAll(TrustStoreHandler.loadSigsFromFile(in));
+            if (n == JOptionPane.YES_OPTION) {
+                Main.worker.submit(new DownloadSignedOsmDataTask(missingData, Main.main.getEditLayer()));
+            }
+        }
+         */
+        TrustOSMplugin.signedItems.putAll(trustitems);
+        new GetMissingDataAction().downloadMissing();
+        //TrustOSMplugin.signedItems.putAll(TrustStoreHandler.loadSigsFromFile(in));
 
-	}
+    }
 }
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 30723)
+++ applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/io/SigReader.java	(revision 30724)
@@ -30,5 +30,4 @@
 import org.openstreetmap.josm.gui.progress.ProgressMonitor;
 import org.openstreetmap.josm.io.IllegalDataException;
-import org.openstreetmap.josm.io.OsmDataParsingException;
 import org.openstreetmap.josm.io.UTFInputStreamReader;
 import org.openstreetmap.josm.plugins.trustosm.data.TrustNode;
@@ -38,4 +37,5 @@
 import org.openstreetmap.josm.plugins.trustosm.data.TrustWay;
 import org.openstreetmap.josm.tools.CheckParameterUtil;
+import org.openstreetmap.josm.tools.XmlParsingException;
 import org.xml.sax.Attributes;
 import org.xml.sax.InputSource;
@@ -47,185 +47,185 @@
 public class SigReader {
 
-	private final Map<String,TrustOsmPrimitive> trustitems = new HashMap<String,TrustOsmPrimitive>();
-	private final Set<OsmPrimitive> missingData = new HashSet<OsmPrimitive>();
-
-	public Map<String,TrustOsmPrimitive> getTrustItems() {
-		return trustitems;
-	}
-
-	public Set<OsmPrimitive> getMissingData() {
-		return missingData;
-	}
-
-	private class Parser extends DefaultHandler {
-		private Locator locator;
-
-		@Override
-		public void setDocumentLocator(Locator locator) {
-			this.locator = locator;
-		}
-
-		protected void throwException(String msg) throws OsmDataParsingException{
-			throw new OsmDataParsingException(msg).rememberLocation(locator);
-		}
-
-		/**
-		 * The current TrustOSMItem to be read.
-		 */
-		private TrustOsmPrimitive trust;
-
-
-		/**
-		 * The current Signatures.
-		 */
-		private TrustSignatures tsigs;
-
-
-		private StringBuffer tmpbuf = new StringBuffer();
-
-
-		@Override public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
-
-			try {
-				if (qName.equals("trustnode") || qName.equals("trustway") || qName.equals("trustrelation")) {
-					if (atts == null) {
-						throwException(tr("Missing mandatory attribute ''{0}'' of XML element {1}.", "osmid", qName));
-					}
-
-					String osmid = atts.getValue("osmid");
-					if (osmid == null){
-						throwException(tr("Missing mandatory attribute ''{0}''.", "osmid"));
-					} else if (!osmid.matches("\\d+")) {
-						throwException(tr("Only digits allowed in osmid: ''{0}''.", osmid));
-					}
-					long uid = Long.parseLong(osmid);
-
-					OsmPrimitiveType t = OsmPrimitiveType.NODE;
-					if (qName.equals("trustway")) t = OsmPrimitiveType.WAY;
-					else if (qName.equals("trustrelation")) t = OsmPrimitiveType.RELATION;
-
-					// search corresponding OsmPrimitive
-					OsmPrimitive osm = Main.main.getCurrentDataSet().getPrimitiveById(uid, t);
-					if (osm == null) {
-						switch (t) {
-						case NODE: osm = new Node(uid); break;
-						case WAY: osm = new Way(uid); break;
-						case RELATION: osm = new Relation(uid); break;
-						}
-						missingData.add(osm);
-					}
-					trust = TrustOsmPrimitive.createTrustOsmPrimitive(osm);
-
-				} else if (qName.equals("key") || qName.equals("node") || qName.equals("segment") || qName.equals("member")) {
-					tsigs = new TrustSignatures();
-				} else if (qName.equals("openpgp")) {
-					tmpbuf = new StringBuffer();
-				}
-			} catch (Exception e) {
-				throw new SAXParseException(e.getMessage(), locator, e);
-			}
-		}
-
-		@Override public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
-			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());
-				try {
-					parseOpenPGP(tmpbuf.toString());
-				} catch (IOException e) {
-					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);
-			}
-		}
-
-		@Override public void characters(char[] ch, int start, int length) {
-			tmpbuf.append(ch, start, length);
-		}
-
-		public void parseOpenPGP(String clearsigned) throws IOException {
-
-			// handle different newline characters and match them all to \n
-			//clearsigned = clearsigned.replace('\r', '\n').replaceAll("\n\n", "\n");
-
-			String plain = "";
-
-			ArmoredInputStream aIn = new ArmoredInputStream(new ByteArrayInputStream(clearsigned.getBytes(Charset.forName("UTF-8"))));
-			PGPObjectFactory pgpFact = new PGPObjectFactory(aIn);
-			// read plain text
-			ByteArrayOutputStream bout = new ByteArrayOutputStream();
-			if (aIn.isClearText()) {
-				int ch = aIn.read();
-				do {
-					bout.write(ch);
-					ch = aIn.read();
-				} while (aIn.isClearText());
-			}
-			plain = bout.toString();
-
-			// remove the last \n because it is not part of the plaintext
-			plain = plain.substring(0, plain.length()-1);
-
-			PGPSignatureList siglist = (PGPSignatureList)pgpFact.nextObject();
-			for (int i=0; i<siglist.size();i++) {
-				tsigs.addSignature(siglist.get(i), plain);
-			}
-
-
-		}
-
-
-	}
-
-	/**
-	 * Parse the given input source and return the TrustosmItems.
-	 *
-	 * @param source the source input stream. Must not be null.
-	 * @param progressMonitor  the progress monitor. If null, {@see NullProgressMonitor#INSTANCE} is assumed
-	 *
-	 * @return a map of the parsed OSM Signatures (TrustOSMItem) with their related OSM-ID as key
-	 * @throws IllegalDataException thrown if the an error was found while parsing the data from the source
-	 * @throws IllegalArgumentException thrown if source is null
-	 */
-	public static Map<String,TrustOsmPrimitive> parseSignatureXML(InputStream source, ProgressMonitor progressMonitor) throws IllegalDataException {
-		if (progressMonitor == null) {
-			progressMonitor = NullProgressMonitor.INSTANCE;
-		}
-		CheckParameterUtil.ensureParameterNotNull(source, "source");
-		SigReader reader = new SigReader();
-		try {
-			progressMonitor.beginTask(tr("Prepare stuff...", 2));
-			progressMonitor.indeterminateSubTask(tr("Parsing Signature data..."));
-
-			InputSource inputSource = new InputSource(UTFInputStreamReader.create(source, "UTF-8"));
-			SAXParserFactory.newInstance().newSAXParser().parse(inputSource, reader.new Parser());
-			//			if (missingData != null)
-			//				missingData.addAll(reader.getMissingData());
-			progressMonitor.worked(1);
-
-			return reader.getTrustItems();
-		} catch(ParserConfigurationException e) {
-			throw new IllegalDataException(e.getMessage(), e);
-		} catch (SAXParseException e) {
-			throw new IllegalDataException(tr("Line {0} column {1}: ", e.getLineNumber(), e.getColumnNumber()) + e.getMessage(), e);
-		} catch(SAXException e) {
-			throw new IllegalDataException(e.getMessage(), e);
-		} catch(Exception e) {
-			throw new IllegalDataException(e);
-		} finally {
-			progressMonitor.finishTask();
-		}
-	}
+    private final Map<String,TrustOsmPrimitive> trustitems = new HashMap<>();
+    private final Set<OsmPrimitive> missingData = new HashSet<>();
+
+    public Map<String,TrustOsmPrimitive> getTrustItems() {
+        return trustitems;
+    }
+
+    public Set<OsmPrimitive> getMissingData() {
+        return missingData;
+    }
+
+    private class Parser extends DefaultHandler {
+        private Locator locator;
+
+        @Override
+        public void setDocumentLocator(Locator locator) {
+            this.locator = locator;
+        }
+
+        protected void throwException(String msg) throws XmlParsingException {
+            throw new XmlParsingException(msg).rememberLocation(locator);
+        }
+
+        /**
+         * The current TrustOSMItem to be read.
+         */
+        private TrustOsmPrimitive trust;
+
+
+        /**
+         * The current Signatures.
+         */
+        private TrustSignatures tsigs;
+
+
+        private StringBuffer tmpbuf = new StringBuffer();
+
+
+        @Override public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
+
+            try {
+                if (qName.equals("trustnode") || qName.equals("trustway") || qName.equals("trustrelation")) {
+                    if (atts == null) {
+                        throwException(tr("Missing mandatory attribute ''{0}'' of XML element {1}.", "osmid", qName));
+                    }
+
+                    String osmid = atts.getValue("osmid");
+                    if (osmid == null){
+                        throwException(tr("Missing mandatory attribute ''{0}''.", "osmid"));
+                    } else if (!osmid.matches("\\d+")) {
+                        throwException(tr("Only digits allowed in osmid: ''{0}''.", osmid));
+                    }
+                    long uid = Long.parseLong(osmid);
+
+                    OsmPrimitiveType t = OsmPrimitiveType.NODE;
+                    if (qName.equals("trustway")) t = OsmPrimitiveType.WAY;
+                    else if (qName.equals("trustrelation")) t = OsmPrimitiveType.RELATION;
+
+                    // search corresponding OsmPrimitive
+                    OsmPrimitive osm = Main.main.getCurrentDataSet().getPrimitiveById(uid, t);
+                    if (osm == null) {
+                        switch (t) {
+                        case NODE: osm = new Node(uid); break;
+                        case WAY: osm = new Way(uid); break;
+                        case RELATION: osm = new Relation(uid); break;
+                        }
+                        missingData.add(osm);
+                    }
+                    trust = TrustOsmPrimitive.createTrustOsmPrimitive(osm);
+
+                } else if (qName.equals("key") || qName.equals("node") || qName.equals("segment") || qName.equals("member")) {
+                    tsigs = new TrustSignatures();
+                } else if (qName.equals("openpgp")) {
+                    tmpbuf = new StringBuffer();
+                }
+            } catch (Exception e) {
+                throw new SAXParseException(e.getMessage(), locator, e);
+            }
+        }
+
+        @Override public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
+            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());
+                try {
+                    parseOpenPGP(tmpbuf.toString());
+                } catch (IOException e) {
+                    throw new XmlParsingException(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);
+            }
+        }
+
+        @Override public void characters(char[] ch, int start, int length) {
+            tmpbuf.append(ch, start, length);
+        }
+
+        public void parseOpenPGP(String clearsigned) throws IOException {
+
+            // handle different newline characters and match them all to \n
+            //clearsigned = clearsigned.replace('\r', '\n').replaceAll("\n\n", "\n");
+
+            String plain = "";
+
+            ArmoredInputStream aIn = new ArmoredInputStream(new ByteArrayInputStream(clearsigned.getBytes(Charset.forName("UTF-8"))));
+            PGPObjectFactory pgpFact = new PGPObjectFactory(aIn);
+            // read plain text
+            ByteArrayOutputStream bout = new ByteArrayOutputStream();
+            if (aIn.isClearText()) {
+                int ch = aIn.read();
+                do {
+                    bout.write(ch);
+                    ch = aIn.read();
+                } while (aIn.isClearText());
+            }
+            plain = bout.toString();
+
+            // remove the last \n because it is not part of the plaintext
+            plain = plain.substring(0, plain.length()-1);
+
+            PGPSignatureList siglist = (PGPSignatureList)pgpFact.nextObject();
+            for (int i=0; i<siglist.size();i++) {
+                tsigs.addSignature(siglist.get(i), plain);
+            }
+
+
+        }
+
+
+    }
+
+    /**
+     * Parse the given input source and return the TrustosmItems.
+     *
+     * @param source the source input stream. Must not be null.
+     * @param progressMonitor  the progress monitor. If null, {@see NullProgressMonitor#INSTANCE} is assumed
+     *
+     * @return a map of the parsed OSM Signatures (TrustOSMItem) with their related OSM-ID as key
+     * @throws IllegalDataException thrown if the an error was found while parsing the data from the source
+     * @throws IllegalArgumentException thrown if source is null
+     */
+    public static Map<String,TrustOsmPrimitive> parseSignatureXML(InputStream source, ProgressMonitor progressMonitor) throws IllegalDataException {
+        if (progressMonitor == null) {
+            progressMonitor = NullProgressMonitor.INSTANCE;
+        }
+        CheckParameterUtil.ensureParameterNotNull(source, "source");
+        SigReader reader = new SigReader();
+        try {
+            progressMonitor.beginTask(tr("Prepare stuff...", 2));
+            progressMonitor.indeterminateSubTask(tr("Parsing Signature data..."));
+
+            InputSource inputSource = new InputSource(UTFInputStreamReader.create(source, "UTF-8"));
+            SAXParserFactory.newInstance().newSAXParser().parse(inputSource, reader.new Parser());
+            //            if (missingData != null)
+            //                missingData.addAll(reader.getMissingData());
+            progressMonitor.worked(1);
+
+            return reader.getTrustItems();
+        } catch(ParserConfigurationException e) {
+            throw new IllegalDataException(e.getMessage(), e);
+        } catch (SAXParseException e) {
+            throw new IllegalDataException(tr("Line {0} column {1}: ", e.getLineNumber(), e.getColumnNumber()) + e.getMessage(), e);
+        } catch(SAXException e) {
+            throw new IllegalDataException(e.getMessage(), e);
+        } catch(Exception e) {
+            throw new IllegalDataException(e);
+        } finally {
+            progressMonitor.finishTask();
+        }
+    }
 
 
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 30723)
+++ applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/io/SigWriter.java	(revision 30724)
@@ -22,182 +22,182 @@
 public class SigWriter extends XmlWriter {
 
-	private String indent = "";
-
-	public SigWriter(PrintWriter out) {
-		super(out);
-	}
-
-	public SigWriter(OutputStream out) throws UnsupportedEncodingException {
-		super(new PrintWriter(new BufferedWriter(new OutputStreamWriter(out, "UTF-8"))));
-	}
-
-	public void write(Collection<TrustOsmPrimitive> items) {
-		writeHeader();
-		indent = "  ";
-		writeItems(items);
-		writeFooter();
-		out.flush();
-	}
-
-	private void writeDTD() {
-		out.println("<!DOCTYPE trustXML [");
-		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("]>");
-	}
-
-	private void writeHeader() {
-		out.println("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>");
-		writeDTD();
-		out.println("<trustXML version=\"0.1\" creator=\"JOSM Signature export\">");
-	}
-
-	private void writeFooter() {
-		out.println("</trustXML>");
-	}
-
-	private void writeSigs(TrustSignatures tsigs) {
-		for (String plain : tsigs.getAllPlainTexts()) {
-			simpleTag("openpgp",tsigs.getArmoredFulltextSignatureAll(plain));
-		}
-
-	}
-
-	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");
-			}
-
-			//			openAtt("trustitem", "osmid=\""+String.valueOf(osm.getUniqueId())+"\" type=\""+osm.getType().getAPIName()+"\"");
-
-		}
-	}
-
-	private void openln(String tag) {
-		open(tag);
-		out.println();
-	}
-
-	private void open(String tag) {
-		out.print(indent + "<" + tag + ">");
-		indent += "  ";
-	}
-
-	private void openAtt(String tag, String attributes) {
-		out.println(indent + "<" + tag + " " + attributes + ">");
-		indent += "  ";
-	}
-
-	private void inline(String tag, String attributes) {
-		out.println(indent + "<" + tag + " " + attributes + " />");
-	}
-
-	private void close(String tag) {
-		indent = indent.substring(2);
-		out.print(indent + "</" + tag + ">");
-	}
-
-	private void closeln(String tag) {
-		close(tag);
-		out.println();
-	}
-
-	/**
-	 * if content not null, open tag, write encoded content, and close tag
-	 * else do nothing.
-	 */
-	private void simpleTag(String tag, String content) {
-		if (content != null && content.length() > 0) {
-			open(tag);
-			out.print(encode(content));
-			//out.print(content);
-			out.println("</" + tag + ">");
-			indent = indent.substring(2);
-		}
-	}
+    private String indent = "";
+
+    public SigWriter(PrintWriter out) {
+        super(out);
+    }
+
+    public SigWriter(OutputStream out) throws UnsupportedEncodingException {
+        super(new PrintWriter(new BufferedWriter(new OutputStreamWriter(out, "UTF-8"))));
+    }
+
+    public void write(Collection<TrustOsmPrimitive> items) {
+        writeHeader();
+        indent = "  ";
+        writeItems(items);
+        writeFooter();
+        out.flush();
+    }
+
+    private void writeDTD() {
+        out.println("<!DOCTYPE trustXML [");
+        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("]>");
+    }
+
+    private void writeHeader() {
+        out.println("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>");
+        writeDTD();
+        out.println("<trustXML version=\"0.1\" creator=\"JOSM Signature export\">");
+    }
+
+    private void writeFooter() {
+        out.println("</trustXML>");
+    }
+
+    private void writeSigs(TrustSignatures tsigs) {
+        for (String plain : tsigs.getAllPlainTexts()) {
+            simpleTag("openpgp",tsigs.getArmoredFulltextSignatureAll(plain));
+        }
+
+    }
+
+    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");
+            }
+
+            //            openAtt("trustitem", "osmid=\""+String.valueOf(osm.getUniqueId())+"\" type=\""+osm.getType().getAPIName()+"\"");
+
+        }
+    }
+
+    private void openln(String tag) {
+        open(tag);
+        out.println();
+    }
+
+    private void open(String tag) {
+        out.print(indent + "<" + tag + ">");
+        indent += "  ";
+    }
+
+    private void openAtt(String tag, String attributes) {
+        out.println(indent + "<" + tag + " " + attributes + ">");
+        indent += "  ";
+    }
+
+    /*private void inline(String tag, String attributes) {
+        out.println(indent + "<" + tag + " " + attributes + " />");
+    }*/
+
+    private void close(String tag) {
+        indent = indent.substring(2);
+        out.print(indent + "</" + tag + ">");
+    }
+
+    private void closeln(String tag) {
+        close(tag);
+        out.println();
+    }
+
+    /**
+     * if content not null, open tag, write encoded content, and close tag
+     * else do nothing.
+     */
+    private void simpleTag(String tag, String content) {
+        if (content != null && content.length() > 0) {
+            open(tag);
+            out.print(encode(content));
+            //out.print(content);
+            out.println("</" + tag + ">");
+            indent = indent.substring(2);
+        }
+    }
 
 }
Index: applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/util/NameGenerator.java
===================================================================
--- applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/util/NameGenerator.java	(revision 30723)
+++ applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/util/NameGenerator.java	(revision 30724)
@@ -49,250 +49,250 @@
  */
 public class NameGenerator {
-	ArrayList<String> pre = new ArrayList<String>();
-	ArrayList<String> mid = new ArrayList<String>();
-	ArrayList<String> sur = new ArrayList<String>();
-
-	final private static char[] vocals = {'a', 'e', 'i', 'o', 'u', 'ä', 'ö', 'õ', 'ü', 'y'};
-	final private static char[] consonants = {'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p',	'q', 'r', 's', 't', 'v', 'w', 'x', 'y'};
-
-	private String fileName;
-
-	/**
-	 * Create new random name generator object. refresh() is automatically called.
-	 * @param fileName insert file name, where syllables are located
-	 * @throws IOException
-	 */
-	public NameGenerator(String fileName) throws IOException{
-		this.fileName = fileName;
-		refresh();
-	}
-
-	/**
-	 * Change the file. refresh() is automatically called during the process.
-	 * @param fileName insert the file name, where syllables are located.
-	 * @throws IOException
-	 */
-	public void changeFile(String fileName) throws IOException{
-		if(fileName == null) throw new IOException("File name cannot be null");
-		this.fileName = fileName;
-		refresh();
-	}
-
-	/**
-	 * Refresh names from file. No need to call that method, if you are not changing the file during the operation of program, as this method
-	 * is called every time file name is changed or new NameGenerator object created.
-	 * @throws IOException
-	 */
-	public void refresh() throws IOException{
-
-		FileReader input = null;
-		BufferedReader bufRead;
-		String line;
-
-		input = new FileReader(fileName);
-
-		bufRead = new BufferedReader(input);
-		line="";
-
-		while(line != null){
-			line = bufRead.readLine();
-			if(line != null && !line.equals("")){
-				if(line.charAt(0) == '-'){
-					pre.add(line.substring(1).toLowerCase());
-				}
-				else if(line.charAt(0) == '+'){
-					sur.add(line.substring(1).toLowerCase());
-				}
-				else{
-					mid.add(line.toLowerCase());
-				}
-			}
-		}
-		bufRead.close();
-	}
-
-	private String upper(String s){
-		return s.substring(0,1).toUpperCase().concat(s.substring(1));
-	}
-
-	private boolean containsConsFirst(ArrayList<String> array){
-		for(String s: array){
-			if(consonantFirst(s)) return true;
-		}
-		return false;
-	}
-
-	private boolean containsVocFirst(ArrayList<String> array){
-		for(String s: array){
-			if(vocalFirst(s)) return true;
-		}
-		return false;
-	}
-
-	private boolean allowCons(ArrayList<String> array){
-		for(String s: array){
-			if(hatesPreviousVocals(s) || hatesPreviousConsonants(s) == false) return true;
-		}
-		return false;
-	}
-
-	private boolean allowVocs(ArrayList<String> array){
-		for(String s: array){
-			if(hatesPreviousConsonants(s) || hatesPreviousVocals(s) == false) return true;
-		}
-		return false;
-	}
-
-	private boolean expectsVocal(String s){
-		if(s.substring(1).contains("+v")) return true;
-		else return false;
-	}
-	private boolean expectsConsonant(String s){
-		if(s.substring(1).contains("+c")) return true;
-		else return false;
-	}
-	private boolean hatesPreviousVocals(String s){
-		if(s.substring(1).contains("-c")) return true;
-		else return false;
-	}
-	private boolean hatesPreviousConsonants(String s){
-		if(s.substring(1).contains("-v")) return true;
-		else return false;
-	}
-
-	private String pureSyl(String s){
-		s = s.trim();
-		if(s.charAt(0) == '+' || s.charAt(0) == '-') s = s.substring(1);
-		return s.split(" ")[0];
-	}
-
-	private boolean vocalFirst(String s){
-		return (String.copyValueOf(vocals).contains(String.valueOf(s.charAt(0)).toLowerCase()));
-	}
-
-	private boolean consonantFirst(String s){
-		return (String.copyValueOf(consonants).contains(String.valueOf(s.charAt(0)).toLowerCase()));
-	}
-
-	private boolean vocalLast(String s){
-		return (String.copyValueOf(vocals).contains(String.valueOf(s.charAt(s.length()-1)).toLowerCase()));
-	}
-
-	private boolean consonantLast(String s){
-		return (String.copyValueOf(consonants).contains(String.valueOf(s.charAt(s.length()-1)).toLowerCase()));
-	}
-
-
-	/**
-	 * Compose a new name.
-	 * @param syls The number of syllables used in name.
-	 * @return Returns composed name as a String
-	 * @throws RuntimeException when logical mistakes are detected inside chosen file, and program is unable to complete the name.
-	 */
-	public String compose(int syls){
-		if(syls > 2 && mid.size() == 0) throw new RuntimeException("You are trying to create a name with more than 3 parts, which requires middle parts, " +
-				"which you have none in the file "+fileName+". You should add some. Every word, which doesn't have + or - for a prefix is counted as a middle part.");
-		if(pre.size() == 0) throw new RuntimeException("You have no prefixes to start creating a name. add some and use \"-\" prefix, to identify it as a prefix for a name. (example: -asd)");
-		if(sur.size() == 0) throw new RuntimeException("You have no suffixes to end a name. add some and use \"+\" prefix, to identify it as a suffix for a name. (example: +asd)");
-		if(syls < 1) throw new RuntimeException("compose(int syls) can't have less than 1 syllable");
-		int expecting = 0; // 1 for vocal, 2 for consonant
-		int last = 0; // 1 for vocal, 2 for consonant
-		String name;
-		int a = (int)(Math.random() * pre.size());
-
-		if(vocalLast(pureSyl(pre.get(a)))) last = 1;
-		else last = 2;
-
-		if(syls > 2){
-			if(expectsVocal(pre.get(a))){
-				expecting = 1;
-				if(containsVocFirst(mid) == false) throw new RuntimeException("Expecting \"middle\" part starting with vocal, " +
-				"but there is none. You should add one, or remove requirement for one.. ");
-			}
-			if(expectsConsonant(pre.get(a))){
-				expecting = 2;
-				if(containsConsFirst(mid) == false) throw new RuntimeException("Expecting \"middle\" part starting with consonant, " +
-				"but there is none. You should add one, or remove requirement for one.. ");
-			}
-		}
-		else{
-			if(expectsVocal(pre.get(a))){
-				expecting = 1;
-				if(containsVocFirst(sur) == false) throw new RuntimeException("Expecting \"suffix\" part starting with vocal, " +
-				"but there is none. You should add one, or remove requirement for one.. ");
-			}
-			if(expectsConsonant(pre.get(a))){
-				expecting = 2;
-				if(containsConsFirst(sur) == false) throw new RuntimeException("Expecting \"suffix\" part starting with consonant, " +
-				"but there is none. You should add one, or remove requirement for one.. ");
-			}
-		}
-		if(vocalLast(pureSyl(pre.get(a))) && allowVocs(mid) == false) throw new RuntimeException("Expecting \"middle\" part that allows last character of prefix to be a vocal, " +
-				"but there is none. You should add one, or remove requirements that cannot be fulfilled.. the prefix used, was : \""+pre.get(a)+"\", which" +
-		"means there should be a part available, that has \"-v\" requirement or no requirements for previous syllables at all.");
-
-		if(consonantLast(pureSyl(pre.get(a))) && allowCons(mid) == false) throw new RuntimeException("Expecting \"middle\" part that allows last character of prefix to be a consonant, " +
-				"but there is none. You should add one, or remove requirements that cannot be fulfilled.. the prefix used, was : \""+pre.get(a)+"\", which" +
-		"means there should be a part available, that has \"-c\" requirement or no requirements for previous syllables at all.");
-
-		int b[] = new int[syls];
-		for(int i = 0; i<b.length-2; i++){
-
-			do{
-				b[i] = (int)(Math.random() * mid.size());
-				//System.out.println("exp " +expecting+" vocalF:"+vocalFirst(mid.get(b[i]))+" syl: "+mid.get(b[i]));
-			}
-			while(expecting == 1 && vocalFirst(pureSyl(mid.get(b[i]))) == false || expecting == 2 && consonantFirst(pureSyl(mid.get(b[i]))) == false
-					|| last == 1 && hatesPreviousVocals(mid.get(b[i])) || last == 2 && hatesPreviousConsonants(mid.get(b[i])));
-
-			expecting = 0;
-			if(expectsVocal(mid.get(b[i]))){
-				expecting = 1;
-				if(i < b.length-3 && containsVocFirst(mid) == false) throw new RuntimeException("Expecting \"middle\" part starting with vocal, " +
-				"but there is none. You should add one, or remove requirement for one.. ");
-				if(i == b.length-3 && containsVocFirst(sur) == false) throw new RuntimeException("Expecting \"suffix\" part starting with vocal, " +
-				"but there is none. You should add one, or remove requirement for one.. ");
-			}
-			if(expectsConsonant(mid.get(b[i]))){
-				expecting = 2;
-				if(i < b.length-3 && containsConsFirst(mid) == false) throw new RuntimeException("Expecting \"middle\" part starting with consonant, " +
-				"but there is none. You should add one, or remove requirement for one.. ");
-				if(i == b.length-3 && containsConsFirst(sur) == false) throw new RuntimeException("Expecting \"suffix\" part starting with consonant, " +
-				"but there is none. You should add one, or remove requirement for one.. ");
-			}
-			if(vocalLast(pureSyl(mid.get(b[i]))) && allowVocs(mid) == false && syls > 3) throw new RuntimeException("Expecting \"middle\" part that allows last character of last syllable to be a vocal, " +
-					"but there is none. You should add one, or remove requirements that cannot be fulfilled.. the part used, was : \""+mid.get(b[i])+"\", which " +
-			"means there should be a part available, that has \"-v\" requirement or no requirements for previous syllables at all.");
-
-			if(consonantLast(pureSyl(mid.get(b[i]))) && allowCons(mid) == false && syls > 3) throw new RuntimeException("Expecting \"middle\" part that allows last character of last syllable to be a consonant, " +
-					"but there is none. You should add one, or remove requirements that cannot be fulfilled.. the part used, was : \""+mid.get(b[i])+"\", which " +
-			"means there should be a part available, that has \"-c\" requirement or no requirements for previous syllables at all.");
-			if(i == b.length-3){
-				if(vocalLast(pureSyl(mid.get(b[i]))) && allowVocs(sur) == false) throw new RuntimeException("Expecting \"suffix\" part that allows last character of last syllable to be a vocal, " +
-						"but there is none. You should add one, or remove requirements that cannot be fulfilled.. the part used, was : \""+mid.get(b[i])+"\", which " +
-				"means there should be a suffix available, that has \"-v\" requirement or no requirements for previous syllables at all.");
-
-				if(consonantLast(pureSyl(mid.get(b[i]))) && allowCons(sur) == false) throw new RuntimeException("Expecting \"suffix\" part that allows last character of last syllable to be a consonant, " +
-						"but there is none. You should add one, or remove requirements that cannot be fulfilled.. the part used, was : \""+mid.get(b[i])+"\", which " +
-				"means there should be a suffix available, that has \"-c\" requirement or no requirements for previous syllables at all.");
-			}
-			if(vocalLast(pureSyl(mid.get(b[i])))) last = 1;
-			else last = 2;
-		}
-
-		int c;
-		do{
-			c = (int)(Math.random() * sur.size());
-		}
-		while(expecting == 1 && vocalFirst(pureSyl(sur.get(c))) == false || expecting == 2 && consonantFirst(pureSyl(sur.get(c))) == false
-				|| last == 1 && hatesPreviousVocals(sur.get(c)) || last == 2 && hatesPreviousConsonants(sur.get(c)));
-
-		name = upper(pureSyl(pre.get(a).toLowerCase()));
-		for(int i = 0; i<b.length-2; i++){
-			name = name.concat(pureSyl(mid.get(b[i]).toLowerCase()));
-		}
-		if(syls > 1)
-			name = name.concat(pureSyl(sur.get(c).toLowerCase()));
-		return name;
-	}
+    ArrayList<String> pre = new ArrayList<>();
+    ArrayList<String> mid = new ArrayList<>();
+    ArrayList<String> sur = new ArrayList<>();
+
+    final private static char[] vocals = {'a', 'e', 'i', 'o', 'u', 'ä', 'ö', 'õ', 'ü', 'y'};
+    final private static char[] consonants = {'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p',    'q', 'r', 's', 't', 'v', 'w', 'x', 'y'};
+
+    private String fileName;
+
+    /**
+     * Create new random name generator object. refresh() is automatically called.
+     * @param fileName insert file name, where syllables are located
+     * @throws IOException
+     */
+    public NameGenerator(String fileName) throws IOException{
+        this.fileName = fileName;
+        refresh();
+    }
+
+    /**
+     * Change the file. refresh() is automatically called during the process.
+     * @param fileName insert the file name, where syllables are located.
+     * @throws IOException
+     */
+    public void changeFile(String fileName) throws IOException{
+        if(fileName == null) throw new IOException("File name cannot be null");
+        this.fileName = fileName;
+        refresh();
+    }
+
+    /**
+     * Refresh names from file. No need to call that method, if you are not changing the file during the operation of program, as this method
+     * is called every time file name is changed or new NameGenerator object created.
+     * @throws IOException
+     */
+    public void refresh() throws IOException{
+
+        FileReader input = null;
+        BufferedReader bufRead;
+        String line;
+
+        input = new FileReader(fileName);
+
+        bufRead = new BufferedReader(input);
+        line="";
+
+        while(line != null){
+            line = bufRead.readLine();
+            if(line != null && !line.equals("")){
+                if(line.charAt(0) == '-'){
+                    pre.add(line.substring(1).toLowerCase());
+                }
+                else if(line.charAt(0) == '+'){
+                    sur.add(line.substring(1).toLowerCase());
+                }
+                else{
+                    mid.add(line.toLowerCase());
+                }
+            }
+        }
+        bufRead.close();
+    }
+
+    private String upper(String s){
+        return s.substring(0,1).toUpperCase().concat(s.substring(1));
+    }
+
+    private boolean containsConsFirst(ArrayList<String> array){
+        for(String s: array){
+            if(consonantFirst(s)) return true;
+        }
+        return false;
+    }
+
+    private boolean containsVocFirst(ArrayList<String> array){
+        for(String s: array){
+            if(vocalFirst(s)) return true;
+        }
+        return false;
+    }
+
+    private boolean allowCons(ArrayList<String> array){
+        for(String s: array){
+            if(hatesPreviousVocals(s) || hatesPreviousConsonants(s) == false) return true;
+        }
+        return false;
+    }
+
+    private boolean allowVocs(ArrayList<String> array){
+        for(String s: array){
+            if(hatesPreviousConsonants(s) || hatesPreviousVocals(s) == false) return true;
+        }
+        return false;
+    }
+
+    private boolean expectsVocal(String s){
+        if(s.substring(1).contains("+v")) return true;
+        else return false;
+    }
+    private boolean expectsConsonant(String s){
+        if(s.substring(1).contains("+c")) return true;
+        else return false;
+    }
+    private boolean hatesPreviousVocals(String s){
+        if(s.substring(1).contains("-c")) return true;
+        else return false;
+    }
+    private boolean hatesPreviousConsonants(String s){
+        if(s.substring(1).contains("-v")) return true;
+        else return false;
+    }
+
+    private String pureSyl(String s){
+        s = s.trim();
+        if(s.charAt(0) == '+' || s.charAt(0) == '-') s = s.substring(1);
+        return s.split(" ")[0];
+    }
+
+    private boolean vocalFirst(String s){
+        return (String.copyValueOf(vocals).contains(String.valueOf(s.charAt(0)).toLowerCase()));
+    }
+
+    private boolean consonantFirst(String s){
+        return (String.copyValueOf(consonants).contains(String.valueOf(s.charAt(0)).toLowerCase()));
+    }
+
+    private boolean vocalLast(String s){
+        return (String.copyValueOf(vocals).contains(String.valueOf(s.charAt(s.length()-1)).toLowerCase()));
+    }
+
+    private boolean consonantLast(String s){
+        return (String.copyValueOf(consonants).contains(String.valueOf(s.charAt(s.length()-1)).toLowerCase()));
+    }
+
+
+    /**
+     * Compose a new name.
+     * @param syls The number of syllables used in name.
+     * @return Returns composed name as a String
+     * @throws RuntimeException when logical mistakes are detected inside chosen file, and program is unable to complete the name.
+     */
+    public String compose(int syls){
+        if(syls > 2 && mid.size() == 0) throw new RuntimeException("You are trying to create a name with more than 3 parts, which requires middle parts, " +
+                "which you have none in the file "+fileName+". You should add some. Every word, which doesn't have + or - for a prefix is counted as a middle part.");
+        if(pre.size() == 0) throw new RuntimeException("You have no prefixes to start creating a name. add some and use \"-\" prefix, to identify it as a prefix for a name. (example: -asd)");
+        if(sur.size() == 0) throw new RuntimeException("You have no suffixes to end a name. add some and use \"+\" prefix, to identify it as a suffix for a name. (example: +asd)");
+        if(syls < 1) throw new RuntimeException("compose(int syls) can't have less than 1 syllable");
+        int expecting = 0; // 1 for vocal, 2 for consonant
+        int last = 0; // 1 for vocal, 2 for consonant
+        String name;
+        int a = (int)(Math.random() * pre.size());
+
+        if(vocalLast(pureSyl(pre.get(a)))) last = 1;
+        else last = 2;
+
+        if(syls > 2){
+            if(expectsVocal(pre.get(a))){
+                expecting = 1;
+                if(containsVocFirst(mid) == false) throw new RuntimeException("Expecting \"middle\" part starting with vocal, " +
+                "but there is none. You should add one, or remove requirement for one.. ");
+            }
+            if(expectsConsonant(pre.get(a))){
+                expecting = 2;
+                if(containsConsFirst(mid) == false) throw new RuntimeException("Expecting \"middle\" part starting with consonant, " +
+                "but there is none. You should add one, or remove requirement for one.. ");
+            }
+        }
+        else{
+            if(expectsVocal(pre.get(a))){
+                expecting = 1;
+                if(containsVocFirst(sur) == false) throw new RuntimeException("Expecting \"suffix\" part starting with vocal, " +
+                "but there is none. You should add one, or remove requirement for one.. ");
+            }
+            if(expectsConsonant(pre.get(a))){
+                expecting = 2;
+                if(containsConsFirst(sur) == false) throw new RuntimeException("Expecting \"suffix\" part starting with consonant, " +
+                "but there is none. You should add one, or remove requirement for one.. ");
+            }
+        }
+        if(vocalLast(pureSyl(pre.get(a))) && allowVocs(mid) == false) throw new RuntimeException("Expecting \"middle\" part that allows last character of prefix to be a vocal, " +
+                "but there is none. You should add one, or remove requirements that cannot be fulfilled.. the prefix used, was : \""+pre.get(a)+"\", which" +
+        "means there should be a part available, that has \"-v\" requirement or no requirements for previous syllables at all.");
+
+        if(consonantLast(pureSyl(pre.get(a))) && allowCons(mid) == false) throw new RuntimeException("Expecting \"middle\" part that allows last character of prefix to be a consonant, " +
+                "but there is none. You should add one, or remove requirements that cannot be fulfilled.. the prefix used, was : \""+pre.get(a)+"\", which" +
+        "means there should be a part available, that has \"-c\" requirement or no requirements for previous syllables at all.");
+
+        int b[] = new int[syls];
+        for(int i = 0; i<b.length-2; i++){
+
+            do{
+                b[i] = (int)(Math.random() * mid.size());
+                //System.out.println("exp " +expecting+" vocalF:"+vocalFirst(mid.get(b[i]))+" syl: "+mid.get(b[i]));
+            }
+            while(expecting == 1 && vocalFirst(pureSyl(mid.get(b[i]))) == false || expecting == 2 && consonantFirst(pureSyl(mid.get(b[i]))) == false
+                    || last == 1 && hatesPreviousVocals(mid.get(b[i])) || last == 2 && hatesPreviousConsonants(mid.get(b[i])));
+
+            expecting = 0;
+            if(expectsVocal(mid.get(b[i]))){
+                expecting = 1;
+                if(i < b.length-3 && containsVocFirst(mid) == false) throw new RuntimeException("Expecting \"middle\" part starting with vocal, " +
+                "but there is none. You should add one, or remove requirement for one.. ");
+                if(i == b.length-3 && containsVocFirst(sur) == false) throw new RuntimeException("Expecting \"suffix\" part starting with vocal, " +
+                "but there is none. You should add one, or remove requirement for one.. ");
+            }
+            if(expectsConsonant(mid.get(b[i]))){
+                expecting = 2;
+                if(i < b.length-3 && containsConsFirst(mid) == false) throw new RuntimeException("Expecting \"middle\" part starting with consonant, " +
+                "but there is none. You should add one, or remove requirement for one.. ");
+                if(i == b.length-3 && containsConsFirst(sur) == false) throw new RuntimeException("Expecting \"suffix\" part starting with consonant, " +
+                "but there is none. You should add one, or remove requirement for one.. ");
+            }
+            if(vocalLast(pureSyl(mid.get(b[i]))) && allowVocs(mid) == false && syls > 3) throw new RuntimeException("Expecting \"middle\" part that allows last character of last syllable to be a vocal, " +
+                    "but there is none. You should add one, or remove requirements that cannot be fulfilled.. the part used, was : \""+mid.get(b[i])+"\", which " +
+            "means there should be a part available, that has \"-v\" requirement or no requirements for previous syllables at all.");
+
+            if(consonantLast(pureSyl(mid.get(b[i]))) && allowCons(mid) == false && syls > 3) throw new RuntimeException("Expecting \"middle\" part that allows last character of last syllable to be a consonant, " +
+                    "but there is none. You should add one, or remove requirements that cannot be fulfilled.. the part used, was : \""+mid.get(b[i])+"\", which " +
+            "means there should be a part available, that has \"-c\" requirement or no requirements for previous syllables at all.");
+            if(i == b.length-3){
+                if(vocalLast(pureSyl(mid.get(b[i]))) && allowVocs(sur) == false) throw new RuntimeException("Expecting \"suffix\" part that allows last character of last syllable to be a vocal, " +
+                        "but there is none. You should add one, or remove requirements that cannot be fulfilled.. the part used, was : \""+mid.get(b[i])+"\", which " +
+                "means there should be a suffix available, that has \"-v\" requirement or no requirements for previous syllables at all.");
+
+                if(consonantLast(pureSyl(mid.get(b[i]))) && allowCons(sur) == false) throw new RuntimeException("Expecting \"suffix\" part that allows last character of last syllable to be a consonant, " +
+                        "but there is none. You should add one, or remove requirements that cannot be fulfilled.. the part used, was : \""+mid.get(b[i])+"\", which " +
+                "means there should be a suffix available, that has \"-c\" requirement or no requirements for previous syllables at all.");
+            }
+            if(vocalLast(pureSyl(mid.get(b[i])))) last = 1;
+            else last = 2;
+        }
+
+        int c;
+        do{
+            c = (int)(Math.random() * sur.size());
+        }
+        while(expecting == 1 && vocalFirst(pureSyl(sur.get(c))) == false || expecting == 2 && consonantFirst(pureSyl(sur.get(c))) == false
+                || last == 1 && hatesPreviousVocals(sur.get(c)) || last == 2 && hatesPreviousConsonants(sur.get(c)));
+
+        name = upper(pureSyl(pre.get(a).toLowerCase()));
+        for(int i = 0; i<b.length-2; i++){
+            name = name.concat(pureSyl(mid.get(b[i]).toLowerCase()));
+        }
+        if(syls > 1)
+            name = name.concat(pureSyl(sur.get(c).toLowerCase()));
+        return name;
+    }
 }
Index: applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/util/TrustAnalyzer.java
===================================================================
--- applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/util/TrustAnalyzer.java	(revision 30723)
+++ applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/util/TrustAnalyzer.java	(revision 30724)
@@ -17,5 +17,4 @@
 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;
@@ -23,221 +22,221 @@
 public class TrustAnalyzer {
 
-	public static void showManipulationWarning(){
-		JOptionPane.showMessageDialog(Main.parent, tr("The Signature is broken!"), tr("Manipulation Warning"), JOptionPane.WARNING_MESSAGE);
-	}
-
-
-	public static double computeReputation(TrustOsmPrimitive trust, Map<String, List<PGPSignature>> textsigs) {
-		/** just for simplicity - count all valid sigs */
-		int count = 0;
-		for (List<PGPSignature> siglist : textsigs.values()) {
-			count += siglist.size();
-		}
-		return count;
-	}
-
-	public static boolean isTagRatingValid(TrustOsmPrimitive trust, String key, String signedPlaintext) {
-		/** Rating is valid if signed plaintext matches the current plaintext */
-		String currentSigtext = TrustOsmPrimitive.generateTagSigtext(trust.getOsmPrimitive(),key);
-		return currentSigtext.equals(signedPlaintext);
-	}
-
-
-	public static void checkTag(TrustOsmPrimitive trust, String key) {
-		Map<String, List<PGPSignature>> validRatings = new HashMap<String, List<PGPSignature>>();
-
-		TrustSignatures sigs;
-		if ((sigs = trust.getSigsOnKey(key))!=null) {
-			for (PGPSignature sig : sigs.getSignatures()) {
-				/** Here we have a full rating
-				 *  The first question: Is the Signature valid?
-				 *  It could be manipulated...
-				 * */
-				String signedPlaintext = sigs.getSigtext(sig);
-				if (TrustOSMplugin.gpg.verify(signedPlaintext, sig)) {
-					/** If it is valid...
-					 * Second question: Is the rating valid?
-					 */
-					if (isTagRatingValid(trust,key,signedPlaintext)) {
-						/** if the rating is good, we can try to compute a reputation value at the end
-						 *  so we save the important rating stuff
-						 */
-						if (validRatings.containsKey(signedPlaintext)) {
-							validRatings.get(signedPlaintext).add(sig);
-						} else {
-							List<PGPSignature> l = new ArrayList<PGPSignature>();
-							l.add(sig);
-							validRatings.put(signedPlaintext, l);
-						}
-
-						//if (sigs.getStatus() == TrustSignatures.SIG_UNKNOWN) sigs.setStatus(TrustSignatures.SIG_VALID);
-					} else {
-						//sigs.setStatus(TrustSignatures.SIG_BROKEN);
-					}
-				} else {
-					//sigs.setStatus(TrustSignatures.SIG_BROKEN);
-					showManipulationWarning();
-				}
-			}
-			/** now we know which ratings are valid to compute a reputation */
-			sigs.setReputation(computeReputation(trust, validRatings));
-			/** if all available signatures are valid we can set the TrustSignatures status to valid */
-			System.out.println(validRatings.size()+":"+sigs.countSigs());
-			if (validRatings.size() == 1) sigs.setStatus(TrustSignatures.SIG_VALID);
-			else sigs.setStatus(TrustSignatures.SIG_BROKEN);
-		}
-	}
-
-
-	public static boolean isNodeRatingValid(TrustNode trust, String signedPlaintext, PGPSignature sig) {
-		/** Rating is valid if Node from signed plaintext is inside Tolerance given in Signature */
-		Node signedNode = TrustNode.generateNodeFromSigtext(signedPlaintext);
-		Node currentNode = (Node)trust.getOsmPrimitive();
-		double dist = signedNode.getCoor().greatCircleDistance(currentNode.getCoor());
-
-		/** is distance between signed Node and current Node inside tolerance? */
-		return dist<=TrustGPG.searchTolerance(sig);
-	}
-
-	/**
-	 * Check if the ratings made for a Node are valid for the current position of that node
-	 * and compute reputation.
-	 * @param trust	The current TrustNode with its ratings
-	 */
-	public static void checkNode(TrustNode trust) {
-		Map<String, List<PGPSignature>> validRatings = new HashMap<String, List<PGPSignature>>();
-		Node node = (Node)trust.getOsmPrimitive();
-		TrustSignatures sigs;
-		if ((sigs = trust.getNodeSigs())!=null) {
-			for (String signedPlaintext : sigs.getAllPlainTexts()) {
-				for (PGPSignature sig : sigs.getSignaturesByPlaintext(signedPlaintext)) {
-					/** first thing: check signature */
-					if (TrustOSMplugin.gpg.verify(signedPlaintext,sig)) {
-						/** if signature is valid check rating */
-						if (isNodeRatingValid(trust,signedPlaintext,sig)) {
-							/** if the rating is good, we can try to compute a reputation value at the end
-							 *  so we save the important rating stuff
-							 */
-							if (validRatings.containsKey(signedPlaintext)) {
-								validRatings.get(signedPlaintext).add(sig);
-							} else {
-								List<PGPSignature> l = new ArrayList<PGPSignature>();
-								l.add(sig);
-								validRatings.put(signedPlaintext, l);
-							}
-
-							//if (sigs.getStatus() == TrustSignatures.SIG_UNKNOWN) sigs.setStatus(TrustSignatures.SIG_VALID);
-						} else {
-							//sigs.setStatus(TrustSignatures.SIG_BROKEN);
-						}
-
-					} else {
-						//sigs.setStatus(TrustSignatures.SIG_BROKEN);
-						showManipulationWarning();
-					}
-				}
-			}
-			/** now we know which ratings are valid to compute a reputation */
-			sigs.setReputation(computeReputation(trust, validRatings));
-			/** if all available signatures are valid we can set the TrustSignatures status to valid */
-			if (validRatings.size() == 1) sigs.setStatus(TrustSignatures.SIG_VALID);
-			else sigs.setStatus(TrustSignatures.SIG_BROKEN);
-		}
-	}
-
-	/**
-	 * Check if the ratings made for a specific WaySegment are valid for the current form of that WaySegment
-	 * @param trust
-	 * @param seg
-	 * @param signedPlaintext
-	 * @param sig
-	 * @return
-	 */
-	public static boolean isSegmentRatingValid(TrustWay trust, List<Node> nodes, String signedPlaintext, PGPSignature sig) {
-		/** Rating is valid if Nodes from Segment of signed plaintext are inside Tolerance given in Signature */
-		List<Node> signedSegment = TrustWay.generateSegmentFromSigtext(signedPlaintext);
-
-		double tolerance = TrustGPG.searchTolerance(sig);
-
-		for (int i = 0; i<2; i++){
-			Node signedNode = signedSegment.get(i);
-			Node currentNode = nodes.get(i);
-			double dist = signedNode.getCoor().greatCircleDistance(currentNode.getCoor());
-			if (dist>tolerance) return false;
-		}
-		return true;
-	}
-
-	/**
-	 * Check if there are ratings for a current WaySegment of a TrustWay
-	 * and if so, compute Reputation
-	 * @param trust the current TrustWay
-	 * @param seg the current WaySegment to check for reputation
-	 */
-	public static void checkSegment(TrustWay trust, List<Node> nodes) {
-		Map<String, List<PGPSignature>> validRatings = new HashMap<String, List<PGPSignature>>();
-
-		TrustSignatures sigs;
-		if ((sigs = trust.getSigsOnSegment(nodes))!=null) {
-			for (String signedPlaintext : sigs.getAllPlainTexts()) {
-				for (PGPSignature sig : sigs.getSignaturesByPlaintext(signedPlaintext)) {
-					/** first thing: check signature */
-					if (TrustOSMplugin.gpg.verify(signedPlaintext,sig)) {
-						/** if signature is valid check rating */
-						if (isSegmentRatingValid(trust,nodes,signedPlaintext,sig)) {
-							/** if the rating is good, we can try to compute a reputation value at the end
-							 *  so we save the important rating stuff
-							 */
-							if (validRatings.containsKey(signedPlaintext)) {
-								validRatings.get(signedPlaintext).add(sig);
-							} else {
-								List<PGPSignature> l = new ArrayList<PGPSignature>();
-								l.add(sig);
-								validRatings.put(signedPlaintext, l);
-							}
-
-							//if (sigs.getStatus() == TrustSignatures.SIG_UNKNOWN) sigs.setStatus(TrustSignatures.SIG_VALID);
-						} else {
-							//sigs.setStatus(TrustSignatures.SIG_BROKEN);
-						}
-
-					} else {
-						//sigs.setStatus(TrustSignatures.SIG_BROKEN);
-						showManipulationWarning();
-					}
-				}
-			}
-			/** now we know which ratings are valid to compute a reputation */
-			sigs.setReputation(computeReputation(trust, validRatings));
-			/** if all available signatures are valid we can set the TrustSignatures status to valid */
-			if (validRatings.size() == sigs.countSigs()) sigs.setStatus(TrustSignatures.SIG_VALID);
-			else sigs.setStatus(TrustSignatures.SIG_BROKEN);
-		}
-	}
-
-
-	public static void checkEverything(TrustOsmPrimitive trust) {
-		/** check every single tag for reputation */
-		for (String key : trust.getSignedKeys()){
-			checkTag(trust, key);
-		}
-		if (trust instanceof TrustNode) {
-			/** check all reputation of this single Node */
-			checkNode((TrustNode) trust);
-		} else if (trust instanceof TrustWay){
-			TrustWay tw = (TrustWay) trust;
-			/** check all reputation for every Segment of this Way */
-			List<Node> wayNodes = ((Way)tw.getOsmPrimitive()).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));
-				checkSegment(tw,nodes);
-			}
-
-		} else if (trust instanceof TrustRelation){
-			TrustRelation tr = (TrustRelation) trust;
-		}
-
-	}
+    public static void showManipulationWarning(){
+        JOptionPane.showMessageDialog(Main.parent, tr("The Signature is broken!"), tr("Manipulation Warning"), JOptionPane.WARNING_MESSAGE);
+    }
+
+
+    public static double computeReputation(TrustOsmPrimitive trust, Map<String, List<PGPSignature>> textsigs) {
+        /** just for simplicity - count all valid sigs */
+        int count = 0;
+        for (List<PGPSignature> siglist : textsigs.values()) {
+            count += siglist.size();
+        }
+        return count;
+    }
+
+    public static boolean isTagRatingValid(TrustOsmPrimitive trust, String key, String signedPlaintext) {
+        /** Rating is valid if signed plaintext matches the current plaintext */
+        String currentSigtext = TrustOsmPrimitive.generateTagSigtext(trust.getOsmPrimitive(),key);
+        return currentSigtext.equals(signedPlaintext);
+    }
+
+
+    public static void checkTag(TrustOsmPrimitive trust, String key) {
+        Map<String, List<PGPSignature>> validRatings = new HashMap<>();
+
+        TrustSignatures sigs;
+        if ((sigs = trust.getSigsOnKey(key))!=null) {
+            for (PGPSignature sig : sigs.getSignatures()) {
+                /** Here we have a full rating
+                 *  The first question: Is the Signature valid?
+                 *  It could be manipulated...
+                 * */
+                String signedPlaintext = sigs.getSigtext(sig);
+                if (TrustOSMplugin.gpg.verify(signedPlaintext, sig)) {
+                    /** If it is valid...
+                     * Second question: Is the rating valid?
+                     */
+                    if (isTagRatingValid(trust,key,signedPlaintext)) {
+                        /** if the rating is good, we can try to compute a reputation value at the end
+                         *  so we save the important rating stuff
+                         */
+                        if (validRatings.containsKey(signedPlaintext)) {
+                            validRatings.get(signedPlaintext).add(sig);
+                        } else {
+                            List<PGPSignature> l = new ArrayList<>();
+                            l.add(sig);
+                            validRatings.put(signedPlaintext, l);
+                        }
+
+                        //if (sigs.getStatus() == TrustSignatures.SIG_UNKNOWN) sigs.setStatus(TrustSignatures.SIG_VALID);
+                    } else {
+                        //sigs.setStatus(TrustSignatures.SIG_BROKEN);
+                    }
+                } else {
+                    //sigs.setStatus(TrustSignatures.SIG_BROKEN);
+                    showManipulationWarning();
+                }
+            }
+            /** now we know which ratings are valid to compute a reputation */
+            sigs.setReputation(computeReputation(trust, validRatings));
+            /** if all available signatures are valid we can set the TrustSignatures status to valid */
+            System.out.println(validRatings.size()+":"+sigs.countSigs());
+            if (validRatings.size() == 1) sigs.setStatus(TrustSignatures.SIG_VALID);
+            else sigs.setStatus(TrustSignatures.SIG_BROKEN);
+        }
+    }
+
+
+    public static boolean isNodeRatingValid(TrustNode trust, String signedPlaintext, PGPSignature sig) {
+        /** Rating is valid if Node from signed plaintext is inside Tolerance given in Signature */
+        Node signedNode = TrustNode.generateNodeFromSigtext(signedPlaintext);
+        Node currentNode = (Node)trust.getOsmPrimitive();
+        double dist = signedNode.getCoor().greatCircleDistance(currentNode.getCoor());
+
+        /** is distance between signed Node and current Node inside tolerance? */
+        return dist<=TrustGPG.searchTolerance(sig);
+    }
+
+    /**
+     * Check if the ratings made for a Node are valid for the current position of that node
+     * and compute reputation.
+     * @param trust    The current TrustNode with its ratings
+     */
+    public static void checkNode(TrustNode trust) {
+        Map<String, List<PGPSignature>> validRatings = new HashMap<>();
+        //Node node = (Node)trust.getOsmPrimitive();
+        TrustSignatures sigs;
+        if ((sigs = trust.getNodeSigs())!=null) {
+            for (String signedPlaintext : sigs.getAllPlainTexts()) {
+                for (PGPSignature sig : sigs.getSignaturesByPlaintext(signedPlaintext)) {
+                    /** first thing: check signature */
+                    if (TrustOSMplugin.gpg.verify(signedPlaintext,sig)) {
+                        /** if signature is valid check rating */
+                        if (isNodeRatingValid(trust,signedPlaintext,sig)) {
+                            /** if the rating is good, we can try to compute a reputation value at the end
+                             *  so we save the important rating stuff
+                             */
+                            if (validRatings.containsKey(signedPlaintext)) {
+                                validRatings.get(signedPlaintext).add(sig);
+                            } else {
+                                List<PGPSignature> l = new ArrayList<>();
+                                l.add(sig);
+                                validRatings.put(signedPlaintext, l);
+                            }
+
+                            //if (sigs.getStatus() == TrustSignatures.SIG_UNKNOWN) sigs.setStatus(TrustSignatures.SIG_VALID);
+                        } else {
+                            //sigs.setStatus(TrustSignatures.SIG_BROKEN);
+                        }
+
+                    } else {
+                        //sigs.setStatus(TrustSignatures.SIG_BROKEN);
+                        showManipulationWarning();
+                    }
+                }
+            }
+            /** now we know which ratings are valid to compute a reputation */
+            sigs.setReputation(computeReputation(trust, validRatings));
+            /** if all available signatures are valid we can set the TrustSignatures status to valid */
+            if (validRatings.size() == 1) sigs.setStatus(TrustSignatures.SIG_VALID);
+            else sigs.setStatus(TrustSignatures.SIG_BROKEN);
+        }
+    }
+
+    /**
+     * Check if the ratings made for a specific WaySegment are valid for the current form of that WaySegment
+     * @param trust
+     * @param seg
+     * @param signedPlaintext
+     * @param sig
+     * @return
+     */
+    public static boolean isSegmentRatingValid(TrustWay trust, List<Node> nodes, String signedPlaintext, PGPSignature sig) {
+        /** Rating is valid if Nodes from Segment of signed plaintext are inside Tolerance given in Signature */
+        List<Node> signedSegment = TrustWay.generateSegmentFromSigtext(signedPlaintext);
+
+        double tolerance = TrustGPG.searchTolerance(sig);
+
+        for (int i = 0; i<2; i++){
+            Node signedNode = signedSegment.get(i);
+            Node currentNode = nodes.get(i);
+            double dist = signedNode.getCoor().greatCircleDistance(currentNode.getCoor());
+            if (dist>tolerance) return false;
+        }
+        return true;
+    }
+
+    /**
+     * Check if there are ratings for a current WaySegment of a TrustWay
+     * and if so, compute Reputation
+     * @param trust the current TrustWay
+     * @param seg the current WaySegment to check for reputation
+     */
+    public static void checkSegment(TrustWay trust, List<Node> nodes) {
+        Map<String, List<PGPSignature>> validRatings = new HashMap<>();
+
+        TrustSignatures sigs;
+        if ((sigs = trust.getSigsOnSegment(nodes))!=null) {
+            for (String signedPlaintext : sigs.getAllPlainTexts()) {
+                for (PGPSignature sig : sigs.getSignaturesByPlaintext(signedPlaintext)) {
+                    /** first thing: check signature */
+                    if (TrustOSMplugin.gpg.verify(signedPlaintext,sig)) {
+                        /** if signature is valid check rating */
+                        if (isSegmentRatingValid(trust,nodes,signedPlaintext,sig)) {
+                            /** if the rating is good, we can try to compute a reputation value at the end
+                             *  so we save the important rating stuff
+                             */
+                            if (validRatings.containsKey(signedPlaintext)) {
+                                validRatings.get(signedPlaintext).add(sig);
+                            } else {
+                                List<PGPSignature> l = new ArrayList<>();
+                                l.add(sig);
+                                validRatings.put(signedPlaintext, l);
+                            }
+
+                            //if (sigs.getStatus() == TrustSignatures.SIG_UNKNOWN) sigs.setStatus(TrustSignatures.SIG_VALID);
+                        } else {
+                            //sigs.setStatus(TrustSignatures.SIG_BROKEN);
+                        }
+
+                    } else {
+                        //sigs.setStatus(TrustSignatures.SIG_BROKEN);
+                        showManipulationWarning();
+                    }
+                }
+            }
+            /** now we know which ratings are valid to compute a reputation */
+            sigs.setReputation(computeReputation(trust, validRatings));
+            /** if all available signatures are valid we can set the TrustSignatures status to valid */
+            if (validRatings.size() == sigs.countSigs()) sigs.setStatus(TrustSignatures.SIG_VALID);
+            else sigs.setStatus(TrustSignatures.SIG_BROKEN);
+        }
+    }
+
+
+    public static void checkEverything(TrustOsmPrimitive trust) {
+        /** check every single tag for reputation */
+        for (String key : trust.getSignedKeys()){
+            checkTag(trust, key);
+        }
+        if (trust instanceof TrustNode) {
+            /** check all reputation of this single Node */
+            checkNode((TrustNode) trust);
+        } else if (trust instanceof TrustWay){
+            TrustWay tw = (TrustWay) trust;
+            /** check all reputation for every Segment of this Way */
+            List<Node> wayNodes = ((Way)tw.getOsmPrimitive()).getNodes();
+            for (int i=0; i<wayNodes.size()-1; i++) {
+                List<Node> nodes = new ArrayList<>();
+                nodes.add(wayNodes.get(i));
+                nodes.add(wayNodes.get(i+1));
+                checkSegment(tw,nodes);
+            }
+
+        } /*else if (trust instanceof TrustRelation){
+            TrustRelation tr = (TrustRelation) trust;
+        }*/
+
+    }
 }
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 30723)
+++ applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/util/TrustGPG.java	(revision 30724)
@@ -81,773 +81,771 @@
 public class TrustGPG {
 
-	//	private GnuPG gpg;
-	private char[] password;
-	private PGPSecretKeyRingCollection pgpSec;
-	private PGPPublicKeyRingCollection pgpPub;
-	private static int digest = PGPUtil.SHA1;
-	private PGPSecretKey pgpSecKey;
-	public boolean keepkey = false;
-
-	public static final String NOTATION_DATA_KEY = "trustosm@openstreetmap.org";
-
-	public TrustGPG() {
-		Security.addProvider(new BouncyCastleProvider());
-		try {
-			readGpgFiles();
-		} catch (Exception e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
-	}
-
-	public PGPPublicKey getPublicKeyFromRing(long keyID) {
-		try {
-			if (pgpPub.contains(keyID))
-				return pgpPub.getPublicKey(keyID);
-			else if (pgpSec.contains(keyID))
-				return pgpSec.getSecretKey(keyID).getPublicKey();
-		} catch (PGPException e) {
-			System.err.println("Could not read a PGPPublic key from your KeyRingCollectionFile. Stacktrace:");
-			e.printStackTrace();
-		}
-		return null;
-	}
-
-	public static String secKeytoString(PGPSecretKey k) {
-		String keyText = "0x"+Long.toHexString(k.getKeyID()).substring(8).toUpperCase() + " ";
-		//			keyText = new String(Hex.encode(sigKey.getPublicKey().getFingerprint()),"UTF-8") + " ";
-		Iterator iter = k.getUserIDs();
-		if (iter.hasNext()) {
-			keyText += (String)iter.next();
-		}
-		/*			iter = sigKey.getUserIDs();
-		while (iter.hasNext()) {
-			keyText += (String)iter.next() + "; ";
-		}
-		 */
-		return keyText.trim();
-	}
-
-	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) return;
-
-		final ArrayList<PGPSecretKey> sigKeys = new ArrayList<PGPSecretKey>();
-
-		//
-		// iterate through the key rings.
-		//
-		Iterator rIt = pgpSec.getKeyRings();
-
-		while (rIt.hasNext()) {
-
-			PGPSecretKeyRing    kRing = (PGPSecretKeyRing)rIt.next();
-			Iterator            kIt = kRing.getSecretKeys();
-
-			while (kIt.hasNext()) {
-				PGPSecretKey    k = (PGPSecretKey)kIt.next();
-
-				if (k.isSigningKey()) {
-					sigKeys.add(k);
-				}
-			}
-		}
-
-
-		Iterator<PGPSecretKey> skIt = sigKeys.iterator();
-
-		final Vector<String> keys = new Vector<String>();
-
-		while (skIt.hasNext()) {
-			PGPSecretKey sigKey = skIt.next();
-			keys.add(secKeytoString(sigKey));
-		}
-
-		JPanel p = new JPanel();
-		p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS));
-		Dimension d = new Dimension(0,20);
-
-		JLabel head = new JLabel(tr("Select a signing key from your keyring-file:"));
-		head.setAlignmentX(Component.LEFT_ALIGNMENT);
-		p.add(head);
-
-		final JComboBox keyBox = new JComboBox(keys);
-		keyBox.setAlignmentX(Component.LEFT_ALIGNMENT);
-		p.add(keyBox);
-
-		JCheckBox keepkeyBox = new JCheckBox(tr("Don''t ask again for the key"));
-		keepkeyBox.setAlignmentX(Component.LEFT_ALIGNMENT);
-		p.add(keepkeyBox);
-
-		JButton detailsButton = new JButton(tr("Details"), ImageProvider.get("keydetails"));
-		detailsButton.setAlignmentX(Component.LEFT_ALIGNMENT);
-		detailsButton.addActionListener(new ActionListener(){
-
-			@Override
-			public void actionPerformed(ActionEvent arg0) {
-				PGPSecretKey sk = sigKeys.get(keyBox.getSelectedIndex());
-				showKeyDetails(getPublicKeyFromRing(sk.getKeyID()));
-			}});
-		p.add(detailsButton);
-
-		JCheckBox random = new JCheckBox(tr("Use a random key from this list"));
-		random.setAlignmentX(Component.LEFT_ALIGNMENT);
-		p.add(random);
-
-		p.add(Box.createRigidArea(d));
-
-		JButton createButton = new JButton(tr("Create new Key"), ImageProvider.get("key"));
-		createButton.setAlignmentX(Component.LEFT_ALIGNMENT);
-		createButton.addActionListener(new ActionListener(){
-
-			@Override
-			public void actionPerformed(ActionEvent arg0) {
-				try {
-					PGPSecretKey secKey = generateKey();
-					if (secKey != null) {
-						keyBox.addItem(secKeytoString(secKey));
-						sigKeys.add(secKey);
-					}
-				} catch (NoSuchAlgorithmException e) {
-					// TODO Auto-generated catch block
-					e.printStackTrace();
-				} catch (NoSuchProviderException e) {
-					// TODO Auto-generated catch block
-					e.printStackTrace();
-				} catch (FileNotFoundException e) {
-					// TODO Auto-generated catch block
-					e.printStackTrace();
-				} catch (PGPException e) {
-					// TODO Auto-generated catch block
-					e.printStackTrace();
-				} catch (IOException e) {
-					// TODO Auto-generated catch block
-					e.printStackTrace();
-				}
-
-			}});
-		p.add(createButton);
-		p.add(Box.createRigidArea(d));
-
-		int n = JOptionPane.showOptionDialog(Main.parent, p, tr("Select a Key to sign"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, ImageProvider.get("keyring"), null, null);
-
-		if (n == JOptionPane.OK_OPTION) {
-			keepkey = keepkeyBox.isSelected();
-			if (random.isSelected()) {
-				Random r = new Random();
-				pgpSecKey = sigKeys.get(r.nextInt(sigKeys.size()-1));
-			} else {
-				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]);
-
-		//System.out.println(selection);
-
-		//		return pgpSecKey;
-	}
-
-	public void readGpgFiles() throws PGPException, IOException, NoSuchAlgorithmException, NoSuchProviderException {
-		FileInputStream pubIn;
-		FileInputStream secIn;
-		try {
-			pubIn = new FileInputStream(Main.pref.getPluginsDirectory().getPath() + "/trustosm/gnupg/secring.gpg");
-			secIn = new FileInputStream(Main.pref.getPluginsDirectory().getPath() + "/trustosm/gnupg/pubring.gpg");
-			//pubIn = new FileInputStream("/tmp/secring.gpg");
-			//secIn = new FileInputStream("/tmp/pubring.gpg");
-			pgpSec = new PGPSecretKeyRingCollection(PGPUtil.getDecoderStream(pubIn));
-			pgpPub = new PGPPublicKeyRingCollection(PGPUtil.getDecoderStream(secIn));
-		} catch (FileNotFoundException e) {
-			System.err.println("No gpg files found in "+Main.pref.getPluginsDirectory().getPath() + "/trustosm/gnupg/secring.gpg");
-			pgpSec = null;
-			pgpPub = null;
-		}
-
-	}
-
-	public void writeGpgFiles() throws FileNotFoundException, IOException {
-		FileOutputStream    pubOut = new FileOutputStream(Main.pref.getPluginsDirectory().getPath() + "/trustosm/gnupg/pubring.gpg");
-		FileOutputStream    secOut = new FileOutputStream(Main.pref.getPluginsDirectory().getPath() + "/trustosm/gnupg/secring.gpg");
-		pgpSec.encode(secOut);
-		pgpPub.encode(pubOut);
-		pubOut.flush();
-		secOut.flush();
-		pubOut.close();
-		secOut.close();
-	}
-
-
-
-	public void getPasswordfromUser() {
-
-		final JPasswordField passwordField = new JPasswordField();
-		JOptionPane jop = new JOptionPane(passwordField, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, ImageProvider.get("lock"));
-		JDialog dialog = jop.createDialog("Password:");
-		dialog.addComponentListener(new ComponentAdapter(){
-			@Override
-			public void componentShown(ComponentEvent e){
-				passwordField.requestFocusInWindow();
-			}
-		});
-		dialog.setVisible(true);
-		int result = (Integer)jop.getValue();
-		dialog.dispose();
-		if(result == JOptionPane.OK_OPTION){
-			password = passwordField.getPassword();
-		}
-
-
-		/*final JPasswordField passwordField = new JPasswordField(10);
-		JOptionPane.showMessageDialog(Main.parent, passwordField, "Enter password", JOptionPane.OK_OPTION, ImageProvider.get("lock"));
-		password = passwordField.getPassword();
-		 */
-	}
-	/*
-	public void checkTag(TrustOsmPrimitive trust, String key) {
-		String sigtext = TrustOsmPrimitive.generateTagSigtext(trust.getOsmPrimitive(),key);
-		TrustSignatures sigs;
-		if ((sigs = trust.getSigsOnKey(key))!=null)
-			for (PGPSignature sig : sigs.getSignatures()) {
-				trust.updateTagSigStatus(key, verify(sigtext,sig)? TrustSignatures.SIG_VALID : TrustSignatures.SIG_BROKEN);
-			}
-	}
-
-
-
-	/*	public void checkAll(TrustOsmPrimitive trust) {
-		OsmPrimitive osm = trust.getOsmPrimitive();
-		for (String key : osm.keySet()) {
-			checkTag(trust, key);
-		}
-
-		if(osm instanceof Node) {
-			checkNode((TrustNode) trust);
-		} else if(osm instanceof Way) {
-			/*			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 TrustOsmPrimitive signGeometry(TrustOsmPrimitive trust) {
-		PGPSignatureSubpacketGenerator spGen = chooseAccuracy();
-		PGPSignature s;
-		Node node;
-		OsmPrimitive osm = trust.getOsmPrimitive();
-		if (osm.isNew()) {
-			invalidIDWarning(osm);
-			return trust;
-		}
-		if(osm instanceof Node) {
-			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,spGen);
-				if (s != null) ((TrustNode)trust).storeNodeSig(s);
-			}
-		} else if(osm instanceof Relation) {
-
-		}
-		return trust;
-	}*/
-
-	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 false;
-		}
-		PGPSignature s;
-		String tosign = TrustOsmPrimitive.generateTagSigtext(osm,key);
-		//s = sign(tosign);
-		s = sign(tosign,chooseInformationSource());
-		if (s != null) {
-			trust.storeTagSig(key, s);
-			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{
-
-			readSecretKey();
-			if (pgpSec == null) return null;
-
-			if (password == null) {
-				getPasswordfromUser();
-			}
-
-			PGPPrivateKey pgpPrivKey = pgpSecKey.extractPrivateKey(password, "BC");
-			PGPSignatureGenerator sGen = new PGPSignatureGenerator(pgpSecKey.getPublicKey().getAlgorithm(), digest, "BC");
-			sGen.initSign(PGPSignature.CANONICAL_TEXT_DOCUMENT, pgpPrivKey);
-
-			Iterator it = pgpSecKey.getPublicKey().getUserIDs();
-			if (it.hasNext()) {
-				spGen.setSignerUserID(false, (String)it.next());
-			}
-			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("PGP Signing Error: " + e.getMessage());
-		}
-
-
-		/*		String seckeys = gpg.listSecretKeys()? gpg.getResult() : "GPG-ERROR: " + gpg.getErrorString();
-		System.out.println("Die gelisteten keys sehen so aus:\n"+seckeys);
-		String[] keys = seckeys.split("\n");
-		System.out.println("Das Array hat so viele einträge:"+keys.length);
-		if (keys.length <= 1) {
-			System.out.println("Auf auf zum lustigen generieren!");
-			generateKey();
-		}
-		System.out.println("Achtung die Errorausgabe sieht so aus:\n"+gpg.getErrorString());
-		String sig = gpg.sign(tosign, password)? gpg.getResult() : "GPG-ERROR: " + gpg.getErrorString();
-		 */
-
-
-		return null;
-	}
-
-	public boolean verify(String sigtext, PGPSignature sig) {
-		/*		if (gpg.verifySignature(sig)) {
-		success = trust.updateSigStatus(key, gpg.getResult().equals(sigtext)? TrustSignatures.SIG_VALID : TrustSignatures.SIG_BROKEN);
-	}*/
-		try {
-			sig.initVerify(pgpPub.getPublicKey(sig.getKeyID()), "BC");
-			sig.update(sigtext.getBytes(Charset.forName("UTF-8")));
-			return sig.verify();
-		}catch (Exception e){//Catch exception if any
-			System.err.println("PGP Verification Error: " + e.getMessage());
-		}
-		return false;
-	}
-
-
-	//	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) {
-		String userid = "Unknown";
-		Iterator iter = key.getUserIDs();
-		if (iter.hasNext()) {
-			userid = (String)iter.next();
-		}
-
-		String fingerprint = new String(Hex.encode(key.getFingerprint())).toUpperCase();
-		String keyid = "0x"+Long.toHexString(key.getKeyID()).substring(8).toUpperCase();
-
-		String algorithm = "";
-		int algo = key.getAlgorithm();
-		switch(algo) {
-		case PGPPublicKey.DIFFIE_HELLMAN:
-			algorithm = "Diffie Hellman (DH)"; break;
-		case PGPPublicKey.DSA:
-			algorithm = "Digital Signature Algorithm (DSA)"; break;
-		case PGPPublicKey.EC:
-			algorithm = "Elliptic Curve (EC)"; break;
-		case PGPPublicKey.ECDSA:
-			algorithm = "Elliptic Curve Digital Signature Algorithm (ECDSA)"; break;
-		case PGPPublicKey.ELGAMAL_ENCRYPT:
-			algorithm = "Elgamal encrypt-only"; break;
-		case PGPPublicKey.ELGAMAL_GENERAL:
-			algorithm = "Elgamal"; break;
-		case PGPPublicKey.RSA_ENCRYPT:
-			algorithm = "Rivest Shamir Adleman (RSA) encrypt-only"; break;
-		case PGPPublicKey.RSA_GENERAL:
-			algorithm = "Rivest Shamir Adleman (RSA)"; break;
-		case PGPPublicKey.RSA_SIGN:
-			algorithm = "Rivest Shamir Adleman (RSA) sign-only"; break;
-		default:
-			algorithm = "Unknown algorithm ID: "+algo; break;
-		}
-
-		String strength = String.valueOf(key.getBitStrength());
-
-		//SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd:hh.mm.ss");
-		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
-		String creationTime = formatter.format(key.getCreationTime());
-
-		long validSeconds = key.getValidSeconds();
-		String expirationTime;
-		if (validSeconds == 0) {
-			expirationTime = tr("never");
-		} else {
-			expirationTime = formatter.format(new Date(key.getCreationTime().getTime()+validSeconds*1000));
-		}
-
-
-		String[] labels = {tr("Primary user-ID: "), tr("Key-ID: "), tr("Fingerprint: "), tr("Algorithm: "), tr("Strength in bit: "), tr("Creation date: "), tr("Expiration date: ")};
-		String[] values = {userid, keyid, fingerprint, algorithm, strength, creationTime, expirationTime};
-		int numPairs = labels.length;
-
-		//Create and populate the panel.
-		JPanel p = new JPanel(new SpringLayout());
-		for (int i = 0; i < numPairs; i++) {
-			JLabel l = new JLabel(labels[i], JLabel.TRAILING);
-			p.add(l);
-			JTextField textField = new JTextField(values[i]);
-			textField.setEditable(false);
-			l.setLabelFor(textField);
-			p.add(textField);
-		}
-
-		//Lay out the panel.
-		SpringUtilities.makeCompactGrid(p,
-				numPairs, 2, //rows, cols
-				6, 6,        //initX, initY
-				6, 6);       //xPad, yPad
-
-
-		//		JPanel metaPanel = new JPanel();
-		//		metaPanel.setLayout(new BoxLayout(metaPanel, BoxLayout.PAGE_AXIS));
-		//		metaPanel.add(p);
-		//		JScrollPane sp = new JScrollPane(new KeySignaturesDialog(key));
-		//		sp.setPreferredSize(new Dimension(0,200));
-		//		metaPanel.add(sp);
-
-		JOptionPane.showMessageDialog(Main.parent, p, tr("PGP-Key details"), JOptionPane.INFORMATION_MESSAGE);
-	}
-
-
-	public PGPSecretKey generateKey() throws NoSuchAlgorithmException, NoSuchProviderException, PGPException, FileNotFoundException, IOException {
-
-		JTextField userId = new JTextField();
-		NameGenerator nameGen = new NameGenerator(Main.pref.getPluginsDirectory().getPath()+"/trustosm/resources/syllables.txt");
-		userId.setText(nameGen.compose(3));
-
-		final String[] sizes = {"1024", "2048", "3072", "4096"};
-
-		final JComboBox strengthBox = new JComboBox(sizes);
-		strengthBox.setEnabled(false);
-
-		/*		final String[] curves = {"prime192v1", "prime192v2", "prime192v3", "prime239v1", "prime239v2", "prime239v3", "prime256v1", "secp224r1", "secp256r1", "secp384r1", "secp521r1", "P-224", "P-256", "P-384", "P-521", "c2pnb163v1", "c2pnb163v2", "c2pnb163v3", "c2pnb176w1", "c2tnb191v2", "c2tnb191v1", "c2tnb191v3", "c2pnb208w1", "c2tnb239v1", "c2tnb239v2", "c2tnb239v3", "c2pnb272w1", "c2pnb304w1", "c2tnb359v1", "c2pnb368w1", "c2tnb431r1", "sect163r2", "sect233r1", "sect283r1", "sect409r1", "sect571r1", "B-163", "B-233", "B-283", "B-409", "B-571", "brainpoolp160r1", "brainpoolp160t1", "brainpoolp192r1", "brainpoolp192t1", "brainpoolp224r1", "brainpoolp224t1", "brainpoolp256r1", "brainpoolp256t1", "brainpoolp320r1", "brainpoolp320t1", "brainpoolp384r1", "brainpoolp384t1", "brainpoolp512r1", "brainpoolp512t1"};
-		final String[] curvesizes = {"192", "192", "192", "239", "239", "239", "256", "224", "256", "384", "521", "224", "256", "384", "521", "163", "163", "163", "176", "191", "191", "191", "208", "239", "239", "239", "272", "304", "359", "368", "431", "163", "233", "283", "409", "571", "163", "233", "283", "409", "571", "160", "160", "192", "192", "224", "224", "256", "256", "320", "320", "384", "384", "512", "512"};
-		final JComboBox curveBox = new JComboBox(curves);
-		curveBox.addActionListener(new ActionListener(){
-
-			@Override
-			public void actionPerformed(ActionEvent e) {
-				strengthBox.setSelectedIndex(((JComboBox)e.getSource()).getSelectedIndex());
-			}});
-		curveBox.setEnabled(false);
-		 */
-
-		//		final String[] algos = {"DSA","RSA","ECDSA"};
-		final String[] algos = {"DSA","RSA"};
-		final JComboBox algoBox = new JComboBox(algos);
-		algoBox.addActionListener(new ActionListener(){
-
-			@Override
-			public void actionPerformed(ActionEvent e) {
-				JComboBox cb = (JComboBox)e.getSource();
-				String alg = (String)cb.getSelectedItem();
-				if (alg.equals("DSA")) {
-					strengthBox.setSelectedItem("1024");
-					strengthBox.setEnabled(false);
-				} else
-					strengthBox.setEnabled(true);
-				/*if (alg.equals("ECDSA")) {
-					curveBox.setEnabled(true);
-					strengthBox.setModel(new DefaultComboBoxModel(curvesizes));
-					strengthBox.setSelectedItem(curvesizes[curveBox.getSelectedIndex()]);
-					strengthBox.setEnabled(false);
-				} else {
-					curveBox.setEnabled(false);
-					strengthBox.setModel(new DefaultComboBoxModel(sizes));
-					strengthBox.setEnabled(true);
-				}*/
-			}
-		});
-
-
-
-
-
-		final String[] protectAlgos = {"AES_256", "AES_192", "AES_128", "BLOWFISH", "CAST5", "DES", "IDEA", "SAFER", "TRIPLE_DES", "TWOFISH", "NULL"};
-		int[] protAl = {PGPEncryptedData.AES_256, PGPEncryptedData.AES_192, PGPEncryptedData.AES_128, PGPEncryptedData.BLOWFISH, PGPEncryptedData.CAST5, PGPEncryptedData.DES, PGPEncryptedData.IDEA, PGPEncryptedData.SAFER, PGPEncryptedData.TRIPLE_DES, PGPEncryptedData.TWOFISH, PGPEncryptedData.NULL};
-		final JComboBox protectBox = new JComboBox(protectAlgos);
-
-		final JDateChooser cal = new JDateChooser(null, null, null, new JSpinnerDateEditor());
-		cal.setPreferredSize(new Dimension(130,cal.getPreferredSize().height));
-
-		final String[] labels = {tr("User-ID:"), tr("Select algorithm:"), tr("Choose Bitlength (Strength):"), tr("Encryption algorithm to protect private key:"), tr("Choose an expiry date for the key:")};
-		final JComponent[] values = {userId, algoBox, strengthBox, protectBox, cal};
-
-		int numPairs = labels.length;
-
-		//Create and populate the panel.
-		JPanel p = new JPanel(new SpringLayout());
-		for (int i = 0; i < numPairs; i++) {
-			JLabel l = new JLabel(labels[i], JLabel.TRAILING);
-			p.add(l);
-			l.setLabelFor(values[i]);
-			p.add(values[i]);
-		}
-
-		//Lay out the panel.
-		SpringUtilities.makeCompactGrid(p,
-				numPairs, 2, //rows, cols
-				6, 6,        //initX, initY
-				16, 6);       //xPad, yPad
-
-		int n = JOptionPane.showOptionDialog(Main.parent, p, tr("Create a new signing key"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
-
-		if (n != JOptionPane.OK_OPTION)
-			return null;
-
-
-		String algo = (String)algoBox.getSelectedItem();
-
-		KeyPairGenerator Kpg = KeyPairGenerator.getInstance(algo, "BC");
-
-		int al;
-		/*		if (algo.equals("ECDSA")) {
-			al = PGPPublicKey.ECDSA;
-			ECParameterSpec ecSpec = ECNamedCurveTable.getParameterSpec((String)curveBox.getSelectedItem());
-			try {
-				Kpg.initialize(ecSpec);
-			} catch (InvalidAlgorithmParameterException e1) {
-				// TODO Auto-generated catch block
-				System.err.println("EC-Parameter not accepted");
-				e1.printStackTrace();
-			}
-		}
-		else {*/
-		Kpg.initialize(Integer.parseInt((String)strengthBox.getSelectedItem()));
-		//
-		// this takes a while as the key generator has to generate some DSA params
-		// before it generates the key.
-		//
-
-		if (algo.equals("RSA")) al = PGPPublicKey.RSA_GENERAL;
-		else al = PGPPublicKey.DSA;
-		//		}
-
-
-		KeyPair kp = Kpg.generateKeyPair();
-
-		Date now = new Date();
-		PGPKeyPair pgpKp = new PGPKeyPair(al, kp, now);
-
-		getPasswordfromUser();
-
-		PGPSignatureSubpacketVector subPck = null;
-		PGPSignatureSubpacketGenerator spGen = null;
-		Date expire = cal.getDate();
-		if (expire != null && expire.after(now)) {
-			spGen = new PGPSignatureSubpacketGenerator();
-			spGen.setKeyExpirationTime(true, (expire.getTime()-now.getTime())/1000);
-			subPck = spGen.generate();
-		}
-
-		PGPKeyRingGenerator keyRingGen = new PGPKeyRingGenerator(PGPSignature.POSITIVE_CERTIFICATION, pgpKp,
-				userId.getText(), protAl[protectBox.getSelectedIndex()], password, true, subPck, null, new SecureRandom(), "BC");
-
-		if (pgpPub == null) {
-			Vector<PGPPublicKeyRing> pubKeyRing = new Vector<PGPPublicKeyRing>(1);
-			pubKeyRing.add(keyRingGen.generatePublicKeyRing());
-			pgpPub = new PGPPublicKeyRingCollection(pubKeyRing);
-		} else {
-			pgpPub = PGPPublicKeyRingCollection.addPublicKeyRing(pgpPub, keyRingGen.generatePublicKeyRing());
-		}
-
-		PGPSecretKeyRing secRing = keyRingGen.generateSecretKeyRing();
-		if (pgpSec == null) {
-			Vector<PGPSecretKeyRing> secKeyRing = new Vector<PGPSecretKeyRing>(1);
-			secKeyRing.add(secRing);
-			pgpSec = new PGPSecretKeyRingCollection(secKeyRing);
-		} else {
-			pgpSec = PGPSecretKeyRingCollection.addSecretKeyRing(pgpSec, secRing);
-		}
-
-
-		writeGpgFiles();
-
-		return secRing.getSecretKey();
-	}
+    //    private GnuPG gpg;
+    private char[] password;
+    private PGPSecretKeyRingCollection pgpSec;
+    private PGPPublicKeyRingCollection pgpPub;
+    private static int digest = PGPUtil.SHA1;
+    private PGPSecretKey pgpSecKey;
+    public boolean keepkey = false;
+
+    public static final String NOTATION_DATA_KEY = "trustosm@openstreetmap.org";
+
+    public TrustGPG() {
+        Security.addProvider(new BouncyCastleProvider());
+        try {
+            readGpgFiles();
+        } catch (Exception e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+    }
+
+    public PGPPublicKey getPublicKeyFromRing(long keyID) {
+        try {
+            if (pgpPub.contains(keyID))
+                return pgpPub.getPublicKey(keyID);
+            else if (pgpSec.contains(keyID))
+                return pgpSec.getSecretKey(keyID).getPublicKey();
+        } catch (PGPException e) {
+            System.err.println("Could not read a PGPPublic key from your KeyRingCollectionFile. Stacktrace:");
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    public static String secKeytoString(PGPSecretKey k) {
+        String keyText = "0x"+Long.toHexString(k.getKeyID()).substring(8).toUpperCase() + " ";
+        //            keyText = new String(Hex.encode(sigKey.getPublicKey().getFingerprint()),"UTF-8") + " ";
+        Iterator<?> iter = k.getUserIDs();
+        if (iter.hasNext()) {
+            keyText += (String)iter.next();
+        }
+        /*            iter = sigKey.getUserIDs();
+        while (iter.hasNext()) {
+            keyText += (String)iter.next() + "; ";
+        }
+         */
+        return keyText.trim();
+    }
+
+    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) return;
+
+        final ArrayList<PGPSecretKey> sigKeys = new ArrayList<>();
+
+        //
+        // iterate through the key rings.
+        //
+        Iterator<?> rIt = pgpSec.getKeyRings();
+
+        while (rIt.hasNext()) {
+
+            PGPSecretKeyRing    kRing = (PGPSecretKeyRing)rIt.next();
+            Iterator<?>            kIt = kRing.getSecretKeys();
+
+            while (kIt.hasNext()) {
+                PGPSecretKey    k = (PGPSecretKey)kIt.next();
+
+                if (k.isSigningKey()) {
+                    sigKeys.add(k);
+                }
+            }
+        }
+
+
+        Iterator<PGPSecretKey> skIt = sigKeys.iterator();
+
+        final Vector<String> keys = new Vector<>();
+
+        while (skIt.hasNext()) {
+            PGPSecretKey sigKey = skIt.next();
+            keys.add(secKeytoString(sigKey));
+        }
+
+        JPanel p = new JPanel();
+        p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS));
+        Dimension d = new Dimension(0,20);
+
+        JLabel head = new JLabel(tr("Select a signing key from your keyring-file:"));
+        head.setAlignmentX(Component.LEFT_ALIGNMENT);
+        p.add(head);
+
+        final JComboBox<String> keyBox = new JComboBox<>(keys);
+        keyBox.setAlignmentX(Component.LEFT_ALIGNMENT);
+        p.add(keyBox);
+
+        JCheckBox keepkeyBox = new JCheckBox(tr("Don''t ask again for the key"));
+        keepkeyBox.setAlignmentX(Component.LEFT_ALIGNMENT);
+        p.add(keepkeyBox);
+
+        JButton detailsButton = new JButton(tr("Details"), ImageProvider.get("keydetails"));
+        detailsButton.setAlignmentX(Component.LEFT_ALIGNMENT);
+        detailsButton.addActionListener(new ActionListener(){
+
+            @Override
+            public void actionPerformed(ActionEvent arg0) {
+                PGPSecretKey sk = sigKeys.get(keyBox.getSelectedIndex());
+                showKeyDetails(getPublicKeyFromRing(sk.getKeyID()));
+            }});
+        p.add(detailsButton);
+
+        JCheckBox random = new JCheckBox(tr("Use a random key from this list"));
+        random.setAlignmentX(Component.LEFT_ALIGNMENT);
+        p.add(random);
+
+        p.add(Box.createRigidArea(d));
+
+        JButton createButton = new JButton(tr("Create new Key"), ImageProvider.get("key"));
+        createButton.setAlignmentX(Component.LEFT_ALIGNMENT);
+        createButton.addActionListener(new ActionListener(){
+
+            @Override
+            public void actionPerformed(ActionEvent arg0) {
+                try {
+                    PGPSecretKey secKey = generateKey();
+                    if (secKey != null) {
+                        keyBox.addItem(secKeytoString(secKey));
+                        sigKeys.add(secKey);
+                    }
+                } catch (NoSuchAlgorithmException e) {
+                    // TODO Auto-generated catch block
+                    e.printStackTrace();
+                } catch (NoSuchProviderException e) {
+                    // TODO Auto-generated catch block
+                    e.printStackTrace();
+                } catch (FileNotFoundException e) {
+                    // TODO Auto-generated catch block
+                    e.printStackTrace();
+                } catch (PGPException e) {
+                    // TODO Auto-generated catch block
+                    e.printStackTrace();
+                } catch (IOException e) {
+                    // TODO Auto-generated catch block
+                    e.printStackTrace();
+                }
+
+            }});
+        p.add(createButton);
+        p.add(Box.createRigidArea(d));
+
+        int n = JOptionPane.showOptionDialog(Main.parent, p, tr("Select a Key to sign"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, ImageProvider.get("keyring"), null, null);
+
+        if (n == JOptionPane.OK_OPTION) {
+            keepkey = keepkeyBox.isSelected();
+            if (random.isSelected()) {
+                Random r = new Random();
+                pgpSecKey = sigKeys.get(r.nextInt(sigKeys.size()-1));
+            } else {
+                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]);
+
+        //System.out.println(selection);
+
+        //        return pgpSecKey;
+    }
+
+    public void readGpgFiles() throws PGPException, IOException, NoSuchAlgorithmException, NoSuchProviderException {
+        FileInputStream pubIn;
+        FileInputStream secIn;
+        try {
+            pubIn = new FileInputStream(Main.pref.getPluginsDirectory().getPath() + "/trustosm/gnupg/secring.gpg");
+            secIn = new FileInputStream(Main.pref.getPluginsDirectory().getPath() + "/trustosm/gnupg/pubring.gpg");
+            //pubIn = new FileInputStream("/tmp/secring.gpg");
+            //secIn = new FileInputStream("/tmp/pubring.gpg");
+            pgpSec = new PGPSecretKeyRingCollection(PGPUtil.getDecoderStream(pubIn));
+            pgpPub = new PGPPublicKeyRingCollection(PGPUtil.getDecoderStream(secIn));
+        } catch (FileNotFoundException e) {
+            System.err.println("No gpg files found in "+Main.pref.getPluginsDirectory().getPath() + "/trustosm/gnupg/secring.gpg");
+            pgpSec = null;
+            pgpPub = null;
+        }
+
+    }
+
+    public void writeGpgFiles() throws FileNotFoundException, IOException {
+    	String path = Main.pref.getPluginsDirectory().getPath();
+        try (FileOutputStream pubOut = new FileOutputStream(path + "/trustosm/gnupg/pubring.gpg");
+             FileOutputStream secOut = new FileOutputStream(path + "/trustosm/gnupg/secring.gpg")) {
+	        pgpSec.encode(secOut);
+	        pgpPub.encode(pubOut);
+	        pubOut.flush();
+	        secOut.flush();
+        }
+    }
+
+    public void getPasswordfromUser() {
+
+        final JPasswordField passwordField = new JPasswordField();
+        JOptionPane jop = new JOptionPane(passwordField, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, ImageProvider.get("lock"));
+        JDialog dialog = jop.createDialog("Password:");
+        dialog.addComponentListener(new ComponentAdapter(){
+            @Override
+            public void componentShown(ComponentEvent e){
+                passwordField.requestFocusInWindow();
+            }
+        });
+        dialog.setVisible(true);
+        int result = (Integer)jop.getValue();
+        dialog.dispose();
+        if(result == JOptionPane.OK_OPTION){
+            password = passwordField.getPassword();
+        }
+
+
+        /*final JPasswordField passwordField = new JPasswordField(10);
+        JOptionPane.showMessageDialog(Main.parent, passwordField, "Enter password", JOptionPane.OK_OPTION, ImageProvider.get("lock"));
+        password = passwordField.getPassword();
+         */
+    }
+    /*
+    public void checkTag(TrustOsmPrimitive trust, String key) {
+        String sigtext = TrustOsmPrimitive.generateTagSigtext(trust.getOsmPrimitive(),key);
+        TrustSignatures sigs;
+        if ((sigs = trust.getSigsOnKey(key))!=null)
+            for (PGPSignature sig : sigs.getSignatures()) {
+                trust.updateTagSigStatus(key, verify(sigtext,sig)? TrustSignatures.SIG_VALID : TrustSignatures.SIG_BROKEN);
+            }
+    }
+
+
+
+    /*    public void checkAll(TrustOsmPrimitive trust) {
+        OsmPrimitive osm = trust.getOsmPrimitive();
+        for (String key : osm.keySet()) {
+            checkTag(trust, key);
+        }
+
+        if(osm instanceof Node) {
+            checkNode((TrustNode) trust);
+        } else if(osm instanceof Way) {
+            /*            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 TrustOsmPrimitive signGeometry(TrustOsmPrimitive trust) {
+        PGPSignatureSubpacketGenerator spGen = chooseAccuracy();
+        PGPSignature s;
+        Node node;
+        OsmPrimitive osm = trust.getOsmPrimitive();
+        if (osm.isNew()) {
+            invalidIDWarning(osm);
+            return trust;
+        }
+        if(osm instanceof Node) {
+            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,spGen);
+                if (s != null) ((TrustNode)trust).storeNodeSig(s);
+            }
+        } else if(osm instanceof Relation) {
+
+        }
+        return trust;
+    }*/
+
+    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<>();
+            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 false;
+        }
+        PGPSignature s;
+        String tosign = TrustOsmPrimitive.generateTagSigtext(osm,key);
+        //s = sign(tosign);
+        s = sign(tosign,chooseInformationSource());
+        if (s != null) {
+            trust.storeTagSig(key, s);
+            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{
+
+            readSecretKey();
+            if (pgpSec == null) return null;
+
+            if (password == null) {
+                getPasswordfromUser();
+            }
+
+            PGPPrivateKey pgpPrivKey = pgpSecKey.extractPrivateKey(password, "BC");
+            PGPSignatureGenerator sGen = new PGPSignatureGenerator(pgpSecKey.getPublicKey().getAlgorithm(), digest, "BC");
+            sGen.initSign(PGPSignature.CANONICAL_TEXT_DOCUMENT, pgpPrivKey);
+
+            Iterator<?> it = pgpSecKey.getPublicKey().getUserIDs();
+            if (it.hasNext()) {
+                spGen.setSignerUserID(false, (String)it.next());
+            }
+            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("PGP Signing Error: " + e.getMessage());
+        }
+
+
+        /*        String seckeys = gpg.listSecretKeys()? gpg.getResult() : "GPG-ERROR: " + gpg.getErrorString();
+        System.out.println("Die gelisteten keys sehen so aus:\n"+seckeys);
+        String[] keys = seckeys.split("\n");
+        System.out.println("Das Array hat so viele einträge:"+keys.length);
+        if (keys.length <= 1) {
+            System.out.println("Auf auf zum lustigen generieren!");
+            generateKey();
+        }
+        System.out.println("Achtung die Errorausgabe sieht so aus:\n"+gpg.getErrorString());
+        String sig = gpg.sign(tosign, password)? gpg.getResult() : "GPG-ERROR: " + gpg.getErrorString();
+         */
+
+
+        return null;
+    }
+
+    public boolean verify(String sigtext, PGPSignature sig) {
+        /*        if (gpg.verifySignature(sig)) {
+        success = trust.updateSigStatus(key, gpg.getResult().equals(sigtext)? TrustSignatures.SIG_VALID : TrustSignatures.SIG_BROKEN);
+    }*/
+        try {
+            sig.initVerify(pgpPub.getPublicKey(sig.getKeyID()), "BC");
+            sig.update(sigtext.getBytes(Charset.forName("UTF-8")));
+            return sig.verify();
+        }catch (Exception e){//Catch exception if any
+            System.err.println("PGP Verification Error: " + e.getMessage());
+        }
+        return false;
+    }
+
+
+    //    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) {
+        String userid = "Unknown";
+        Iterator<?> iter = key.getUserIDs();
+        if (iter.hasNext()) {
+            userid = (String)iter.next();
+        }
+
+        String fingerprint = new String(Hex.encode(key.getFingerprint())).toUpperCase();
+        String keyid = "0x"+Long.toHexString(key.getKeyID()).substring(8).toUpperCase();
+
+        String algorithm = "";
+        int algo = key.getAlgorithm();
+        switch(algo) {
+        case PGPPublicKey.DIFFIE_HELLMAN:
+            algorithm = "Diffie Hellman (DH)"; break;
+        case PGPPublicKey.DSA:
+            algorithm = "Digital Signature Algorithm (DSA)"; break;
+        case PGPPublicKey.EC:
+            algorithm = "Elliptic Curve (EC)"; break;
+        case PGPPublicKey.ECDSA:
+            algorithm = "Elliptic Curve Digital Signature Algorithm (ECDSA)"; break;
+        case PGPPublicKey.ELGAMAL_ENCRYPT:
+            algorithm = "Elgamal encrypt-only"; break;
+        case PGPPublicKey.ELGAMAL_GENERAL:
+            algorithm = "Elgamal"; break;
+        case PGPPublicKey.RSA_ENCRYPT:
+            algorithm = "Rivest Shamir Adleman (RSA) encrypt-only"; break;
+        case PGPPublicKey.RSA_GENERAL:
+            algorithm = "Rivest Shamir Adleman (RSA)"; break;
+        case PGPPublicKey.RSA_SIGN:
+            algorithm = "Rivest Shamir Adleman (RSA) sign-only"; break;
+        default:
+            algorithm = "Unknown algorithm ID: "+algo; break;
+        }
+
+        String strength = String.valueOf(key.getBitStrength());
+
+        //SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd:hh.mm.ss");
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
+        String creationTime = formatter.format(key.getCreationTime());
+
+        long validSeconds = key.getValidSeconds();
+        String expirationTime;
+        if (validSeconds == 0) {
+            expirationTime = tr("never");
+        } else {
+            expirationTime = formatter.format(new Date(key.getCreationTime().getTime()+validSeconds*1000));
+        }
+
+
+        String[] labels = {tr("Primary user-ID: "), tr("Key-ID: "), tr("Fingerprint: "), tr("Algorithm: "), tr("Strength in bit: "), tr("Creation date: "), tr("Expiration date: ")};
+        String[] values = {userid, keyid, fingerprint, algorithm, strength, creationTime, expirationTime};
+        int numPairs = labels.length;
+
+        //Create and populate the panel.
+        JPanel p = new JPanel(new SpringLayout());
+        for (int i = 0; i < numPairs; i++) {
+            JLabel l = new JLabel(labels[i], JLabel.TRAILING);
+            p.add(l);
+            JTextField textField = new JTextField(values[i]);
+            textField.setEditable(false);
+            l.setLabelFor(textField);
+            p.add(textField);
+        }
+
+        //Lay out the panel.
+        SpringUtilities.makeCompactGrid(p,
+                numPairs, 2, //rows, cols
+                6, 6,        //initX, initY
+                6, 6);       //xPad, yPad
+
+
+        //        JPanel metaPanel = new JPanel();
+        //        metaPanel.setLayout(new BoxLayout(metaPanel, BoxLayout.PAGE_AXIS));
+        //        metaPanel.add(p);
+        //        JScrollPane sp = new JScrollPane(new KeySignaturesDialog(key));
+        //        sp.setPreferredSize(new Dimension(0,200));
+        //        metaPanel.add(sp);
+
+        JOptionPane.showMessageDialog(Main.parent, p, tr("PGP-Key details"), JOptionPane.INFORMATION_MESSAGE);
+    }
+
+
+    public PGPSecretKey generateKey() throws NoSuchAlgorithmException, NoSuchProviderException, PGPException, FileNotFoundException, IOException {
+
+        JTextField userId = new JTextField();
+        NameGenerator nameGen = new NameGenerator(Main.pref.getPluginsDirectory().getPath()+"/trustosm/resources/syllables.txt");
+        userId.setText(nameGen.compose(3));
+
+        final String[] sizes = {"1024", "2048", "3072", "4096"};
+
+        final JComboBox<?> strengthBox = new JComboBox<Object>(sizes);
+        strengthBox.setEnabled(false);
+
+        /*        final String[] curves = {"prime192v1", "prime192v2", "prime192v3", "prime239v1", "prime239v2", "prime239v3", "prime256v1", "secp224r1", "secp256r1", "secp384r1", "secp521r1", "P-224", "P-256", "P-384", "P-521", "c2pnb163v1", "c2pnb163v2", "c2pnb163v3", "c2pnb176w1", "c2tnb191v2", "c2tnb191v1", "c2tnb191v3", "c2pnb208w1", "c2tnb239v1", "c2tnb239v2", "c2tnb239v3", "c2pnb272w1", "c2pnb304w1", "c2tnb359v1", "c2pnb368w1", "c2tnb431r1", "sect163r2", "sect233r1", "sect283r1", "sect409r1", "sect571r1", "B-163", "B-233", "B-283", "B-409", "B-571", "brainpoolp160r1", "brainpoolp160t1", "brainpoolp192r1", "brainpoolp192t1", "brainpoolp224r1", "brainpoolp224t1", "brainpoolp256r1", "brainpoolp256t1", "brainpoolp320r1", "brainpoolp320t1", "brainpoolp384r1", "brainpoolp384t1", "brainpoolp512r1", "brainpoolp512t1"};
+        final String[] curvesizes = {"192", "192", "192", "239", "239", "239", "256", "224", "256", "384", "521", "224", "256", "384", "521", "163", "163", "163", "176", "191", "191", "191", "208", "239", "239", "239", "272", "304", "359", "368", "431", "163", "233", "283", "409", "571", "163", "233", "283", "409", "571", "160", "160", "192", "192", "224", "224", "256", "256", "320", "320", "384", "384", "512", "512"};
+        final JComboBox curveBox = new JComboBox(curves);
+        curveBox.addActionListener(new ActionListener(){
+
+            @Override
+            public void actionPerformed(ActionEvent e) {
+                strengthBox.setSelectedIndex(((JComboBox)e.getSource()).getSelectedIndex());
+            }});
+        curveBox.setEnabled(false);
+         */
+
+        //        final String[] algos = {"DSA","RSA","ECDSA"};
+        final String[] algos = {"DSA","RSA"};
+        final JComboBox<?> algoBox = new JComboBox<Object>(algos);
+        algoBox.addActionListener(new ActionListener(){
+
+            @Override
+            public void actionPerformed(ActionEvent e) {
+                JComboBox<?> cb = (JComboBox<?>)e.getSource();
+                String alg = (String)cb.getSelectedItem();
+                if (alg.equals("DSA")) {
+                    strengthBox.setSelectedItem("1024");
+                    strengthBox.setEnabled(false);
+                } else
+                    strengthBox.setEnabled(true);
+                /*if (alg.equals("ECDSA")) {
+                    curveBox.setEnabled(true);
+                    strengthBox.setModel(new DefaultComboBoxModel(curvesizes));
+                    strengthBox.setSelectedItem(curvesizes[curveBox.getSelectedIndex()]);
+                    strengthBox.setEnabled(false);
+                } else {
+                    curveBox.setEnabled(false);
+                    strengthBox.setModel(new DefaultComboBoxModel(sizes));
+                    strengthBox.setEnabled(true);
+                }*/
+            }
+        });
+
+
+
+
+
+        final String[] protectAlgos = {"AES_256", "AES_192", "AES_128", "BLOWFISH", "CAST5", "DES", "IDEA", "SAFER", "TRIPLE_DES", "TWOFISH", "NULL"};
+        int[] protAl = {PGPEncryptedData.AES_256, PGPEncryptedData.AES_192, PGPEncryptedData.AES_128, PGPEncryptedData.BLOWFISH, PGPEncryptedData.CAST5, PGPEncryptedData.DES, PGPEncryptedData.IDEA, PGPEncryptedData.SAFER, PGPEncryptedData.TRIPLE_DES, PGPEncryptedData.TWOFISH, PGPEncryptedData.NULL};
+        final JComboBox<?> protectBox = new JComboBox<Object>(protectAlgos);
+
+        final JDateChooser cal = new JDateChooser(null, null, null, new JSpinnerDateEditor());
+        cal.setPreferredSize(new Dimension(130,cal.getPreferredSize().height));
+
+        final String[] labels = {tr("User-ID:"), tr("Select algorithm:"), tr("Choose Bitlength (Strength):"), tr("Encryption algorithm to protect private key:"), tr("Choose an expiry date for the key:")};
+        final JComponent[] values = {userId, algoBox, strengthBox, protectBox, cal};
+
+        int numPairs = labels.length;
+
+        //Create and populate the panel.
+        JPanel p = new JPanel(new SpringLayout());
+        for (int i = 0; i < numPairs; i++) {
+            JLabel l = new JLabel(labels[i], JLabel.TRAILING);
+            p.add(l);
+            l.setLabelFor(values[i]);
+            p.add(values[i]);
+        }
+
+        //Lay out the panel.
+        SpringUtilities.makeCompactGrid(p,
+                numPairs, 2, //rows, cols
+                6, 6,        //initX, initY
+                16, 6);       //xPad, yPad
+
+        int n = JOptionPane.showOptionDialog(Main.parent, p, tr("Create a new signing key"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
+
+        if (n != JOptionPane.OK_OPTION)
+            return null;
+
+
+        String algo = (String)algoBox.getSelectedItem();
+
+        KeyPairGenerator Kpg = KeyPairGenerator.getInstance(algo, "BC");
+
+        int al;
+        /*        if (algo.equals("ECDSA")) {
+            al = PGPPublicKey.ECDSA;
+            ECParameterSpec ecSpec = ECNamedCurveTable.getParameterSpec((String)curveBox.getSelectedItem());
+            try {
+                Kpg.initialize(ecSpec);
+            } catch (InvalidAlgorithmParameterException e1) {
+                // TODO Auto-generated catch block
+                System.err.println("EC-Parameter not accepted");
+                e1.printStackTrace();
+            }
+        }
+        else {*/
+        Kpg.initialize(Integer.parseInt((String)strengthBox.getSelectedItem()));
+        //
+        // this takes a while as the key generator has to generate some DSA params
+        // before it generates the key.
+        //
+
+        if (algo.equals("RSA")) al = PGPPublicKey.RSA_GENERAL;
+        else al = PGPPublicKey.DSA;
+        //        }
+
+
+        KeyPair kp = Kpg.generateKeyPair();
+
+        Date now = new Date();
+        PGPKeyPair pgpKp = new PGPKeyPair(al, kp, now);
+
+        getPasswordfromUser();
+
+        PGPSignatureSubpacketVector subPck = null;
+        PGPSignatureSubpacketGenerator spGen = null;
+        Date expire = cal.getDate();
+        if (expire != null && expire.after(now)) {
+            spGen = new PGPSignatureSubpacketGenerator();
+            spGen.setKeyExpirationTime(true, (expire.getTime()-now.getTime())/1000);
+            subPck = spGen.generate();
+        }
+
+        PGPKeyRingGenerator keyRingGen = new PGPKeyRingGenerator(PGPSignature.POSITIVE_CERTIFICATION, pgpKp,
+                userId.getText(), protAl[protectBox.getSelectedIndex()], password, true, subPck, null, new SecureRandom(), "BC");
+
+        if (pgpPub == null) {
+            Vector<PGPPublicKeyRing> pubKeyRing = new Vector<>(1);
+            pubKeyRing.add(keyRingGen.generatePublicKeyRing());
+            pgpPub = new PGPPublicKeyRingCollection(pubKeyRing);
+        } else {
+            pgpPub = PGPPublicKeyRingCollection.addPublicKeyRing(pgpPub, keyRingGen.generatePublicKeyRing());
+        }
+
+        PGPSecretKeyRing secRing = keyRingGen.generateSecretKeyRing();
+        if (pgpSec == null) {
+            Vector<PGPSecretKeyRing> secKeyRing = new Vector<>(1);
+            secKeyRing.add(secRing);
+            pgpSec = new PGPSecretKeyRingCollection(secKeyRing);
+        } else {
+            pgpSec = PGPSecretKeyRingCollection.addSecretKeyRing(pgpSec, secRing);
+        }
+
+
+        writeGpgFiles();
+
+        return secRing.getSecretKey();
+    }
 
 }
Index: applications/editors/josm/plugins/trustosm/src/tools/NameGenerator.java
===================================================================
--- applications/editors/josm/plugins/trustosm/src/tools/NameGenerator.java	(revision 30723)
+++ applications/editors/josm/plugins/trustosm/src/tools/NameGenerator.java	(revision 30724)
@@ -49,250 +49,250 @@
  */
 public class NameGenerator {
-	ArrayList<String> pre = new ArrayList<String>();
-	ArrayList<String> mid = new ArrayList<String>();
-	ArrayList<String> sur = new ArrayList<String>();
-
-	final private static char[] vocals = {'a', 'e', 'i', 'o', 'u', 'ä', 'ö', 'õ', 'ü', 'y'};
-	final private static char[] consonants = {'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p',	'q', 'r', 's', 't', 'v', 'w', 'x', 'y'};
-
-	private String fileName;
-
-	/**
-	 * Create new random name generator object. refresh() is automatically called.
-	 * @param fileName insert file name, where syllables are located
-	 * @throws IOException
-	 */
-	public NameGenerator(String fileName) throws IOException{
-		this.fileName = fileName;
-		refresh();
-	}
-
-	/**
-	 * Change the file. refresh() is automatically called during the process.
-	 * @param fileName insert the file name, where syllables are located.
-	 * @throws IOException
-	 */
-	public void changeFile(String fileName) throws IOException{
-		if(fileName == null) throw new IOException("File name cannot be null");
-		this.fileName = fileName;
-		refresh();
-	}
-
-	/**
-	 * Refresh names from file. No need to call that method, if you are not changing the file during the operation of program, as this method
-	 * is called every time file name is changed or new NameGenerator object created.
-	 * @throws IOException
-	 */
-	public void refresh() throws IOException{
-
-		FileReader input = null;
-		BufferedReader bufRead;
-		String line;
-
-		input = new FileReader(fileName);
-
-		bufRead = new BufferedReader(input);
-		line="";
-
-		while(line != null){
-			line = bufRead.readLine();
-			if(line != null && !line.equals("")){
-				if(line.charAt(0) == '-'){
-					pre.add(line.substring(1).toLowerCase());
-				}
-				else if(line.charAt(0) == '+'){
-					sur.add(line.substring(1).toLowerCase());
-				}
-				else{
-					mid.add(line.toLowerCase());
-				}
-			}
-		}
-		bufRead.close();
-	}
-
-	private String upper(String s){
-		return s.substring(0,1).toUpperCase().concat(s.substring(1));
-	}
-
-	private boolean containsConsFirst(ArrayList<String> array){
-		for(String s: array){
-			if(consonantFirst(s)) return true;
-		}
-		return false;
-	}
-
-	private boolean containsVocFirst(ArrayList<String> array){
-		for(String s: array){
-			if(vocalFirst(s)) return true;
-		}
-		return false;
-	}
-
-	private boolean allowCons(ArrayList<String> array){
-		for(String s: array){
-			if(hatesPreviousVocals(s) || hatesPreviousConsonants(s) == false) return true;
-		}
-		return false;
-	}
-
-	private boolean allowVocs(ArrayList<String> array){
-		for(String s: array){
-			if(hatesPreviousConsonants(s) || hatesPreviousVocals(s) == false) return true;
-		}
-		return false;
-	}
-
-	private boolean expectsVocal(String s){
-		if(s.substring(1).contains("+v")) return true;
-		else return false;
-	}
-	private boolean expectsConsonant(String s){
-		if(s.substring(1).contains("+c")) return true;
-		else return false;
-	}
-	private boolean hatesPreviousVocals(String s){
-		if(s.substring(1).contains("-c")) return true;
-		else return false;
-	}
-	private boolean hatesPreviousConsonants(String s){
-		if(s.substring(1).contains("-v")) return true;
-		else return false;
-	}
-
-	private String pureSyl(String s){
-		s = s.trim();
-		if(s.charAt(0) == '+' || s.charAt(0) == '-') s = s.substring(1);
-		return s.split(" ")[0];
-	}
-
-	private boolean vocalFirst(String s){
-		return (String.copyValueOf(vocals).contains(String.valueOf(s.charAt(0)).toLowerCase()));
-	}
-
-	private boolean consonantFirst(String s){
-		return (String.copyValueOf(consonants).contains(String.valueOf(s.charAt(0)).toLowerCase()));
-	}
-
-	private boolean vocalLast(String s){
-		return (String.copyValueOf(vocals).contains(String.valueOf(s.charAt(s.length()-1)).toLowerCase()));
-	}
-
-	private boolean consonantLast(String s){
-		return (String.copyValueOf(consonants).contains(String.valueOf(s.charAt(s.length()-1)).toLowerCase()));
-	}
-
-
-	/**
-	 * Compose a new name.
-	 * @param syls The number of syllables used in name.
-	 * @return Returns composed name as a String
-	 * @throws RuntimeException when logical mistakes are detected inside chosen file, and program is unable to complete the name.
-	 */
-	public String compose(int syls){
-		if(syls > 2 && mid.size() == 0) throw new RuntimeException("You are trying to create a name with more than 3 parts, which requires middle parts, " +
-				"which you have none in the file "+fileName+". You should add some. Every word, which doesn't have + or - for a prefix is counted as a middle part.");
-		if(pre.size() == 0) throw new RuntimeException("You have no prefixes to start creating a name. add some and use \"-\" prefix, to identify it as a prefix for a name. (example: -asd)");
-		if(sur.size() == 0) throw new RuntimeException("You have no suffixes to end a name. add some and use \"+\" prefix, to identify it as a suffix for a name. (example: +asd)");
-		if(syls < 1) throw new RuntimeException("compose(int syls) can't have less than 1 syllable");
-		int expecting = 0; // 1 for vocal, 2 for consonant
-		int last = 0; // 1 for vocal, 2 for consonant
-		String name;
-		int a = (int)(Math.random() * pre.size());
-
-		if(vocalLast(pureSyl(pre.get(a)))) last = 1;
-		else last = 2;
-
-		if(syls > 2){
-			if(expectsVocal(pre.get(a))){
-				expecting = 1;
-				if(containsVocFirst(mid) == false) throw new RuntimeException("Expecting \"middle\" part starting with vocal, " +
-				"but there is none. You should add one, or remove requirement for one.. ");
-			}
-			if(expectsConsonant(pre.get(a))){
-				expecting = 2;
-				if(containsConsFirst(mid) == false) throw new RuntimeException("Expecting \"middle\" part starting with consonant, " +
-				"but there is none. You should add one, or remove requirement for one.. ");
-			}
-		}
-		else{
-			if(expectsVocal(pre.get(a))){
-				expecting = 1;
-				if(containsVocFirst(sur) == false) throw new RuntimeException("Expecting \"suffix\" part starting with vocal, " +
-				"but there is none. You should add one, or remove requirement for one.. ");
-			}
-			if(expectsConsonant(pre.get(a))){
-				expecting = 2;
-				if(containsConsFirst(sur) == false) throw new RuntimeException("Expecting \"suffix\" part starting with consonant, " +
-				"but there is none. You should add one, or remove requirement for one.. ");
-			}
-		}
-		if(vocalLast(pureSyl(pre.get(a))) && allowVocs(mid) == false) throw new RuntimeException("Expecting \"middle\" part that allows last character of prefix to be a vocal, " +
-				"but there is none. You should add one, or remove requirements that cannot be fulfilled.. the prefix used, was : \""+pre.get(a)+"\", which" +
-		"means there should be a part available, that has \"-v\" requirement or no requirements for previous syllables at all.");
-
-		if(consonantLast(pureSyl(pre.get(a))) && allowCons(mid) == false) throw new RuntimeException("Expecting \"middle\" part that allows last character of prefix to be a consonant, " +
-				"but there is none. You should add one, or remove requirements that cannot be fulfilled.. the prefix used, was : \""+pre.get(a)+"\", which" +
-		"means there should be a part available, that has \"-c\" requirement or no requirements for previous syllables at all.");
-
-		int b[] = new int[syls];
-		for(int i = 0; i<b.length-2; i++){
-
-			do{
-				b[i] = (int)(Math.random() * mid.size());
-				//System.out.println("exp " +expecting+" vocalF:"+vocalFirst(mid.get(b[i]))+" syl: "+mid.get(b[i]));
-			}
-			while(expecting == 1 && vocalFirst(pureSyl(mid.get(b[i]))) == false || expecting == 2 && consonantFirst(pureSyl(mid.get(b[i]))) == false
-					|| last == 1 && hatesPreviousVocals(mid.get(b[i])) || last == 2 && hatesPreviousConsonants(mid.get(b[i])));
-
-			expecting = 0;
-			if(expectsVocal(mid.get(b[i]))){
-				expecting = 1;
-				if(i < b.length-3 && containsVocFirst(mid) == false) throw new RuntimeException("Expecting \"middle\" part starting with vocal, " +
-				"but there is none. You should add one, or remove requirement for one.. ");
-				if(i == b.length-3 && containsVocFirst(sur) == false) throw new RuntimeException("Expecting \"suffix\" part starting with vocal, " +
-				"but there is none. You should add one, or remove requirement for one.. ");
-			}
-			if(expectsConsonant(mid.get(b[i]))){
-				expecting = 2;
-				if(i < b.length-3 && containsConsFirst(mid) == false) throw new RuntimeException("Expecting \"middle\" part starting with consonant, " +
-				"but there is none. You should add one, or remove requirement for one.. ");
-				if(i == b.length-3 && containsConsFirst(sur) == false) throw new RuntimeException("Expecting \"suffix\" part starting with consonant, " +
-				"but there is none. You should add one, or remove requirement for one.. ");
-			}
-			if(vocalLast(pureSyl(mid.get(b[i]))) && allowVocs(mid) == false && syls > 3) throw new RuntimeException("Expecting \"middle\" part that allows last character of last syllable to be a vocal, " +
-					"but there is none. You should add one, or remove requirements that cannot be fulfilled.. the part used, was : \""+mid.get(b[i])+"\", which " +
-			"means there should be a part available, that has \"-v\" requirement or no requirements for previous syllables at all.");
-
-			if(consonantLast(pureSyl(mid.get(b[i]))) && allowCons(mid) == false && syls > 3) throw new RuntimeException("Expecting \"middle\" part that allows last character of last syllable to be a consonant, " +
-					"but there is none. You should add one, or remove requirements that cannot be fulfilled.. the part used, was : \""+mid.get(b[i])+"\", which " +
-			"means there should be a part available, that has \"-c\" requirement or no requirements for previous syllables at all.");
-			if(i == b.length-3){
-				if(vocalLast(pureSyl(mid.get(b[i]))) && allowVocs(sur) == false) throw new RuntimeException("Expecting \"suffix\" part that allows last character of last syllable to be a vocal, " +
-						"but there is none. You should add one, or remove requirements that cannot be fulfilled.. the part used, was : \""+mid.get(b[i])+"\", which " +
-				"means there should be a suffix available, that has \"-v\" requirement or no requirements for previous syllables at all.");
-
-				if(consonantLast(pureSyl(mid.get(b[i]))) && allowCons(sur) == false) throw new RuntimeException("Expecting \"suffix\" part that allows last character of last syllable to be a consonant, " +
-						"but there is none. You should add one, or remove requirements that cannot be fulfilled.. the part used, was : \""+mid.get(b[i])+"\", which " +
-				"means there should be a suffix available, that has \"-c\" requirement or no requirements for previous syllables at all.");
-			}
-			if(vocalLast(pureSyl(mid.get(b[i])))) last = 1;
-			else last = 2;
-		}
-
-		int c;
-		do{
-			c = (int)(Math.random() * sur.size());
-		}
-		while(expecting == 1 && vocalFirst(pureSyl(sur.get(c))) == false || expecting == 2 && consonantFirst(pureSyl(sur.get(c))) == false
-				|| last == 1 && hatesPreviousVocals(sur.get(c)) || last == 2 && hatesPreviousConsonants(sur.get(c)));
-
-		name = upper(pureSyl(pre.get(a).toLowerCase()));
-		for(int i = 0; i<b.length-2; i++){
-			name = name.concat(pureSyl(mid.get(b[i]).toLowerCase()));
-		}
-		if(syls > 1)
-			name = name.concat(pureSyl(sur.get(c).toLowerCase()));
-		return name;
-	}
+    ArrayList<String> pre = new ArrayList<String>();
+    ArrayList<String> mid = new ArrayList<String>();
+    ArrayList<String> sur = new ArrayList<String>();
+
+    final private static char[] vocals = {'a', 'e', 'i', 'o', 'u', 'ä', 'ö', 'õ', 'ü', 'y'};
+    final private static char[] consonants = {'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p',    'q', 'r', 's', 't', 'v', 'w', 'x', 'y'};
+
+    private String fileName;
+
+    /**
+     * Create new random name generator object. refresh() is automatically called.
+     * @param fileName insert file name, where syllables are located
+     * @throws IOException
+     */
+    public NameGenerator(String fileName) throws IOException{
+        this.fileName = fileName;
+        refresh();
+    }
+
+    /**
+     * Change the file. refresh() is automatically called during the process.
+     * @param fileName insert the file name, where syllables are located.
+     * @throws IOException
+     */
+    public void changeFile(String fileName) throws IOException{
+        if(fileName == null) throw new IOException("File name cannot be null");
+        this.fileName = fileName;
+        refresh();
+    }
+
+    /**
+     * Refresh names from file. No need to call that method, if you are not changing the file during the operation of program, as this method
+     * is called every time file name is changed or new NameGenerator object created.
+     * @throws IOException
+     */
+    public void refresh() throws IOException{
+
+        FileReader input = null;
+        BufferedReader bufRead;
+        String line;
+
+        input = new FileReader(fileName);
+
+        bufRead = new BufferedReader(input);
+        line="";
+
+        while(line != null){
+            line = bufRead.readLine();
+            if(line != null && !line.equals("")){
+                if(line.charAt(0) == '-'){
+                    pre.add(line.substring(1).toLowerCase());
+                }
+                else if(line.charAt(0) == '+'){
+                    sur.add(line.substring(1).toLowerCase());
+                }
+                else{
+                    mid.add(line.toLowerCase());
+                }
+            }
+        }
+        bufRead.close();
+    }
+
+    private String upper(String s){
+        return s.substring(0,1).toUpperCase().concat(s.substring(1));
+    }
+
+    private boolean containsConsFirst(ArrayList<String> array){
+        for(String s: array){
+            if(consonantFirst(s)) return true;
+        }
+        return false;
+    }
+
+    private boolean containsVocFirst(ArrayList<String> array){
+        for(String s: array){
+            if(vocalFirst(s)) return true;
+        }
+        return false;
+    }
+
+    private boolean allowCons(ArrayList<String> array){
+        for(String s: array){
+            if(hatesPreviousVocals(s) || hatesPreviousConsonants(s) == false) return true;
+        }
+        return false;
+    }
+
+    private boolean allowVocs(ArrayList<String> array){
+        for(String s: array){
+            if(hatesPreviousConsonants(s) || hatesPreviousVocals(s) == false) return true;
+        }
+        return false;
+    }
+
+    private boolean expectsVocal(String s){
+        if(s.substring(1).contains("+v")) return true;
+        else return false;
+    }
+    private boolean expectsConsonant(String s){
+        if(s.substring(1).contains("+c")) return true;
+        else return false;
+    }
+    private boolean hatesPreviousVocals(String s){
+        if(s.substring(1).contains("-c")) return true;
+        else return false;
+    }
+    private boolean hatesPreviousConsonants(String s){
+        if(s.substring(1).contains("-v")) return true;
+        else return false;
+    }
+
+    private String pureSyl(String s){
+        s = s.trim();
+        if(s.charAt(0) == '+' || s.charAt(0) == '-') s = s.substring(1);
+        return s.split(" ")[0];
+    }
+
+    private boolean vocalFirst(String s){
+        return (String.copyValueOf(vocals).contains(String.valueOf(s.charAt(0)).toLowerCase()));
+    }
+
+    private boolean consonantFirst(String s){
+        return (String.copyValueOf(consonants).contains(String.valueOf(s.charAt(0)).toLowerCase()));
+    }
+
+    private boolean vocalLast(String s){
+        return (String.copyValueOf(vocals).contains(String.valueOf(s.charAt(s.length()-1)).toLowerCase()));
+    }
+
+    private boolean consonantLast(String s){
+        return (String.copyValueOf(consonants).contains(String.valueOf(s.charAt(s.length()-1)).toLowerCase()));
+    }
+
+
+    /**
+     * Compose a new name.
+     * @param syls The number of syllables used in name.
+     * @return Returns composed name as a String
+     * @throws RuntimeException when logical mistakes are detected inside chosen file, and program is unable to complete the name.
+     */
+    public String compose(int syls){
+        if(syls > 2 && mid.size() == 0) throw new RuntimeException("You are trying to create a name with more than 3 parts, which requires middle parts, " +
+                "which you have none in the file "+fileName+". You should add some. Every word, which doesn't have + or - for a prefix is counted as a middle part.");
+        if(pre.size() == 0) throw new RuntimeException("You have no prefixes to start creating a name. add some and use \"-\" prefix, to identify it as a prefix for a name. (example: -asd)");
+        if(sur.size() == 0) throw new RuntimeException("You have no suffixes to end a name. add some and use \"+\" prefix, to identify it as a suffix for a name. (example: +asd)");
+        if(syls < 1) throw new RuntimeException("compose(int syls) can't have less than 1 syllable");
+        int expecting = 0; // 1 for vocal, 2 for consonant
+        int last = 0; // 1 for vocal, 2 for consonant
+        String name;
+        int a = (int)(Math.random() * pre.size());
+
+        if(vocalLast(pureSyl(pre.get(a)))) last = 1;
+        else last = 2;
+
+        if(syls > 2){
+            if(expectsVocal(pre.get(a))){
+                expecting = 1;
+                if(containsVocFirst(mid) == false) throw new RuntimeException("Expecting \"middle\" part starting with vocal, " +
+                "but there is none. You should add one, or remove requirement for one.. ");
+            }
+            if(expectsConsonant(pre.get(a))){
+                expecting = 2;
+                if(containsConsFirst(mid) == false) throw new RuntimeException("Expecting \"middle\" part starting with consonant, " +
+                "but there is none. You should add one, or remove requirement for one.. ");
+            }
+        }
+        else{
+            if(expectsVocal(pre.get(a))){
+                expecting = 1;
+                if(containsVocFirst(sur) == false) throw new RuntimeException("Expecting \"suffix\" part starting with vocal, " +
+                "but there is none. You should add one, or remove requirement for one.. ");
+            }
+            if(expectsConsonant(pre.get(a))){
+                expecting = 2;
+                if(containsConsFirst(sur) == false) throw new RuntimeException("Expecting \"suffix\" part starting with consonant, " +
+                "but there is none. You should add one, or remove requirement for one.. ");
+            }
+        }
+        if(vocalLast(pureSyl(pre.get(a))) && allowVocs(mid) == false) throw new RuntimeException("Expecting \"middle\" part that allows last character of prefix to be a vocal, " +
+                "but there is none. You should add one, or remove requirements that cannot be fulfilled.. the prefix used, was : \""+pre.get(a)+"\", which" +
+        "means there should be a part available, that has \"-v\" requirement or no requirements for previous syllables at all.");
+
+        if(consonantLast(pureSyl(pre.get(a))) && allowCons(mid) == false) throw new RuntimeException("Expecting \"middle\" part that allows last character of prefix to be a consonant, " +
+                "but there is none. You should add one, or remove requirements that cannot be fulfilled.. the prefix used, was : \""+pre.get(a)+"\", which" +
+        "means there should be a part available, that has \"-c\" requirement or no requirements for previous syllables at all.");
+
+        int b[] = new int[syls];
+        for(int i = 0; i<b.length-2; i++){
+
+            do{
+                b[i] = (int)(Math.random() * mid.size());
+                //System.out.println("exp " +expecting+" vocalF:"+vocalFirst(mid.get(b[i]))+" syl: "+mid.get(b[i]));
+            }
+            while(expecting == 1 && vocalFirst(pureSyl(mid.get(b[i]))) == false || expecting == 2 && consonantFirst(pureSyl(mid.get(b[i]))) == false
+                    || last == 1 && hatesPreviousVocals(mid.get(b[i])) || last == 2 && hatesPreviousConsonants(mid.get(b[i])));
+
+            expecting = 0;
+            if(expectsVocal(mid.get(b[i]))){
+                expecting = 1;
+                if(i < b.length-3 && containsVocFirst(mid) == false) throw new RuntimeException("Expecting \"middle\" part starting with vocal, " +
+                "but there is none. You should add one, or remove requirement for one.. ");
+                if(i == b.length-3 && containsVocFirst(sur) == false) throw new RuntimeException("Expecting \"suffix\" part starting with vocal, " +
+                "but there is none. You should add one, or remove requirement for one.. ");
+            }
+            if(expectsConsonant(mid.get(b[i]))){
+                expecting = 2;
+                if(i < b.length-3 && containsConsFirst(mid) == false) throw new RuntimeException("Expecting \"middle\" part starting with consonant, " +
+                "but there is none. You should add one, or remove requirement for one.. ");
+                if(i == b.length-3 && containsConsFirst(sur) == false) throw new RuntimeException("Expecting \"suffix\" part starting with consonant, " +
+                "but there is none. You should add one, or remove requirement for one.. ");
+            }
+            if(vocalLast(pureSyl(mid.get(b[i]))) && allowVocs(mid) == false && syls > 3) throw new RuntimeException("Expecting \"middle\" part that allows last character of last syllable to be a vocal, " +
+                    "but there is none. You should add one, or remove requirements that cannot be fulfilled.. the part used, was : \""+mid.get(b[i])+"\", which " +
+            "means there should be a part available, that has \"-v\" requirement or no requirements for previous syllables at all.");
+
+            if(consonantLast(pureSyl(mid.get(b[i]))) && allowCons(mid) == false && syls > 3) throw new RuntimeException("Expecting \"middle\" part that allows last character of last syllable to be a consonant, " +
+                    "but there is none. You should add one, or remove requirements that cannot be fulfilled.. the part used, was : \""+mid.get(b[i])+"\", which " +
+            "means there should be a part available, that has \"-c\" requirement or no requirements for previous syllables at all.");
+            if(i == b.length-3){
+                if(vocalLast(pureSyl(mid.get(b[i]))) && allowVocs(sur) == false) throw new RuntimeException("Expecting \"suffix\" part that allows last character of last syllable to be a vocal, " +
+                        "but there is none. You should add one, or remove requirements that cannot be fulfilled.. the part used, was : \""+mid.get(b[i])+"\", which " +
+                "means there should be a suffix available, that has \"-v\" requirement or no requirements for previous syllables at all.");
+
+                if(consonantLast(pureSyl(mid.get(b[i]))) && allowCons(sur) == false) throw new RuntimeException("Expecting \"suffix\" part that allows last character of last syllable to be a consonant, " +
+                        "but there is none. You should add one, or remove requirements that cannot be fulfilled.. the part used, was : \""+mid.get(b[i])+"\", which " +
+                "means there should be a suffix available, that has \"-c\" requirement or no requirements for previous syllables at all.");
+            }
+            if(vocalLast(pureSyl(mid.get(b[i])))) last = 1;
+            else last = 2;
+        }
+
+        int c;
+        do{
+            c = (int)(Math.random() * sur.size());
+        }
+        while(expecting == 1 && vocalFirst(pureSyl(sur.get(c))) == false || expecting == 2 && consonantFirst(pureSyl(sur.get(c))) == false
+                || last == 1 && hatesPreviousVocals(sur.get(c)) || last == 2 && hatesPreviousConsonants(sur.get(c)));
+
+        name = upper(pureSyl(pre.get(a).toLowerCase()));
+        for(int i = 0; i<b.length-2; i++){
+            name = name.concat(pureSyl(mid.get(b[i]).toLowerCase()));
+        }
+        if(syls > 1)
+            name = name.concat(pureSyl(sur.get(c).toLowerCase()));
+        return name;
+    }
 }
