diff --git a/src/org/ice4j/ice/checks/ConnectivityCheckServer.java b/src/org/ice4j/ice/checks/ConnectivityCheckServer.java
index cc270af..d9ce552 100644
--- a/src/org/ice4j/ice/checks/ConnectivityCheckServer.java
+++ b/src/org/ice4j/ice/checks/ConnectivityCheckServer.java
@@ -71,8 +71,11 @@ public class ConnectivityCheckServer
stunStack.getCredentialsManager().registerAuthority(this);
}
- public void requestReceived(StunMessageEvent evt)
+ public void processRequest(StunMessageEvent evt)
{
+ if(true)
+ throw new NullPointerException("i am the king fo the w");
+
Request request = (Request)evt.getMessage();
//ignore incoming requests that are not meant for the local user.
diff --git a/src/org/ice4j/stack/EventDispatcher.java b/src/org/ice4j/stack/EventDispatcher.java
index 66f7912..5ee661f 100644
--- a/src/org/ice4j/stack/EventDispatcher.java
+++ b/src/org/ice4j/stack/EventDispatcher.java
@@ -142,7 +142,7 @@ public class EventDispatcher
for (RequestListener target : listenersCopy)
{
- target.requestReceived(evt);
+ target.processRequest(evt);
}
synchronized(requestListenersChildren)
diff --git a/src/org/ice4j/stack/RequestListener.java b/src/org/ice4j/stack/RequestListener.java
index b09c9f6..874eb32 100644
--- a/src/org/ice4j/stack/RequestListener.java
+++ b/src/org/ice4j/stack/RequestListener.java
@@ -21,5 +21,5 @@ public interface RequestListener
*
* @param evt the event containing the incoming STUN request.
*/
- public void requestReceived(StunMessageEvent evt);
+ public void processRequest(StunMessageEvent evt);
}
diff --git a/src/org/ice4j/stack/StunStack.java b/src/org/ice4j/stack/StunStack.java
index 5b4a008..bfe08c4 100644
--- a/src/org/ice4j/stack/StunStack.java
+++ b/src/org/ice4j/stack/StunStack.java
@@ -528,7 +528,7 @@ public class StunStack
//validate attributes that need validation.
try
{
- validateRequestAttributes((Request)msg, event.getRawMessage());
+ validateRequestAttributes(event);
}
catch(Exception exc)
{
@@ -536,8 +536,28 @@ public class StunStack
return;
}
- eventDispatcher.fireMessageEvent(event);
+ try
+ {
+ eventDispatcher.fireMessageEvent(event);
+ }
+ catch (Throwable t)
+ {
+ Response error = MessageFactory.createBindingErrorResponse(
+ ErrorCodeAttribute.SERVER_ERROR,
+ "Oops! Something went wrong on our side :(");
+ try
+ {
+ sendResponse(event.getTransactionID().getTransactionID(),
+ error, event.getLocalAddress(),
+ event.getRemoteAddress());
+ }
+ catch(Exception exc)
+ {
+ logger.log(Level.FINE, "Couldn't send a server error "
+ + "response", exc);
+ }
+ }
}
//response
else if(msg instanceof Response)
@@ -602,9 +622,8 @@ public class StunStack
* Executes actions related specific attributes like asserting proper
* checksums or verifying the validity of user names.
*
- * @param request the {@link Request} to validate.
- * @param rawMessage the {@link RawMessage} containing the bytes of the
- * {@link Request} so that we could check MESSAGE-INTEGRITY if necessary..
+ * @param evt the {@link StunMessageEvent} that contains the {@link
+ * Request} that we need to validate.
*
* @throws IllegalArgumentException if there's something in the
* attribute that caused us to discard the whole message (e.g. an
@@ -613,10 +632,10 @@ public class StunStack
* @throws StunException if we fail while sending an error response.
* @throws IOException if we fail while sending an error response.
*/
- private void validateRequestAttributes(Request request,
- RawMessage rawMessage)
+ private void validateRequestAttributes(StunMessageEvent evt)
throws IllegalArgumentException, StunException, IOException
{
+ Message request = evt.getMessage();
//assert valid username
UsernameAttribute unameAttr = (UsernameAttribute)request
@@ -633,8 +652,8 @@ public class StunStack
"unknown user " + username);
sendResponse(request.getTransactionID(), error,
- rawMessage.getLocalAddress(),
- rawMessage.getRemoteAddress());
+ evt.getLocalAddress(),
+ evt.getRemoteAddress());
throw new IllegalArgumentException(
"Non-recognized username: "
@@ -656,8 +675,8 @@ public class StunStack
"missing username");
sendResponse(request.getTransactionID(), error,
- rawMessage.getLocalAddress(),
- rawMessage.getRemoteAddress());
+ evt.getLocalAddress(),
+ evt.getRemoteAddress());
throw new IllegalArgumentException(
"Missing USERNAME in the presence of MESSAGE-INTEGRITY: ");
@@ -665,15 +684,15 @@ public class StunStack
if (!validateMessageIntegrity(msgIntAttr,
new String(unameAttr.getUsername()),
- rawMessage.getBytes(), 0))
+ evt.getRawMessage().getBytes(), 0))
{
Response error = MessageFactory.createBindingErrorResponse(
ErrorCodeAttribute.UNAUTHORIZED,
"Wrong MESSAGE-INTEGRITY value");
sendResponse(request.getTransactionID(), error,
- rawMessage.getLocalAddress(),
- rawMessage.getRemoteAddress());
+ evt.getLocalAddress(),
+ evt.getRemoteAddress());
throw new IllegalArgumentException(
"Wrong MESSAGE-INTEGRITY value.");
@@ -687,8 +706,8 @@ public class StunStack
"Missing MESSAGE-INTEGRITY.");
sendResponse(request.getTransactionID(), error,
- rawMessage.getLocalAddress(),
- rawMessage.getRemoteAddress());
+ evt.getLocalAddress(),
+ evt.getRemoteAddress());
throw new IllegalArgumentException(
"Missing MESSAGE-INTEGRITY.");
}
@@ -711,8 +730,8 @@ public class StunStack
"missing username", sBuff.toString().toCharArray());
sendResponse(request.getTransactionID(), error,
- rawMessage.getLocalAddress(),
- rawMessage.getRemoteAddress());
+ evt.getLocalAddress(),
+ evt.getRemoteAddress());
throw new IllegalArgumentException(
"Missing MESSAGE-INTEGRITY.");
diff --git a/test/org/ice4j/MessageEventDispatchingTest.java b/test/org/ice4j/MessageEventDispatchingTest.java
index b05436e..baf33f5 100644
--- a/test/org/ice4j/MessageEventDispatchingTest.java
+++ b/test/org/ice4j/MessageEventDispatchingTest.java
@@ -255,7 +255,7 @@ public class MessageEventDispatchingTest extends TestCase
*
* @param evt the event containing the incoming request.
*/
- public void requestReceived(StunMessageEvent evt)
+ public void processRequest(StunMessageEvent evt)
{
synchronized (this)
{
diff --git a/test/org/ice4j/TransactionSupportTests.java b/test/org/ice4j/TransactionSupportTests.java
index 57b0cf2..e51ea6b 100644
--- a/test/org/ice4j/TransactionSupportTests.java
+++ b/test/org/ice4j/TransactionSupportTests.java
@@ -468,7 +468,7 @@ public class TransactionSupportTests extends TestCase
*
* @param evt the {@link StunMessageEvent} to log.
*/
- public void requestReceived(StunMessageEvent evt)
+ public void processRequest(StunMessageEvent evt)
{
synchronized(this)
diff --git a/test/org/ice4j/stack/ShallowStackTest.java b/test/org/ice4j/stack/ShallowStackTest.java
index b76aa0d..a319154 100644
--- a/test/org/ice4j/stack/ShallowStackTest.java
+++ b/test/org/ice4j/stack/ShallowStackTest.java
@@ -381,7 +381,7 @@ public class ShallowStackTest extends TestCase {
* @param evt the StunMessageEvent containing the details of
* the newly received request.
*/
- public void requestReceived(StunMessageEvent evt)
+ public void processRequest(StunMessageEvent evt)
{
synchronized(this)
{
diff --git a/test/org/ice4j/stunclient/ResponseSequenceServer.java b/test/org/ice4j/stunclient/ResponseSequenceServer.java
index f197dc5..b234bae 100644
--- a/test/org/ice4j/stunclient/ResponseSequenceServer.java
+++ b/test/org/ice4j/stunclient/ResponseSequenceServer.java
@@ -95,7 +95,7 @@ public class ResponseSequenceServer
* different from a Response on the current position.
* @param evt the event being dispatched
*/
- public void requestReceived(StunMessageEvent evt)
+ public void processRequest(StunMessageEvent evt)
{
if(messageSequence.isEmpty())
return;