org.springframework.security.remoting.dns
Class JndiDnsResolver

java.lang.Object
  extended by org.springframework.security.remoting.dns.JndiDnsResolver
All Implemented Interfaces:
DnsResolver

public class JndiDnsResolver
extends Object
implements DnsResolver

Implementation of DnsResolver which uses JNDI for the DNS queries. Uses an InitialContextFactory to get the JNDI DirContext. The default implementation will just create a new Context with the context factory com.sun.jndi.dns.DnsContextFactory

Since:
3.0
Version:
$Id: JndiDnsResolver.java 3862 2009-09-03 19:55:18Z ltaylor $
Author:
Mike Wiesner
See Also:
DnsResolver, InitialContextFactory

Constructor Summary
JndiDnsResolver()
           
 
Method Summary
 String resolveIpAddress(String hostname)
          Resolves the IP Address (A record) to the specified host name.
 String resolveServiceEntry(String serviceType, String domain)
          Resolves the host name for the specified service in the specified domain For example, if you need the host name for an LDAP server running in the domain springsource.com, you would call resolveServiceEntry("ldap", "springsource.com").
 String resolveServiceIpAddress(String serviceType, String domain)
          Resolves the host name for the specified service and then the IP Address for this host in one call.
 void setCtxFactory(InitialContextFactory ctxFactory)
          Allows to inject an own JNDI context factory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JndiDnsResolver

public JndiDnsResolver()
Method Detail

setCtxFactory

public void setCtxFactory(InitialContextFactory ctxFactory)
Allows to inject an own JNDI context factory.

Parameters:
ctxFactory - factory to use, when a DirContext is needed
See Also:
InitialDirContext, DirContext

resolveIpAddress

public String resolveIpAddress(String hostname)
Description copied from interface: DnsResolver
Resolves the IP Address (A record) to the specified host name. Throws DnsEntryNotFoundException if there is no record.

Specified by:
resolveIpAddress in interface DnsResolver
Parameters:
hostname - The hostname for which you need the IP Address
Returns:
IP Address as a String

resolveServiceEntry

public String resolveServiceEntry(String serviceType,
                                  String domain)
Description copied from interface: DnsResolver

Resolves the host name for the specified service in the specified domain

For example, if you need the host name for an LDAP server running in the domain springsource.com, you would call resolveServiceEntry("ldap", "springsource.com").

The DNS server needs to provide the service records for this, in the example above, it would look like this:

_ldap._tcp.springsource.com IN SRV 10 0 88 ldap.springsource.com.
The method will return the record with highest priority (which means the lowest number in the DNS record) and if there are more than one records with the same priority, it will return the one with the highest weight. You will find more informatione about DNS service records at Wikipedia.

Specified by:
resolveServiceEntry in interface DnsResolver
Parameters:
serviceType - The service type you are searching for, e.g. ldap, kerberos, ...
domain - The domain, in which you are searching for the service
Returns:
The hostname of the service

resolveServiceIpAddress

public String resolveServiceIpAddress(String serviceType,
                                      String domain)
Description copied from interface: DnsResolver
Resolves the host name for the specified service and then the IP Address for this host in one call.

Specified by:
resolveServiceIpAddress in interface DnsResolver
Parameters:
serviceType - The service type you are searching for, e.g. ldap, kerberos, ...
domain - The domain, in which you are searching for the service
Returns:
IP Address of the service
See Also:
DnsResolver.resolveServiceEntry(String, String), DnsResolver.resolveIpAddress(String)


Copyright © 2004-2009 SpringSource, Inc. All Rights Reserved.