コード例 #1
0
        public void negotiateProtocolClient(BAsyncResultIF <Boolean> asyncResult)
        {
            if (log.isDebugEnabled())
            {
                log.debug("negotiateProtocolClient(");
            }

            ByteBuffer buf  = ByteBuffer.allocate(BNegotiate.NEGOTIATE_MAX_SIZE);
            BNegotiate nego = new BNegotiate(apiDesc);

            nego.write(buf);
            buf.flip();

            BAsyncResultIF <BMessage> outerResult = new MyNegoAsyncResult(this, asyncResult);

            if (log.isDebugEnabled())
            {
                log.debug("wire.send");
            }
            BMessageHeader header = new BMessageHeader();

            header.messageId = wire.makeMessageId();
            BMessage msg = new BMessage(header, buf, null);

            wire.send(msg, outerResult);
            if (log.isDebugEnabled())
            {
                log.debug(")negotiateProtocolClient");
            }
        }
コード例 #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);
        }
コード例 #3
0
ファイル: BTransport.cs プロジェクト: ThomasEcherer/elo
        public void negotiateProtocolClient(BAsyncResultIF <Boolean> asyncResult)
        {
            if (log.isDebugEnabled())
            {
                log.debug("negotiateProtocolClient(");
            }
            if (log.isDebugEnabled())
            {
                log.debug("negotiateActive=" + negotiateActive);
            }

            // Check that we do not run into recursive authentication requests.
            lock (asyncResultsWaitingForAuthentication)
            {
                // Already have an active negotiation request?
                if (negotiateActive)
                {
                    // Are there threads waiting?
                    if (asyncResultsWaitingForAuthentication.Count != 0)
                    {
                        // Most likely slow or recursive authentication
                        BException ex = new BException(BExceptionC.FORBIDDEN,
                                                       "Authentication procedure failed. Server returned 401 for every request. "
                                                       + "A common reason for this error is slow authentication handling.");
                        // ... or calling a function that requires authentication in BAuthentication.authenticate() - see. TestRemoteWithAuthentication.testAuthenticateBlocksRecursion
                        asyncResult.setAsyncResult(false, ex);
                        return;
                    }
                    else
                    {
                        // Correction: if no threads are waiting then there cannot be an aktive negotiation request.
                        negotiateActive = true;
                    }
                }
                else
                {
                    // Now, this is the active negotiation request.
                    negotiateActive = true;
                }
            }


            ByteBuffer buf  = ByteBuffer.allocate(BNegotiate.NEGOTIATE_MAX_SIZE);
            BNegotiate nego = new BNegotiate(apiDesc);

            nego.write(buf);
            buf.flip();

            BAsyncResultIF <BMessage> outerResult = new MyNegoAsyncResult(this, asyncResult);

            if (log.isDebugEnabled())
            {
                log.debug("wire.send");
            }
            BMessageHeader header = new BMessageHeader();

            header.messageId = wire.makeMessageId();
            BMessage msg = new BMessage(header, buf, null);

            wire.send(msg, outerResult);
            if (log.isDebugEnabled())
            {
                log.debug(")negotiateProtocolClient");
            }
        }