try
{
ServiceContext sc = ri.get_request_service_context(sasContextId);
Any any = codec.decode_value(sc.context_data,
SASContextBodyHelper.type());
SASContextBody contextBody = SASContextBodyHelper.extract(any);
if (contextBody == null)
{
// we're done
return;
}
else if (contextBody.discriminator() == MTMessageInContext.value)
{
// should not happen, as stateful context requests are always
// negotiated down to stateless in this implementation
long contextId =
contextBody.in_context_msg().client_context_id;
threadLocal.sasReply =
createMsgCtxError(contextId,
4 /* major status: no context */);
throw new NO_PERMISSION("SAS context does not exist.");
}
else if (contextBody.discriminator() == MTEstablishContext.value)
{
EstablishContext message = contextBody.establish_msg();
threadLocal.contextId = message.client_context_id;
threadLocal.sasContextReceived = true;
if (message.client_authentication_token != null
&& message.client_authentication_token.length > 0)