Exemplo n.º 1
0
  private Record parseRR(MyStringTokenizer st, boolean useLast, Record last, Name origin)
      throws IOException {
    Name name;
    int ttl;
    short type, dclass;

    if (!useLast) name = new Name(st.nextToken(), origin);
    else name = last.getName();

    String s = st.nextToken();

    try {
      ttl = TTL.parseTTL(s);
      s = st.nextToken();
    } catch (NumberFormatException e) {
      if (!useLast || last == null) ttl = defaultTTL;
      else ttl = last.getTTL();
    }

    if ((dclass = DClass.value(s)) > 0) s = st.nextToken();
    else dclass = DClass.IN;

    if ((type = Type.value(s)) < 0) throw new IOException("Parse error");

    return Record.fromString(name, type, dclass, ttl, st, origin);
  }
Exemplo n.º 2
0
 public TypeBitmap(Tokenizer st) throws IOException {
   this();
   while (true) {
     Tokenizer.Token t = st.get();
     if (!t.isString()) break;
     int typecode = Type.value(t.value);
     if (typecode < 0) {
       throw st.exception("Invalid type: " + t.value);
     }
     types.add(Mnemonic.toInteger(typecode));
   }
   st.unget();
 }
Exemplo n.º 3
0
 Record rdataFromString(Name name, short dclass, int ttl, MyStringTokenizer st, Name origin)
     throws TextParseException {
   SIGRecord rec = new SIGRecord(name, dclass, ttl);
   rec.covered = Type.value(st.nextToken());
   rec.alg = Byte.parseByte(st.nextToken());
   rec.labels = Byte.parseByte(st.nextToken());
   rec.origttl = TTL.parseTTL(st.nextToken());
   rec.expire = parseDate(st.nextToken());
   rec.timeSigned = parseDate(st.nextToken());
   rec.footprint = (short) Integer.parseInt(st.nextToken());
   rec.signer = Name.fromString(st.nextToken(), origin);
   if (st.hasMoreTokens()) rec.signature = base64.fromString(st.remainingTokens());
   return rec;
 }
Exemplo n.º 4
0
 protected static Record rdataFromString(SIGBase rec, Tokenizer st, Name origin)
     throws IOException {
   String typeString = st.getString();
   int covered = Type.value(typeString);
   if (covered < 0) throw st.exception("Invalid type: " + typeString);
   rec.covered = covered;
   String algString = st.getString();
   int alg = DNSSEC.Algorithm.value(algString);
   if (alg < 0) throw st.exception("Invalid algorithm: " + algString);
   rec.alg = alg;
   rec.labels = st.getUInt8();
   rec.origttl = st.getTTL();
   rec.expire = FormattedTime.parse(st.getString());
   rec.timeSigned = FormattedTime.parse(st.getString());
   rec.footprint = st.getUInt16();
   rec.signer = st.getName(origin);
   rec.signature = st.getBase64();
   return rec;
 }