コード例 #1
0
        private object GetActivityTemplateId(ActivityDTO ad)
        {
            if (ad.ActivityTemplate == null)
            {
                return(null);
            }

            return(_activityTemplate.GetByNameAndVersion(ad.ActivityTemplate).Id);
        }
コード例 #2
0
        public bool ValidateAuthenticationNeeded(IUnitOfWork uow, string userId, ActivityDTO activityDTO)
        {
            var activityTemplate = _activityTemplate.GetByNameAndVersion(activityDTO.ActivityTemplate);

            if (activityTemplate == null)
            {
                throw new MissingObjectException($"Activity template with name '{activityDTO.ActivityTemplate.Name}' and version '{activityDTO.ActivityTemplate.Version}' doesn't exist");
            }

            var activityDO = uow.PlanRepository.GetById <ActivityDO>(activityDTO.Id);

            if (activityDO == null)
            {
                throw new MissingObjectException($"Activity with Id {activityDTO.Id} doesn't exist");
            }

            if (activityTemplate.Terminal.AuthenticationType != AuthenticationType.None &&
                activityTemplate.NeedsAuthentication)
            {
                RemoveAuthenticationCrate(activityDTO);

                AuthorizationTokenDO authToken;
                TryAssignAuthToken(uow, userId, activityTemplate.TerminalId, activityDO, out authToken);

                // FR-1958: remove token if could not extract secure data.
                if (authToken != null && string.IsNullOrEmpty(authToken.Token))
                {
                    EventManager.AuthTokenSilentRevoke(authToken);

                    RemoveToken(uow, authToken);
                    authToken = null;
                }

                if (authToken == null)
                {
                    AddAuthenticationCrate(activityDTO, activityTemplate.Terminal.AuthenticationType);
                    return(true);
                }
            }
            return(false);
        }