/** Returns a <b>new</b> FreenetURI with a new suggested edition number. * Note that the suggested edition number is only valid for USKs. */ public FreenetURI setSuggestedEdition(long newEdition) { return new FreenetURI( keyType, docName, metaStr, routingKey, cryptoKey, extra, newEdition); }
/** Returns a <b>new</b> FreenetURI with a new routing key. KSKs do not * have a routing key. */ public FreenetURI setRoutingKey(byte[] newRoutingKey) { return new FreenetURI( keyType, docName, metaStr, newRoutingKey, cryptoKey, extra, suggestedEdition); }
/** Returns a copy of this URI with new meta-strings. */ public FreenetURI setMetaString(String[] newMetaStr) { return new FreenetURI( keyType, docName, newMetaStr, routingKey, cryptoKey, extra, suggestedEdition); }
/** * Returns a copy of this URI with a new Document name set. */ public FreenetURI setDocName(String name) { return new FreenetURI( keyType, name, metaStr, routingKey, cryptoKey, extra, suggestedEdition); }
@Override public final FreenetURI clone() { return new FreenetURI(this); }
@Override public FreenetURI getURI() { return new FreenetURI("KSK", keyword); }
/** Convert a USK into an SSK by appending "-" and the suggested edition * to the document name and changing the key type. */ public FreenetURI sskForUSK() { if(!keyType.equalsIgnoreCase("USK")) throw new IllegalStateException(); long edition = Math.abs(suggestedEdition); if (edition == Long.MIN_VALUE) edition = Long.MAX_VALUE; return new FreenetURI("SSK", docName+"-"+edition, metaStr, routingKey, cryptoKey, extra, 0); }
/** Convert an SSK into a USK, if possible. */ public FreenetURI uskForSSK() { if(!keyType.equalsIgnoreCase("SSK")) throw new IllegalStateException(); Matcher matcher = docNameWithEditionPattern.matcher(docName); if (!matcher.matches()) throw new IllegalStateException(); int offset = matcher.start(1) - 1; String siteName = docName.substring(0, offset); long edition = Long.parseLong(docName.substring(offset + 1, docName.length())); return new FreenetURI("USK", siteName, metaStr, routingKey, cryptoKey, extra, edition); }
/** * ATTENTION: Please read {@link OfficialPluginDescription#uri} before deciding whether * to use USK or CHK! */ public OfficialPluginBuilder loadedFrom(String uri) throws MalformedURLException { this.uri = new FreenetURI(uri); addCurrentPluginDescription(); return this; }
/** * @return URI form of this key. */ @Override public FreenetURI getURI() { byte[] extra = getExtra(); return new FreenetURI("CHK", null, routingKey, cryptoKey, extra); }
public static FreenetURI sanitizeURI(List<String> errors, String key, boolean breakOnErrors, Options... options) throws MalformedURLException { if (key == null) throw new NullPointerException(); FreenetURI uri = new FreenetURI(key); return sanitizeURI(errors, uri, breakOnErrors, options); }
public static FreenetURI generateRandomCHK(Random rand) { byte[] rkey = new byte[32]; rand.nextBytes(rkey); byte[] ckey = new byte[32]; rand.nextBytes(ckey); byte[] extra = ClientCHK.getExtra(Key.ALGO_AES_CTR_256_SHA256, (short)-1, false); return new FreenetURI("CHK", null, rkey, ckey, extra); }
@Override public FreenetURI getURI() { return new FreenetURI(pubKeyHash, cryptoKey, ClientSSK.getExtraBytes(cryptoAlgorithm), siteName, suggestedEdition); }
/** Run this class to decompose the argument. */ public static void main(String[] args) throws Exception { (new FreenetURI(args[0])).decompose(); }
@Override public FreenetURI getURI() { return new FreenetURI("SSK", docName, pubKeyHash, cryptoKey, getExtraBytes()); }
public SendURIMessage(SimpleFieldSet fs) throws MessageInvalidException { super(fs); try { uri = new FreenetURI(fs.get("URI")); } catch (MalformedURLException e) { throw new MessageInvalidException(ProtocolErrorMessage.FREENET_URI_PARSE_ERROR, e.getMessage(), identifier, false); } }
@Override public FreenetURI checkSource(String source) throws PluginNotFoundException { try { return new FreenetURI(source); } catch (MalformedURLException e) { Logger.error(this, "not a valid freenet key: " + source, e); throw new PluginNotFoundException("not a valid freenet key: " + source, e); } }
public KeyTest() throws MalformedURLException { uri = new FreenetURI( "SSK@NfUYvxDwU9vqb2mh-qdT~DYJ6U0XNbxMGGoLe0aCHJs,Miglsgix0VR56ZiPl4NgjnUd~UdrnHqIvXJ3KKHmxmI,AQACAAE/some-site-12/foo/bar.html"); key = from(uri); }
@Override public void set(String val) throws InvalidConfigValueException { FreenetURI uri; try { uri = new FreenetURI(val); } catch (MalformedURLException e) { throw new InvalidConfigValueException(l10n( "invalidRevocationURI", "error", e.getLocalizedMessage())); } setRevocationURI(uri); } }
@Test public void unregisteringASoneWithAWrongRequestKeyWillNotUnsubscribe() throws MalformedURLException { when(sone.getRequestUri()).thenReturn(new FreenetURI("KSK@GPLv3.txt")); freenetInterface.registerUsk(sone.getRequestUri(), null); freenetInterface.unregisterUsk(sone); verify(uskManager, never()).unsubscribe(any(USK.class), any(USKCallback.class)); }