Allows the application to trigger a 400 Bad Request response by throwing an IllegalArgumentException from within processRequest(). Responds with a 400 when incoming requests are missing the PRIORITY attribute
This commit is contained in:
parent
acb573dbab
commit
6747c7cdcd
@ -171,6 +171,29 @@ public class ConnectivityCheckClient
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the corresponding local candidate from the list of candidates
|
||||||
|
* that we are waiting on in order to complete the harvest.
|
||||||
|
*
|
||||||
|
* @param transactionID the ID of the transaction that has just ended.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
private void processFailure(TransactionID transactionID)
|
||||||
|
{
|
||||||
|
synchronized (resolveMap)
|
||||||
|
{
|
||||||
|
Candidate localCand = resolveMap.remove(transactionID);
|
||||||
|
|
||||||
|
//if this was the last candidate, we are done with the STUN
|
||||||
|
//resolution and need to notify the waiters.
|
||||||
|
if(resolveMap.isEmpty())
|
||||||
|
resolveMap.notify();
|
||||||
|
|
||||||
|
logger.finest("a tran expired tranid=" + transactionID);
|
||||||
|
logger.finest("localAddr=" + localCand);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
/**
|
/**
|
||||||
* The thread that actually sends the checks for a particular check list
|
* The thread that actually sends the checks for a particular check list
|
||||||
* in the pace defined in RFC 5245.
|
* in the pace defined in RFC 5245.
|
||||||
|
|||||||
@ -71,11 +71,20 @@ public class ConnectivityCheckServer
|
|||||||
stunStack.getCredentialsManager().registerAuthority(this);
|
stunStack.getCredentialsManager().registerAuthority(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the {@link Request} delivered in <tt>evt</tt> by possibly
|
||||||
|
* queueing a triggered check and sending a success or or error response
|
||||||
|
* depending on how processing goes.
|
||||||
|
*
|
||||||
|
* @param evt the {@link StunMessageEvent} containing the {@link Request}
|
||||||
|
* that we need to process.
|
||||||
|
*
|
||||||
|
* @throws IllegalArgumentException if the request is malformed and the
|
||||||
|
* stack needs to reply with a 400 Bad Request response.
|
||||||
|
*/
|
||||||
public void processRequest(StunMessageEvent evt)
|
public void processRequest(StunMessageEvent evt)
|
||||||
|
throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
if(true)
|
|
||||||
throw new NullPointerException("i am the king fo the w");
|
|
||||||
|
|
||||||
Request request = (Request)evt.getMessage();
|
Request request = (Request)evt.getMessage();
|
||||||
|
|
||||||
//ignore incoming requests that are not meant for the local user.
|
//ignore incoming requests that are not meant for the local user.
|
||||||
@ -109,7 +118,8 @@ public class ConnectivityCheckServer
|
|||||||
logger.log(Level.FINE, "Received a connectivity ckeck with"
|
logger.log(Level.FINE, "Received a connectivity ckeck with"
|
||||||
+"no PRIORITY attribute. Discarting.");
|
+"no PRIORITY attribute. Discarting.");
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
|
throw new IllegalArgumentException("Missing PRIORITY attribtue!");
|
||||||
}
|
}
|
||||||
|
|
||||||
long priority = priorityAttr.getPriority();
|
long priority = priorityAttr.getPriority();
|
||||||
|
|||||||
@ -7,6 +7,9 @@
|
|||||||
package org.ice4j.stack;
|
package org.ice4j.stack;
|
||||||
|
|
||||||
import org.ice4j.*;
|
import org.ice4j.*;
|
||||||
|
import org.ice4j.message.*;
|
||||||
|
|
||||||
|
import com.sun.corba.se.impl.protocol.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles incoming requests.
|
* Handles incoming requests.
|
||||||
@ -17,9 +20,19 @@ import org.ice4j.*;
|
|||||||
public interface RequestListener
|
public interface RequestListener
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Called when delivering incoming STUN requests.
|
* Called when delivering incoming STUN requests. Throwing an
|
||||||
|
* {@link IllegalArgumentException} from within this method would cause the
|
||||||
|
* stack to reply with a <tt>400 Bad Request</tt> {@link Response} using
|
||||||
|
* the exception's message as a reason phrase for the error response. Any
|
||||||
|
* other exception would result in a <tt>500 Server Error</tt> {@link
|
||||||
|
* Response}.
|
||||||
*
|
*
|
||||||
* @param evt the event containing the incoming STUN request.
|
* @param evt the event containing the incoming STUN request.
|
||||||
|
*
|
||||||
|
* @throws IllegalArgumentException if <tt>evt</tt> contains a malformed
|
||||||
|
* {@link Request} and the stack would need to response with a
|
||||||
|
* <tt>400 Bad Request</tt> {@link Response}.
|
||||||
*/
|
*/
|
||||||
public void processRequest(StunMessageEvent evt);
|
public void processRequest(StunMessageEvent evt)
|
||||||
|
throws IllegalArgumentException;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -542,9 +542,20 @@ public class StunStack
|
|||||||
}
|
}
|
||||||
catch (Throwable t)
|
catch (Throwable t)
|
||||||
{
|
{
|
||||||
Response error = MessageFactory.createBindingErrorResponse(
|
Response error;
|
||||||
|
|
||||||
|
if(t instanceof IllegalArgumentException)
|
||||||
|
{
|
||||||
|
error = MessageFactory.createBindingErrorResponse(
|
||||||
|
ErrorCodeAttribute.BAD_REQUEST,
|
||||||
|
t.getMessage());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
error = MessageFactory.createBindingErrorResponse(
|
||||||
ErrorCodeAttribute.SERVER_ERROR,
|
ErrorCodeAttribute.SERVER_ERROR,
|
||||||
"Oops! Something went wrong on our side :(");
|
"Oops! Something went wrong on our side :(");
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user