X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ffreenet%2FKey.java;fp=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ffreenet%2FKey.java;h=0000000000000000000000000000000000000000;hp=68116427ed4d8058748dc7401d7c2f17a084405f;hb=d50730f6a330439e0e7ef97ca9329dffe72d5640;hpb=97fe04482ebb8a08e43294acde041c2975cbd8ee diff --git a/src/main/java/net/pterodactylus/sone/freenet/Key.java b/src/main/java/net/pterodactylus/sone/freenet/Key.java deleted file mode 100644 index 6811642..0000000 --- a/src/main/java/net/pterodactylus/sone/freenet/Key.java +++ /dev/null @@ -1,65 +0,0 @@ -package net.pterodactylus.sone.freenet; - -import static freenet.support.Base64.encode; -import static java.lang.String.format; - -import freenet.keys.FreenetURI; - -import com.google.common.annotations.VisibleForTesting; - -/** - * Encapsulates the parts of a {@link FreenetURI} that do not change while - * being converted from SSK to USK and/or back. - */ -public class Key { - - private final byte[] routingKey; - private final byte[] cryptoKey; - private final byte[] extra; - - private Key(byte[] routingKey, byte[] cryptoKey, byte[] extra) { - this.routingKey = routingKey; - this.cryptoKey = cryptoKey; - this.extra = extra; - } - - @VisibleForTesting - public String getRoutingKey() { - return encode(routingKey); - } - - @VisibleForTesting - public String getCryptoKey() { - return encode(cryptoKey); - } - - @VisibleForTesting - public String getExtra() { - return encode(extra); - } - - public FreenetURI toUsk(String docName, long edition, String... paths) { - return new FreenetURI("USK", docName, paths, routingKey, cryptoKey, - extra, edition); - } - - public FreenetURI toSsk(String docName, String... paths) { - return new FreenetURI("SSK", docName, paths, routingKey, cryptoKey, - extra); - } - - public FreenetURI toSsk(String docName, long edition, String... paths) { - return new FreenetURI("SSK", format("%s-%d", docName, edition), paths, - routingKey, cryptoKey, extra, edition); - } - - public static Key from(FreenetURI freenetURI) { - return new Key(freenetURI.getRoutingKey(), freenetURI.getCryptoKey(), - freenetURI.getExtra()); - } - - public static String routingKey(FreenetURI freenetURI) { - return from(freenetURI).getRoutingKey(); - } - -}