AMQPConnectionCallback implements FailureListener, CloseListener { public ServerSASL getServerSASL(final String mechanism) { ServerSASL result = null; if (isPermittedMechanism(mechanism)) { switch (mechanism) { case PlainSASL.NAME: result = new PlainSASL(server.getSecurityStore(), manager.getSecurityDomain(), connection.getProtocolConnection()); break; case AnonymousServerSASL.NAME: result = new AnonymousServerSASL(); break; case GSSAPIServerSASL.NAME: GSSAPIServerSASL gssapiServerSASL = new GSSAPIServerSASL(); gssapiServerSASL.setLoginConfigScope(manager.getSaslLoginConfigScope()); result = gssapiServerSASL; break; case ExternalServerSASL.NAME: Principal principal = CertificateUtil.getPeerPrincipalFromConnection(protonConnectionDelegate); if (principal != null) { ExternalServerSASL externalServerSASL = new ExternalServerSASL(); externalServerSASL.setPrincipal(principal); result = externalServerSASL; } else { logger.debug("SASL EXTERNAL mechanism requires a TLS peer principal"); } break; default: logger.debug("Mo matching mechanism found for: " + mechanism); break; } } return result; } AMQPConnectionCallback(ProtonProtocolManager manager,
                                 Connection connection,
                                 Executor sessionExecutor,
                                 ActiveMQServer server); Connection getTransportConnection(); String[] getSaslMechanisms(); ServerSASL getServerSASL(final String mechanism); boolean isSupportsAnonymous(); void close(); void setConnection(AMQPConnectionContext connection); AMQPConnectionContext getConnection(); ActiveMQProtonRemotingConnection getProtonConnectionDelegate(); void setProtonConnectionDelegate(ActiveMQProtonRemotingConnection protonConnectionDelegate); void onTransport(ByteBuf byteBuf, AMQPConnectionContext amqpConnection); boolean isWritable(ReadyListener readyListener); AMQPSessionCallback createSessionCallback(AMQPConnectionContext connection); void sendSASLSupported(); boolean validateConnection(org.apache.qpid.proton.engine.Connection connection, SASLResult saslResult); @Override void connectionClosed(); @Override void connectionFailed(ActiveMQException exception, boolean failedOver); @Override void connectionFailed(ActiveMQException exception, boolean failedOver, String scaleDownTargetNodeID); Binary newTransaction(); Transaction getTransaction(Binary txid, boolean remove); URI getFailoverList(); String invokeIncomingInterceptors(AMQPMessage message, ActiveMQProtonRemotingConnection connection); String invokeOutgoingInterceptors(AMQPMessage message, ActiveMQProtonRemotingConnection connection);  }
@Test public void getServerSASLAnonDefault() throws Exception { ProtonProtocolManager protonProtocolManager = new ProtonProtocolManager(new ProtonProtocolManagerFactory(), null, null, null); protonProtocolManager.setSaslMechanisms(new String[]{}); AMQPConnectionCallback connectionCallback = new AMQPConnectionCallback(protonProtocolManager, null, null, new ActiveMQServerImpl()); assertNotNull("can get anon with empty list", connectionCallback.getServerSASL(AnonymousServerSASL.NAME)); }