public static AuthenticationToken Deserialize(byte[] data)
        {
            EventData eventData;

            if (!serializationProtocol.TryParseEventData(data, out eventData))
            {
                throw new SerializationException("Could not deserialize authentication token.");
            }

            var token = new AuthenticationToken(serializationProtocol, eventData.Parameters);

            return(token);
        }
        public new static bool TryDeserialize(byte[] data, out AuthenticationToken token, out string errorMsg)
        {
            token = null;
            EventData eventData;

            if (!serializationProtocol.TryParseEventData(data, out eventData, out errorMsg))
            {
                return(false);
            }

            // code = version
            switch (eventData.Code)
            {
            default:
                errorMsg = string.Format("Unknown version of token: {0}", eventData.Code);
                return(false);

            case 1:
                token = new VAppsAuthenticationToken(serializationProtocol, eventData.Parameters);
                return(true);
            }
        }
Example #3
0
        private void OnEventInternal(RtsMessageHeader header, byte[] data)
        {
            EventData data2;

            if (!(header.IsEncrypted ? protocol.TryParseEventDataEncrypted(data, this.CryptoProvider, out data2) : protocol.TryParseEventData(data, out data2)))
            {
                if (log.IsDebugEnabled)
                {
                    log.DebugFormat("Failed to parse event for peer with connection id {0}.", new object[] { this.ConnectionId });
                }
            }
            else
            {
                SendParameters sendParameters = new SendParameters
                {
                    Encrypted = header.IsEncrypted
                };
                this.OnEvent(data2, sendParameters);
            }
        }