/** * @return URI for the user-facing changelog. */ public synchronized FreenetURI getChangelogURI() { return updateURI.setDocName("changelog"); }
public synchronized FreenetURI getDeveloperChangelogURI() { return updateURI.setDocName("fullchangelog"); }
/** * Generate a Sone URI from the given URI. * * @param uri * The URI to derive the Sone URI from * @return The derived URI */ public static FreenetURI create(String uri) { try { return new FreenetURI(uri).setDocName("Sone").setMetaString(new String[0]); } catch (MalformedURLException mue1) { /* this should never happen. */ logger.log(Level.WARNING, String.format("Could not create Sone URI from URI: %s", uri), mue1); return null; } }
public FreenetURI getSeednodesURI() { return updateURI.sskForUSK().setDocName( "seednodes-" + Version.buildNumber()); }
public FreenetURI getInstallerNonWindowsURI() { return updateURI.sskForUSK().setDocName( "installer-" + Version.buildNumber()); }
public FreenetURI getInstallerWindowsURI() { return updateURI.sskForUSK().setDocName( "wininstaller-" + Version.buildNumber()); }
public FreenetURI getIPv4ToCountryURI() { return updateURI.sskForUSK().setDocName( "iptocountryv4-" + Version.buildNumber()); }
static FreenetURI checkEmptySSK(FreenetURI uri, String filename, ClientContext context) { if("SSK".equals(uri.getKeyType()) && uri.getDocName() == null && uri.getRoutingKey() == null) { if(filename == null || filename.equals("")) filename = "key"; // SSK@ = use a random SSK. InsertableClientSSK key = InsertableClientSSK.createRandom(context.random, ""); return key.getInsertURI().setDocName(filename); } else { return uri; } }
private FreenetURI setupFreenetUri() { FreenetURI sskKey = mock(FreenetURI.class); FreenetURI keyWithDocName = mock(FreenetURI.class); FreenetURI keyWithMetaStrings = mock(FreenetURI.class); when(keyWithDocName.setMetaString(eq(new String[] { "sone.xml" }))).thenReturn(keyWithMetaStrings); when(sskKey.setDocName(eq("Sone-" + CURRENT_EDITION))).thenReturn(keyWithDocName); when(sone.getRequestUri().setKeyType(eq("SSK"))).thenReturn(sskKey); return keyWithMetaStrings; }
/** * Returns the insert URI of this Sone. * * @return The insert URI of this Sone */ @Nullable public FreenetURI getInsertUri() { if (!isLocal()) { return null; } try { return new FreenetURI(((OwnIdentity) getIdentity()).getInsertUri()) .setDocName("Sone") .setMetaString(new String[0]) .setSuggestedEdition(latestEdition); } catch (MalformedURLException e) { throw new IllegalStateException(format("Own identity %s's insert URI is incorrect.", getIdentity()), e); } }
/** * Returns the request URI of this Sone. * * @return The request URI of this Sone */ @Nonnull public FreenetURI getRequestUri() { try { return new FreenetURI(getIdentity().getRequestUri()) .setKeyType("USK") .setDocName("Sone") .setMetaString(new String[0]) .setSuggestedEdition(latestEdition); } catch (MalformedURLException e) { throw new IllegalStateException( format("Identity %s's request URI is incorrect.", getIdentity()), e); } }
@Override public FreenetURI checkSource(String source) throws PluginNotFoundException { OfficialPluginDescription desc = node.getPluginManager().getOfficialPlugin(source); if(desc == null) throw new PluginNotFoundException("Not in the official plugins list: "+source); if(desc.uri != null) return desc.uri; else { return node.nodeUpdater.getURI().setDocName(source).setSuggestedEdition(desc.recommendedVersion).sskForUSK(); } }
FreenetURI uri = updateURI.setDocName(name).setSuggestedEdition(minVer); PluginJarUpdater updater = new PluginJarUpdater(this, uri, (int) minVer, -1, (plugin.essential ? (int)minVer : Integer.MAX_VALUE)
outsb.append("Insert URI: ").append(key.getInsertURI().toString(false, false)).append("\r\n"); outsb.append("Request URI: ").append(key.getURI().toString(false, false)).append("\r\n"); FreenetURI insertURI = key.getInsertURI().setDocName("testsite"); String fixedInsertURI = insertURI.toString(false, false); outsb.append("Note that you MUST add a filename to the end of the above URLs e.g.:\r\n").append(fixedInsertURI).append("\r\n");
private void setupSone(Sone sone, Class<? extends Identity> identityClass) { Identity identity = mock(identityClass); InsertableClientSSK clientSSK = createRandom(new DummyRandomSource(), "WoT"); when(identity.getRequestUri()).thenReturn(clientSSK.getURI().toString()); when(identity.getId()).thenReturn("identity"); when(sone.getId()).thenReturn("identity"); when(sone.getIdentity()).thenReturn(identity); requestUri = clientSSK.getURI().setKeyType("USK").setDocName("Sone"); when(sone.getRequestUri()).thenAnswer(new Answer<FreenetURI>() { @Override public FreenetURI answer(InvocationOnMock invocation) throws Throwable { return requestUri; } }); when(sone.getTime()) .thenReturn(currentTimeMillis() - DAYS.toMillis(1)); }
/** * {@inheritDoc} */ @Override protected void serviceRun() { while (!shouldStop()) { while (!shouldStop() && !fetching) { sleep(); } if (fetching) { core.lockSone(sone); FreenetURI soneUri = sone.getRequestUri().setKeyType("SSK").setDocName("Sone-" + currentEdition).setMetaString(new String[] { "sone.xml" }); System.out.println("URI: " + soneUri); Sone fetchedSone = soneDownloader.fetchSone(sone, soneUri, true); System.out.println("Sone: " + fetchedSone); lastFetchSuccessful = (fetchedSone != null); if (lastFetchSuccessful) { core.updateSone(fetchedSone, true); } fetching = false; } } }
@Before public void setupSone() { Sone sone = SoneDownloaderTest.this.sone; Identity identity = mock(Identity.class); InsertableClientSSK clientSSK = createRandom(new DummyRandomSource(), "WoT"); when(identity.getRequestUri()).thenReturn(clientSSK.getURI().toString()); when(identity.getId()).thenReturn("identity"); when(sone.getId()).thenReturn("identity"); when(sone.getIdentity()).thenReturn(identity); requestUri = clientSSK.getURI().setKeyType("USK").setDocName("Sone"); when(sone.getRequestUri()).thenAnswer(new Answer<FreenetURI>() { @Override public FreenetURI answer(InvocationOnMock invocation) throws Throwable { return requestUri; } }); when(sone.getTime()).thenReturn(currentTimeMillis() - DAYS.toMillis(1)); }
/** * Inserts the image data of the given {@link TemporaryImage} and returns * the given insert token that can be used to add listeners or cancel the * insert. * * @param temporaryImage * The temporary image data * @param image * The image * @param insertToken * The insert token * @throws SoneException * if the insert could not be started */ public void insertImage(TemporaryImage temporaryImage, Image image, InsertToken insertToken) throws SoneException { String filenameHint = image.getId() + "." + temporaryImage.getMimeType().substring(temporaryImage.getMimeType().lastIndexOf("/") + 1); InsertableClientSSK key = InsertableClientSSK.createRandom(node.random, ""); FreenetURI targetUri = key.getInsertURI().setDocName(filenameHint); InsertContext insertContext = client.getInsertContext(true); RandomAccessBucket bucket = new ArrayBucket(temporaryImage.getImageData()); insertToken.setBucket(bucket); ClientMetadata metadata = new ClientMetadata(temporaryImage.getMimeType()); InsertBlock insertBlock = new InsertBlock(bucket, metadata, targetUri); try { ClientPutter clientPutter = client.insert(insertBlock, null, false, insertContext, insertToken, RequestStarter.INTERACTIVE_PRIORITY_CLASS); insertToken.setClientPutter(clientPutter); } catch (InsertException ie1) { throw new SoneInsertException("Could not start image insert.", ie1); } }