X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fde%2Ftodesbaum%2Fjsite%2Fapplication%2FWebOfTrustInterface.java;h=eeee195533397289d4d671ed12d6d3169024bdc0;hb=7ec476fcc83a2ebe74a9faf3251d9d60fd03f58e;hp=d1fd31d4f17d7319a937518b741164a082cad8d9;hpb=8b9cdbbb17878232fb2400a48e154823b7a306bf;p=jSite.git diff --git a/src/main/java/de/todesbaum/jsite/application/WebOfTrustInterface.java b/src/main/java/de/todesbaum/jsite/application/WebOfTrustInterface.java index d1fd31d..eeee195 100644 --- a/src/main/java/de/todesbaum/jsite/application/WebOfTrustInterface.java +++ b/src/main/java/de/todesbaum/jsite/application/WebOfTrustInterface.java @@ -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. */