public async Task<IHttpActionResult> Get(string realm = "", string tokenType = "", string redirect_uri = "", bool deflate = false, bool sign_out = false)
        {
            var message = new SignInRequestMessage(realm, tokenType, redirect_uri, deflate, sign_out);

            var result = await _validator.ValidateAsync(Request.RequestUri.AbsoluteUri, message, User as ClaimsPrincipal);

            if (result.IsSignout)
            {
                var url = this.Request.GetOwinContext().Environment.GetIdentityServerLogoutUrl();
                return Redirect(url);
            }

            if (result.IsSignInRequired)
            {
                Logger.Info("Redirect to login page");
                return RedirectToLogin();
            }

            if (result.IsError)
            {
                Logger.Error(result.Error);
                return BadRequest(result.Error);
            }

            var responseMessage = await _signInResponseGenerator.GenerateResponseAsync(message, result,Request);
            
            return responseMessage;

            
        }
        /// <summary>
        /// Generate the reponse async
        /// </summary>
        /// <param name="message">The request input message</param>
        /// <param name="result">The validation result</param>
        /// <param name="request">The original http request</param>
        /// <returns></returns>
        public async Task<IHttpActionResult> GenerateResponseAsync(SignInRequestMessage message, SignInValidationResult result,HttpRequestMessage request)
        {
            Logger.Info("Creating SiteFinity signin response");

            var principal = new ClaimsPrincipal(result.Subject);
            var identity = ClaimsPrincipal.PrimaryIdentitySelector(principal.Identities);

            var token =  CreateToken(identity.Name, identity.Claims, result);

            NameValueCollection queryString;
            if (!String.IsNullOrEmpty(result.ReplyUrl))
            {
                string path;
                var idx = result.ReplyUrl.IndexOf('?');
                if (idx != -1)
                {
                    path = result.ReplyUrl.Substring(0, idx);
                    queryString = ParseQueryString(result.ReplyUrl.Substring(idx + 1));
                }
                else
                {
                    path = result.ReplyUrl;
                    queryString = new NameValueCollection();
                }
                WrapSWT(queryString, token, message.Deflate);
                path = String.Concat(path, ToQueryString(queryString));
                var uri = new Uri(new Uri(result.Realm), path);

                var redirectResult = new RedirectResult(uri,request);
                return redirectResult;
            }

            queryString = new NameValueCollection();
            WrapSWT(queryString, token, message.Deflate);

            var content = new StringContent(ToQueryString(queryString, false), Encoding.UTF8,"application/x-www-form-urlencoded");
            var responseMessage = request.CreateResponse(HttpStatusCode.OK,content);
            return new ResponseMessageResult(responseMessage);

        }