if (serviceContext == null) return;
if (log.isDebugEnabled()) log.debug("Found service context");
Any any = Util.getCodec().decode_value(serviceContext.context_data, SASContextBodyHelper.type());
SASContextBody contextBody = SASContextBodyHelper.extract(any);
short msgType = contextBody.discriminator();
switch (msgType) {
case MTEstablishContext.value:
if (log.isDebugEnabled()) log.debug(" EstablishContext");
contextId = contextBody.establish_msg().client_context_id;
identity = tssPolicy.check(SSLSessionManager.getSSLSession(ri.request_id()), contextBody.establish_msg());
if (identity != null) {
ContextManager.registerSubject(identity);
} else {
identity = defaultSubject;
}
SASReplyManager.setSASReply(ri.request_id(), generateContextEstablished(identity, contextId, false));
break;
case MTCompleteEstablishContext.value:
log.error("The CSIv2 TSS is not supposed to receive a CompleteEstablishContext message.");
throw new INTERNAL("The CSIv2 TSS is not supposed to receive a CompleteEstablishContext message.");
case MTContextError.value:
log.error("The CSIv2 TSS is not supposed to receive a CompleteEstablishContext message.");
throw new INTERNAL("The CSIv2 TSS is not supposed to receive a ContextError message.");
case MTMessageInContext.value:
log.error("The CSIv2 TSS is not supposed to receive a CompleteEstablishContext message.");
contextId = contextBody.in_context_msg().client_context_id;
throw new SASNoContextException();
}
} catch (BAD_PARAM e) {
if (log.isDebugEnabled()) log.debug("No security service context found");
identity = defaultSubject;