001/*
002 * Copyright 2015-2024 the original author or authors
003 *
004 * This software is licensed under the Apache License, Version 2.0,
005 * the GNU Lesser General Public License version 2 or later ("LGPL")
006 * and the WTFPL.
007 * You may choose either license to govern your use of this software only
008 * upon the condition that you accept all of the terms of either
009 * the Apache License 2.0, the LGPL 2.1+ or the WTFPL.
010 */
011package org.minidns.dnssec;
012
013import java.util.Collections;
014import java.util.Set;
015
016import org.minidns.dnsmessage.DnsMessage;
017import org.minidns.dnsqueryresult.DnsQueryResult;
018import org.minidns.record.RRSIG;
019import org.minidns.record.Record;
020
021public class DnssecQueryResult {
022
023    public final DnsMessage synthesizedResponse;
024    public final DnsQueryResult dnsQueryResult;
025
026    private final Set<Record<RRSIG>> signatures;
027    private final Set<DnssecUnverifiedReason> dnssecUnverifiedReasons;
028
029    DnssecQueryResult(DnsMessage synthesizedResponse, DnsQueryResult dnsQueryResult, Set<Record<RRSIG>> signatures,
030            Set<DnssecUnverifiedReason> dnssecUnverifiedReasons) {
031        this.synthesizedResponse = synthesizedResponse;
032        this.dnsQueryResult = dnsQueryResult;
033        this.signatures = Collections.unmodifiableSet(signatures);
034        if (dnssecUnverifiedReasons == null) {
035            this.dnssecUnverifiedReasons = Collections.emptySet();
036        } else {
037            this.dnssecUnverifiedReasons = Collections.unmodifiableSet(dnssecUnverifiedReasons);
038        }
039    }
040
041    public boolean isAuthenticData() {
042        return dnssecUnverifiedReasons.isEmpty();
043    }
044
045    public Set<Record<RRSIG>> getSignatures() {
046        return signatures;
047    }
048
049    public Set<DnssecUnverifiedReason> getUnverifiedReasons() {
050        return dnssecUnverifiedReasons;
051    }
052
053}