public override object Handle(IMessage message, object target) { if (ReplayToken.IsReplay(message)) { return(null); } return(base.Handle(message, target)); }
private void CleanOldTokens() { DateTime staleBarrier = DateTime.Now.AddSeconds(-Settings.ReplayDetectionWindowSeconds); while (_queue.Count > 0 && _queue.Peek().UseTime < staleBarrier) { ReplayToken token = _queue.Dequeue(); _set.Remove(token); } }
public override bool Equals(object obj) { ReplayToken that = obj as ReplayToken; if (that == null) { return(false); } return(this.Hash == that.Hash); }
public override bool Equals(object obj) { ReplayToken that = obj as ReplayToken; if (that == null) { return(false); } return(this.SessionId == that.SessionId && this.SequenceNumber == that.SequenceNumber); }
public void CheckAndStore(string hash) { ReplayToken token = new ReplayToken(hash); if (_set.Contains(token)) { throw new AuthException("Message replay detected."); } _set.Add(token); _queue.Enqueue(token); CleanOldTokens(); }
public void CheckAndStore(int sessionId, int sequenceNumber) { ReplayToken token = new ReplayToken(sessionId, sequenceNumber); if (_set.Contains(token)) { throw new AuthException("Session message sequence replay detected."); } _set.Add(token); _queue.Enqueue(token); cleanOldTokens(); }
public new object?Handle(IMessage <object> message, T target) { return(ReplayToken.IsReplay(message) ? null : base.Handle(message, target)); }