本文整理汇总了C#中Blob.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Blob.ToString方法的具体用法?C# Blob.ToString怎么用?C# Blob.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Blob
的用法示例。
在下文中一共展示了Blob.ToString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: sendIdentity
/// <summary> Initiator API used by SASL-OTP consumers that don't use
/// the data on the startChannel option
///
/// If it works, we should get a challenge in our receiveRPY
/// callback ;)
/// </summary>
internal virtual void sendIdentity(System.String authorizeId, System.String authenticateId)
{
log.debug("OTP Authenticator sending Identities");
// Grok and validate the parameters
int limit = authenticateId.Length;
if ((System.Object) authorizeId != null)
{
limit += authorizeId.Length;
}
System.Text.StringBuilder temp = new System.Text.StringBuilder(limit);
if ((System.Object) authorizeId != null)
{
temp.Append(authorizeId);
}
temp.Append((char) 0);
temp.Append(authenticateId);
if (log.isDebugEnabled())
{
log.debug("AuthOTP Using=>" + temp.ToString() + "<=");
}
Blob blob = new Blob(Blob.STATUS_NONE, temp.ToString());
if (log.isDebugEnabled())
{
//UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1043"'
log.debug("AuthOTP Using=>" + blob.ToString() + "<=");
}
try
{
//UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1043"'
channel.sendMSG(new StringOutputDataStream(blob.ToString()), (ReplyListener) this);
}
catch (BEEPException x)
{
//UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1043"'
abort(x.Message);
}
}
示例2: receiveRPY
/// <summary> Method receiveRPY
/// Initiator API
///
/// We receive replies to our ID messages, and to our extended responses
/// Initiator API
///
/// </summary>
/// <param name="Message">message is the data we've received.
/// We parse it to see if it's identity information, an
/// abort, or otherwise.
///
/// </param>
public virtual void receiveRPY(Message message)
{
log.debug("OTP Authenticator.receiveRPY");
Blob blob = null;
// Don't send an abort if we got one.
bool sendAbort = true;
try
{
if ((state != STATE_STARTED) && (state != STATE_CHALLENGE) && (state != STATE_COMPLETE))
{
sendAbort = true;
}
try
{
System.IO.Stream is_Renamed = message.DataStream.InputStream;
long available;
available = is_Renamed.Length - is_Renamed.Position;
int limit = (int) available;
sbyte[] buff = new sbyte[limit];
SupportClass.ReadInput(is_Renamed, ref buff, 0, buff.Length);
blob = new Blob(new System.String(SupportClass.ToCharArray(SupportClass.ToByteArray(buff))));
}
catch (System.IO.IOException x)
{
//UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1043"'
abort(x.Message);
}
System.String status = blob.Status;
if (((System.Object) status != null) && status.Equals(SASLProfile.SASL_STATUS_ABORT))
{
log.debug("OTPAuthenticator receiveRPY got an RPY=>" + blob.Data);
sendAbort = false;
abort(ERR_PEER_ABORTED + blob.Data);
}
// If this reply is a reply to our authenticate message
if (state == STATE_STARTED)
{
receiveChallenge(blob);
return ;
}
// If it's a reply to our authentication request
else if ((System.Object) blob.Status != (System.Object) Blob.ABORT)
{
// Success case
// Set creds...
profile.finishInitiatorAuthentication(new SessionCredential(credential), channel.Session);
lock (this)
{
System.Threading.Monitor.Pulse(this);
}
return ;
}
else
{
// Error case
abort(ERR_UNKNOWN_COMMAND);
return ;
}
}
catch (System.Exception x)
{
log.error(x);
lock (this)
{
System.Threading.Monitor.Pulse(this);
}
// Throw an error
// Do a flag to indicate when this happens?
if (sendAbort)
{
try
{
//UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1043"'
Blob a = new Blob(Blob.STATUS_ABORT, x.Message);
//UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1043"'
channel.sendMSG(new StringOutputDataStream(a.ToString()), this);
}
catch (BEEPException y)
{
//UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1043"'
message.Channel.Session.terminate(y.Message);
//.........这里部分代码省略.........
示例3: receiveChallenge
/// <summary> Initiator API
/// Receive Challenge, respond with a hash.
/// </summary>
//UPGRADE_NOTE: Synchronized keyword was removed from method 'receiveChallenge'. Lock expression was added. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1027"'
internal virtual void receiveChallenge(Blob blob)
{
lock (this)
{
log.debug("OTP Authenticator received Challenge");
// If we're initiating, the last state we should
// have gotten to was STATE_STARTED
if (state != STATE_STARTED)
{
abortNoThrow(ERR_OTP_STATE);
}
if (blob.Status.Equals(Blob.ABORT))
{
abort(ERR_PEER_ABORTED);
}
System.String challenge = blob.Data;
// Parse Challenge, provide response
state = STATE_CHALLENGE;
int sequence = 0;
System.String seed = null, algo = null;
if (log.isDebugEnabled())
{
log.debug("Tokenizing=>" + challenge);
}
SupportClass.Tokenizer st = new SupportClass.Tokenizer(challenge);
if (st.Count != 4)
{
abort("Failed to understand server's Challenge" + st.Count);
}
algo = st.NextToken();
algorithm = SASLOTPProfile.getAlgorithm(algo);
if (algorithm == null)
{
abort("Unrecognized algorithm in server challenge");
}
sequence = System.Int32.Parse(st.NextToken());
seed = st.NextToken().ToLower();
if (!OTPGenerator.validateSeed(seed))
abort("Invalid Seed");
if (log.isDebugEnabled())
{
log.debug("Algo is=>" + algo + " seed is=>" + seed + " seq=>" + sequence);
}
System.String phrase = new System.Text.StringBuilder(seed + password).ToString();
password = null;
sbyte[] response = null, temp;
temp = SupportClass.ToSByteArray(SupportClass.ToByteArray(phrase));
for (int i = 0; i < sequence; i++)
{
response = algorithm.generateHash(temp);
temp = response;
}
if (log.isDebugEnabled())
{
log.debug(SASLOTPProfile.convertBytesToHex(temp));
}
long l = profile.convertBytesToLong(temp);
phrase = new System.Text.StringBuilder(WORD + OTPDictionary.convertHashToWords(l)).ToString();
if (log.isDebugEnabled())
{
log.debug("Prelim response is =>" + phrase + "<=");
}
// IF this is an init request
if ((System.Object) initData != null)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder(128);
sb.Append(SASLOTPProfile.HEX_INIT);
sb.Append(SASLOTPProfile.convertBytesToHex(temp));
sb.Append(initData);
phrase = sb.ToString();
if (log.isDebugEnabled())
{
log.debug("Produced INIT response of " + phrase);
}
}
try
{
blob = new Blob(Blob.STATUS_CONTINUE, phrase);
//UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1043"'
//.........这里部分代码省略.........
示例4: receiveMSG
/// <summary> Method receiveMSG
/// Listener API
///
/// We receive MSGS - IDs, and extended responses (hash)
/// in response to our challenges and stuff.
///
/// </summary>
/// <param name="Message">message is the data we've received.
/// We parse it to see if it's identity information, an
/// abort, or otherwise.
///
/// @throws BEEPError if an ERR message is generated
/// that's relative to the BEEP protocol is encountered.
/// </param>
public virtual void receiveMSG(MessageMSG message)
{
try
{
log.debug("OTP Authenticator.receiveMSG");
System.String data = null;
Blob blob = null;
if ((state != STATE_STARTED) && (state != STATE_ID))
{
abort(ERR_OTP_STATE);
}
// Read the data in the message and produce a Blob
try
{
System.IO.Stream is_Renamed = message.DataStream.InputStream;
long available;
available = is_Renamed.Length - is_Renamed.Position;
int limit = (int) available;
sbyte[] buff = new sbyte[limit];
SupportClass.ReadInput(is_Renamed, ref buff, 0, buff.Length);
blob = new Blob(new System.String(SupportClass.ToCharArray(SupportClass.ToByteArray(buff))));
data = blob.Data;
}
catch (System.IO.IOException x)
{
//UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1043"'
abort(x.Message);
}
if (log.isDebugEnabled())
{
log.debug("MSG DATA=>" + data);
}
System.String status = blob.Status;
if (((System.Object) status != null) && status.Equals(SASLProfile.SASL_STATUS_ABORT))
{
abort(ERR_PEER_ABORTED);
}
if (state == STATE_STARTED)
{
Blob reply = receiveIDs(data);
try
{
//UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1043"'
message.sendRPY(new StringOutputDataStream(reply.ToString()));
}
catch (BEEPException x)
{
//UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1043"'
throw new SASLException(x.Message);
}
return ;
}
// Process the user's password and stuff.
SessionCredential cred = null;
cred = validateResponse(data);
if (cred != null)
{
profile.finishListenerAuthentication(cred, channel.Session);
state = STATE_COMPLETE;
if (log.isDebugEnabled())
{
//UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1043"'
log.debug("" + channel.Session + " is valid for\n" + cred.ToString());
}
try
{
//UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1043"'
message.sendRPY(new StringOutputDataStream(new Blob(Blob.STATUS_COMPLETE).ToString()));
channel.setRequestHandler(null);
}
catch (BEEPException x)
{
profile.failListenerAuthentication(channel.Session, authenticated);
//UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1043"'
abortNoThrow(x.Message);
//UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1043"'
//.........这里部分代码省略.........