Ejemplo n.º 1
0
 public EncryptedPeer(Peer enclosedPeer, IOStreamPair ios)
 {
     this.enclosedPeer = enclosedPeer;
     this.@in          = ios.@in;
     this.@out         = ios.@out;
     this.channel      = ios.@in is ReadableByteChannel ? (ReadableByteChannel)ios.@in : null;
 }
Ejemplo n.º 2
0
        /// <summary>Sends client SASL negotiation for a socket if required.</summary>
        /// <param name="socket">connection socket</param>
        /// <param name="underlyingOut">connection output stream</param>
        /// <param name="underlyingIn">connection input stream</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 IOStreamPair SocketSend(Socket socket, OutputStream underlyingOut,
                                               InputStream underlyingIn, DataEncryptionKeyFactory encryptionKeyFactory, Org.Apache.Hadoop.Security.Token.Token
                                               <BlockTokenIdentifier> accessToken, DatanodeID datanodeId)
        {
            IOStreamPair ios = CheckTrustAndSend(socket.GetInetAddress(), underlyingOut, underlyingIn
                                                 , encryptionKeyFactory, accessToken, datanodeId);

            return(ios != null ? ios : new IOStreamPair(underlyingIn, underlyingOut));
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        /// <summary>Sends client SASL negotiation for a newly allocated socket if required.</summary>
        /// <param name="socket">connection socket</param>
        /// <param name="underlyingOut">connection output stream</param>
        /// <param name="underlyingIn">connection input stream</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 IOStreamPair NewSocketSend(Socket socket, OutputStream underlyingOut
                                                  , InputStream underlyingIn, DataEncryptionKeyFactory encryptionKeyFactory, Org.Apache.Hadoop.Security.Token.Token
                                                  <BlockTokenIdentifier> accessToken, DatanodeID datanodeId)
        {
            // The encryption key factory only returns a key if encryption is enabled.
            DataEncryptionKey encryptionKey = !trustedChannelResolver.IsTrusted() ? encryptionKeyFactory
                                              .NewDataEncryptionKey() : null;
            IOStreamPair ios = Send(socket.GetInetAddress(), underlyingOut, underlyingIn, encryptionKey
                                    , accessToken, datanodeId);

            return(ios != null ? ios : new IOStreamPair(underlyingIn, underlyingOut));
        }