diff options
author | Ingo Bauersachs <ingo@jitsi.org> | 2011-12-19 16:28:54 +0000 |
---|---|---|
committer | Ingo Bauersachs <ingo@jitsi.org> | 2011-12-19 16:28:54 +0000 |
commit | d931f8507e6c847dc1ae7052e1edd0d4d42415e4 (patch) | |
tree | 25e2967f4f955825e4175b66f97f6b452873650e /src/net/java/sip/communicator/impl | |
parent | 936e6cbd5287262f04d36d12bb822cdc192e6840 (diff) | |
download | jitsi-d931f8507e6c847dc1ae7052e1edd0d4d42415e4.zip jitsi-d931f8507e6c847dc1ae7052e1edd0d4d42415e4.tar.gz jitsi-d931f8507e6c847dc1ae7052e1edd0d4d42415e4.tar.bz2 |
Make protocols aware of DNSSEC exceptions
Diffstat (limited to 'src/net/java/sip/communicator/impl')
15 files changed, 158 insertions, 52 deletions
diff --git a/src/net/java/sip/communicator/impl/netaddr/NetworkAddressManagerServiceImpl.java b/src/net/java/sip/communicator/impl/netaddr/NetworkAddressManagerServiceImpl.java index 0590c0c..d8238c9 100644 --- a/src/net/java/sip/communicator/impl/netaddr/NetworkAddressManagerServiceImpl.java +++ b/src/net/java/sip/communicator/impl/netaddr/NetworkAddressManagerServiceImpl.java @@ -18,6 +18,7 @@ import net.java.sip.communicator.service.netaddr.*; import net.java.sip.communicator.service.netaddr.event.*; import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.NetworkUtils; +import net.java.sip.communicator.util.dns.*; import org.ice4j.*; import org.ice4j.ice.*; @@ -639,6 +640,11 @@ public class NetworkAddressManagerServiceImpl logger.info(domainName + " seems to be causing parse problems", e); srvrAddress = null; } + catch (DnssecException e) + { + logger.warn("DNSSEC validation for " + domainName + + " STUN/TURN failed.", e); + } if(srvrAddress != null) { diff --git a/src/net/java/sip/communicator/impl/netaddr/netaddr.manifest.mf b/src/net/java/sip/communicator/impl/netaddr/netaddr.manifest.mf index 2488278..eb983c7 100644 --- a/src/net/java/sip/communicator/impl/netaddr/netaddr.manifest.mf +++ b/src/net/java/sip/communicator/impl/netaddr/netaddr.manifest.mf @@ -7,6 +7,7 @@ System-Bundle: yes Import-Package: net.java.sip.communicator.service.configuration, net.java.sip.communicator.service.packetlogging, net.java.sip.communicator.util, + net.java.sip.communicator.util.dns, net.java.sip.communicator.service.sysactivity, net.java.sip.communicator.service.sysactivity.event, org.osgi.framework, diff --git a/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderServiceIcqImpl.java b/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderServiceIcqImpl.java index c2c1e8d..7bf77e3 100644 --- a/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderServiceIcqImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderServiceIcqImpl.java @@ -13,6 +13,7 @@ import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.util.*; import net.kano.joscar.flap.*; import net.kano.joscar.flapcmd.*; +import net.kano.joscar.net.*; import net.kano.joscar.snaccmd.auth.*; import net.kano.joustsim.*; import net.kano.joustsim.oscar.*; @@ -142,18 +143,6 @@ public class ProtocolProviderServiceIcqImpl /** * Converts the specified joust sim connection state to a corresponding * RegistrationState. - * @param jsState the joust sim connection state. - * @return a RegistrationState corresponding best to the specified - * joustSimState. - */ - private RegistrationState joustSimStateToRegistrationState(State jsState) - { - return joustSimStateToRegistrationState(jsState, null); - } - - /** - * Converts the specified joust sim connection state to a corresponding - * RegistrationState. * @param joustSimConnState the joust sim connection state. * @param joustSimConnStateInfo additional stateinfo if available (may be * null) @@ -757,13 +746,28 @@ public class ProtocolProviderServiceIcqImpl if (logger.isDebugEnabled()) logger.debug("The aim Connection was disconnected!"); } - else - if(newState == State.FAILED) + else if(newState == State.FAILED) + { + // assume that a failure during connect&resolve is a DNSSEC + // validation error + if (oldState == State.CONNECTINGAUTH && + conn.getLoginService() != null && + conn.getLoginService().getOscarConnection() != null && + conn.getLoginService().getOscarConnection() + .getConnectionState() == ClientConn.STATE_RESOLVING + ) { - if (logger.isDebugEnabled()) - logger.debug("The aim Connection failed! " - + event.getNewStateInfo()); + fireRegistrationStateChanged( + getRegistrationState(), + RegistrationState.UNREGISTERED, + RegistrationStateChangeEvent.REASON_USER_REQUEST, + "Disconnected due to assumed DNSSEC failure"); + return; } + else if (logger.isDebugEnabled()) + logger.debug("The aim Connection failed! " + + event.getNewStateInfo()); + } if(event.getNewStateInfo() instanceof LoginFailureStateInfo) { diff --git a/src/net/java/sip/communicator/impl/protocol/icq/icq.provider.manifest.mf b/src/net/java/sip/communicator/impl/protocol/icq/icq.provider.manifest.mf index 01c3547..8fe197d 100644 --- a/src/net/java/sip/communicator/impl/protocol/icq/icq.provider.manifest.mf +++ b/src/net/java/sip/communicator/impl/protocol/icq/icq.provider.manifest.mf @@ -10,6 +10,7 @@ Import-Package: org.osgi.framework, net.java.sip.communicator.service.configuration, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, + net.java.sip.communicator.util.dns, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.icqconstants, net.java.sip.communicator.service.protocol.aimconstants, diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java index 309bd0e..17943c7 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java @@ -20,6 +20,7 @@ import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.service.protocol.jabberconstants.*; import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.dns.*; import net.java.sip.communicator.impl.protocol.jabber.extensions.jingle.*; import net.java.sip.communicator.impl.protocol.jabber.extensions.jingleinfo.*; import net.java.sip.communicator.impl.protocol.jabber.extensions.gtalk.*; @@ -576,6 +577,8 @@ public class ProtocolProviderServiceJabberImpl Roster.setDefaultSubscriptionMode(Roster.SubscriptionMode.manual); ConnectState state; + //[0] = hadDnsSecException + boolean[] hadDnsSecException = new boolean[]{false}; // try connecting with auto-detection if enabled boolean isServerOverriden = @@ -584,8 +587,13 @@ public class ProtocolProviderServiceJabberImpl if(!isServerOverriden) { - state = connectUsingSRVRecords( - serviceName, password, serviceName); + state = connectUsingSRVRecords(serviceName, password, + serviceName, hadDnsSecException); + if(hadDnsSecException[0]) + { + setDnssecLoginFailure(); + return; + } if(state == ConnectState.ABORT_CONNECTING || state == ConnectState.STOP_TRYING) return; @@ -596,13 +604,19 @@ public class ProtocolProviderServiceJabberImpl String customXMPPDomain = getAccountID() .getAccountPropertyString("CUSTOM_XMPP_DOMAIN"); - if(customXMPPDomain != null) + if(customXMPPDomain != null && !hadDnsSecException[0]) { state = connectUsingSRVRecords( - customXMPPDomain, password, serviceName); + customXMPPDomain, password, serviceName, + hadDnsSecException); + if(hadDnsSecException[0]) + { + setDnssecLoginFailure(); + return; + } if(state == ConnectState.ABORT_CONNECTING || state == ConnectState.STOP_TRYING) - return; + return; } // connect with specified server name @@ -625,6 +639,13 @@ public class ProtocolProviderServiceJabberImpl { logger.error("Domain not resolved", e); } + catch (DnssecException e) + { + logger.error("DNSSEC failure for overridden server", e); + setDnssecLoginFailure(); + return; + } + if (addrs == null || addrs.length == 0) { fireRegistrationStateChanged( @@ -633,37 +654,52 @@ public class ProtocolProviderServiceJabberImpl RegistrationStateChangeEvent.REASON_SERVER_NOT_FOUND, "No server addresses found"); } - - for (InetSocketAddress isa : addrs) + else { - try - { - state = connectAndLogin(isa, password, serviceName); - if(state == ConnectState.ABORT_CONNECTING - || state == ConnectState.STOP_TRYING) - return; - } - catch(XMPPException ex) + for (InetSocketAddress isa : addrs) { - disconnectAndCleanConnection(); - if(isAuthenticationFailed(ex)) - throw ex; + try + { + state = connectAndLogin(isa, password, + serviceName); + if(state == ConnectState.ABORT_CONNECTING + || state == ConnectState.STOP_TRYING) + return; + } + catch(XMPPException ex) + { + disconnectAndCleanConnection(); + if(isAuthenticationFailed(ex)) + throw ex; + } } } } } + private void setDnssecLoginFailure() + { + eventDuringLogin = new RegistrationStateChangeEvent( + this, + getRegistrationState(), + RegistrationState.UNREGISTERED, + RegistrationStateChangeEvent.REASON_USER_REQUEST, + "No usable host found due to DNSSEC failures"); + } + /** * Connects using the domain specified and its SRV records. * @param domain the domain to use * @param password the password of the user * @param serviceName the domain name of the user's login + * @param dnssecState state of possible received DNSSEC exceptions * @return whether to continue trying or stop. */ private ConnectState connectUsingSRVRecords( String domain, String password, - String serviceName) + String serviceName, + boolean[] dnssecState) throws XMPPException { // check to see is there SRV records for this server domain @@ -677,6 +713,11 @@ public class ProtocolProviderServiceJabberImpl { logger.error("SRV record not resolved", e); } + catch (DnssecException e) + { + logger.error("DNSSEC failure for SRV lookup", e); + dnssecState[0] = true; + } if(srvRecords != null) { @@ -695,14 +736,21 @@ public class ProtocolProviderServiceJabberImpl { logger.error("Invalid SRV record target", e); } - if (addrs == null) + catch (DnssecException e) + { + logger.error("DNSSEC failure for A/AAAA lookup of SRV", e); + dnssecState[0] = true; + } + if (addrs == null || addrs.length == 0) continue; for (InetSocketAddress isa : addrs) { try { - return connectAndLogin(isa, password, serviceName); + ConnectState state = connectAndLogin( + isa, password, serviceName); + return state; } catch(XMPPException ex) { @@ -2381,6 +2429,11 @@ public class ProtocolProviderServiceJabberImpl logger.info("Failed to get SRV records for XMPP domain"); return false; } + catch (DnssecException e) + { + logger.error("DNSSEC failure while checking for google domains", e); + return false; + } if(srvRecords == null) { diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/jabber.provider.manifest.mf b/src/net/java/sip/communicator/impl/protocol/jabber/jabber.provider.manifest.mf index 91983bf..fb2c083 100755..100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/jabber.provider.manifest.mf +++ b/src/net/java/sip/communicator/impl/protocol/jabber/jabber.provider.manifest.mf @@ -34,6 +34,7 @@ Import-Package: org.osgi.framework, net.java.sip.communicator.service.configuration, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, + net.java.sip.communicator.util.dns, net.java.sip.communicator.service.packetlogging, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.jabberconstants, diff --git a/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderServiceMsnImpl.java b/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderServiceMsnImpl.java index 7edfd98..226081c 100644 --- a/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderServiceMsnImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderServiceMsnImpl.java @@ -12,6 +12,7 @@ import java.nio.channels.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.dns.*; import net.sf.jml.*; import net.sf.jml.event.*; import net.sf.jml.exception.*; @@ -229,6 +230,14 @@ public class ProtocolProviderServiceMsnImpl RegistrationStateChangeEvent.REASON_SERVER_NOT_FOUND, null); } + catch(DnssecRuntimeException ex) + { + fireRegistrationStateChanged( + getRegistrationState(), + RegistrationState.UNREGISTERED, + RegistrationStateChangeEvent.REASON_USER_REQUEST, + null); + } } } diff --git a/src/net/java/sip/communicator/impl/protocol/msn/msn.provider.manifest.mf b/src/net/java/sip/communicator/impl/protocol/msn/msn.provider.manifest.mf index e079cc4..b7c7a2d 100755..100644 --- a/src/net/java/sip/communicator/impl/protocol/msn/msn.provider.manifest.mf +++ b/src/net/java/sip/communicator/impl/protocol/msn/msn.provider.manifest.mf @@ -33,6 +33,7 @@ Import-Package: org.apache.commons.logging, net.java.sip.communicator.service.fileaccess, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, + net.java.sip.communicator.util.dns, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.msnconstants, net.java.sip.communicator.service.protocol.event diff --git a/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java index 6cff570..50ee396 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java @@ -15,6 +15,8 @@ import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.service.version.Version; import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.dns.*; + import org.osgi.framework.*; import javax.sip.*; @@ -299,13 +301,14 @@ public class ProtocolProviderServiceSipImpl sipSecurityManager.setSecurityAuthority(authority); initRegistrarConnection(); + //connect to the Registrar. connection = ProxyConnection.create(this); if(!registerUsingNextAddress()) { logger.error("No address found for " + this); fireRegistrationStateChanged( - RegistrationState.UNREGISTERED, + RegistrationState.REGISTERING, RegistrationState.CONNECTION_FAILED, RegistrationStateChangeEvent.REASON_SERVER_NOT_FOUND, "Invalid or inaccessible server address."); @@ -2396,6 +2399,17 @@ public class ProtocolProviderServiceSipImpl return true; } } + catch (DnssecException e) + { + logger.error("DNSSEC failure while getting address for " + + this, e); + fireRegistrationStateChanged( + RegistrationState.REGISTERING, + RegistrationState.UNREGISTERED, + RegistrationStateChangeEvent.REASON_USER_REQUEST, + "Invalid or inaccessible server address."); + return true; + } catch (Throwable e) { logger.error("Cannot send register!", e); diff --git a/src/net/java/sip/communicator/impl/protocol/sip/net/AutoProxyConnection.java b/src/net/java/sip/communicator/impl/protocol/sip/net/AutoProxyConnection.java index 0f84e67..9dc01ac 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/net/AutoProxyConnection.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/net/AutoProxyConnection.java @@ -15,6 +15,7 @@ import javax.sip.*; import net.java.sip.communicator.impl.protocol.sip.*;
import net.java.sip.communicator.util.*;
+import net.java.sip.communicator.util.dns.*;
import static javax.sip.ListeningPoint.*;
/**
@@ -52,19 +53,19 @@ public class AutoProxyConnection }
public String[][] getNAPTRRecords(String address)
- throws ParseException
+ throws ParseException, DnssecException
{
return NetworkUtils.getNAPTRRecords(address);
}
public SRVRecord[] getSRVRecords(String service, String proto,
- String address) throws ParseException
+ String address) throws ParseException, DnssecException
{
return NetworkUtils.getSRVRecords(service, proto, address);
}
public InetSocketAddress[] getAandAAAARecords(String target, int port)
- throws ParseException
+ throws ParseException, DnssecException
{
return NetworkUtils.getAandAAAARecords(target, port);
}
@@ -75,7 +76,7 @@ public class AutoProxyConnection }
public SRVRecord[] getSRVRecords(String domain)
- throws ParseException
+ throws ParseException, DnssecException
{
return NetworkUtils.getSRVRecords(domain);
}
@@ -152,6 +153,7 @@ public class AutoProxyConnection * getNextAddressFromDns()
*/
protected boolean getNextAddressFromDns()
+ throws DnssecException
{
try
{
@@ -167,9 +169,13 @@ public class AutoProxyConnection /**
* Gets the next address from DNS.
+ *
+ * @throws DnssecException When a DNSSEC failure occured during the lookup.
+ * @throws ParseException When a domain name (possibly returned from DNS
+ * itself) is invalid.
*/
private boolean getNextAddressInternal()
- throws ParseException
+ throws DnssecException, ParseException
{
switch(state)
{
diff --git a/src/net/java/sip/communicator/impl/protocol/sip/net/ManualProxyConnection.java b/src/net/java/sip/communicator/impl/protocol/sip/net/ManualProxyConnection.java index 93a3e42..83db84e 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/net/ManualProxyConnection.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/net/ManualProxyConnection.java @@ -14,6 +14,7 @@ import java.text.*; import net.java.sip.communicator.impl.protocol.sip.*;
import net.java.sip.communicator.util.*;
+import net.java.sip.communicator.util.dns.*;
/**
* Implementation of the manually configured SIP proxy connection. IP Address
@@ -52,6 +53,7 @@ public class ManualProxyConnection */
@Override
public boolean getNextAddressFromDns()
+ throws DnssecException
{
if(lookups == null)
{
diff --git a/src/net/java/sip/communicator/impl/protocol/sip/net/ProxyConnection.java b/src/net/java/sip/communicator/impl/protocol/sip/net/ProxyConnection.java index 4de0685..2deebdf 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/net/ProxyConnection.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/net/ProxyConnection.java @@ -4,6 +4,7 @@ import java.net.*; import java.util.*;
import net.java.sip.communicator.impl.protocol.sip.*;
+import net.java.sip.communicator.util.dns.DnssecException;
import static net.java.sip.communicator.service.protocol.ProtocolProviderFactory.*;
/**
@@ -34,8 +35,6 @@ public abstract class ProxyConnection */
public final InetSocketAddress getAddress()
{
- if(socketAddress == null)
- getNextAddress();
return socketAddress;
}
@@ -45,8 +44,6 @@ public abstract class ProxyConnection */
public final String getTransport()
{
- if(transport == null)
- getNextAddress();
return transport;
}
@@ -61,8 +58,7 @@ public abstract class ProxyConnection public final String getOutboundProxyString()
{
if(socketAddress == null)
- if(!getNextAddress())
- return null;
+ return null;
InetAddress proxyAddress = socketAddress.getAddress();
StringBuilder proxyStringBuffer
@@ -106,7 +102,7 @@ public abstract class ProxyConnection * false if the last address was reached. A new lookup from scratch
* can be started by calling {@link #reset()}.
*/
- public final boolean getNextAddress()
+ public final boolean getNextAddress() throws DnssecException
{
boolean result;
String key = null;
@@ -132,8 +128,10 @@ public abstract class ProxyConnection * have to care about duplicate addresses.
*
* @return True when a further address was available.
+ * @throws DnssecException when a DNSSEC validation failure occured.
*/
- protected abstract boolean getNextAddressFromDns();
+ protected abstract boolean getNextAddressFromDns()
+ throws DnssecException;
/**
* Resets the lookup to it's initial state. Overriders methods have to call
diff --git a/src/net/java/sip/communicator/impl/protocol/sip/sip.provider.manifest.mf b/src/net/java/sip/communicator/impl/protocol/sip/sip.provider.manifest.mf index 722c7e5..4416614 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/sip.provider.manifest.mf +++ b/src/net/java/sip/communicator/impl/protocol/sip/sip.provider.manifest.mf @@ -55,6 +55,7 @@ Import-Package: org.apache.log4j, net.java.sip.communicator.service.resources, net.java.sip.communicator.service.version, net.java.sip.communicator.util, + net.java.sip.communicator.util.dns, net.java.sip.communicator.util.xml, javax.net.ssl, javax.security.auth.x500, diff --git a/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolProviderServiceYahooImpl.java b/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolProviderServiceYahooImpl.java index bfa2385..5cf495a 100644 --- a/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolProviderServiceYahooImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolProviderServiceYahooImpl.java @@ -11,6 +11,7 @@ import java.io.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.dns.*; import ymsg.network.*; import ymsg.network.event.*; @@ -251,6 +252,13 @@ public class ProtocolProviderServiceYahooImpl RegistrationState.CONNECTION_FAILED, RegistrationStateChangeEvent.REASON_NOT_SPECIFIED, null); } + catch (DnssecRuntimeException ex) + { + fireRegistrationStateChanged( + getRegistrationState(), + RegistrationState.UNREGISTERED, + RegistrationStateChangeEvent.REASON_USER_REQUEST, null); + } } } diff --git a/src/net/java/sip/communicator/impl/protocol/yahoo/yahoo.provider.manifest.mf b/src/net/java/sip/communicator/impl/protocol/yahoo/yahoo.provider.manifest.mf index d7c5733..c24547c 100644 --- a/src/net/java/sip/communicator/impl/protocol/yahoo/yahoo.provider.manifest.mf +++ b/src/net/java/sip/communicator/impl/protocol/yahoo/yahoo.provider.manifest.mf @@ -16,6 +16,7 @@ Import-Package: org.osgi.framework, net.java.sip.communicator.service.configuration, net.java.sip.communicator.service.resources, net.java.sip.communicator.util, + net.java.sip.communicator.util.dns, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.yahooconstants, net.java.sip.communicator.service.protocol.event |