예제 #1
0
        /// <summary>Receives SASL negotiation for general-purpose handshake.</summary>
        /// <param name="peer">connection peer</param>
        /// <param name="underlyingOut">connection output stream</param>
        /// <param name="underlyingIn">connection input stream</param>
        /// <returns>new pair of streams, wrapped after SASL negotiation</returns>
        /// <exception cref="System.IO.IOException">for any error</exception>
        private IOStreamPair GetSaslStreams(Peer peer, OutputStream underlyingOut, InputStream
                                            underlyingIn)
        {
            if (peer.HasSecureChannel() || dnConf.GetTrustedChannelResolver().IsTrusted(DataTransferSaslUtil.GetPeerAddress
                                                                                            (peer)))
            {
                return(new IOStreamPair(underlyingIn, underlyingOut));
            }
            SaslPropertiesResolver       saslPropsResolver = dnConf.GetSaslPropsResolver();
            IDictionary <string, string> saslProps         = saslPropsResolver.GetServerProperties(DataTransferSaslUtil.GetPeerAddress
                                                                                                       (peer));
            CallbackHandler callbackHandler = new SaslDataTransferServer.SaslServerCallbackHandler
                                                  (new _PasswordFunction_292(this));

            return(DoSaslHandshake(underlyingOut, underlyingIn, saslProps, callbackHandler));
        }
예제 #2
0
        /// <summary>Receives SASL negotiation for specialized encrypted handshake.</summary>
        /// <param name="peer">connection peer</param>
        /// <param name="underlyingOut">connection output stream</param>
        /// <param name="underlyingIn">connection input stream</param>
        /// <returns>new pair of streams, wrapped after SASL negotiation</returns>
        /// <exception cref="System.IO.IOException">for any error</exception>
        private IOStreamPair GetEncryptedStreams(Peer peer, OutputStream underlyingOut, InputStream
                                                 underlyingIn)
        {
            if (peer.HasSecureChannel() || dnConf.GetTrustedChannelResolver().IsTrusted(DataTransferSaslUtil.GetPeerAddress
                                                                                            (peer)))
            {
                return(new IOStreamPair(underlyingIn, underlyingOut));
            }
            IDictionary <string, string> saslProps = DataTransferSaslUtil.CreateSaslPropertiesForEncryption
                                                         (dnConf.GetEncryptionAlgorithm());

            if (Log.IsDebugEnabled())
            {
                Log.Debug("Server using encryption algorithm " + dnConf.GetEncryptionAlgorithm());
            }
            CallbackHandler callbackHandler = new SaslDataTransferServer.SaslServerCallbackHandler
                                                  (new _PasswordFunction_172(this));

            return(DoSaslHandshake(underlyingOut, underlyingIn, saslProps, callbackHandler));
        }