Update year in copyright headers.
[jSite.git] / src / main / java / de / todesbaum / jsite / application / WebOfTrustInterface.java
index d1fd31d..eeee195 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * jSite - WebOfTrustInterface.java - Copyright © 2012 David Roden
+ * jSite - WebOfTrustInterface.java - Copyright © 2012–2014 David Roden
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -122,6 +122,25 @@ public class WebOfTrustInterface implements Runnable {
                }
        }
 
+       /**
+        * Returns the essential parts of an URI, consisting of only the
+        * private/public key, decryption key, and the flags.
+        *
+        * @param uri
+        *            The URI to shorten
+        * @return The shortened URI
+        */
+       private static String shortenUri(String uri) {
+               String shortenedUri = uri;
+               if (shortenedUri.charAt(3) == '@') {
+                       shortenedUri = shortenedUri.substring(4);
+               }
+               if (shortenedUri.indexOf('/') > -1) {
+                       shortenedUri = shortenedUri.substring(0, shortenedUri.indexOf('/'));
+               }
+               return shortenedUri;
+       }
+
        //
        // RUNNABLE METHODS
        //
@@ -186,9 +205,9 @@ public class WebOfTrustInterface implements Runnable {
                                        int identityCounter = -1;
                                        while (message.get("Replies.Identity" + ++identityCounter) != null) {
                                                String id = message.get("Replies.Identity" + identityCounter);
-                                               String nickname = message.get("Replies.Nickname " + identityCounter);
-                                               String requestUri = message.get("Replies.RequestURI" + identityCounter);
-                                               String insertUri = message.get("Replies.InsertURI" + identityCounter);
+                                               String nickname = message.get("Replies.Nickname" + identityCounter);
+                                               String requestUri = shortenUri(message.get("Replies.RequestURI" + identityCounter));
+                                               String insertUri = shortenUri(message.get("Replies.InsertURI" + identityCounter));
                                                DefaultOwnIdentity ownIdentity = new DefaultOwnIdentity(id, nickname, requestUri, insertUri);
                                                logger.log(Level.FINE, String.format("Parsed Own Identity %s.", ownIdentity));
                                                ownIdentities.add(ownIdentity);
@@ -201,6 +220,8 @@ public class WebOfTrustInterface implements Runnable {
                                        }
                                } else if ("ProtocolError".equals(message.getName())) {
                                        logger.log(Level.WARNING, "WebOfTrust Plugin not found!");
+                               } else if ("Error".equals(message.getName())) {
+                                       logger.log(Level.WARNING, "WebOfTrust Plugin returned an error!");
                                }
 
                                /* disconnect. */