Exemplo n.º 1
0
            public void setAsyncResult(ByteBuffer buf, Exception ex)
            {
                if (log.isDebugEnabled())
                {
                    log.debug("setAsyncResult" + this + "(buf=" + buf + ", ex=" + ex);
                }
                if (Interlocked.Increment(ref isOpen) == 1)
                {
                    try
                    {
                        if (ex == null && buf != null && buf.remaining() != 0)
                        {
                            BMessageHeader header = new BMessageHeader();

                            bool nego = BNegotiate.isNegotiateMessage(buf);
                            if (nego)
                            {
                                BNegotiate negoResponse = new BNegotiate();
                                negoResponse.read(buf);

                                header.messageId = messageId;

                                BTransport utransport = wire.getClientUtilityRequests().getTransport();
                                utransport.applyNegotiate(negoResponse);
                            }
                            else
                            {
                                header.read(buf);
                            }

                            BMessage msg = buf != null ? new BMessage(header, buf, null) : null;
                            if (log.isDebugEnabled())
                            {
                                log.debug("asyncResult.set");
                            }
                            asyncResult.setAsyncResult(msg, ex);
                        }
                        else
                        {
                            asyncResult.setAsyncResult(null, ex);
                        }
                    }
                    catch (Exception e)
                    {
                        asyncResult.setAsyncResult(null, e);
                    }
                }
                if (log.isDebugEnabled())
                {
                    log.debug(")setAsyncResult");
                }
            }
Exemplo n.º 2
0
        public BProtocol negotiateProtocolServer(BTargetId targetId, ByteBuffer buf, BAsyncResultIF <ByteBuffer> asyncResult)
        {
            if (log.isDebugEnabled())
            {
                log.debug("negotiateProtocolServer(targetId=" + targetId);
            }
            BProtocol ret = null;

            try
            {
                if (log.isDebugEnabled())
                {
                    log.debug("read nego msg");
                }
                BNegotiate nego = new BNegotiate();
                nego.read(buf);

                lock (this)
                {
                    this.protocol = ret = createNegotiatedProtocol(nego);
                    this.setTargetId(targetId);
                    this.setSessionId(targetId.toSessionId());
                }
                if (log.isDebugEnabled())
                {
                    log.debug("protocol=" + this.protocol + ", targetId=" + this.targetId);
                }

                ByteBuffer bout = ByteBuffer.allocate(BNegotiate.NEGOTIATE_MAX_SIZE);
                try
                {
                    nego.targetId  = targetId;
                    nego.sessionId = targetId.toSessionId();
                    nego.write(bout);
                    bout.flip();
                    asyncResult.setAsyncResult(bout, null);
                }
                finally
                {
                }
            }
            catch (Exception e)
            {
                asyncResult.setAsyncResult(null, e);
            }
            if (log.isDebugEnabled())
            {
                log.debug(")negotiateProtocolServer=" + ret);
            }
            return(ret);
        }
Exemplo n.º 3
0
            public void setAsyncResult(BMessage msg, Exception ex)
            {
                if (log.isDebugEnabled())
                {
                    log.debug("setAsyncResult(msg=" + msg + ", ex=" + ex);
                }
                try
                {
                    if (ex != null)
                    {
                        innerResult.setAsyncResult(false, ex);
                    }
                    else
                    {
                        if (log.isDebugEnabled())
                        {
                            log.debug("read message");
                        }
                        BNegotiate nego = new BNegotiate();
                        nego.read(msg.buf);
                        transport.applyNegotiate(nego);
                        if (log.isDebugEnabled())
                        {
                            log.debug("protocol=" + transport.protocol + ", targetId=" + transport.targetId);
                        }

                        transport.internalAuthenticate(innerResult);
                    }
                }
                catch (Exception e)
                {
                    innerResult.setAsyncResult(false, e);
                }
                if (log.isDebugEnabled())
                {
                    log.debug(")setAsyncResult");
                }
            }