public void GoldenPressIncvRylands() { var test = new Encroachment { Consent = Consent.NotGiven(), SubjectProperty = new LegalProperty("some building") { IsEntitledTo = lp => lp is Rylands }, IsGoodFaithIntent = lp => true, IsUseAffected = lp => false, IsRemovalCostGreat = lp => lp is Rylands }; var testResult = test.IsValid(new GoldenPressInc(), new Rylands()); Assert.IsFalse(testResult); Console.WriteLine(test.ToString()); }
public async Task UpdateAsync(Consent consent) { MongoDbConsent item = await FindOneAsync(x => x.Subject == consent.Subject && x.ClientId == consent.ClientId); if (item != null) { item.Scopes = consent.Scopes; await UpdateAsync(item.Id, item); } else { MongoDbConsent c = new MongoDbConsent(consent) { Id = ObjectId.GenerateNewId().ToString() }; await CreateAsync(c); } }
public async Task <Consent> LoadAsync(string subject, string client) { var found = await dataModel.Consents.SingleOrDefaultAsync(x => x.Subject == subject && x.ClientId == client); if (found == null) { return(null); } var result = new Consent { Subject = found.Subject, ClientId = found.ClientId, Scopes = ParseScopes(found.Scopes) }; return(result); }
public async Task StoreUserConsentAsync_should_persist_grant() { var consent1 = new Consent() { CreationTime = DateTime.UtcNow, ClientId = "client", SubjectId = "123", Scopes = new string[] { "foo", "bar" } }; await _userConsent.StoreUserConsentAsync(consent1); var consent2 = await _userConsent.GetUserConsentAsync("123", "client"); consent2.ClientId.Should().Be(consent1.ClientId); consent2.SubjectId.Should().Be(consent1.SubjectId); consent2.Scopes.Should().BeEquivalentTo(new string[] { "bar", "foo" }); }
public async Task RemoveUserConsentAsync_should_remove_grant() { var consent1 = new Consent() { CreationTime = DateTime.UtcNow, ClientId = "client", SubjectId = "123", Scopes = new string[] { "foo", "bar" } }; await _userConsent.StoreUserConsentAsync(consent1); await _userConsent.RemoveUserConsentAsync("123", "client"); var consent2 = await _userConsent.GetUserConsentAsync("123", "client"); consent2.Should().BeNull(); }
public Consent GetConsent(string subjectId, string clientId) { Consent consent = null; Execute(uow => { var consentJson = uow.Cache.HashGet(KeyToConsentHash + subjectId, clientId); if (consentJson != null) { consent = Serializer.Deserialize <Consent>(consentJson); return; } consent = uow.Store.FirstOrDefault <Consent>(x => x.Subject == subjectId && x.ClientId == clientId); }); return(consent); }
public void SomervillevJacobs() { var test = new ImprovingTrespassers { SubjectProperty = new LegalProperty("Lot 47") { IsEntitledTo = lp => lp is Somerville }, Consent = Consent.NotGiven(), IsOwnerGoodFaithOblivious = lp => lp is Somerville, IsTrespasserGoodFaithIntent = lp => lp is Jacobs }; var testResult = test.IsValid(new Somerville(), new Jacobs()); Assert.IsTrue(testResult); Console.WriteLine(test.ToString()); }
/// <summary> /// Updates the consent asynchronous. /// </summary> /// <param name="client">The client.</param> /// <param name="subject">The subject.</param> /// <param name="parsedScopes">The parsed scopes.</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException"> /// client /// or /// subject /// </exception> public virtual async Task UpdateConsentAsync(ClaimsPrincipal subject, Client client, IEnumerable <ParsedScopeValue> parsedScopes) { if (client == null) { throw new ArgumentNullException(nameof(client)); } if (subject == null) { throw new ArgumentNullException(nameof(subject)); } if (client.AllowRememberConsent) { var subjectId = subject.GetSubjectId(); var clientId = client.ClientId; var scopes = parsedScopes?.Select(x => x.Value).ToArray(); if (scopes != null && scopes.Any()) { Logger.LogDebug("Client allows remembering consent, and consent given. Updating consent store for subject: {subject}", subject.GetSubjectId()); var consent = new Consent { CreationTime = Clock.UtcNow.UtcDateTime, SubjectId = subjectId, ClientId = clientId, Scopes = scopes }; if (client.ConsentLifetime.HasValue) { consent.Expiration = consent.CreationTime.AddSeconds(client.ConsentLifetime.Value); } await UserConsentStore.StoreUserConsentAsync(consent); } else { Logger.LogDebug("Client allows remembering consent, and no scopes provided. Removing consent from consent store for subject: {subject}", subject.GetSubjectId()); await UserConsentStore.RemoveUserConsentAsync(subjectId, clientId); } } }
static void Init(string bicFi, string affiliatedASPSPId) { // // Read configuration // var configurationBuilder = new ConfigurationBuilder(); configurationBuilder.AddJsonFile("appsettings.json", false, false); var config = configurationBuilder.Build(); _settings = config.Get <Settings>(); _accountinformationScope = $"{_settings.PSUContextScope} accountinformation"; _consent = new Consent(bicFi, affiliatedASPSPId); _apiClientHandler = new HttpClientHandler(); // // Set up for different environments // if (_settings.UseProductionEnvironment) { Console.WriteLine("Using production"); Console.WriteLine(); _authBaseUri = "https://auth.openbankingplatform.com"; _apiBaseUri = "https://api.openbankingplatform.com"; Console.Write("Enter Certificate Password: "******"Using sandbox"); Console.WriteLine(); _authBaseUri = "https://auth.sandbox.openbankingplatform.com"; _apiBaseUri = "https://api.sandbox.openbankingplatform.com"; } }
public static IEnumerable <IConsent> BuildEntities(IEnumerable <ConsentDto> dtos) { var ix = new Dictionary <string, Consent>(); var output = new List <Consent>(); foreach (ConsentDto dto in dtos) { var k = dto.Source + "::" + dto.Context + "::" + dto.Action; var consent = new Consent { Id = dto.Id, Current = dto.Current, CreateDate = dto.CreateDate, Source = dto.Source, Context = dto.Context, Action = dto.Action, State = (ConsentState)dto.State, // assume value is valid Comment = dto.Comment, }; // on initial construction we don't want to have dirty properties tracked // http://issues.umbraco.org/issue/U4-1946 consent.ResetDirtyProperties(false); if (ix.TryGetValue(k, out Consent? current)) { if (current.HistoryInternal == null) { current.HistoryInternal = new List <IConsent>(); } current.HistoryInternal.Add(consent); } else { ix[k] = consent; output.Add(consent); } } return(output); }
public void TestSearchIsValid01() { var testSubject = new Search { GetConductorOfSearch = lps => lps.FirstOrDefault(lp => lp is ExampleLawEnforcement), ExpectationOfPrivacy = new ExpectationOfPrivacy { GetSubjectOfSearch = lps => lps.FirstOrDefault(lp => lp is ExamplePersonSearched), Consent = Consent.IsGiven(), IsPrivacyExpected = lp => false, IsPrivacyExpectedReasonable = lp => false } }; var testResult = testSubject.IsValid(new ExamplePersonSearched(), new ExampleLawEnforcement()); Console.WriteLine(testSubject.ToString()); Assert.IsTrue(testResult); }
public ActionResult Create([Bind(Include = "ID,Description,InsertDate")] Consent consent, FormCollection collection) { if (ModelState.IsValid) { Data data = new Data(); for (int i = 2; i < collection.Count; i++) { string nameOFData = collection[i].ToString(); var query1 = (from m in db.Datas where m.NameOfData == nameOFData select m.ID); db.Consents.Add(consent); db.SaveChanges(); } return(RedirectToAction("Index")); } return(View(consent)); }
public async Task RevokeAsync(string subject, string client) { Consent found = null; if (options != null && options.SynchronousReads) { found = context.Consents.Find(subject, client); } else { found = await context.Consents.FindAsync(subject, client); } if (found != null) { context.Consents.Remove(found); await context.SaveChangesAsync(); } }
/// <inheritdoc /> public IConsent RegisterConsent(string source, string context, string action, ConsentState state, string comment = null) { // prevent stupid states var v = 0; if ((state & ConsentState.Pending) > 0) { v++; } if ((state & ConsentState.Granted) > 0) { v++; } if ((state & ConsentState.Revoked) > 0) { v++; } if (v != 1) { throw new ArgumentException("Invalid state.", nameof(state)); } var consent = new Consent { Current = true, Source = source, Context = context, Action = action, CreateDate = DateTime.Now, State = state, Comment = comment }; using (var uow = UowProvider.GetUnitOfWork()) { var repository = RepositoryFactory.CreateConsentRepository(uow); repository.ClearCurrent(source, context, action); repository.AddOrUpdate(consent); uow.Commit(); } return(consent); }
public IEnumerable <Claim> ToClaims() { if (!string.IsNullOrWhiteSpace(DisplayName)) { yield return(new Claim(SquidexClaimTypes.DisplayName, DisplayName)); } if (!string.IsNullOrWhiteSpace(PictureUrl)) { yield return(new Claim(SquidexClaimTypes.PictureUrl, PictureUrl)); } if (Hidden.HasValue) { yield return(new Claim(SquidexClaimTypes.Hidden, Hidden.ToString())); } if (Invited.HasValue) { yield return(new Claim(SquidexClaimTypes.Invited, Invited.ToString())); } if (Consent.HasValue) { yield return(new Claim(SquidexClaimTypes.Consent, Consent.ToString())); } if (ConsentForEmails.HasValue) { yield return(new Claim(SquidexClaimTypes.ConsentForEmails, ConsentForEmails.ToString())); } if (Permissions != null) { yield return(new Claim(SquidexClaimTypes.Permissions, string.Empty)); foreach (var permission in Permissions) { yield return(new Claim(SquidexClaimTypes.Permissions, permission.Id)); } } }
/// <inheritdoc /> public IConsent RegisterConsent(string source, string context, string action, ConsentState state, string comment = null) { // prevent stupid states var v = 0; if ((state & ConsentState.Pending) > 0) { v++; } if ((state & ConsentState.Granted) > 0) { v++; } if ((state & ConsentState.Revoked) > 0) { v++; } if (v != 1) { throw new ArgumentException("Invalid state.", nameof(state)); } var consent = new Consent { Current = true, Source = source, Context = context, Action = action, CreateDate = DateTime.Now, State = state, Comment = comment }; using (var scope = ScopeProvider.CreateScope()) { _consentRepository.ClearCurrent(source, context, action); _consentRepository.Save(consent); scope.Complete(); } return(consent); }
public async Task <ActionResult> StoreConsent( [FromHeader(Name = "X-GatewayID ")] string consentManagerId, [FromBody] ConsentArtefactRequest consentArtefactRequest) { if (consentArtefactRequest.Status == ConsentStatus.GRANTED) { var consent = new Consent(consentArtefactRequest.ConsentDetail.ConsentId, consentArtefactRequest.ConsentDetail, consentArtefactRequest.Signature, consentArtefactRequest.Status, consentManagerId); await consentRepository.AddAsync(consent); } else { await consentRepository.UpdateAsync(consentArtefactRequest.ConsentId, consentArtefactRequest.Status); } return(NoContent()); }
public async Task LoadsAllConsentsForASubject(NpgsqlConsentStore store, Consent consent1, Consent consent2) { // Given consent2.Subject = consent1.Subject; await store.UpdateAsync(consent1); await store.UpdateAsync(consent2); // When var fromDb = await store.LoadAllAsync(consent1.Subject); // Then fromDb.Count().ShouldBe(2); fromDb.ShouldContain(x => x.ClientId == consent1.ClientId); fromDb.ShouldContain(x => x.ClientId == consent2.ClientId); fromDb.ShouldContain(x => x.Scopes.All(y => consent1.Scopes.Contains(y))); fromDb.ShouldContain(x => x.Scopes.All(y => consent2.Scopes.Contains(y))); }
public ConsentStoreTests(PersistenceTestFixture data) : base(data) { _store = Factory.Resolve <IConsentStore>(); _subjectAConsents = new List <Consent>(); _subjectBConsents = new List <Consent>(); _subjectCConsents = new List <Consent>(); List <Task> tasks = new List <Task>(); foreach (var subject in new [] { new { Subject = SubjectA, Consents = (List <Consent>)_subjectAConsents }, new { Subject = SubjectB, Consents = (List <Consent>)_subjectBConsents }, new { Subject = SubjectC, Consents = (List <Consent>)_subjectCConsents } }) { for (int i = 0; i < 10; i++) { var consent = new Consent() { ClientId = "ClientId" + i, Scopes = new[] { "scope1", "scope2" }, Subject = subject.Subject }; subject.Consents.Add(consent); tasks.Add(_store.UpdateAsync(consent)); } } _setup = Task.WhenAll(tasks); }
public async Task StoreConsent(ConsentArtefactRepresentation consentArtefact, String correlationId) { var notification = consentArtefact.Notification; if (notification.Status == ConsentStatus.GRANTED) { var consent = new Consent(notification.ConsentDetail.ConsentId, notification.ConsentDetail, notification.Signature, notification.Status, notification.ConsentId); await consentRepository.AddAsync(consent); var cmSuffix = consent.ConsentArtefact.ConsentManager.Id; var gatewayResponse = new GatewayConsentRepresentation( Guid.NewGuid(), DateTime.Now.ToUniversalTime(), new ConsentUpdateResponse(ConsentUpdateStatus.OK.ToString(), notification.ConsentId), null, new Resp(consentArtefact.RequestId)); await gatewayClient.SendDataToGateway(PATH_CONSENT_ON_NOTIFY, gatewayResponse, cmSuffix, correlationId); } else { await consentRepository.UpdateAsync(notification.ConsentId, notification.Status); if (notification.Status == ConsentStatus.REVOKED) { var consent = await consentRepository.GetFor(notification.ConsentId); var cmSuffix = consent.ConsentArtefact.ConsentManager.Id; var gatewayResponse = new GatewayConsentRepresentation( Guid.NewGuid(), DateTime.Now.ToUniversalTime(), new ConsentUpdateResponse(ConsentUpdateStatus.OK.ToString(), notification.ConsentId), null, new Resp(consentArtefact.RequestId)); await gatewayClient.SendDataToGateway(PATH_CONSENT_ON_NOTIFY, gatewayResponse, cmSuffix, correlationId); } } }
public void OKeeffevSnyder() { var test = new AdversePossession(ExtensionMethods.Disseisor) { Consent = Consent.NotGiven(), IsExclusivePossession = lp => lp is Snyder, IsContinuousPossession = lp => true, IsOpenNotoriousPossession = lp => false, SubjectProperty = new OKeeffePaintings() { IsEntitledTo = lp => lp is OKeeffe, IsInPossessionOf = lp => lp is Snyder }, Inception = new DateTime(1972, 6, 1) }; var testResult = test.IsValid(new OKeeffe(), new Snyder()); Console.WriteLine(test.ToString()); Assert.IsFalse(testResult); }
/// <summary> /// Persists the subject's consent. /// </summary> /// <param name="consent">The consent.</param> /// <returns></returns> public Task UpdateAsync(Consent consent) { // makes a snapshot as a DB would consent.Scopes = consent.Scopes.ToArray(); var query = from c in _consents where c.Subject == consent.Subject && c.ClientId == consent.ClientId select c; var item = query.SingleOrDefault(); if (item != null) { item.Scopes = consent.Scopes; } else { _consents.Add(consent); } return(Task.FromResult(0)); }
public void BrownvGobble() { var test = new AdversePossession(ExtensionMethods.Disseisor) { SubjectProperty = new TwoFeetWideTract { IsEntitledTo = lp => lp is Gobble, IsInPossessionOf = lp => lp is Brown, }, Consent = Consent.NotGiven(), IsOpenNotoriousPossession = p => p is Brown, IsExclusivePossession = p => p is Brown, IsContinuousPossession = p => p is Brown, Inception = new DateTime(1931, 1, 1) }; var testResult = test.IsValid(new Brown(), new Gobble()); Console.WriteLine(test.ToString()); Assert.IsTrue(testResult); }
public void TestCreateAsync() { string testData = System.IO.File.ReadAllText(Path.Combine(TargetFolder, @"clients.json")); Consent consent = new Consent() { ClientId = "CLIENTID", Scopes = new List <string>() { "a", "b" }, Subject = "SUBJECT" }; ConsentRecord consentRecord = new ConsentRecord(new ConsentHandle(consent)); _consentStore.CreateAsync(consentRecord.Record); var result = _consentStore.LoadAsync(consent.Subject, consent.ClientId); ConsentRecord consentRecordStored = new ConsentRecord(new ConsentHandle(result.Result)); Assert.AreEqual(consentRecord.Id, consentRecordStored.Id); }
private void SetupConsentNotification(ConsentStatus consentStatus) { const string consentMangerId = "consentMangerId"; var notification = TestBuilder.Notification(consentStatus); var faker = new Faker(); consentNotification = new ConsentArtefactRepresentation(notification, DateTime.Now, faker.Random.Hash()); var consent = new Consent(notification.ConsentDetail.ConsentId, notification.ConsentDetail, notification.Signature, consentStatus, consentMangerId); consentRepository.Setup(x => x.AddAsync(consent)); consentRepository .Setup(x => x.GetFor(It.IsAny <string>())) .Returns(System.Threading.Tasks.Task.FromResult(consent)); }
public override bool IsValid(params ILegalPerson[] persons) { var defendant = this.Defendant(persons); if (defendant == null) { return(false); } var title = defendant.GetLegalPersonTypeName(); //is consented to jurisdiction if (Consent != null && Consent.IsValid(persons)) { AddReasonEntryRange(Consent.GetReasonEntries()); if (!GetReasonEntries().Any()) { AddReasonEntry($"{title} {defendant.Name}, {nameof(Consent)} {nameof(IsValid)} returned true"); } return(true); } //is pass minimum contact test if (IsMinimumContact(persons)) { return(true); } //idea of general in personam jurisdiction if (IsCourtDomicileLocationOfDefendant(defendant, title)) { return(true); } if (IsCourtCurrentLocationOfDefendant(defendant, title)) { return(true); } return(false); }
private static void ImportData(ConfigurationConsentItem[] configuration, Entities edc) { List <Consent> list = new List <Consent>(); foreach (ConfigurationConsentItem item in configuration) { Consent cns = new Consent { IsIPR = item.IsIPR, ProductivityRateMax = item.ProductivityRateMax, ProductivityRateMin = item.ProductivityRateMin, ValidFromDate = item.ValidFromDate, ValidToDate = item.ValidToDate, ConsentPeriod = item.ConsentPeriod, ConsentDate = item.ConsentDate, Title = item.ConsentNo }; list.Add(cns); } ; edc.Consent.InsertAllOnSubmit(list); } //ImportData
/// <summary> /// Updates the consent asynchronous. /// </summary> /// <param name="client">The client.</param> /// <param name="subject">The subject.</param> /// <param name="scopes">The scopes.</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException"> /// client /// or /// subject /// </exception> public virtual async Task UpdateConsentAsync(ClaimsPrincipal subject, Client client, IEnumerable <string> scopes) { if (client == null) { throw new ArgumentNullException(nameof(client)); } if (subject == null) { throw new ArgumentNullException(nameof(subject)); } if (client.AllowRememberConsent) { var subjectId = subject.GetSubjectId(); var clientId = client.ClientId; if (scopes != null && scopes.Any()) { var consent = new Consent { CreationTime = _options.UtcNow, SubjectId = subjectId, ClientId = clientId, Scopes = scopes }; if (client.ConsentLifetime.HasValue) { consent.Expiration = consent.CreationTime.AddSeconds(client.ConsentLifetime.Value); } await _userConsentStore.StoreUserConsentAsync(consent); } else { await _userConsentStore.RemoveUserConsentAsync(subjectId, clientId); } } }
public async Task UpdateAsync(IdentityServer3.Core.Models.Consent consent) { ExecuteInTransaction(session => { var item = session .Query <Consent>() .SingleOrDefault(c => c.Subject == consent.Subject && c.ClientId == consent.ClientId); if (item == null) { if (consent.Scopes == null || !consent.Scopes.Any()) { return; } item = new Consent { Subject = consent.Subject, ClientId = consent.ClientId, Scopes = StringifyScopes(consent.Scopes) }; session.Save(item); } else { if (consent.Scopes == null || !consent.Scopes.Any()) { session.Delete(item); } item.Scopes = StringifyScopes(consent.Scopes); session.SaveOrUpdate(item); } }); await TaskExtensions.CompletedTask; }
public void AustinvHealy03() { var testSubject = new PersonalJurisdiction(new StateCourt("Minnesota")) { Consent = Consent.NotGiven(), MinimumContact = new MinimumContact { GetCommerciallyEngagedLocation = lp => lp is Austin ? new[] { new VocaBase("North Dakota"), new VocaBase("South Dakota"), new VocaBase("Minnesota") } : null, }, GetInjuryLocation = lp => new VocaBase("Minnesota"), GetDomicileLocation = GetState, GetCurrentLocation = GetState }; var testResult = testSubject.IsValid(new HealyAsPlaintiff(), new AustinAsDefendant()); Assert.IsTrue(testResult); Console.WriteLine(testSubject.ToString()); }
public void Setup() { _cookieService = new FakeCookieService(); _consentUnderTest = new Consent(); _consentUnderTest.SetCookieService(_cookieService); }
public void Add(Consent consent) { context.Consents.Add(consent); }
internal static extern int WerReportSubmit( ReportHandle reportHandle, Consent consent, SubmitFlags flags, out SubmitResult result);
public ConsentFacade(Consent consent) { this.consent = consent; }