Пример #1
0
        public AuthenticateResponse GetToken()
        {
            AuthenticateResponse authenticateResponse;

            // first see if we have already got a token
            if (cacheService.ItemExists(CacheServiceEnum.GatewayToken))
            {
                authenticateResponse = cacheService.GetItem<AuthenticateResponse>(CacheServiceEnum.GatewayToken);
                // check that it has not expired
                if (authenticateResponse.Expiry > DateTime.Now)
                    return authenticateResponse;
            }

            // get new token
            DirectoryServiceSoapClient directoryServiceSoapClient = new DirectoryServiceSoapClient();
            authenticateResponse = directoryServiceSoapClient.Authenticate(new AuthenticateRequest
            {
                Application = settings.GatewaySettings.Application,
                BranchCode = settings.GatewaySettings.BranchCode,
                BranchID = settings.GatewaySettings.BranchID,
                UserName = settings.GatewaySettings.UserName,
                Password = settings.GatewaySettings.Password,
                RemoteIPAddress = HttpContext.Current.Request.UserHostAddress
            });

            // if it sucess then add it to the cache
            if (authenticateResponse.Success)
                cacheService.SetItem(CacheServiceEnum.GatewayToken, authenticateResponse);

            return authenticateResponse;
        }
Пример #2
0
        public AuthenticateResponse GetToken()
        {
            AuthenticateResponse authenticateResponse;

            // first see if we have already got a token
            if (cacheService.ItemExists(CacheServiceEnum.GatewayToken))
            {
                authenticateResponse = cacheService.GetItem <AuthenticateResponse>(CacheServiceEnum.GatewayToken);
                // check that it has not expired
                if (authenticateResponse.Expiry > DateTime.Now)
                {
                    return(authenticateResponse);
                }
            }

            // get new token
            DirectoryServiceSoapClient directoryServiceSoapClient = new DirectoryServiceSoapClient();

            authenticateResponse = directoryServiceSoapClient.Authenticate(new AuthenticateRequest
            {
                Application     = settings.GatewaySettings.Application,
                BranchCode      = settings.GatewaySettings.BranchCode,
                BranchID        = settings.GatewaySettings.BranchID,
                UserName        = settings.GatewaySettings.UserName,
                Password        = settings.GatewaySettings.Password,
                RemoteIPAddress = HttpContext.Current.Request.UserHostAddress
            });

            // if it sucess then add it to the cache
            if (authenticateResponse.Success)
            {
                cacheService.SetItem(CacheServiceEnum.GatewayToken, authenticateResponse);
            }

            return(authenticateResponse);
        }