}
public void receive_request( ServerRequestInfo sri )
throws ForwardRequest
{
ServerRequestInfoImpl ri = ((ServerRequestInfoImpl)sri);
if (logger.isDebugEnabled())
logger.debug("receive_request for "+ri.operation());
if (sasContext == null || ri.isLocalInterceptor())
{
return;
}
GIOPConnection connection = ri.getConnection();
// check policy
SASPolicyValues sasValues = null;
try
{
ObjectImpl oi =
(ObjectImpl)ri.target();
org.jacorb.orb.Delegate d =
(org.jacorb.orb.Delegate)oi._get_delegate();
SASPolicy policy =
(SASPolicy)d.getPOA().getPolicy(SAS_POLICY_TYPE.value);
if (policy != null)
sasValues = policy.value();
}
catch (BAD_PARAM e)
{
if (logger.isDebugEnabled())
logger.debug("No SAS Policy for "+ri.operation());
}
catch (Exception e)
{
if (logger.isWarnEnabled())
logger.warn("Error fetching SAS policy for "+
ri.operation()+": "+e);
throw new org.omg.CORBA.NO_PERMISSION("Error fetching SAS policy: "+e,
MinorCodes.SAS_TSS_FAILURE,
CompletionStatus.COMPLETED_NO);
}
if (sasValues == null)
return;
if (sasValues.targetRequires == 0 && sasValues.targetSupports == 0)
return;
ATLASPolicyValues atlasValues = null;
try
{
ObjectImpl oi = (ObjectImpl)ri.target();
org.jacorb.orb.Delegate d = (org.jacorb.orb.Delegate)oi._get_delegate();
ATLASPolicy policy = (ATLASPolicy)d.getPOA().getPolicy(ATLAS_POLICY_TYPE.value);
if (policy != null)
atlasValues = policy.value();
}
catch (BAD_PARAM e)
{
if (logger.isDebugEnabled())
logger.debug("No ATLAS Policy for "+ri.operation());
}
catch (Exception e)
{
if (logger.isWarnEnabled())
logger.warn("Error fetching ATLAS policy for "+
ri.operation()+": "+e);
throw new org.omg.CORBA.NO_PERMISSION("Error fetching ATLAS policy: "+e,
MinorCodes.SAS_TSS_FAILURE,
CompletionStatus.COMPLETED_NO);
}
// parse service context
SASContextBody contextBody = null;
long client_context_id = 0;
byte[] contextToken = null;
try
{
ServiceContext ctx =
ri.get_request_service_context(SASInitializer.SecurityAttributeService);
Any ctx_any =
codec.decode_value( ctx.context_data, SASContextBodyHelper.type() );
contextBody =
SASContextBodyHelper.extract(ctx_any);
}
catch (BAD_PARAM e)
{
if (logger.isDebugEnabled())
logger.debug("Could not parse service context for operation " +
ri.operation());
}
catch (Exception e)
{
if (logger.isWarnEnabled())
logger.warn("Could not parse service context for operation " +
ri.operation() + ": " + e);
}
if (contextBody == null &&
(sasValues.targetRequires & org.omg.CSIIOP.EstablishTrustInClient.value) != 0 &&
!ri.operation().equals("_non_existent") &&
!ri.operation().equals("_is_a"))
{
if (logger.isErrorEnabled())
logger.error("Did not parse service context for operation " +
ri.operation());
throw new org.omg.CORBA.NO_PERMISSION("No SAS service context found",
MinorCodes.SAS_TSS_FAILURE,
CompletionStatus.COMPLETED_NO);
}
if (contextBody == null)
{
if (logger.isDebugEnabled())
logger.debug("No context found, but not required");
return;
}
// process MessageInContext
if (contextBody.discriminator() == MTMessageInContext.value)
{
MessageInContext msg = null;
try
{
msg = contextBody.in_context_msg();
client_context_id = msg.client_context_id;
contextToken = getSASContext(connection, msg.client_context_id);
}
catch (Exception e)
{
if (logger.isErrorEnabled())
logger.error("Could not parse service MessageInContext " +
ri.operation() + ": " + e);
makeContextError(ri, client_context_id, 1, 1, contextToken);
throw new org.omg.CORBA.NO_PERMISSION("SAS Error parsing MessageInContext: " + e,
MinorCodes.SAS_TSS_FAILURE,
CompletionStatus.COMPLETED_NO);
}
if (contextToken == null)
{
if (logger.isErrorEnabled())
logger.error("Could not find context in MessageInContext " +
ri.operation() + ": " + msg.client_context_id);
makeContextError(ri, client_context_id, 2, 1, contextToken);
throw new org.omg.CORBA.NO_PERMISSION("SAS Error invalid context in MessageInContext",
MinorCodes.SAS_TSS_FAILURE,
CompletionStatus.COMPLETED_NO);
}
}
// process EstablishContext
if (contextBody.discriminator() == MTEstablishContext.value)
{
EstablishContext msg = null;
String principalName = null;
try
{
msg = contextBody.establish_msg();
client_context_id = msg.client_context_id;
contextToken = msg.client_authentication_token;
principalName = sasContext.getValidatedPrincipal();
}
catch (org.omg.CORBA.NO_PERMISSION e)
{
if (logger.isErrorEnabled())
logger.error("Err " + ri.operation() + ": " + e);
makeContextError(ri, client_context_id, 1, 1, contextToken);
throw e;
}
catch (Exception e)
{
if (logger.isErrorEnabled())
logger.error("Could not parse service EstablishContext " +
ri.operation() + ": " + e);
makeContextError(ri, client_context_id, 2, 1, contextToken);
throw new org.omg.CORBA.NO_PERMISSION("SAS Error parsing EstablishContext: " + e,
MinorCodes.SAS_TSS_FAILURE,
CompletionStatus.COMPLETED_NO);
}
if (contextToken == null)
{
if (logger.isErrorEnabled())
logger.error("Could not parse service EstablishContext " +
ri.operation() + ": " + msg.client_context_id);
makeContextError(ri, client_context_id, 2, 1, contextToken);
throw new org.omg.CORBA.NO_PERMISSION("SAS Error parsing EstablishContext",
MinorCodes.SAS_TSS_FAILURE,
CompletionStatus.COMPLETED_NO);
}
// cache context
if (sasValues.stateful)
cacheSASContext(connection, msg.client_context_id,
contextToken, principalName);
}
// set slots
try
{
makeCompleteEstablishContext(ri, client_context_id, sasValues);
}
catch (Exception e)
{
if (logger.isErrorEnabled())
logger.error("Error inserting service context into slots for " +
ri.operation() + ": " + e);
makeContextError(ri, client_context_id, 1, 1, contextToken);
throw new org.omg.CORBA.NO_PERMISSION("SAS Error insert service context into slots: " + e, MinorCodes.SAS_TSS_FAILURE, CompletionStatus.COMPLETED_NO);
}
}