X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnet%2Fpterodactylus%2Ffcp%2Fplugin%2FWebOfTrustPlugin.java;h=d5cedfc56d3138f106296fa39b7dfcf9685c832c;hb=c200f549b8ebde87b6145f1f5bacf932e68151f5;hp=bb6d682cb9ad0fabc2947d2ba3190126edb44c18;hpb=6c773a5587ca6206bad9ca5686d6b69a9916eb63;p=jFCPlib.git diff --git a/src/net/pterodactylus/fcp/plugin/WebOfTrustPlugin.java b/src/net/pterodactylus/fcp/plugin/WebOfTrustPlugin.java index bb6d682..d5cedfc 100644 --- a/src/net/pterodactylus/fcp/plugin/WebOfTrustPlugin.java +++ b/src/net/pterodactylus/fcp/plugin/WebOfTrustPlugin.java @@ -173,6 +173,27 @@ public class WebOfTrustPlugin { return new IdentityTrust(trust, score, rank); } + /** + * Adds a new identity by its request URI. + * + * @param requestUri + * The request URI of the identity to add + * @return The added identity + * @throws IOException + * if an I/O error occurs + * @throws FcpException + * if an FCP error occurs + */ + public Identity addIdentity(String requestUri) throws IOException, FcpException { + Map replies = fcpClient.sendPluginMessage("plugins.WoT.WoT", createParameters("Message", "AddIdentity", "RequestURI", requestUri)); + if (!replies.get("Message").equals("IdentityAdded")) { + throw new FcpException("WebOfTrust Plugin did not reply with “IdentityAdded” message!"); + } + String identifier = replies.get("ID"); + String nickname = replies.get("Nickname"); + return new Identity(identifier, nickname, requestUri); + } + // // PRIVATE METHODS // @@ -325,16 +346,7 @@ public class WebOfTrustPlugin { * * @author David ‘Bombe’ Roden <bombe@freenetproject.org> */ - public static class OwnIdentity { - - /** The identity’s identifier. */ - private final String identifier; - - /** The identity’s nickname. */ - private final String nickname; - - /** The identity’s request URI. */ - private final String requestUri; + public static class OwnIdentity extends Identity { /** The identity’s insert URI. */ private final String insertUri; @@ -352,40 +364,11 @@ public class WebOfTrustPlugin { * The insert URI of the identity */ public OwnIdentity(String identifier, String nickname, String requestUri, String insertUri) { - this.identifier = identifier; - this.nickname = nickname; - this.requestUri = requestUri; + super(identifier, nickname, requestUri); this.insertUri = insertUri; } /** - * Returns the identifier of this identity. - * - * @return This identity’s identifier - */ - public String getIdentifier() { - return identifier; - } - - /** - * Returns the nickname of this identity. - * - * @return This identity’s nickname - */ - public String getNickname() { - return nickname; - } - - /** - * Returns the request URI of this identity. - * - * @return This identity’s request URI - */ - public String getRequestUri() { - return requestUri; - } - - /** * Returns the insert URI of this identity. * * @return This identity’s insert URI