/// <summary> /// Handle request for a cookie /// </summary> /// <param name="request">Cookie request. Not used; all requests are granted</param> /// <returns>A cookie that expires in 5 days.</returns> public Task <Cookie> GetCookieAsync(GetCookieRequest request) { return(Task.FromResult(new Cookie() { Expiration = DateTime.Now.AddDays(5), EncryptedData = new byte[12] })); }
public async Task <IEnumerable <Cookie> > GetAll([FromQuery] GetCookieRequest loginBody) { var CookieList = await _cookieService.GetAll(loginBody.Name, loginBody.Type, loginBody.Price, loginBody.Sweeteners, loginBody.Rating); //var model = _mapper.Map<IList<CookieResponse>>(CookieList); return(CookieList); }
/// <summary> /// Retrieves a server access cookie based on an authentication cookie. /// </summary> /// <param name="authCookie">The auth cookie to use when requesting the access cookie</param> /// <returns>An access cookie</returns> private async Task <Cookie> GetServerAccessCookie(WebServices.DssAuthentication.AuthorizationCookie authCookie) { var httpBinding = new System.ServiceModel.BasicHttpBinding(); var upstreamEndpoint = new System.ServiceModel.EndpointAddress(UpstreamEndpoint.ServerSyncURI); if (upstreamEndpoint.Uri.Scheme.Equals("https", StringComparison.OrdinalIgnoreCase)) { httpBinding.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.Transport; } // Create a service client on the default Microsoft upstream server. IServerSyncWebService serverSyncClient = new ServerSyncWebServiceClient(httpBinding, upstreamEndpoint); // Create an access cookie request using the authentication cookie parameter. var cookieRequest = new GetCookieRequest(); cookieRequest.GetCookie = new GetCookieRequestBody(); cookieRequest.GetCookie.authCookies = new WebServices.ServerSync.AuthorizationCookie[] { new WebServices.ServerSync.AuthorizationCookie() }; cookieRequest.GetCookie.authCookies[0].CookieData = authCookie.CookieData; cookieRequest.GetCookie.authCookies[0].PlugInId = authCookie.PlugInId; cookieRequest.GetCookie.oldCookie = null; cookieRequest.GetCookie.protocolVersion = "1.7"; GetCookieResponse cookieResponse; try { cookieResponse = await serverSyncClient.GetCookieAsync(cookieRequest); } catch (System.ServiceModel.FaultException ex) { throw new UpstreamServerException(ex); } if (cookieResponse == null || cookieResponse.GetCookieResponse1.GetCookieResult.EncryptedData == null) { throw new Exception("Failed to get access cookie. Response or cookie is null."); } return(cookieResponse.GetCookieResponse1.GetCookieResult); }