コード例 #1
0
ファイル: Record.java プロジェクト: jonbodner/hopper
 /** Converts a Record into a String representation */
 public String toString() {
   StringBuilder sb = new StringBuilder();
   sb.append(name);
   if (sb.length() < 8) {
     sb.append("\t");
   }
   if (sb.length() < 16) {
     sb.append("\t");
   }
   sb.append("\t");
   if (Options.check("BINDTTL")) {
     sb.append(TTL.format(ttl));
   } else {
     sb.append(ttl);
   }
   sb.append("\t");
   if (dclass != DClass.IN || !Options.check("noPrintIN")) {
     sb.append(dclass.getName());
     sb.append("\t");
   }
   sb.append(Type.string(type));
   String rdata = rrToString();
   if (!rdata.equals("")) {
     sb.append("\t");
     sb.append(rdata);
   }
   return sb.toString();
 }
コード例 #2
0
ファイル: SIG0.java プロジェクト: rinkymangal2010/hopper
  /**
   * Sign a message with SIG(0). The DNS key and private key must refer to the same underlying
   * cryptographic key.
   *
   * @param message The message to be signed
   * @param key The DNSKEY record to use as part of signing
   * @param privkey The PrivateKey to use when signing
   * @param previous If this message is a response, the SIG(0) from the query
   */
  public static void signMessage(
      Message message, KEYRecord key, PrivateKey privkey, SIGRecord previous)
      throws DNSSEC.DNSSECException {

    int validity = Options.intValue("sig0validity");
    if (validity < 0) {
      validity = VALIDITY;
    }

    long now = System.currentTimeMillis();
    Date timeSigned = new Date(now);
    Date timeExpires = new Date(now + validity * 1000);

    SIGRecord sig = DNSSEC.signMessage(message, previous, key, privkey, timeSigned, timeExpires);

    message.addRecord(sig, Section.ADDITIONAL);
  }