Esempio n. 1
0
        public static string CreateSessionToken(HttpRequestMessage request)
        {
            ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

            _log.Info("AutoLogin.CreateSessionToken");
            HttpAuthentication _httpAuthentication     = new HttpAuthentication(WebApiConfig.CreateAuthenticationConfiguration(_log));
            string             _resultadoAutenticacion = _httpAuthentication.CreateSessionTokenResponse(_httpAuthentication.Authenticate(request));

            _log.Info("Resultado autenticación: " + _resultadoAutenticacion);
            return(_resultadoAutenticacion);
        }
Esempio n. 2
0
        private Task <HttpResponseMessage> SendSessionTokenResponse(ClaimsPrincipal principal)
        {
            var token         = _authN.CreateSessionToken(principal);
            var tokenResponse = _authN.CreateSessionTokenResponse(token);

            return(Task <HttpResponseMessage> .Factory.StartNew(() =>
            {
                var response = new HttpResponseMessage(HttpStatusCode.OK);
                response.Content = new StringContent(tokenResponse, Encoding.UTF8, "application/json");

                return response;
            }));
        }