001/*
002 * (C) Copyright 2010 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Robert Browning - initial implementation
018 *     Nuxeo - code review and integration
019 */
020package org.nuxeo.ecm.directory.ldap.dns;
021
022import java.util.List;
023
024import javax.naming.NamingException;
025
026/**
027 * Utility to fetch SRV records from a DNS server to get the list of available ldap servers from the DN representation
028 * of the domain.
029 * <p>
030 * See: http://en.wikipedia.org/wiki/SRV_record
031 *
032 * @author Robert Browning
033 */
034public interface DNSServiceResolver {
035
036    /**
037     * DNS Cache Expiry property
038     */
039    String DNS_CACHE_EXPIRY = "org.nuxeo.ecm.directory.ldap.dns.cache.expiry";
040
041    /**
042     * Prefix to locate LDAP service on DNS Server.
043     * <p>
044     * <b>service</b>: _ldap
045     * <p>
046     * <b>protocol</b>: _tcp
047     */
048    String LDAP_SERVICE_PREFIX = "_ldap._tcp";
049
050    /**
051     * Returns a list of LDAP servers for the specified domain by performing an SRV DNS lookup on _ldap._tcp.${domain}.
052     *
053     * @return the list of SRV dns entries
054     */
055    List<DNSServiceEntry> resolveLDAPDomainServers(final String domain) throws NamingException;
056
057    /**
058     * Returns a list of LDAP servers for the specified domain by performing an SRV DNS lookup using a custom DNS
059     * service prefix.
060     *
061     * @param prefix custom SRV prefix such as "_gc._tcp"
062     * @return the list of SRV dns entries
063     */
064    List<DNSServiceEntry> resolveLDAPDomainServers(final String domain, final String prefix) throws NamingException;
065
066}