Пример #1
0
            public override void MessageReceived(ChannelHandlerContext ctx, MessageEvent e)
            {
                ChannelBuffer buf = (ChannelBuffer)e.GetMessage();

                // Read reply
                if (!ValidMessageLength(buf.ReadableBytes()))
                {
                    e.GetChannel().Close();
                    return;
                }
                // handling fragment header for TCP, 4 bytes.
                byte[] fragmentHeader = Arrays.CopyOfRange(buf.Array(), 0, 4);
                int    fragmentSize   = XDR.FragmentSize(fragmentHeader);
                bool   isLast         = XDR.IsLastFragment(fragmentHeader);

                System.Diagnostics.Debug.Assert((fragmentSize == 28 && isLast == true));
                XDR xdr = new XDR();

                xdr.WriteFixedOpaque(Arrays.CopyOfRange(buf.Array(), 4, buf.ReadableBytes()));
                RpcReply reply = RpcReply.Read(xdr);

                if (reply.GetState() == RpcReply.ReplyState.MsgAccepted)
                {
                    RpcAcceptedReply acceptedReply = (RpcAcceptedReply)reply;
                    Handle(acceptedReply, xdr);
                }
                else
                {
                    RpcDeniedReply deniedReply = (RpcDeniedReply)reply;
                    Handle(deniedReply);
                }
                e.GetChannel().Close();
            }
Пример #2
0
        public virtual void TestConstructor()
        {
            RpcDeniedReply reply = new RpcDeniedReply(0, RpcReply.ReplyState.MsgAccepted, RpcDeniedReply.RejectState
                                                      .AuthError, new VerifierNone());

            Assert.Equal(0, reply.GetXid());
            Assert.Equal(RpcMessage.Type.RpcReply, reply.GetMessageType());
            Assert.Equal(RpcReply.ReplyState.MsgAccepted, reply.GetState()
                         );
            Assert.Equal(RpcDeniedReply.RejectState.AuthError, reply.GetRejectState
                             ());
        }
Пример #3
0
        protected internal static void SendRejectedReply(RpcCall call, EndPoint remoteAddress
                                                         , ChannelHandlerContext ctx)
        {
            XDR            @out  = new XDR();
            RpcDeniedReply reply = new RpcDeniedReply(call.GetXid(), RpcReply.ReplyState.MsgDenied
                                                      , RpcDeniedReply.RejectState.AuthError, new VerifierNone());

            reply.Write(@out);
            ChannelBuffer buf = ChannelBuffers.WrappedBuffer(@out.AsReadOnlyWrap().Buffer());
            RpcResponse   rsp = new RpcResponse(buf, remoteAddress);

            RpcUtil.SendRpcResponse(ctx, rsp);
        }
Пример #4
0
        public static RpcReply Read(XDR xdr)
        {
            int xid = xdr.ReadInt();

            RpcMessage.Type messageType = RpcMessage.Type.FromValue(xdr.ReadInt());
            Preconditions.CheckState(messageType == RpcMessage.Type.RpcReply);
            RpcReply.ReplyState stat = RpcReply.ReplyState.FromValue(xdr.ReadInt());
            switch (stat)
            {
            case RpcReply.ReplyState.MsgAccepted:
            {
                return(RpcAcceptedReply.Read(xid, stat, xdr));
            }

            case RpcReply.ReplyState.MsgDenied:
            {
                return(RpcDeniedReply.Read(xid, stat, xdr));
            }
            }
            return(null);
        }
Пример #5
0
 // shutdown now that request is complete
 private void Handle(RpcDeniedReply deniedReply)
 {
     Log.Warn("Portmap mapping registration request was denied , " + deniedReply);
 }