Exemple #1
0
        /// <summary>Sends client SASL negotiation for a peer if required.</summary>
        /// <param name="peer">connection peer</param>
        /// <param name="encryptionKeyFactory">for creation of an encryption key</param>
        /// <param name="accessToken">connection block access token</param>
        /// <param name="datanodeId">ID of destination DataNode</param>
        /// <returns>new pair of streams, wrapped after SASL negotiation</returns>
        /// <exception cref="System.IO.IOException">for any error</exception>
        public virtual Peer PeerSend(Peer peer, DataEncryptionKeyFactory encryptionKeyFactory
                                     , Org.Apache.Hadoop.Security.Token.Token <BlockTokenIdentifier> accessToken, DatanodeID
                                     datanodeId)
        {
            IOStreamPair ios = CheckTrustAndSend(DataTransferSaslUtil.GetPeerAddress(peer), peer
                                                 .GetOutputStream(), peer.GetInputStream(), encryptionKeyFactory, accessToken, datanodeId
                                                 );

            // TODO: Consider renaming EncryptedPeer to SaslPeer.
            return(ios != null ? new EncryptedPeer(peer, ios) : peer);
        }
        /// <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));
        }
        /// <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));
        }