java.naming.factory.initial ==> DnsSecContextFactory ?
ralfhauser opened this issue · comments
E.g. in badpenguin.dkim, the following approach to DNS lookup is used:
Hashtable<String,String> env = new Hashtable<String,String>();
env.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory");
env.put("java.naming.provider.url", "dns://" + nameServer );
dnsCtx = new InitialDirContext(env);
...
Attributes attrs = null;
try {
attrs = dnsCtx.getAttributes(lookup, new String[] {"txt"});
} catch (NamingException e) {
...
Could your code be fit into something like
public class DnsSecContextFactory extends DnsContextFactory {
...
?
I don't know the API of DnsContextFactory. But if this is still supported in Java 9+ then why not give it a go?
It might be a good idea to implement this as a separate project though to support any implementation of Dnsjava's Resolver interface. The suggested DnssecContextFactory would then simply be a specific implementation taking care of the initialization (setting options, key loading).
There's basically nothing to reuse in DnsContextFactory
and it's in a private namespace that cannot be used in Java 9+.
A DnssecContextFactory
doesn't make much sense to me, while a DnsjavaContextFactory
could be useful. Which resolver type/class to use could be specified with a property in the env-Hashtable.
Implementing this would basically follow the JNDI DNS specification and API.