001/** 002 * 003 * Copyright 2003-2005 Jive Software, 2016-2020 Florian Schmaus. 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.jivesoftware.smack.util; 018 019import org.jivesoftware.smack.util.dns.DNSResolver; 020import org.jivesoftware.smack.util.dns.SmackDaneProvider; 021 022/** 023 * Utility class to perform DNS lookups for XMPP services. 024 * 025 * @author Matt Tucker 026 * @author Florian Schmaus 027 */ 028public class DNSUtil { 029 030 private static DNSResolver dnsResolver = null; 031 private static SmackDaneProvider daneProvider; 032 033 /** 034 * Set the DNS resolver that should be used to perform DNS lookups. 035 * 036 * @param resolver TODO javadoc me please 037 */ 038 public static void setDNSResolver(DNSResolver resolver) { 039 dnsResolver = Objects.requireNonNull(resolver); 040 } 041 042 /** 043 * Returns the current DNS resolved used to perform DNS lookups. 044 * 045 * @return the active DNSResolver 046 */ 047 public static DNSResolver getDNSResolver() { 048 return dnsResolver; 049 } 050 051 /** 052 * Set the DANE provider that should be used when DANE is enabled. 053 * 054 * @param daneProvider TODO javadoc me please 055 */ 056 public static void setDaneProvider(SmackDaneProvider daneProvider) { 057 DNSUtil.daneProvider = Objects.requireNonNull(daneProvider); 058 } 059 060 /** 061 * Returns the currently active DANE provider used when DANE is enabled. 062 * 063 * @return the active DANE provider 064 */ 065 public static SmackDaneProvider getDaneProvider() { 066 return daneProvider; 067 } 068 069}