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.*;
31 * A version of the RRset class overrides the standard security status.
33 public class SRRset extends RRset {
34 private SecurityStatus mSecurityStatus;
36 /** Create a new, blank SRRset. */
39 mSecurityStatus = new SecurityStatus();
43 * Create a new SRRset from an existing RRset. This SRRset will contain that
44 * same internal Record objects as the original RRset.
46 @SuppressWarnings("unchecked")
47 public SRRset(RRset r) {
50 for (Iterator i = r.rrs(); i.hasNext();) {
51 addRR((Record) i.next());
54 for (Iterator i = r.sigs(); i.hasNext();) {
55 addRR((Record) i.next());
60 * Return the current security status (generally: UNCHECKED, BOGUS, or
63 public int getSecurity() {
64 return getSecurityStatus();
68 * Return the current security status (generally: UNCHECKED, BOGUS, or
71 public byte getSecurityStatus() {
72 return mSecurityStatus.getStatus();
76 * Set the current security status for this SRRset. This status will be
77 * shared amongst all copies of this SRRset (created with cloneSRRset())
79 public void setSecurityStatus(byte status) {
80 mSecurityStatus.setStatus(status);
83 @SuppressWarnings("unchecked")
84 public Iterator<Record> rrs() {
85 return (Iterator<Record>) super.rrs();
88 @SuppressWarnings("unchecked")
89 public Iterator<RRSIGRecord> sigs() {
90 return (Iterator<RRSIGRecord>) super.sigs();
93 public int totalSize() {
96 for (Iterator<RRSIGRecord> i = sigs(); i.hasNext();) {
101 return size() + num_sigs;
105 * @return The total number of records (data + sigs) in the SRRset.
107 public int getNumRecords() {
111 public RRSIGRecord firstSig() {
112 for (Iterator<RRSIGRecord> i = sigs(); i.hasNext();) {
120 * @return true if this RRset has RRSIG records that cover data records.
121 * (i.e., RRSIG SRRsets return false)
123 public boolean isSigned() {
124 if (getType() == Type.RRSIG) {
128 return firstSig() != null;
132 * @return The "signer" name for this SRRset, if signed, or null if not.
134 public Name getSignerName() {
135 RRSIGRecord sig = (RRSIGRecord) firstSig();
141 return sig.getSigner();