public String getGuessableKey() { return getDocName(); }
public static InsertableClientSSK create(FreenetURI uri) { if(!uri.getKeyType().equals("KSK")) throw new IllegalArgumentException(); return create(uri.getDocName()); }
@Override public String getPreferredFilename() { if(destFilename != null) return destFilename.getName(); if(uri != null && (uri.hasMetaStrings() || uri.getDocName() != null)) return uri.getPreferredFilename(); return null; }
public static BaseClientKey getBaseKey(FreenetURI origURI) throws MalformedURLException { String keyType = origURI.getKeyType(); if("CHK".equals(keyType)) return new ClientCHK(origURI); if("SSK".equals(keyType)) return new ClientSSK(origURI); if("KSK".equals(keyType)) return ClientKSK.create(origURI.getDocName()); if("USK".equals(keyType)) return USK.create(origURI); throw new MalformedURLException("Unknown keytype from "+origURI); }
public ClientSSK(FreenetURI origURI) throws MalformedURLException { this(origURI.getDocName(), origURI.getRoutingKey(), origURI.getExtra(), null, origURI.getCryptoKey()); if(!origURI.getKeyType().equalsIgnoreCase("SSK")) throw new MalformedURLException(); }
public FreenetURI turnMySSKIntoUSK(FreenetURI uri) { if(uri.getKeyType().equals("SSK") && Arrays.equals(uri.getRoutingKey(), pubKeyHash) && Arrays.equals(uri.getCryptoKey(), cryptoKey) && Arrays.equals(uri.getExtra(), ClientSSK.getExtraBytes(cryptoAlgorithm)) && uri.getDocName() != null && uri.getDocName().startsWith(siteName)) { String doc = uri.getDocName(); doc = doc.substring(siteName.length()); if(doc.length() < 2 || doc.charAt(0) != '-') return uri; doc = doc.substring(1); long edition; try { edition = Long.parseLong(doc); } catch (NumberFormatException e) { Logger.normal(this, "Trying to turn SSK back into USK: "+uri+" doc="+doc+" caught "+e, e); return uri; } if(!doc.equals(Long.toString(edition))) return uri; return new FreenetURI("USK", siteName, uri.getAllMetaStrings(), pubKeyHash, cryptoKey, ClientSSK.getExtraBytes(cryptoAlgorithm), edition); } return uri; }
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; } }
@Override public String getPreferredFilename() { FreenetURI uri = getFinalURI(); if(uri != null && (uri.hasMetaStrings() || uri.getDocName() != null)) return uri.getPreferredFilename(); uri = getTargetURI(); if(uri != null && (uri.hasMetaStrings() || uri.getDocName() != null)) return uri.getPreferredFilename(); return null; }
public static USK create(FreenetURI uri) throws MalformedURLException { if(!uri.isUSK()) throw new MalformedURLException("Not a USK"); return new USK(uri.getRoutingKey(), uri.getCryptoKey(), uri.getExtra(), uri.getDocName(), uri.getSuggestedEdition()); }
if(uri.getDocName() == null) throw new MalformedURLException("SSK URIs must have a document name (to avoid ambiguity)"); DSAGroup g = Global.DSAgroupBigA; return new InsertableClientSSK(uri.getDocName(), pkHash, pubKey, privKey, uri.getCryptoKey(), keyType);
Bucket data = result.asBucket(); String fnam = uri.getDocName(); fnam = sanitize(fnam); if(fnam.length() == 0) {
} catch (IdentifierCollisionException ee) { try { innerMakePersistentGlobalRequest(fetchURI, filterData, persistence, returnType, "FProxy:"+fetchURI.getDocName(), returnFilename, realTimeFlag); return; } catch (IdentifierCollisionException e) {
ctx, priorityClass, isMetadata, this.uri.getDocName() == null ? targetFilename : null, binaryBlob, core.clientContext, overrideSplitfileKey, -1);
@Test public void returnedUriHasCorrectDocNameAndMetaStrings() { FreenetURI uri = createRandom(new DummyRandomSource(), "test-0").getURI().uskForSSK(); assertThat(create(uri.toString()).getDocName(), is("Sone")); assertThat(create(uri.toString()).getAllMetaStrings(), is(new String[0])); }
ctx, priorityClass, isMetadata, this.uri.getDocName() == null ? targetFilename : null, binaryBlob, server.core.clientContext, message.overrideSplitfileCryptoKey, message.metadataThreshold);
if(furi.getDocName() != null) target = null; else