コード例 #1
0
 /// <summary>Unwraps a byte array.</summary>
 /// <param name="bytes">The array containing the bytes to unwrap.</param>
 /// <param name="off">The starting position at the array</param>
 /// <param name="len">The number of bytes to unwrap</param>
 /// <returns>byte[] unwrapped bytes</returns>
 /// <exception cref="Javax.Security.Sasl.SaslException">if the bytes cannot be successfully unwrapped
 ///     </exception>
 public virtual byte[] Unwrap(byte[] bytes, int off, int len)
 {
     if (saslClient != null)
     {
         return(saslClient.Unwrap(bytes, off, len));
     }
     else
     {
         return(saslServer.Unwrap(bytes, off, len));
     }
 }
コード例 #2
0
 /// <summary>
 /// Read more data and get them processed <br />
 /// Entry condition: ostart = ofinish <br />
 /// Exit condition: ostart <= ofinish &lt;br>
 /// return (ofinish-ostart) (we have this many bytes for you), 0 (no data now,
 /// but could have more later), or -1 (absolutely no more data)
 /// </summary>
 /// <exception cref="System.IO.IOException"/>
 private int ReadMoreData()
 {
     try
     {
         inStream.ReadFully(lengthBuf);
         int length = UnsignedBytesToInt(lengthBuf);
         if (Log.IsDebugEnabled())
         {
             Log.Debug("Actual length is " + length);
         }
         saslToken = new byte[length];
         inStream.ReadFully(saslToken);
     }
     catch (EOFException)
     {
         return(-1);
     }
     try
     {
         if (saslServer != null)
         {
             // using saslServer
             obuffer = saslServer.Unwrap(saslToken, 0, saslToken.Length);
         }
         else
         {
             // using saslClient
             obuffer = saslClient.Unwrap(saslToken, 0, saslToken.Length);
         }
     }
     catch (SaslException se)
     {
         try
         {
             DisposeSasl();
         }
         catch (SaslException)
         {
         }
         throw;
     }
     ostart = 0;
     if (obuffer == null)
     {
         ofinish = 0;
     }
     else
     {
         ofinish = obuffer.Length;
     }
     return(ofinish);
 }