001/*
002 * (C) Copyright 2010 Nuxeo SAS (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Robert Browning - initial implementation
016 *     Nuxeo - code review and integration
017 */
018package org.nuxeo.ecm.directory.ldap.dns;
019
020import java.util.List;
021
022import javax.naming.NamingException;
023
024/**
025 * Utility to fetch SRV records from a DNS server to get the list of available ldap servers from the DN representation
026 * of the domain.
027 * <p>
028 * See: http://en.wikipedia.org/wiki/SRV_record
029 *
030 * @author Robert Browning
031 */
032public interface DNSServiceResolver {
033
034    /**
035     * DNS Cache Expiry property
036     */
037    String DNS_CACHE_EXPIRY = "org.nuxeo.ecm.directory.ldap.dns.cache.expiry";
038
039    /**
040     * Prefix to locate LDAP service on DNS Server.
041     * <p>
042     * <b>service</b>: _ldap<br/>
043     * <b>protocol</b>: _tcp
044     */
045    String LDAP_SERVICE_PREFIX = "_ldap._tcp";
046
047    /**
048     * Returns a list of LDAP servers for the specified domain by performing an SRV DNS lookup on _ldap._tcp.${domain}.
049     *
050     * @param domain
051     * @return the list of SRV dns entries
052     * @throws NamingException
053     */
054    List<DNSServiceEntry> resolveLDAPDomainServers(final String domain) throws NamingException;
055
056    /**
057     * Returns a list of LDAP servers for the specified domain by performing an SRV DNS lookup using a custom DNS
058     * service prefix.
059     *
060     * @param domain
061     * @param prefix custom SRV prefix such as "_gc._tcp"
062     * @return the list of SRV dns entries
063     * @throws NamingException
064     */
065    List<DNSServiceEntry> resolveLDAPDomainServers(final String domain, final String prefix) throws NamingException;
066
067}