示例#1
0
        public void CallSsoService()
        {
            var login            = GetSsoDetails();
            var privateKey       = GetPrivateInfo();
            var expiredSeconds   = GetConfig(DataKey.SsoTokenExpired);
            var notBeforeSeconds = GetConfig(DataKey.SsoTokenNotBefore);
            var payload          = GetPayload(login, expiredSeconds, notBeforeSeconds);
            var token            = WebServiceExchangeHelper.CreateJwtToken(privateKey, payload);
            var data             = WebServiceExchangeHelper.GetCustomerTravelPlannerJson();
            var serviceUrl       = GetConfig(DataKey.OwrUrlConfigName);
            var content          = WebServiceExchangeHelper.SendHttpRequest(serviceUrl, token, data);
            var eventParams      = WebServiceExchangeHelper.ContentToEventParams(content);

            FireEvent(EventName.SsoCompleteEvent, eventParams);
        }
        public void CallSsoService(RequestActionEventArgs args)
        {
            var opportunityId     = GetParamValue(args, EntityRecords.Configuration.OwrOpportunityIdParamName);
            var createdByInitials = GetCreatorsInitials(opportunityId);
            var login             = GetSsoDetails(_client.CrmInterface.GetMyCrmUserId());
            var privateKey        = GetPrivateInfo();
            var expiredSeconds    = GetConfig(EntityRecords.Configuration.OwrSsoTokenExpired);
            var notBeforeSeconds  = GetConfig(EntityRecords.Configuration.OwrSsoTokenNotBefore);
            var payload           = GetPayload(login, expiredSeconds, notBeforeSeconds, createdByInitials);
            var token             = _jtiService.CreateJwtToken(privateKey, payload);
            var data        = WebServiceExchangeHelper.GetCustomerTravelPlannerJson();
            var serviceUrl  = GetConfig(EntityRecords.Configuration.OwrUrlConfigName);
            var content     = _jtiService.SendHttpRequest(HttpMethod.Post, serviceUrl, token, data).Content;
            var eventParams = WebServiceExchangeHelper.ContentToEventParams(content);

            FireEvent(EntityRecords.Configuration.SsoCompleteEvent, eventParams);
        }
示例#3
0
        private void CallTravelPlannerSso(string id)
        {
            var opportunity = CrmService.GetOpportunity(_client.CrmInterface, _logger, id);

            if (opportunity == null)
            {
                FireEventOnOwrError("There is no opportunity in context.");
                return;
            }

            var rooms             = CrmService.GetTravelPlannerRooms(id, _logger, _client.CrmInterface);
            var createdByInitials = opportunity.GetAttributeValue <string>(Opportunity.Initials);
            var login             = CrmService.GetSsoDetails(_client.CrmInterface.GetMyCrmUserId(), _logger, _client.CrmInterface);

            if (login == null)
            {
                FireEventOnOwrError("Login details are missing for the logged-in user.");
                return;
            }

            var privateKey = CrmService.GetPrivateInfo(_logger, _client.CrmInterface);

            if (privateKey == null)
            {
                FireEventOnOwrError("Private Key is missing in the system");
                return;
            }
            var expiredSeconds   = CrmService.GetConfig(Configuration.OwrSsoTokenExpired, _logger, _client.CrmInterface);
            var notBeforeSeconds = CrmService.GetConfig(Configuration.OwrSsoTokenNotBefore, _logger, _client.CrmInterface);

            if (expiredSeconds == null || notBeforeSeconds == null)
            {
                FireEventOnOwrError("Missing payload configuration");
                return;
            }
            var payload = GetPayload(login, expiredSeconds, notBeforeSeconds, createdByInitials);
            var token   = _jtiService.CreateJwtToken(privateKey, payload);

            if (token == null)
            {
                FireEventOnOwrError("JWT token is null");
                return;
            }
            var owrJsonHelper = new OwrJsonHelper(_client.CrmInterface, opportunity);
            var data          = owrJsonHelper.GetCustomerTravelPlannerJson(rooms);

            _logger.LogInformation($"Json to be passed to owr: {data}");
            var serviceUrl = CrmService.GetConfig(Configuration.OwrUrlConfigName, _logger, _client.CrmInterface);

            if (serviceUrl == null)
            {
                FireEventOnOwrError("Service Url is null");
                return;
            }
            var content = _jtiService.SendHttpRequest(HttpMethod.Post, serviceUrl, token, data).Content;

            if (content == null)
            {
                FireEventOnOwrError("Owr response content is null. Please See Details in log output");
                return;
            }
            var ssoResponse = WebServiceExchangeHelper.DeserializeOwrResponseJson(content, _logger);

            if (ssoResponse == null)
            {
                FireEventOnOwrError($"SSO Response could not be parsed. Response is {content}");
                return;
            }
            var eventParams = WebServiceExchangeHelper.ContentToEventParams(ssoResponse, _logger);

            if (eventParams == null)
            {
                FireEventOnOwrError("SSO Response could not be parsed. Please See Details in log output");
                return;
            }
            FireEventOnOwrSuccess(eventParams);
        }