public string Serialize()
        {
            IStateFormatter formatter = TokenPersister.CreateFormatter();
            State           state     = new State(_value, _signature, _creationDate);

            return(formatter.Serialize(state));
        }
Esempio n. 2
0
        public TeamTimeWarp_VsPackagePackage()
        {
            _restServiceUriFactory = new RestServiceUriFactory();

            _tokenStore            = new TokenStore();
            _tokenPersister        = new TokenPersister();
            _authenticationService = new AuthenticationService(_tokenStore, _restServiceUriFactory, _tokenPersister, new SynchronizationContext());
            _userStateService      = new UserStateService(_tokenStore, _restServiceUriFactory,
                                                          new AgentTypeProvider(TimeWarpAgent.VisualStudio));
        }
        private static Func <IStateFormatter> GetFormatterGenerator(bool encrypt, bool sign)
        {
            Link <Func <IStateFormatter> > factory = new Link <Func <IStateFormatter> >(
                () => TokenPersister.CreateFormatterGenerator(encrypt, sign)
                );

            return(() => {
                return factory.Value();
            });
        }
Esempio n. 4
0
        private static Func <IStateFormatter> LazilyGetFormatterGenerator(bool encrypt, bool sign)
        {
            Lazy <Func <IStateFormatter> > generatorFactory = new Lazy <Func <IStateFormatter> >(
                () => TokenPersister.CreateFormatterGenerator(encrypt, sign)
                );

            return(() => {
                Func <IStateFormatter> generator = generatorFactory.Eval();
                return generator();
            });
        }
Esempio n. 5
0
        public ServiceContainer(SynchronizationContext synchronizationContext)
        {
            var tokenStore    = new TokenStore();
            var uri           = new RestServiceUriFactory();
            var loginPersiter = new TokenPersister();

            AuthenticationService = new AuthenticationService(tokenStore, uri, loginPersiter, synchronizationContext);
            RoomService           = new RoomService(tokenStore, uri);
            GlobalRoomService     = new GlobalRoomsService(tokenStore, uri, synchronizationContext);
            UserStateService      = new UserStateService(tokenStore, uri, new AgentTypeProvider(TimeWarpAgent.WindowsTrayClient));
            UserMessageService    = new UserMessageService(tokenStore, uri, synchronizationContext);
        }
        public static RequestValidationToken Create(string serializedTokenData)
        {
            RequestValidationToken token     = new RequestValidationToken();
            IStateFormatter        formatter = TokenPersister.CreateFormatter();

            try
            {
                State state = (State)formatter.Deserialize(serializedTokenData);

                token._value        = state.Value;
                token._signature    = state.Signature;
                token._creationDate = state.CreationDate;
            }
            catch (Exception exception)
            {
                throw Error.RequestValidationError(exception);
            }
            return(token);
        }