1// Copyright (c) 1999-2004 Brian Wellington (bwelling@xbill.org) 2 3package org.xbill.DNS; 4 5import 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 19public class NSECRecord extends Record { 20 21private static final long serialVersionUID = -5165065768816265385L; 22 23private Name next; 24private TypeBitmap types; 25 26NSECRecord() {} 27 28Record 29getObject() { 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 */ 38public 39NSECRecord(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 48void 49rrFromWire(DNSInput in) throws IOException { 50 next = new Name(in); 51 types = new TypeBitmap(in); 52} 53 54void 55rrToWire(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 61void 62rdataFromString(Tokenizer st, Name origin) throws IOException { 63 next = st.getName(origin); 64 types = new TypeBitmap(st); 65} 66 67/** Converts rdata to a String */ 68String 69rrToString() 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 */ 81public Name 82getNext() { 83 return next; 84} 85 86/** Returns the set of types defined for this name */ 87public int [] 88getTypes() { 89 return types.toArray(); 90} 91 92/** Returns whether a specific type is in the set of types. */ 93public boolean 94hasType(int type) { 95 return types.contains(type); 96} 97 98} 99