summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Ritchie <ritchiem@apache.org>2007-04-26 12:38:41 +0000
committerMartin Ritchie <ritchiem@apache.org>2007-04-26 12:38:41 +0000
commit166c454ba3756a73e2ac4cc7c4bf05841b9429ea (patch)
tree9f89ae3d7e1e9a2eaec02fca26e3b305aa02fac8
parentf2652cf2f194c7b5b7405baec39e07bda2ebd43b (diff)
downloadqpid-python-166c454ba3756a73e2ac4cc7c4bf05841b9429ea.tar.gz
QPID-292 - Authentication not handled correctly.
Copied handling from SecureOkMethod handler. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/M2@532728 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionStartOkMethodHandler.java19
1 files changed, 17 insertions, 2 deletions
diff --git a/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionStartOkMethodHandler.java b/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionStartOkMethodHandler.java
index 4734143497..29d6c26b66 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionStartOkMethodHandler.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionStartOkMethodHandler.java
@@ -30,6 +30,7 @@ import org.apache.qpid.framing.AMQFrame;
import org.apache.qpid.framing.ConnectionSecureBody;
import org.apache.qpid.framing.ConnectionStartOkBody;
import org.apache.qpid.framing.ConnectionTuneBody;
+import org.apache.qpid.framing.ConnectionCloseBody;
import org.apache.qpid.protocol.AMQMethodEvent;
import org.apache.qpid.protocol.AMQConstant;
import org.apache.qpid.server.protocol.AMQProtocolSession;
@@ -93,10 +94,24 @@ public class ConnectionStartOkMethodHandler implements StateAwareMethodListener<
switch (authResult.status)
{
case ERROR:
- throw new AMQException("Authentication failed");
+ _logger.info("Authentication failed");
+ stateManager.changeState(AMQState.CONNECTION_CLOSING);
+ // AMQP version change: Hardwire the version to 0-8 (major=8, minor=0)
+ // TODO: Connect this to the session version obtained from ProtocolInitiation for this session.
+ // Be aware of possible changes to parameter order as versions change.
+ AMQFrame close = ConnectionCloseBody.createAMQFrame(0,
+ (byte) 8, (byte) 0, // AMQP version (major, minor)
+ ConnectionCloseBody.getClazz((byte) 8, (byte) 0), // classId
+ ConnectionCloseBody.getMethod((byte) 8, (byte) 0), // methodId
+ AMQConstant.NOT_ALLOWED.getCode(), // replyCode
+ AMQConstant.NOT_ALLOWED.getName()); // replyText
+ session.writeFrame(close);
+ disposeSaslServer(session);
+ break;
+
case SUCCESS:
_logger.info("Connected as: " + ss.getAuthorizationID());
- session.setAuthorizedID(new UsernamePrincipal(ss.getAuthorizationID()));
+ session.setAuthorizedID(new UsernamePrincipal(ss.getAuthorizationID()));
stateManager.changeState(AMQState.CONNECTION_NOT_TUNED);
// AMQP version change: Hardwire the version to 0-8 (major=8, minor=0)