if (mechanism == null)
{
throw new AMQException("No supported security mechanism found, passed: " + new String(body.mechanisms));
}
final AMQProtocolSession ps = evt.getProtocolSession();
byte[] saslResponse;
try
{
SaslClient sc = Sasl.createSaslClient(new String[]{mechanism},
null, "AMQP", "localhost",
null, createCallbackHandler(mechanism, ps));
if (sc == null)
{
throw new AMQException("Client SASL configuration error: no SaslClient could be created for mechanism " +
mechanism + ". Please ensure all factories are registered. See DynamicSaslRegistrar for " +
" details of how to register non-standard SASL client providers.");
}
ps.setSaslClient(sc);
saslResponse = (sc.hasInitialResponse() ? sc.evaluateChallenge(new byte[0]) : null);
}
catch (SaslException e)
{
ps.setSaslClient(null);
throw new AMQException("Unable to create SASL client: " + e, e);
}
if (body.locales == null)
{
throw new AMQException("Locales is not defined in Connection Start method");
}
final String locales = new String(body.locales, "utf8");
final StringTokenizer tokenizer = new StringTokenizer(locales, " ");
String selectedLocale = null;
if (tokenizer.hasMoreTokens())
{
selectedLocale = tokenizer.nextToken();
}
else
{
throw new AMQException("No locales sent from server, passed: " + locales);
}
stateManager.changeState(AMQState.CONNECTION_NOT_TUNED);
FieldTable clientProperties = new FieldTable();
clientProperties.put("instance", ps.getClientID());
clientProperties.put("product", "Qpid");
clientProperties.put("version", "1.0");
clientProperties.put("platform", getFullSystemInfo());
ps.writeFrame(ConnectionStartOkBody.createAMQFrame(evt.getChannelId(), clientProperties, mechanism,
saslResponse, selectedLocale));
}
catch (UnsupportedEncodingException e)
{
throw new AMQException(_log, "Unable to decode data: " + e, e);