예제 #1
0
 /// <inheritdoc />
 public void receive_request(ServerRequestInfo ri)
 {
     // FIXME: O código abaixo é necessário porque:
     // (1) para que informações possam ser colocadas nos slots do PICurrent,
     // esse tipo de código deve ficar na receive_request_service_contexts.
     // No entanto, essas informações acabam não ficando disponíveis para a
     // send_exception.
     // (2) a send_exception NÃO É CHAMADA caso a exceção seja lançada na
     // receive_request_service_contexts. A exceção precisa ser lançada aqui.
     // (3) não é possível colocar o código da send_exception nas
     // receive_request*, pois é impossível chamar ri.add_reply_service_context
     // nesses pontos devido a erro do IIOP.Net.
     try {
         string reset = ri.get_slot(ChainSlotId) as string;
         if ((reset != null) && (reset.Equals("reset")))
         {
             throw new NO_PERMISSION(InvalidCredentialCode.ConstVal,
                                     CompletionStatus.Completed_No);
         }
     }
     catch (InvalidSlot e) {
         Logger.Fatal(
             "Falha ao acessar o slot da credencial para avaliar se um reset deve ser enviado.",
             e);
         throw;
     }
     Logger.Info(String.Format(
                     "A operação '{0}' será executada.", ri.operation));
 }
예제 #2
0
        public void send_reply(ServerRequestInfo ri)
        {
            object testEntryAsObject = ri.get_slot(m_slotId);

            if (testEntryAsObject != null)
            {
                int entryResult = (int)testEntryAsObject;
                TestServiceContext resultContextEntry =
                    new TestServiceContext(entryResult);
                ServiceContext context = new ServiceContext(1000, m_codec.encode(resultContextEntry));
                ri.add_reply_service_context(context, true);
            }
        }
예제 #3
0
        /// <inheritdoc />
        public void send_exception(ServerRequestInfo ri)
        {
            // esse tratamento precisa ser feito aqui (não é possível na receive_request) por causa de bugs do IIOP.net, descritos em OPENBUS-1677.
            String interceptedOperation = ri.operation;

            Logger.Info(String.Format(
                            "O lançamento de uma exceção para a operação '{0}' foi interceptado no servidor.",
                            interceptedOperation), (Exception)ri.sending_exception);

            NO_PERMISSION ex = ri.sending_exception as NO_PERMISSION;

            if (ex == null)
            {
                return;
            }
            if (ex.Minor == InvalidCredentialCode.ConstVal)
            {
                try {
                    // pela implementação do IIOP.Net, o ServerRequestInfo da send_exception é
                    // diferente do existente na receive_request. Assim, não podemos passar a
                    // credencial por um slot e então precisamos fazer o unmarshal novamente.
                    ConnectionImpl conn =
                        ri.get_slot(ReceivingConnectionSlotId) as ConnectionImpl;
                    if (conn == null)
                    {
                        Logger.Error(
                            "Sem conexão ao barramento, impossível enviar exceção à chamada remota.");
                        throw new NO_PERMISSION(UnverifiedLoginCode.ConstVal,
                                                CompletionStatus.Completed_No);
                    }
                    bool           legacyContext;
                    ServiceContext serviceContext =
                        GetContextFromRequestInfo(ri, conn.Legacy, out legacyContext);
                    // credencial é inválida
                    AnyCredential anyCredential = new AnyCredential(serviceContext,
                                                                    legacyContext);
                    Logger.Debug(String.Format(
                                     "A operação '{0}' para a qual será lançada a exceção possui credencial. Legada? {1}.",
                                     interceptedOperation, anyCredential.Legacy));

                    conn.SendException(ri, anyCredential);
                }
                catch (InvalidSlot e) {
                    Logger.Fatal(
                        "Falha ao acessar o slot da conexão de recebimento para enviar uma exceção.",
                        e);
                    throw;
                }
            }
        }
예제 #4
0
 public void receive_request(ServerRequestInfo ri)
 {
     // modify request scope after copy to the thread scope -> must not be propagated to the thread scope.
     if (ri.operation == "TestReceiveReqNotChangeThreadScope")
     {
         ri.set_slot(m_slotId, 2 * (int)ri.get_slot(m_slotId));
     }
     else if (ri.operation == "TestReceiveReqChangeThreadScope")
     {
         ORB orb = OrbServices.GetSingleton();
         omg.org.PortableInterceptor.Current current =
             (omg.org.PortableInterceptor.Current)orb.resolve_initial_references("PICurrent");
         current.set_slot(m_slotId, 3 * (int)current.get_slot(m_slotId));
     }
 }
예제 #5
0
 public void receive_request(ServerRequestInfo ri) {
     // modify request scope after copy to the thread scope -> must not be propagated to the thread scope.
     if (ri.operation == "TestReceiveReqNotChangeThreadScope") {
         ri.set_slot(m_slotId, 2 * (int)ri.get_slot(m_slotId));
     } else if (ri.operation == "TestReceiveReqChangeThreadScope") {
         ORB orb = OrbServices.GetSingleton();
         omg.org.PortableInterceptor.Current current = 
             (omg.org.PortableInterceptor.Current)orb.resolve_initial_references("PICurrent");
         current.set_slot(m_slotId, 3 * (int)current.get_slot(m_slotId));
     }
 }
예제 #6
0
 public void send_reply(ServerRequestInfo ri) {
     object testEntryAsObject = ri.get_slot(m_slotId);
     if (testEntryAsObject != null) {
         int entryResult = (int)testEntryAsObject;
         TestServiceContext resultContextEntry = 
             new TestServiceContext(entryResult);
         ServiceContext context = new ServiceContext(1000, m_codec.encode(resultContextEntry));
         ri.add_reply_service_context(context, true);
     }
 }