예제 #1
0
void
ServerInterceptor::receive_request (
                                    PortableInterceptor::ServerRequestInfo_ptr ri)
{
  bool permission_granted = false;
  std::cout << "Calling receive_request()." << std::endl;

  if (ri->target_is_a(restricted_interfaces[0])){
    IOP::ServiceId id = service_id;
    // Check that the request service context can be retrieved.
    IOP::ServiceContext_var sc =
      ri->get_request_service_context (id);

    CORBA::OctetSeq ocSeq = sc->context_data;

    const char * buf =
      reinterpret_cast<const char *> (ocSeq.get_buffer ());

    for (unsigned int i=0; i<num_allowed_users; ++i) {
      if (ACE_OS::strcmp (buf, allowed_users[i]) == 0)
        {
          permission_granted = true;
        }
    }
  }

  if (permission_granted == true) {
    std::cout << "Permission Granted " << std::endl;
  }
  else {
    std::cout << "Permission Denied " << std::endl;;
  }
}
void
ServerContainerInterceptor::receive_request (Components::ContainerPortableInterceptor::ContainerServerRequestInfo_ptr csi)
{
	std::cout << "COPI: receive_request: " << csi->request_info()->operation();
	std::cout << " for id:" << csi->component_id() << std::endl;

#ifdef WIN32

		/* 
		 * Get encoded context information
		 */
	
		std::string trail_id;
		char mess_cnt[11];
		unsigned long event_number = executor_ -> get_new_event_number();
		sprintf (mess_cnt, "__%08x", event_number);	
	 
		IOP::ServiceContext_var sc = 0;
		char *message_data;
		CORBA::Any_var any = new CORBA::Any;

		try {
			sc = csi->request_info()->get_request_service_context(101);	
			
		    CORBA::OctetSeq data;

			data.length(sc->context_data.length());
			memcpy(data.get_buffer(), sc->context_data.get_buffer(), sc->context_data.length());
			any = executor_-> get_cdr_codec_ptr() -> decode_value(data, CORBA::_tc_string);


			any >>= message_data;
			
		} catch (CORBA::BAD_PARAM&)
		{
			//no service context for tracing
			message_data = new char[11];
			strcpy(message_data,mess_cnt);		
		} catch (...)
		{
			return;
		}
		
//		trail_id = process_id_ + message_data;
		trail_id = message_data;

		org::coach::tracing::api::TraceEvent_var event = new org::coach::tracing::api::TraceEvent;

		// set time_stamp
		struct _timeb current_time;
		_ftime(&current_time);
		CORBA::LongLong tm = current_time.time;
		tm = tm * 1000 + current_time.millitm;
		event->time_stamp = tm;

		// set ineraction point
		event->interaction_point = org::coach::tracing::api::POA_IN;


		event->trail_label= CORBA::string_dup ("");

		event->message_id = CORBA::string_dup (message_data);

		event->thread_id = CORBA::string_dup (message_data);

		event->trail_id	= CORBA::string_dup ("");
		
		event->event_counter  = event_number;
		event->op_name = CORBA::string_dup (CORBA::string_dup(csi->request_info()->operation()));
		event->identity.object_instance_id		= CORBA::string_dup (csi->name());
		event->identity.object_repository_id	= CORBA::string_dup (csi->request_info()->target_most_derived_interface());
		event->identity.cmp_name				= CORBA::string_dup (csi->component_id());
		event->identity.cmp_type				= CORBA::string_dup ("UNKNOWN_COMPONENT_TYPE");
		event->identity.cnt_name				= CORBA::string_dup ("UNKNOW_CONTAINER_NAME");
		event->identity.cnt_type				= CORBA::string_dup ("UNKONWN_CONTAINER_TYPE");
		event->identity.node_name				= CORBA::string_dup (hostname_.c_str());
		event->identity.node_ip					= CORBA::string_dup (" e");
		event->identity.process_id				= CORBA::string_dup (process_id_.c_str());

//			Dynamic::ParameterList_var parameters = new Dynamic::ParameterList();
//			parameters->length(0);

		event->parameters.length(0);

		org::coach::tracing::api::TraceEvents_var trace = new org::coach::tracing::api::TraceEvents;
		trace->length(1);
		(*trace)[0] = event;
		context_-> get_connection_to_trace_server() -> receiveEvent(trace.in());
#endif
}
예제 #3
0
void TIDorb::core::compression::ZlibCompressorImpl::decompress(
                                      const ::CORBA::OctetSeq& source, 
                                      ::CORBA::OctetSeq& target)
  throw (Compression::CompressionException)
{
  // TODO: Control error -> throw adequeate exceptions
  int ret;

  z_stream strm;
  
  /* allocate inflate state */
  strm.zalloc = Z_NULL;
  strm.zfree = Z_NULL;
  strm.opaque = Z_NULL;
  strm.avail_in = 0;
  strm.next_in = Z_NULL;

  ret = inflateInit(&strm);
  if (ret != Z_OK)
    throw Compression::CompressionException();
  

  unsigned char out[chunk_size]; // temporal buffer

  CORBA::ULong  source_length = source.length();
  const CORBA::Octet* source_buffer = source.get_buffer();
   
  CORBA::ULong  target_length = 0;
  //CORBA::Octet* target_buffer = target.get_buffer();

  // Set initial input buffer
  strm.avail_in = source_length;
  strm.next_in  = (CORBA::Octet*) source_buffer;

  unsigned have;


  /* run inflate() on input until output buffer not full */
  do {

    strm.avail_out = chunk_size;
    strm.next_out  = out;
    
    ret = inflate(&strm, Z_NO_FLUSH);
    assert(ret != Z_STREAM_ERROR);  /* state not clobbered */
    switch (ret) {
    case Z_NEED_DICT:
      ret = Z_DATA_ERROR;     /* and fall through */
      throw Compression::CompressionException();
    case Z_DATA_ERROR:
    case Z_MEM_ERROR:
      (void)inflateEnd(&strm);
      throw Compression::CompressionException();
    }

    have = chunk_size - strm.avail_out;
    if ( have > 0) {
      // Copy 'out' buffer to 'target' OctetSeq
      CORBA::Long current_length = target_length;
      target_length += have;
      target.length(target_length);
      memcpy(&(target[current_length]), out, have);
    }

  } while (strm.avail_out == 0);
  
  
  /* clean up and return */
  (void)inflateEnd(&strm);
}
예제 #4
0
void TIDorb::core::compression::ZlibCompressorImpl::compress(
                                      const ::CORBA::OctetSeq& source, 
                                      ::CORBA::OctetSeq& target)
  throw (Compression::CompressionException)
{

  // TODO: Control error -> throw adequeate exceptions
  // target must have memory now??


  int ret, flush;

  z_stream strm;

  /* allocate deflate state */
  strm.zalloc = Z_NULL;
  strm.zfree  = Z_NULL;
  strm.opaque = Z_NULL;

  ret = deflateInit(&strm, m_level);
  if (ret != Z_OK)
    throw Compression::CompressionException();


  unsigned have;

  unsigned char out[chunk_size]; // temporal buffer

  CORBA::ULong  source_length = source.length();
  const CORBA::Octet* source_buffer = source.get_buffer();
   
  CORBA::ULong  target_length = 0;
  //CORBA::Octet* target_buffer = target.get_buffer();

  // Set initial input buffer
  strm.avail_in = source_length;
  strm.next_in  = (CORBA::Octet*) source_buffer;

  // Set flush flag: strm.next_in has the whole input
  flush = Z_FINISH;

  // Run deflate() on input until output buffer not full, finish
  // compression if all of source has been read in 
  do {

    strm.avail_out = chunk_size;
    strm.next_out  = out;
    ret = deflate(&strm, flush);    /* no bad return value */
    assert(ret != Z_STREAM_ERROR);  /* state not clobbered */

    have = chunk_size - strm.avail_out;
    if (have > 0) {
      // Copy 'out' buffer to 'target' OctetSeq
      CORBA::Long current_length = target_length;
      target_length += have;
      target.length(target_length+1);
      memcpy(&(target[current_length]), out, have);
    }

  } while (strm.avail_out == 0);
  assert(strm.avail_in == 0);     /* all input will be used */
      
  (void)deflateEnd(&strm);
  
  //m_factory->add_sample(target.length(), source.length());
  m_compressed_bytes   += target.length();
  m_uncompressed_bytes += source.length();
}
예제 #5
0
void
TAO_ServerRequest::send_cached_reply (CORBA::OctetSeq &s)
{
#if defined(ACE_INITIALIZE_MEMORY_BEFORE_USE)
  // Only inititialize the buffer if we're compiling with Purify.
  // Otherwise, there is no real need to do so, especially since
  // we can avoid the initialization overhead at runtime if we
  // are not compiling with Purify support.
  char repbuf[ACE_CDR::DEFAULT_BUFSIZE] = { 0 };
#else
  char repbuf[ACE_CDR::DEFAULT_BUFSIZE];
#endif /* ACE_HAS_PURIFY */
  TAO_GIOP_Message_Version gv;
  if (this->outgoing_)
    {
      this->outgoing_->get_version (gv);
    }
  TAO_OutputCDR output (repbuf,
                        sizeof repbuf,
                        TAO_ENCAP_BYTE_ORDER,
                        this->orb_core_->output_cdr_buffer_allocator (),
                        this->orb_core_->output_cdr_dblock_allocator (),
                        this->orb_core_->output_cdr_msgblock_allocator (),
                        this->orb_core_->orb_params ()->cdr_memcpy_tradeoff (),
                        this->mesg_base_->fragmentation_strategy (),
                        gv.major,
                        gv.minor);

  this->transport_->assign_translators (0, &output);

  // A copy of the reply parameters
  TAO_Pluggable_Reply_Params_Base reply_params;

  reply_params.request_id_ = this->request_id_;

  reply_params.svc_ctx_.length (0);

  // Send back the empty reply service context.
  reply_params.service_context_notowned (&this->reply_service_info ());

  // We are going to send some data
  reply_params.argument_flag_ = true;

  // Make a default reply status
  reply_params.reply_status (GIOP::NO_EXCEPTION);

  this->outgoing_->message_attributes (this->request_id_,
                                       0,
                                       TAO_Message_Semantics (TAO_Message_Semantics::TAO_REPLY),
                                       0);

  // Make the reply message
  if (this->mesg_base_->generate_reply_header (*this->outgoing_,
                                               reply_params) == -1)
    {
      TAOLIB_ERROR ((LM_ERROR,
                  ACE_TEXT ("TAO (%P|%t) - ServerRequest::send_cached_reply, ")
                  ACE_TEXT ("could not make cached reply\n")));

    }

  /// Append reply here....
  this->outgoing_->write_octet_array (
    s.get_buffer (),
    s.length ());

  if (!this->outgoing_->good_bit ())
    {
      TAOLIB_ERROR ((LM_ERROR,
                  ACE_TEXT ("TAO (%P|%t) - ServerRequest::send_cached_reply, ")
                  ACE_TEXT ("could not marshal reply\n")));
    }

  this->outgoing_->more_fragments (false);

  // Send the message
  if (this->transport_->send_message (*this->outgoing_,
                                      0,
                                      this,
                                      TAO_Message_Semantics (TAO_Message_Semantics::TAO_REPLY)) == -1)
    {
      TAOLIB_ERROR ((LM_ERROR,
                  ACE_TEXT ("TAO (%P|%t) - ServerRequest::send_cached_reply, ")
                  ACE_TEXT ("could not send cached reply\n")));
    }
}