/// <exception cref="System.IO.IOException"/> public HdfsDataOutputStream(CryptoOutputStream @out, FileSystem.Statistics stats, long startPosition) : base(@out, stats, startPosition) { Preconditions.CheckArgument(@out.GetWrappedStream() is DFSOutputStream, "CryptoOutputStream should wrap a DFSOutputStream" ); }
/// <summary> /// Write the contents of the DataStream to an output stream. /// </summary> /// <param name="stream"> </param> /// <exception cref="IOException"> </exception> public virtual void send(CryptoOutputStream stream) { try { stream.writeLength(totalLength); for (DataSegment segment = firstSegment; segment != null; segment = segment.next) { stream.Write(segment.buffer, 0, segment.length); } stream.Flush(); } finally { reset(); } }
/// <summary> /// Create IOStreamPair of /// <see cref="Org.Apache.Hadoop.Crypto.CryptoInputStream"/> /// and /// <see cref="Org.Apache.Hadoop.Crypto.CryptoOutputStream"/> /// </summary> /// <param name="conf">the configuration</param> /// <param name="cipherOption">negotiated cipher option</param> /// <param name="out">underlying output stream</param> /// <param name="in">underlying input stream</param> /// <param name="isServer">is server side</param> /// <returns>IOStreamPair the stream pair</returns> /// <exception cref="System.IO.IOException">for any error</exception> public static IOStreamPair CreateStreamPair(Configuration conf, CipherOption cipherOption , OutputStream @out, InputStream @in, bool isServer) { if (Log.IsDebugEnabled()) { Log.Debug("Creating IOStreamPair of CryptoInputStream and " + "CryptoOutputStream." ); } CryptoCodec codec = CryptoCodec.GetInstance(conf, cipherOption.GetCipherSuite()); byte[] inKey = cipherOption.GetInKey(); byte[] inIv = cipherOption.GetInIv(); byte[] outKey = cipherOption.GetOutKey(); byte[] outIv = cipherOption.GetOutIv(); InputStream cIn = new CryptoInputStream(@in, codec, isServer ? inKey : outKey, isServer ? inIv : outIv); OutputStream cOut = new CryptoOutputStream(@out, codec, isServer ? outKey : inKey , isServer ? outIv : inIv); return(new IOStreamPair(cIn, cOut)); }
/// <exception cref="System.IO.IOException"/> public HdfsDataOutputStream(CryptoOutputStream @out, FileSystem.Statistics stats) : this(@out, stats, 0L) { }