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);
            }
        }
        /// <summary>
        /// Create a renewed Authentication Token on Master server - to be validated on GS
        /// </summary>
        /// <returns></returns>
        private VAppsAuthenticationToken CreateAuthenticationToken(ApplicationAccount account, IAuthenticateRequest authRequest,
                                                                   string userId, Dictionary <string, object> authCookie = null)
        {
            var token = new VAppsAuthenticationToken
            {
                ApplicationId      = account.ApplicationId,
                ApplicationVersion = authRequest.ApplicationVersion,
                MaxCcu             = int.MaxValue,
                IsCcuBurstAllowed  = true,
                UserId             = userId,
                PrivateCloud       = null,
                AuthCookie         = new Dictionary <string, object>(),
                HasExternalApi     = account.HasExternalApi,
                Flags = authRequest.Flags,
                CustomAuthProvider = authRequest.ClientAuthenticationType,
            };

            this.SetupToken(token);
            if (authCookie != null)
            {
                token.AuthCookie = authCookie;
            }
            return(token);
        }
 protected override bool TryDeserializeToken(byte[] tokenData, out AuthenticationToken authToken, out string errorMsg)
 {
     return(VAppsAuthenticationToken.TryDeserialize(tokenData, out authToken, out errorMsg));
 }