Enable cname resolution when realm is specified in connection
* Enable cname resolution when realm is specified in connection
properties.
* Logging
* Wording
@@ -149,22 +149,33 @@ abstract class SSPIAuthentication {
String dnsName = m.group(1);
String portOrInstance = m.group(2);
+ try {
if (null == realm || realm.trim().isEmpty()) {
RealmValidator realmValidator = getRealmValidator();
realm = findRealmFromHostname(realmValidator, dnsName);
if (null == realm && allowHostnameCanonicalization) {
+ if (logger.isLoggable(Level.FINER)) {
+ logger.finer("Attempt to derive realm using canonical host name with InetAddress");
+ }
// We failed, try with canonical host name to find a better match
- try {
String canonicalHostName = InetAddress.getByName(dnsName).getCanonicalHostName();
realm = findRealmFromHostname(realmValidator, canonicalHostName);
- // match means hostname is correct (eg if server name was an IP) so override dnsName as well
+ // Match means hostname is correct (eg if server name was an IP) so override dnsName as well
dnsName = canonicalHostName;
- } catch (UnknownHostException e) {
- // ignored, cannot canonicalize
+ }
+ } else {
+ if (allowHostnameCanonicalization) {
if (logger.isLoggable(Level.FINER)) {
- logger.finer("Could not canonicalize host name. " + e.toString());
+ logger.finer("Since realm is provided, try to resolve canonical host name to host name with InetAddress");
+ }
+ // Realm was provided, try to resolve cname to hostname
+ dnsName = InetAddress.getByName(dnsName).getCanonicalHostName();
}
}
+ } catch (UnknownHostException e) {
+ // Ignored, cannot canonicalize
+ if (logger.isLoggable(Level.FINER)) {
+ logger.finer("Could not canonicalize host name. " + e.toString());
}
}
