DNSUtil.java

  1. /**
  2.  *
  3.  * Copyright 2003-2005 Jive Software, 2016-2020 Florian Schmaus.
  4.  *
  5.  * Licensed under the Apache License, Version 2.0 (the "License");
  6.  * you may not use this file except in compliance with the License.
  7.  * You may obtain a copy of the License at
  8.  *
  9.  *     http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.jivesoftware.smack.util;

  18. import org.jivesoftware.smack.util.dns.DNSResolver;
  19. import org.jivesoftware.smack.util.dns.SmackDaneProvider;

  20. /**
  21.  * Utility class to perform DNS lookups for XMPP services.
  22.  *
  23.  * @author Matt Tucker
  24.  * @author Florian Schmaus
  25.  */
  26. public class DNSUtil {

  27.     private static DNSResolver dnsResolver = null;
  28.     private static SmackDaneProvider daneProvider;

  29.     /**
  30.      * Set the DNS resolver that should be used to perform DNS lookups.
  31.      *
  32.      * @param resolver TODO javadoc me please
  33.      */
  34.     public static void setDNSResolver(DNSResolver resolver) {
  35.         dnsResolver = Objects.requireNonNull(resolver);
  36.     }

  37.     /**
  38.      * Returns the current DNS resolved used to perform DNS lookups.
  39.      *
  40.      * @return the active DNSResolver
  41.      */
  42.     public static DNSResolver getDNSResolver() {
  43.         return dnsResolver;
  44.     }

  45.     /**
  46.      * Set the DANE provider that should be used when DANE is enabled.
  47.      *
  48.      * @param daneProvider TODO javadoc me please
  49.      */
  50.     public static void setDaneProvider(SmackDaneProvider daneProvider) {
  51.         DNSUtil.daneProvider = Objects.requireNonNull(daneProvider);
  52.     }

  53.     /**
  54.      * Returns the currently active DANE provider used when DANE is enabled.
  55.      *
  56.      * @return the active DANE provider
  57.      */
  58.     public static SmackDaneProvider getDaneProvider() {
  59.         return daneProvider;
  60.     }

  61. }