Esempio n. 1
0
        public async Task ReceiveAsync(AuthenticationTokenReceiveContext context)
        {
            context.AssertNotNull("context");

            var allowedOrigin = context.OwinContext.Get <string>(Core.Constants.TokenAllowedOriginKey);

            if (allowedOrigin == null)
            {
                throw new InvalidOperationException("Allowed origin not found.");
            }

            Helper.SetAccessControlAllowOrigin(context.OwinContext, allowedOrigin);

            var suppliedRefreshTokenId  = context.Token;
            var encryptedrefreshTokenId = this.encryptionService.EncryptRefreshTokenId(new RefreshTokenId(suppliedRefreshTokenId));

            var refreshToken = await this.tryGetRefreshTokenByEncryptedId.HandleAsync(new TryGetRefreshTokenByEncryptedIdQuery(encryptedrefreshTokenId));

            if (refreshToken != null)
            {
                // Get protectedTicket from refreshToken class
                context.DeserializeTicket(refreshToken.ProtectedTicket);
            }
            else
            {
                Trace.TraceWarning("Refresh token not found: " + encryptedrefreshTokenId);
            }
        }