Exemplo n.º 1
0
        /// <summary>Sends client SASL negotiation for general-purpose handshake.</summary>
        /// <param name="addr">connection address</param>
        /// <param name="underlyingOut">connection output stream</param>
        /// <param name="underlyingIn">connection input stream</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>
        private IOStreamPair GetSaslStreams(IPAddress addr, OutputStream underlyingOut, InputStream
                                            underlyingIn, Org.Apache.Hadoop.Security.Token.Token <BlockTokenIdentifier> accessToken
                                            , DatanodeID datanodeId)
        {
            IDictionary <string, string> saslProps = saslPropsResolver.GetClientProperties(addr
                                                                                           );
            string userName = BuildUserName(accessToken);

            char[]          password        = BuildClientPassword(accessToken);
            CallbackHandler callbackHandler = new SaslDataTransferClient.SaslClientCallbackHandler
                                                  (userName, password);

            return(DoSaslHandshake(underlyingOut, underlyingIn, userName, saslProps, callbackHandler
                                   ));
        }
Exemplo n.º 2
0
        /// <summary>Sends client SASL negotiation for specialized encrypted handshake.</summary>
        /// <param name="underlyingOut">connection output stream</param>
        /// <param name="underlyingIn">connection input stream</param>
        /// <param name="encryptionKey">for an encrypted SASL handshake</param>
        /// <returns>new pair of streams, wrapped after SASL negotiation</returns>
        /// <exception cref="System.IO.IOException">for any error</exception>
        private IOStreamPair GetEncryptedStreams(OutputStream underlyingOut, InputStream
                                                 underlyingIn, DataEncryptionKey encryptionKey)
        {
            IDictionary <string, string> saslProps = DataTransferSaslUtil.CreateSaslPropertiesForEncryption
                                                         (encryptionKey.encryptionAlgorithm);

            Log.Debug("Client using encryption algorithm {}", encryptionKey.encryptionAlgorithm
                      );
            string userName = GetUserNameFromEncryptionKey(encryptionKey);

            char[] password = DataTransferSaslUtil.EncryptionKeyToPassword(encryptionKey.encryptionKey
                                                                           );
            CallbackHandler callbackHandler = new SaslDataTransferClient.SaslClientCallbackHandler
                                                  (userName, password);

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