protected override void AdditionalSetup()
        {
            _fixture = new Fixture().Customize(new AutoMoqCustomization());
            _fixture.Customize <MobileData>(md => md.With(x => x.EffectiveDate, DateTime.Now));

            _applicationProfile                  = _fixture.Create <ApplicationProfile>();
            _applicationProfile.DisplaySpan      = 3;
            _applicationProfile.DisplayRetention = 3;

            _applicationProfileRepoMock = _fixture.InjectNewMock <IApplicationProfileRepository>();
            _applicationProfileRepoMock.Setup(aprm => aprm.GetAllAsync()).ReturnsAsync(new List <ApplicationProfile>()
            {
                _applicationProfile
            });

            _mockMobileDataRepo = _fixture.InjectNewMock <IMobileDataRepository>();

            _fixture.Inject <IRepositories>(_fixture.Create <Repositories>());

            _navigationService = _fixture.InjectNewMock <INavigationService>();

            _infoService = _fixture.Create <InfoService>();
            _fixture.Inject <IInfoService>(_infoService);

            _mockCustomUserInteraction = Ioc.RegisterNewMock <ICustomUserInteraction>();

            _mockMessenger = Ioc.RegisterNewMock <IMvxMessenger>();
            _mockMessenger.Setup(m => m.Unsubscribe <GatewayInstructionNotificationMessage>(It.IsAny <MvxSubscriptionToken>()));
            _mockMessenger.Setup(m => m.Subscribe(It.IsAny <Action <GatewayInstructionNotificationMessage> >(), It.IsAny <MvxReference>(), It.IsAny <string>())).Returns(_fixture.Create <MvxSubscriptionToken>());

            Ioc.RegisterSingleton <INavigationService>(_navigationService.Object);
        }
Example #2
0
        public void MakeItSoSandboxes(ApplicationProfile app)
        {
            app.id = $"{_veracodeRepository.GetAllApps().SingleOrDefault(x => x.app_name == app.application_name).app_id}";
            _logger.LogInformation($"[{app.application_name}] Checking Sandboxes...");
            var current_sandboxes = _veracodeRepository.GetSandboxesForApp(app.id);
            var config_sandboxes  = app.sandboxes;

            if (!config_sandboxes.Any())
            {
                _logger.LogInformation($"[{app.application_name}] No sandboxes in configuration. Skipping.");
                return;
            }

            foreach (var config_sandbox in config_sandboxes)
            {
                if (!current_sandboxes.Any(x => x.sandbox_name == config_sandbox.sandbox_name))
                {
                    _logger.LogInformation($"[{app.application_name}] Does not have sandbox with name {config_sandbox.sandbox_name}. Creating...");
                    _veracodeRepository.CreateSandbox(app.id, config_sandbox.sandbox_name);
                    _logger.LogInformation($"[{app.application_name}] {config_sandbox.sandbox_name} creation complete!");
                }
                else
                {
                    _logger.LogInformation($"[{app.application_name}] {config_sandbox.sandbox_name} already exists! Nothing to do.");
                }
            }

            _logger.LogInformation($"[{app.application_name}] Finished Sandboxes!");
        }
Example #3
0
        public bool IsScanDueFromSchedule(ApplicationProfile app)
        {
            app.id = $"{_veracodeRepository.GetAllApps().SingleOrDefault(x => x.app_name == app.application_name).app_id}";
            var lastScan = _veracodeRepository.GetLatestScan(app.id);

            if (lastScan == null)
            {
                _logger.LogWarning($"[{app.application_name}] Has not had a scan yet, the first scan is due.");
                return(true);
            }

            if (lastScan.build.analysis_unit[0].status != BuildStatusType.ResultsReady)
            {
                _logger.LogWarning($"[{app.application_name}] Currently has a scan in progress in the status of [{lastScan.build.analysis_unit[0].status}]");
            }


            if (CronHelper.IsANewScanDue(app.policy_schedule, lastScan.build.analysis_unit[0].published_date))
            {
                var dueDays = CronHelper.HowManyDaysAgo(app.policy_schedule, lastScan.build.analysis_unit[0].published_date);
                _logger.LogWarning($"[{app.application_name}] last scan was {lastScan.build.analysis_unit[0].published_date.ToLongDateString()} and was due {dueDays} days ago.");
                return(true);
            }
            else
            {
                _logger.LogInformation($"A scan is not due according to the schedule.");
                _logger.LogInformation($"Last scan completed at {lastScan.build.analysis_unit[0].published_date.ToLongDateString()}");
            }

            _logger.LogInformation($"A new scan does not need to be started.");
            return(false);
        }
Example #4
0
        public void GetLatestStatus(ApplicationProfile app)
        {
            app.id = $"{_veracodeRepository.GetAllApps().SingleOrDefault(x => x.app_name == app.application_name).app_id}";
            var sandboxes           = _veracodeRepository.GetSandboxesForApp(app.id);
            var latest_policy_build = _veracodeRepository.GetLatestScan(app.id).build;

            var scanStatus = _veracodeService.GetScanStatus(app.id, $"{latest_policy_build.build_id}");

            _logger.LogInformation($"[{app.application_name}][Policy][Scan Status] {VeracodeEnumConverter.Convert(scanStatus)}");

            var compliance = VeracodeEnumConverter.Convert(latest_policy_build.policy_compliance_status);

            _logger.LogInformation($"[{app.application_name}][Policy][Compliance Status] {compliance}");

            foreach (var sandbox in sandboxes)
            {
                var latest_sandbox_build = _veracodeRepository.GetLatestScanSandbox(app.id, $"{sandbox.sandbox_id}");
                if (latest_sandbox_build == null)
                {
                    _logger.LogInformation($"[{app.application_name}][Sandbox {sandbox.sandbox_name}][Scan Status] There are no scans!");
                }
                else
                {
                    var latest_sandbox_build_id = $"{latest_sandbox_build.build.build_id}";
                    var scanSandboxStatus       = _veracodeService.GetScanStatus(app.id, latest_sandbox_build_id);
                    _logger.LogInformation($"[{app.application_name}][Sandbox {sandbox.sandbox_name}][Scan Status] {VeracodeEnumConverter.Convert(scanSandboxStatus)}");

                    var sandboxCompliance = VeracodeEnumConverter.Convert(latest_sandbox_build.build.policy_compliance_status);
                    _logger.LogInformation($"[{app.application_name}][Sandbox {sandbox.sandbox_name}][Compliance Status] {VeracodeEnumConverter.Convert(latest_sandbox_build.build.policy_compliance_status)}");
                }
            }
        }
Example #5
0
        public async Task ManifestVM_InstructionDisplaySpan_Include()
        {
            base.ClearAll();

            List <ApplicationProfile> appProfiles = new List <ApplicationProfile>();
            ApplicationProfile        appProfile  = new ApplicationProfile();

            appProfile.DisplayRetention = 2;
            appProfile.DisplaySpan      = 2;
            appProfiles.Add(appProfile);

            _mockApplicationProfile.Setup(map => map.GetAllAsync()).ReturnsAsync(appProfiles);

            List <MobileData> mobileDataStartedList = new List <MobileData>();
            var mobileData = _fixture.Create <MobileData>(new MobileData()
            {
                ProgressState = Core.Enums.InstructionProgress.OnSite
            });

            mobileData.EffectiveDate = DateTime.Now.AddDays(1);
            mobileDataStartedList.Add(mobileData);

            List <MobileData> mobileDataNotStartedList = new List <MobileData>();

            _mobileDataRepoMock.Setup(mdr => mdr.GetInProgressInstructionsAsync(It.IsAny <Guid>())).ReturnsAsync(mobileDataStartedList);
            _mobileDataRepoMock.Setup(mdr => mdr.GetNotStartedInstructionsAsync(It.IsAny <Guid>())).ReturnsAsync(mobileDataNotStartedList);

            var viewModel = _fixture.Build <ManifestViewModel>().Without(mvm => mvm.Sections).Create();
            await viewModel.Init();

            Assert.Equal((mobileDataStartedList.Count + mobileDataNotStartedList.Count), viewModel.InstructionsCount);
        }
Example #6
0
 protected void CreateTestMaps(ApplicationProfile profile)
 {
     foreach (var mappedType in MappedTypes)
     {
         profile.CreateMaps(mappedType);
     }
 }
Example #7
0
 internal VirtualMachineData(ResourceIdentifier id, string name, ResourceType type, SystemData systemData, IDictionary <string, string> tags, AzureLocation location, Models.Plan plan, IReadOnlyList <VirtualMachineExtensionData> resources, ManagedServiceIdentity identity, IList <string> zones, Models.ExtendedLocation extendedLocation, HardwareProfile hardwareProfile, StorageProfile storageProfile, AdditionalCapabilities additionalCapabilities, OSProfile osProfile, NetworkProfile networkProfile, SecurityProfile securityProfile, DiagnosticsProfile diagnosticsProfile, WritableSubResource availabilitySet, WritableSubResource virtualMachineScaleSet, WritableSubResource proximityPlacementGroup, VirtualMachinePriorityTypes?priority, VirtualMachineEvictionPolicyTypes?evictionPolicy, BillingProfile billingProfile, WritableSubResource host, WritableSubResource hostGroup, string provisioningState, VirtualMachineInstanceView instanceView, string licenseType, string vmId, string extensionsTimeBudget, int?platformFaultDomain, ScheduledEventsProfile scheduledEventsProfile, string userData, CapacityReservationProfile capacityReservation, ApplicationProfile applicationProfile) : base(id, name, type, systemData, tags, location)
 {
     Plan                    = plan;
     Resources               = resources;
     Identity                = identity;
     Zones                   = zones;
     ExtendedLocation        = extendedLocation;
     HardwareProfile         = hardwareProfile;
     StorageProfile          = storageProfile;
     AdditionalCapabilities  = additionalCapabilities;
     OSProfile               = osProfile;
     NetworkProfile          = networkProfile;
     SecurityProfile         = securityProfile;
     DiagnosticsProfile      = diagnosticsProfile;
     AvailabilitySet         = availabilitySet;
     VirtualMachineScaleSet  = virtualMachineScaleSet;
     ProximityPlacementGroup = proximityPlacementGroup;
     Priority                = priority;
     EvictionPolicy          = evictionPolicy;
     BillingProfile          = billingProfile;
     Host                    = host;
     HostGroup               = hostGroup;
     ProvisioningState       = provisioningState;
     InstanceView            = instanceView;
     LicenseType             = licenseType;
     VmId                    = vmId;
     ExtensionsTimeBudget    = extensionsTimeBudget;
     PlatformFaultDomain     = platformFaultDomain;
     ScheduledEventsProfile  = scheduledEventsProfile;
     UserData                = userData;
     CapacityReservation     = capacityReservation;
     ApplicationProfile      = applicationProfile;
 }
Example #8
0
        public async Task <Result> CreateAsync(ApplicationUserDTO userDto)
        {
            ApplicationUser user = await Database.UserManager.FindByEmailAsync(userDto.Email);

            if (user == null)
            {
                user = new ApplicationUser {
                    Email = userDto.Email, UserName = userDto.Email
                };
                var result = await Database.UserManager.CreateAsync(user, userDto.Password);

                if (result.Errors.Count() > 0)
                {
                    return(new Result(false, result.Errors.FirstOrDefault(), ""));
                }
                await Database.UserManager.AddToRoleAsync(user.Id, userDto.Role);

                ApplicationProfile clientProfile = new ApplicationProfile {
                    Id = user.Id, Name = userDto.ApplicationProfile.Name, Balance = userDto.ApplicationProfile.Balance, CreditCard = userDto.ApplicationProfile.CreditCard
                };
                user.ApplicationProfile = clientProfile;
                var list = Database.UserManager.Users.ToList();
                await Database.SaveAsync();

                return(new Result(true, $"User {userDto.Email} has been registered", ""));
            }
            else
            {
                return(new Result(false, $"The user with {userDto.Email} is already registered", "Email"));
            }
        }
Example #9
0
        protected override void AdditionalSetup()
        {
            _fixture = new Fixture().Customize(new AutoMoqCustomization());
            _fixture.Register <IReachability>(() => Mock.Of <IReachability>(r => r.IsConnected() == true));

            _mobileData            = _fixture.Create <MobileData>();
            _mobileData.GroupTitle = "Run1010";

            _infoService = _fixture.Create <InfoService>();
            _fixture.Inject <IInfoService>(_infoService);

            _mockApplicationProfile = _fixture.InjectNewMock <IApplicationProfileRepository>();
            List <ApplicationProfile> appProfiles = new List <ApplicationProfile>();
            ApplicationProfile        appProfile  = new ApplicationProfile();

            appProfile.DisplayRetention = 2;
            appProfile.DisplaySpan      = 2;
            appProfiles.Add(appProfile);

            _mockApplicationProfile.Setup(map => map.GetAllAsync()).ReturnsAsync(appProfiles);

            _mobileDataRepoMock = _fixture.InjectNewMock <IMobileDataRepository>();

            _fixture.Inject <IRepositories>(_fixture.Create <Repositories>());

            _mockMessenger = Ioc.RegisterNewMock <IMvxMessenger>();
            _mockMessenger.Setup(m => m.Unsubscribe <GatewayInstructionNotificationMessage>(It.IsAny <MvxSubscriptionToken>()));
            _mockMessenger.Setup(m => m.Subscribe(It.IsAny <Action <GatewayInstructionNotificationMessage> >(), It.IsAny <MvxReference>(), It.IsAny <string>())).Returns(_fixture.Create <MvxSubscriptionToken>());

            _mockCheckForSoftwareUpdates = Ioc.RegisterNewMock <ICheckForSoftwareUpdates>();

            _mockNavigationService = _fixture.InjectNewMock <INavigationService>();
            Ioc.RegisterSingleton <INavigationService>(_mockNavigationService.Object);
        }
Example #10
0
        public bool HasAppChanged(ApplicationProfile app)
        {
            var retrievedApp = _veracodeRepository.GetAllApps()
                               .SingleOrDefault(x => x.app_name == app.application_name);

            if (retrievedApp == null)
            {
                Console.WriteLine($"There is no application profile with the name {app.application_name}.");
                return(true);
            }

            var appDetail = _veracodeRepository.GetAppDetail($"{retrievedApp.app_id}");

            if (appDetail.application[0].business_criticality != VeracodeEnumConverter.Convert(app.criticality))
            {
                Console.WriteLine($"The criticality for {app.application_name} is no longer {appDetail.application[0].business_criticality} it is {app.criticality}.");
                return(true);
            }

            if (appDetail.application[0].business_owner_email != app.business_owner_email)
            {
                Console.WriteLine($"The business_owner_email for {app.application_name} is no longer {appDetail.application[0].business_owner_email} it is {app.business_owner_email}.");
                return(true);
            }

            if (appDetail.application[0].business_owner != app.business_owner)
            {
                Console.WriteLine($"The business_owner for {app.application_name} is no longer {appDetail.application[0].business_owner} it is {app.business_owner}.");
                return(true);
            }
            return(false);
        }
Example #11
0
 public void DeleteApp(ApplicationProfile app)
 {
     _veracodeRepository.DeleteApp(new ApplicationType
     {
         app_id = Int32.Parse(app.id)
     });
 }
Example #12
0
        public void DeleteProfile(ApplicationProfile profile)
        {
            if (profile != null && !String.IsNullOrWhiteSpace(profile.ProfileFilepath))
            {
                if (Profile.Equals(profile))
                {
                    SwitchToProfile(Profiles[Math.Max(Profiles.IndexOf(profile) - 1, 0)]);
                }

                if (Profiles.Contains(profile))
                {
                    Profiles.Remove(profile);
                }

                if (File.Exists(profile.ProfileFilepath))
                {
                    try
                    {
                        File.Delete(profile.ProfileFilepath);
                    }
                    catch (Exception exc)
                    {
                        Global.logger.LogLine($"Could not delete profile with path \"{profile.ProfileFilepath}\"", Logging_Level.Error);
                        Global.logger.LogLine($"Exception: {exc}", Logging_Level.Error, false);
                    }
                }

                SaveProfiles();
            }
        }
        protected override void AdditionalSetup()
        {
            var mockDispatcher = new MockDispatcher();

            Ioc.RegisterSingleton <IMvxViewDispatcher>(mockDispatcher);
            Ioc.RegisterSingleton <IMvxMainThreadDispatcher>(mockDispatcher);

            _mockUserInteraction = Ioc.RegisterNewMock <ICustomUserInteraction>();

            _fixture = new Fixture().Customize(new AutoMoqCustomization());

            _fixture.Register <IReachability>(() => Mock.Of <IReachability>(r => r.IsConnected() == true));

            _driver = new Core.Models.Driver()
            {
                LastName = "TestName", ID = Guid.NewGuid()
            };

            _trailer = new Core.Models.Trailer()
            {
                Registration = "TestRegistration", ID = Guid.NewGuid()
            };
            _trailerItemViewModel = new TrailerItemViewModel()
            {
                Trailer = _trailer
            };

            _infoService = _fixture.Create <InfoService>();
            _infoService.CurrentDriverID = _driver.ID;
            _fixture.Inject <IInfoService>(_infoService);

            _currentDriverRepository = new Mock <ICurrentDriverRepository>();
            _currentDriverRepository.Setup(cdr => cdr.GetByIDAsync(It.IsAny <Guid>())).ReturnsAsync(new CurrentDriver());
            _fixture.Inject <ICurrentDriverRepository>(_currentDriverRepository.Object);

            _applicationProfile = new ApplicationProfile {
                LastVehicleAndDriverSync = DateTime.Now
            };
            _applicationRepository = _fixture.InjectNewMock <IApplicationProfileRepository>();
            _applicationRepository.Setup(ar => ar.GetAllAsync()).ReturnsAsync(new List <ApplicationProfile>()
            {
                _applicationProfile
            });

            _trailerRepository = new Mock <ITrailerRepository>();
            _fixture.Inject <ITrailerRepository>(_trailerRepository.Object);

            var mockAuthenticationService = new Mock <IAuthenticationService>();

            mockAuthenticationService.Setup(m => m.AuthenticateAsync(It.IsAny <string>())).ReturnsAsync(new AuthenticationResult {
                Success = false
            });
            mockAuthenticationService.Setup(m => m.AuthenticateAsync(It.Is <string>(s => s == "9999"))).ReturnsAsync(new AuthenticationResult {
                Success = true, Driver = _driver
            });
            _fixture.Inject <IAuthenticationService>(mockAuthenticationService.Object);

            _fixture.Inject <IRepositories>(_fixture.Create <Repositories>());
        }
Example #14
0
        protected override ApplicationProfile CreateNewProfile(string profileName)
        {
            ApplicationProfile profile = (ApplicationProfile)Activator.CreateInstance(Config.ProfileType, Path.GetFileNameWithoutExtension(Config.ID));

            profile.ProfileName     = profileName;
            profile.ProfileFilepath = Path.Combine(GetProfileFolderPath(), GetValidFilename(profile.ProfileName) + ".json");
            return(profile);
        }
Example #15
0
        protected virtual ApplicationProfile CreateNewProfile(string profileName)
        {
            ApplicationProfile profile = (ApplicationProfile)Activator.CreateInstance(Config.ProfileType);

            profile.ProfileName     = profileName;
            profile.ProfileFilepath = Path.Combine(GetProfileFolderPath(), GetUnusedFilename(GetProfileFolderPath(), profile.ProfileName) + ".json");
            return(profile);
        }
Example #16
0
        public bool ConformToPreviousScan(ApplicationProfile app, Module[] configModules)
        {
            app.id = $"{_veracodeRepository.GetAllApps().SingleOrDefault(x => x.app_name == app.application_name).app_id}";
            var latest_build   = _veracodeRepository.GetLatestScan(app.id);
            var prescanModules = _veracodeService.GetModules(app.id, $"{latest_build.build.build_id}");

            return(DoesModuleConfigConform($"{latest_build.build.build_id}", configModules, prescanModules));
        }
        public void GetAttributeShouldReturnNullWhenNoAttributePresent()
        {
            var applicationProfile = new ApplicationProfile();

            YotiAttribute <string> notPresentAttribute = applicationProfile.GetAttributeByName <string>("notPresent");

            Assert.IsNull(notPresentAttribute);
        }
Example #18
0
        private void CtrlProfileManager_ProfileSelected(ApplicationProfile profile)
        {
            profilePresenter.Profile = profile;

            if (_selectedManager.Equals(this.ctrlProfileManager))
            {
                SelectedControl = profilePresenter;
            }
        }
Example #19
0
 protected void Application_Start()
 {
     ApplicationProfile.Run();
     GlobalConfiguration.Configure(WebApiConfig.Register);
     AreaRegistration.RegisterAllAreas();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
 }
Example #20
0
        public void Update(ApplicationProfile profile)
        {
            using (var conn = Database.Open())
            {
                string sql = "UPDATE regiser_profile SET LastUpdate =@LastUpdate, Content =@Content WHERE Id =@Id";

                conn.Execute(sql, new { LastUpdate = profile.LastUpdate, Content = profile.Content, Id = profile.Id });
            }
        }
        public void Update(ApplicationProfile profile)
        {
            using (var conn = Database.Open())
            {
                string sql = "UPDATE regiser_profile SET LastUpdate =@LastUpdate, Content =@Content WHERE Id =@Id";

                conn.Execute(sql, new { LastUpdate = profile.LastUpdate, Content = profile.Content, Id = profile.Id });
            }
        }
Example #22
0
        private void CtrlProfileManager_ProfileSelected(ApplicationProfile profile)
        {
            profilecontrol_presenter.Profile = profile;

            if (_selectedManager.Equals(this.ctrlProfileManager))
            {
                this.content_grid.Content = profilecontrol_presenter;
            }
        }
        private void InviteCandidate(ApplicationProfile obj)
        {
            NavigationParameters p = new NavigationParameters();

            p.Add("JobPostId", obj.JobPostId);
            p.Add("ProfileId", obj.ProfileId);

            _nav.NavigateAsync(nameof(CandidateInvitePage), p);
        }
 internal ActivityDetails(string rememberMeId, string parentRememberMeId, DateTime?timestamp, YotiProfile yotiProfile, ApplicationProfile applicationProfile, string receiptId, ExtraData extraData)
 {
     RememberMeId       = rememberMeId;
     ParentRememberMeId = parentRememberMeId;
     Timestamp          = timestamp;
     Profile            = yotiProfile;
     ApplicationProfile = applicationProfile;
     ReceiptId          = receiptId;
     ExtraData          = extraData;
 }
Example #25
0
 public bool CreateTeamForApp(ApplicationProfile app)
 {
     _veracodeRepository.CreateTeam(new teaminfo
     {
         team_name = $"{app.application_name}"
     });
     return(_veracodeRepository
            .GetTeams()
            .Any(x => x.team_name == app.application_name));
 }
Example #26
0
        public void AddProfile(ApplicationProfile profile)
        {
            if (Disposed)
            {
                return;
            }

            profile.ProfileFilepath = Path.Combine(GetProfileFolderPath(), GetUnusedFilename(GetProfileFolderPath(), profile.ProfileName) + ".json");
            this.Profiles.Add(profile);
        }
Example #27
0
        public void SaveDefaultProfile()
        {
            ApplicationProfile _newProfile = CreateNewProfile($"Profile {Profiles.Count + 1}");

            Profiles.Add(_newProfile);

            SaveProfiles();

            SwitchToProfile(_newProfile);
        }
Example #28
0
        protected void CreateDefaultProfile()
        {
            ApplicationProfile _newProfile = CreateNewProfile("default");

            Profiles.Add(_newProfile);

            SaveProfiles();

            SwitchToProfile(_newProfile);
        }
        public async Task Init(Guid navID)
        {
            DoneButtonEnabled       = false;
            _navData                = _navigationService.GetNavData <MobileData>(navID);
            this.MessageId          = navID;
            _additionalInstructions = _navData.GetAdditionalInstructions();
            _appProfile             = (await _repositories.ApplicationRepository.GetAllAsync()).First();
            await this.GetDeliveryInstructionsAsync();

            DoneButtonEnabled = true;
        }
        public static ActivityDetails HandleResponse(AsymmetricCipherKeyPair keyPair, string responseContent)
        {
            if (string.IsNullOrEmpty(responseContent))
            {
                throw new YotiProfileException(Properties.Resources.NullOrEmptyResponseContent);
            }

            ProfileDO parsedResponse = JsonConvert.DeserializeObject <ProfileDO>(responseContent);

            if (parsedResponse.Receipt == null)
            {
                throw new YotiProfileException(Properties.Resources.NullParsedResponse);
            }
            else if (parsedResponse.Receipt.SharingOutcome != "SUCCESS")
            {
                throw new YotiProfileException(
                          $"The share was not successful, sharing_outcome: '{parsedResponse.Receipt.SharingOutcome}'");
            }

            ReceiptDO receipt = parsedResponse.Receipt;

            var userProfile = new YotiProfile(
                ParseProfileContent(keyPair, receipt.WrappedReceiptKey, receipt.OtherPartyProfileContent));

            SetAddressToBeFormattedAddressIfNull(userProfile);

            var applicationProfile = new ApplicationProfile(
                ParseProfileContent(keyPair, receipt.WrappedReceiptKey, receipt.ProfileContent));

            ExtraData extraData = new ExtraData();

            if (!string.IsNullOrEmpty(parsedResponse.Receipt.ExtraDataContent))
            {
                extraData = CryptoEngine.DecryptExtraData(
                    receipt.WrappedReceiptKey,
                    parsedResponse.Receipt.ExtraDataContent,
                    keyPair);
            }

            DateTime?timestamp = null;

            if (receipt.Timestamp != null &&
                DateTime.TryParseExact(
                    receipt.Timestamp,
                    "yyyy-MM-ddTHH:mm:ssZ",
                    CultureInfo.InvariantCulture,
                    DateTimeStyles.AdjustToUniversal,
                    out DateTime parsedDate))
            {
                timestamp = parsedDate;
            }

            return(new ActivityDetails(parsedResponse.Receipt.RememberMeId, parsedResponse.Receipt.ParentRememberMeId, timestamp, userProfile, applicationProfile, parsedResponse.Receipt.ReceiptId, extraData));
        }
Example #31
0
        public void MakeItSoTeam(ApplicationProfile app)
        {
            _logger.LogInformation($"Checking to see if team {app.application_name} already exists.");
            if (!_veracodeService.DoesTeamExistForApp(app))
            {
                _logger.LogInformation($"Team {app.application_name} does not exist, adding configuration.");
                try
                {
                    _veracodeService.CreateTeamForApp(app);
                    _logger.LogInformation($"Team {app.application_name} created succesfully.");
                }
                catch (Exception e)
                {
                    _logger.LogError($"Team {app.application_name} could not be created!");
                    _logger.LogError($"{e.Message}.");
                }
                return;
            }

            _logger.LogInformation($"Team {app.application_name} exists.");
            var usersInTeam = _veracodeService.GetUserEmailsOnTeam(app);

            foreach (var user in usersInTeam)
            {
                _logger.LogInformation($"Checking if {user.email_address} is assigned to team {app.application_name}.");
                if (!_veracodeService.IsUserAssignedToTeam(user, app))
                {
                    _logger.LogInformation($"User {user.email_address} is not assigned to team {app.application_name}, updating configuration.");
                    try
                    {
                        if (string.IsNullOrEmpty(user.teams))
                        {
                            user.teams = $"{app.application_name}";
                        }
                        else
                        {
                            user.teams = $",{app.application_name}";
                        }

                        _veracodeService.UpdateUser(user);
                        _logger.LogInformation($"User {user.email_address} assigned to team {app.application_name} succesfully.");
                    }
                    catch (Exception e)
                    {
                        _logger.LogError($"User {user.email_address} could not be added to team {app.application_name}!");
                        _logger.LogError($"{e.Message}.");
                    }
                }
                else
                {
                    _logger.LogInformation($"User {user.email_address} is already assigned to team {app.application_name}.");
                }
            }
        }
        public void Add(ApplicationProfile profile)
        {
            using (var conn = Database.Open())
            {
                string sql = @"INSERT INTO regiser_profile
	                            (ApplicationName, ProfileName, ContentType, CreateDate, LastUpdate, Content)
	                            VALUES (@ApplicationName, @ProfileName, @ContentType, @CreateDate, @LastUpdate, @Content);select last_insert_id()";

                int result = conn.ExecuteScalar<int>(sql, profile);
                helper.SetValue(m => m.Id, profile, result);
            }
        }
        public void UpdateTest()
        {
            var profile = new ApplicationProfile("123", "123", ProfileContentType.XML);
            profile.UpdateContent("12123");

            RepositoryRegistry.ApplicationProfile.Add(profile);

            profile.UpdateContent("9999");
            RepositoryRegistry.ApplicationProfile.Update(profile);

            var actual = RepositoryRegistry.ApplicationProfile.FindBy(profile.Id);
            Assert.AreEqual(profile.Content, actual.Content);
            Assert.AreEqual(profile.LastUpdate.Hour, actual.LastUpdate.Hour);
        }
Example #34
0
 public FileResult ApplicationProfile(string profileguid)
 {
     var profile = new ApplicationProfile();
     var resourceStream = new MemoryStream(profile.JsonData());
     return new FileStreamResult(resourceStream, "text/javascript");
 }
 /// <summary>
 /// Add application profile
 /// </summary>
 /// <param name="ApplicationProfile">Profile to add</param>
 /// <returns>The interface class for the profile that was added.</returns>
 public MeshApplication Add(ApplicationProfile ApplicationProfile) {
     return null;
     }