Пример #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 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");
            }
        }