public String toString(boolean prefix, boolean pureAscii) {
    if (keyType == null) {
      // Not activated or something...
      if (logMINOR)
        Logger.minor(this, "Not activated?? in toString(" + prefix + "," + pureAscii + ")");
      return null;
    }
    StringBuilder b;
    if (prefix) b = new StringBuilder("freenet:");
    else b = new StringBuilder();

    b.append(keyType).append('@');

    if (!"KSK".equals(keyType)) {
      if (routingKey != null) b.append(Base64.encode(routingKey));
      if (cryptoKey != null) b.append(',').append(Base64.encode(cryptoKey));
      if (extra != null) b.append(',').append(Base64.encode(extra));
      if (docName != null) b.append('/');
    }

    if (docName != null) b.append(URLEncoder.encode(docName, "/", pureAscii));
    if (keyType.equals("USK")) {
      b.append('/');
      b.append(suggestedEdition);
    }
    if (metaStr != null)
      for (int i = 0; i < metaStr.length; i++) {
        b.append('/').append(URLEncoder.encode(metaStr[i], "/", pureAscii));
      }
    return b.toString();
  }
 public String getPreferredFilename() {
   if (logMINOR) Logger.minor(this, "Getting preferred filename for " + this);
   ArrayList<String> names = new ArrayList<String>();
   if (keyType != null
       && (keyType.equals("KSK") || keyType.equals("SSK") || keyType.equals("USK"))) {
     if (logMINOR) Logger.minor(this, "Adding docName: " + docName);
     names.add(docName);
     if (keyType.equals("USK")) names.add(Long.toString(suggestedEdition));
   }
   if (metaStr != null)
     for (int i = 0; i < metaStr.length; i++) {
       if (logMINOR) Logger.minor(this, "Adding metaString " + i + ": " + metaStr[i]);
       names.add(metaStr[i]);
     }
   StringBuilder out = new StringBuilder();
   for (int i = 0; i < names.size(); i++) {
     String s = names.get(i);
     if (logMINOR) Logger.minor(this, "name " + i + " = " + s);
     s = FileUtil.sanitize(s);
     if (logMINOR) Logger.minor(this, "Sanitized name " + i + " = " + s);
     if (s.length() > 0) {
       if (out.length() > 0) out.append('-');
       out.append(s);
     }
   }
   if (logMINOR) Logger.minor(this, "out = " + out.toString());
   if (out.length() == 0) {
     if (routingKey != null) {
       if (logMINOR) Logger.minor(this, "Returning base64 encoded routing key");
       return Base64.encode(routingKey);
     }
     return "unknown";
   }
   return out.toString();
 }
 // TODO: Replace with IdentityID.constructFromURI
 public static String getIDFromURI(FreenetURI uri) {
   /* WARNING: This is a copy of the code of plugins.WoT.Identity. Freetalk is not allowed to have its own custom IDs, you cannot change
    * this code here. */
   return Base64.encode(uri.getRoutingKey());
 }
Beispiel #4
0
 @Override
 public String toString() {
   return super.toString() + '@' + Base64.encode(routingKey) + ':' + Integer.toHexString(hash);
 }