James.Strachan wrote: > >> All of the wire protocols tie back to some sort of core, where auth is >> evaluated. And that is supposed to flow back to the wire protocol again. >> >> And the ActiveMQ core just depends on the protocol to do the right >> thing. If the auth failed, it will still take successive commands. > > Yeah, that sounds an easy one to fix; we just need to disconnect the > socket if a connection fails I guess? Fancy taking a stab at it? Am > thinking some code in ProtcolConverter if an exception occurs on the > response, to just close the connection (after the ERROR is sent back). > This is more or less what my patch does posted elsewhere in this thread. It's a bit of a hack however, it doesn't send an error frame. This is (I think) because the connection isn't set up properly, the function just bails out. A proper solution (which sends an ERROR frame) probably requires a bit of rewriting of the onStompConnect method.
BTW, Tom reported in this thread this patch didn't work for him. I have no idea why, it did for me. It is against a 4.2 snapshot from ~ 1 month old I think. I think it doesn't work for 4.1, I believe there were some changes after that upstream in the code flow to actually throw the Exception. This is the patch I was talking about: --- src/activemq-core/src/main/java/org/apache/activemq/transport/stomp/ProtocolConverter.java 2007-05-11 02:02:04.000000000 +0200 +++ src/activemq-core/src/main/java/org/apache/activemq/transport/stomp/ProtocolConverter.java 2007-05-22 12:41:32.000000000 +0200 @@ -36,6 +36,7 @@ import org.apache.activemq.command.ConnectionInfo; import org.apache.activemq.command.ConsumerId; import org.apache.activemq.command.ConsumerInfo; +import org.apache.activemq.command.ExceptionResponse; import org.apache.activemq.command.LocalTransactionId; import org.apache.activemq.command.MessageAck; import org.apache.activemq.command.MessageDispatch; @@ -413,7 +414,18 @@ connectionInfo.setPassword(passcode); sendToActiveMQ(connectionInfo, new ResponseHandler(){ - public void onResponse(ProtocolConverter converter, Response response) throws IOException { + public void onResponse(ProtocolConverter converter, Response response) throws IOException, ProtocolException { + + /* PN: if the response is an exception, propagate the exception to send an ERROR frame */ + if (response.isException()) { + ExceptionResponse exception = (ExceptionResponse) response; + // apparently, other (non-fatal) exceptions are generated as well (see debug log) + if (exception.getException() instanceof SecurityException) { + // FIXME: should set up connection, send an ERROR frame, and disconnect + // this disconnects immediately + throw new ProtocolException(exception.getException().getMessage()); + } + } final SessionInfo sessionInfo = new SessionInfo(sessionId); sendToActiveMQ(sessionInfo,null); Hope this helps. Regards, Pieter Naaijkens -- View this message in context: http://www.nabble.com/Getting-Stomp-support-to-a-usable-state...-tf3858629s2354.html#a11248423 Sent from the ActiveMQ - User mailing list archive at Nabble.com.