1 /***************************** -*- Java -*- ********************************\
3 * Copyright (c) 2009 VeriSign, Inc. All rights reserved. *
5 * This software is provided solely in connection with the terms of the *
6 * license agreement. Any other use without the prior express written *
7 * permission of VeriSign is completely prohibited. The software and *
8 * documentation are "Commercial Items", as that term is defined in 48 *
9 * C.F.R. section 2.101, consisting of "Commercial Computer Software" and *
10 * "Commercial Computer Software Documentation" as such terms are defined *
11 * in 48 C.F.R. section 252.227-7014(a)(5) and 48 C.F.R. section *
12 * 252.227-7014(a)(1), and used in 48 C.F.R. section 12.212 and 48 C.F.R. *
13 * section 227.7202, as applicable. Pursuant to the above and other *
14 * relevant sections of the Code of Federal Regulations, as applicable, *
15 * VeriSign's publications, commercial computer software, and commercial *
16 * computer software documentation are distributed and licensed to United *
17 * States Government end users with only those rights as granted to all *
18 * other end users, according to the terms and conditions contained in the *
19 * license agreement(s) that accompany the products and software *
22 \***************************************************************************/
24 package com.verisign.tat.dnssec;
26 import org.xbill.DNS.*;
32 * A version of the RRset class overrides the standard security status.
34 public class SRRset extends RRset {
35 private SecurityStatus mSecurityStatus;
37 /** Create a new, blank SRRset. */
40 mSecurityStatus = new SecurityStatus();
44 * Create a new SRRset from an existing RRset. This SRRset will contain that
45 * same internal Record objects as the original RRset.
47 @SuppressWarnings("unchecked")
48 public SRRset(RRset r) {
51 for (Iterator i = r.rrs(); i.hasNext();) {
52 addRR((Record) i.next());
55 for (Iterator i = r.sigs(); i.hasNext();) {
56 addRR((Record) i.next());
61 * Return the current security status (generally: UNCHECKED, BOGUS, or
64 public int getSecurity() {
65 return getSecurityStatus();
69 * Return the current security status (generally: UNCHECKED, BOGUS, or
72 public byte getSecurityStatus() {
73 return mSecurityStatus.getStatus();
77 * Set the current security status for this SRRset. This status will be
78 * shared amongst all copies of this SRRset (created with cloneSRRset())
80 public void setSecurityStatus(byte status) {
81 mSecurityStatus.setStatus(status);
84 @SuppressWarnings("unchecked")
85 public Iterator<Record> rrs() {
86 return (Iterator<Record>) super.rrs();
89 @SuppressWarnings("unchecked")
90 public Iterator<RRSIGRecord> sigs() {
91 return (Iterator<RRSIGRecord>) super.sigs();
94 public int totalSize() {
97 for (Iterator<RRSIGRecord> i = sigs(); i.hasNext();) {
102 return size() + num_sigs;
106 * @return The total number of records (data + sigs) in the SRRset.
108 public int getNumRecords() {
112 public RRSIGRecord firstSig() {
113 for (Iterator<RRSIGRecord> i = sigs(); i.hasNext();) {
121 * @return true if this RRset has RRSIG records that cover data records.
122 * (i.e., RRSIG SRRsets return false)
124 public boolean isSigned() {
125 if (getType() == Type.RRSIG) {
129 return firstSig() != null;
133 * @return The "signer" name for this SRRset, if signed, or null if not.
135 public Name getSignerName() {
136 RRSIGRecord sig = (RRSIGRecord) firstSig();
142 return sig.getSigner();