Home | History | Annotate | Download | only in DNS
      1 // Copyright (c) 1999-2004 Brian Wellington (bwelling (at) xbill.org)
      2 
      3 package org.xbill.DNS;
      4 
      5 import java.io.*;
      6 
      7 /**
      8  * Next SECure name - this record contains the following name in an
      9  * ordered list of names in the zone, and a set of types for which
     10  * records exist for this name.  The presence of this record in a response
     11  * signifies a negative response from a DNSSEC-signed zone.
     12  *
     13  * This replaces the NXT record.
     14  *
     15  * @author Brian Wellington
     16  * @author David Blacka
     17  */
     18 
     19 public class NSECRecord extends Record {
     20 
     21 private static final long serialVersionUID = -5165065768816265385L;
     22 
     23 private Name next;
     24 private TypeBitmap types;
     25 
     26 NSECRecord() {}
     27 
     28 Record
     29 getObject() {
     30 	return new NSECRecord();
     31 }
     32 
     33 /**
     34  * Creates an NSEC Record from the given data.
     35  * @param next The following name in an ordered list of the zone
     36  * @param types An array containing the types present.
     37  */
     38 public
     39 NSECRecord(Name name, int dclass, long ttl, Name next, int [] types) {
     40 	super(name, Type.NSEC, dclass, ttl);
     41 	this.next = checkName("next", next);
     42 	for (int i = 0; i < types.length; i++) {
     43 		Type.check(types[i]);
     44 	}
     45 	this.types = new TypeBitmap(types);
     46 }
     47 
     48 void
     49 rrFromWire(DNSInput in) throws IOException {
     50 	next = new Name(in);
     51 	types = new TypeBitmap(in);
     52 }
     53 
     54 void
     55 rrToWire(DNSOutput out, Compression c, boolean canonical) {
     56 	// Note: The next name is not lowercased.
     57 	next.toWire(out, null, false);
     58 	types.toWire(out);
     59 }
     60 
     61 void
     62 rdataFromString(Tokenizer st, Name origin) throws IOException {
     63 	next = st.getName(origin);
     64 	types = new TypeBitmap(st);
     65 }
     66 
     67 /** Converts rdata to a String */
     68 String
     69 rrToString()
     70 {
     71 	StringBuffer sb = new StringBuffer();
     72 	sb.append(next);
     73 	if (!types.empty()) {
     74 		sb.append(' ');
     75 		sb.append(types.toString());
     76 	}
     77 	return sb.toString();
     78 }
     79 
     80 /** Returns the next name */
     81 public Name
     82 getNext() {
     83 	return next;
     84 }
     85 
     86 /** Returns the set of types defined for this name */
     87 public int []
     88 getTypes() {
     89 	return types.toArray();
     90 }
     91 
     92 /** Returns whether a specific type is in the set of types. */
     93 public boolean
     94 hasType(int type) {
     95 	return types.contains(type);
     96 }
     97 
     98 }
     99