-
Notifications
You must be signed in to change notification settings - Fork 264
Expand file tree
/
Copy pathNSECRecord.java
More file actions
86 lines (74 loc) · 2.27 KB
/
Copy pathNSECRecord.java
File metadata and controls
86 lines (74 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 1999-2004 Brian Wellington (bwelling@xbill.org)
package org.xbill.DNS;
import java.io.IOException;
/**
* Next SECure name - this record contains the following name in an ordered list of names in the
* zone, and a set of types for which records exist for this name. The presence of this record in a
* response signifies a negative response from a DNSSEC-signed zone.
*
* <p>This replaces the NXT record.
*
* @author Brian Wellington
* @author David Blacka
* @see <a href="https://datatracker.ietf.org/doc/html/rfc4034">RFC 4034: Resource Records for the
* DNS Security Extensions</a>
*/
public class NSECRecord extends Record {
private Name next;
private TypeBitmap types;
NSECRecord() {}
/**
* Creates an NSEC Record from the given data.
*
* @param next The following name in an ordered list of the zone
* @param types An array containing the types present.
*/
public NSECRecord(Name name, int dclass, long ttl, Name next, int[] types) {
super(name, Type.NSEC, dclass, ttl);
this.next = checkName("next", next);
for (int value : types) {
Type.check(value);
}
this.types = new TypeBitmap(types);
}
@Override
protected void rrFromWire(DNSInput in) throws IOException {
next = new Name(in);
types = new TypeBitmap(in);
}
@Override
protected void rrToWire(DNSOutput out, Compression c, boolean canonical) {
// Note: The next name is not lowercased.
next.toWire(out, null, false);
types.toWire(out);
}
@Override
protected void rdataFromString(Tokenizer st, Name origin) throws IOException {
next = st.getName(origin);
types = new TypeBitmap(st);
}
/** Converts rdata to a String */
@Override
protected String rrToString() {
StringBuilder sb = new StringBuilder();
sb.append(next);
if (!types.empty()) {
sb.append(' ');
sb.append(types.toString());
}
return sb.toString();
}
/** Returns the next name */
public Name getNext() {
return next;
}
/** Returns the set of types defined for this name */
public int[] getTypes() {
return types.toArray();
}
/** Returns whether a specific type is in the set of types. */
public boolean hasType(int type) {
return types.contains(type);
}
}