async public Task RemoveIdentityResourceAsync(IdentityResourceModel identityResource) { var collection = GetIdentityResourceCollection(); string id = identityResource.Name.IdentityNameToHexId(_cryptoService); await collection .DeleteOneAsync <IdentityResourceDocument>(d => d.Id == id); }
public void identity_resource_model() { var model = NewIdentityResourceModel; var model2 = new IdentityResourceModel(model.ToIdentityResource()); var model3 = NewIdentityResourceModel; model.ShouldBe(model2); model.ShouldNotBe(model3); }
public IActionResult Delete(IdentityResourceModel model) { var identity = _configurationDbContext.IdentityResources .FirstOrDefault(x => x.Id == model.Id); _configurationDbContext.IdentityResources.Remove(identity); _configurationDbContext.SaveChanges(); return(RedirectToAction(nameof(Index))); }
public Task RemoveIdentityResourceAsync(IdentityResourceModel identityResource) { FileInfo fi = new FileInfo($"{ _rootPath }/{ identityResource.Name.NameToHexId(_cryptoService) }.identity"); if (fi.Exists) { fi.Delete(); } return(Task.CompletedTask); }
public Task AddIdentityResourceAsync(IdentityResourceModel identityResource) { if (_identityResources.ContainsKey(identityResource.Name)) { throw new Exception($"Identity resource { identityResource.Name } already exists"); } _identityResources[identityResource.Name] = identityResource; return(Task.CompletedTask); }
public Task UpdateIdentityResourceAsync(IdentityResourceModel identityResource, IEnumerable <string> propertyNames) { if (!_identityResources.ContainsKey(identityResource.Name)) { throw new Exception($"Api with clientId { identityResource.Name } not exists"); } _identityResources[identityResource.Name] = identityResource; return(Task.CompletedTask); }
async public Task UpdateIdentityResourceAsync(IdentityResourceModel identityResource, IEnumerable <string> propertyNames) { FileInfo fi = new FileInfo($"{ _rootPath }/{ identityResource.Name.NameToHexId(_cryptoService) }.identity"); if (fi.Exists) { fi.Delete(); } await AddIdentityResourceAsync(identityResource); }
async public Task UpdateIdentityResourceAsync(IdentityResourceModel identityResource, IEnumerable <string> propertyNames = null) { var collection = GetIdentityResourceCollection(); string id = identityResource.Name.IdentityNameToHexId(_cryptoService); UpdateDefinition <IdentityResourceDocument> update = Builders <IdentityResourceDocument> .Update .Set("BlobData", _cryptoService.EncryptText(_blobSerializer.SerializeObject(identityResource))); await collection .UpdateOneAsync <IdentityResourceDocument>(d => d.Id == id, update); }
public static IdentityResourceInputModel ToInputModel(this IdentityResourceModel model) { var inputModel = new IdentityResourceInputModel() { Id = model.Id, Name = model.Name, DisplayName = model.DisplayName, Description = model.Description, UserClaims = model.UserClaims } ?? new IdentityResourceInputModel(); return(inputModel); }
async public Task UpdateIdentityResourceAsync(IdentityResourceModel identityResource, IEnumerable <string> propertyNames = null) { if (_tableStorage == null || identityResource == null) { return; } await _tableStorage.MergeEntity(_tablename, new BlobTableEntity(TableStorageBlobResourceDb.IdentityResourcePartitionKey, identityResource.RowKey(), identityResource, _cryptoService, _blobSerializer)); }
public static IdentityResourceModel ToModel(this IdentityResourceData data) { var model = new IdentityResourceModel() { Id = data.Id, Name = data.Name, DisplayName = data.DisplayName, Description = data.Description, Enabled = data.Enabled, UserClaims = data.UserClaims } ?? new IdentityResourceModel(); return(model); }
async public Task RemoveIdentityResourceAsync(IdentityResourceModel identityResource) { if (_tableStorage == null || identityResource == null) { return; } await _tableStorage.DeleteEntityAsync(_tablename, new BlobTableEntity(TableStorageBlobResourceDb.IdentityResourcePartitionKey, identityResource.RowKey(), identityResource, _cryptoService, _blobSerializer)); }
public Task RemoveIdentityResourceAsync(IdentityResourceModel identityResource) { if (!_identityResources.ContainsKey(identityResource.Name)) { throw new Exception($"Identity { identityResource.Name } not exists"); } if (!_identityResources.TryRemove(identityResource.Name, out identityResource)) { throw new Exception($"Can't remove identity"); } return(Task.CompletedTask); }
public async Task <IActionResult> Delete(IdentityResourceModel model) { if (model.Id == 0) { return(RedirectToAction(nameof(Index))); } var result = await _identityResourceService.DeleteIdentityResourceAsync(CommonMappers.Mapper.Map <IdentityResource>(model)); if (result) { SuccessNotification(await _localizationService.GetResourceAsync("IdentityResource.Deleted")); return(RedirectToAction(nameof(Index))); } return(View(model)); }
async public Task AddIdentityResourceAsync(IdentityResourceModel identityResource) { string id = identityResource.Name.NameToHexId(_cryptoService); FileInfo fi = new FileInfo($"{ _rootPath }/{ id }.identity"); if (fi.Exists) { throw new Exception("Identity resource already exists"); } byte[] buffer = Encoding.UTF8.GetBytes( _cryptoService.EncryptText(_blobSerializer.SerializeObject(identityResource))); using (var fs = new FileStream(fi.FullName, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None, buffer.Length, true)) { await fs.WriteAsync(buffer, 0, buffer.Length); } }
private bool CheckDataAndIdentityModel(IdentityResourceData data, IdentityResourceModel model) { return (data != null && model != null && data.Name == model.Name && data.DisplayName == model.DisplayName && data.Description == model.Description && data.Enabled == model.Enabled && data.Id == model.Id && data.UserClaims.All(dataUserClaim => model.UserClaims.Contains(dataUserClaim))); }
public ActionResult CreatIdentityResources(IdentityResourceModel model) { string sql = "INSERT INTO \"IdentityResources\" (\"Name\",\"DisplayName\",\"Enabled\",\"Description\",\"Required\",\"Emphasize\",\"ShowInDiscoveryDocument\") VALUES ( @name,@displayname,cast(@enabled as bool),@description,false,false,true);"; var paramList = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("name", model.ResourceName), new KeyValuePair <string, string>("displayname", model.DisplayName), new KeyValuePair <string, string>("enabled", model.Enabled.ToString()), new KeyValuePair <string, string>("description", model.Description) }; try { DataServices.executeSQLStatement(sql, paramList, "connectionString_SynapseIdentityStore"); } catch (Exception ex) { } return(RedirectToAction("IdentityResourceManager")); }
public async Task <IActionResult> Create(IdentityResourceModel model) { if (!ModelState.IsValid) { return(View(model)); } model.UserClaims = model.UserClaimsItems.Deserialize <List <string> >()?.Select(x => new IdentityResourceClaimModel { Type = x }).ToList(); var insertedResult = await _identityResourceService.InsertIdentityResourceAsync(CommonMappers.Mapper.Map <IdentityResource>(model)); if (insertedResult > 0) { SuccessNotification(await _localizationService.GetResourceAsync("IdentityResource.Added")); return(RedirectToAction(nameof(Index))); } return(View(model)); }
public DataResult <int> CreateIdentityResource(IdentityResourceModel identityResourceModel, IEnumerable <int> claimsIds) { var identityResourceEntity = new IdentityResourceEntity { Name = identityResourceModel.Name, Description = identityResourceModel.Description, Required = identityResourceModel.Required, ShowInDiscoveryDocument = identityResourceModel.ShowInDiscoveryDocument }; try { var result = m_identityResourceUoW.CreateIdentityResource(identityResourceEntity, claimsIds); return(Success(result)); } catch (DatabaseException e) { m_logger.LogWarning(e); return(Error <int>(e.Message)); } }
public IActionResult Edit(IdentityResourceModel model) { IdentityResource identity; if (model.Id == 0) { identity = new IdentityResource { UserClaims = new List <IdentityResourceClaim>(), }; _configurationDbContext.IdentityResources.Add(identity); } else { identity = _configurationDbContext.IdentityResources .Include(x => x.UserClaims) .FirstOrDefault(x => x.Id == model.Id); identity.UserClaims.Clear(); } model.UpdateEntity(identity); if (!string.IsNullOrEmpty(model.UserClaimsItems)) { model.UserClaims = JsonConvert.DeserializeObject <List <string> >(model.UserClaimsItems); identity.UserClaims.AddRange(model.UserClaims.Select(x => new IdentityResourceClaim { Type = x, })); } _configurationDbContext.SaveChanges(); return(RedirectToAction(nameof(Edit), new { id = identity.Id })); }
public async Task <IActionResult> OnGetAsync(int?id) { Id = id; if (!id.HasValue) { IdentityResource = new IdentityResourceModel(); } else { var identityResource = await LoadIdentityResource(id); if (identityResource == null) { return(NotFound()); } IdentityResource = identityResource.ToModel(); } LoadLookups(); return(Page()); }
async public Task AddIdentityResourceAsync(IdentityResourceModel identityResource) { if (identityResource == null) { return; } if (await FindApiResourceAsync(identityResource.Name) != null) { throw new Exception("Identity resource alread exists"); } string id = identityResource.Name.IdentityNameToHexId(_cryptoService); var collection = GetIdentityResourceCollection(); var document = new IdentityResourceDocument() { Id = id, BlobData = _cryptoService.EncryptText(_blobSerializer.SerializeObject(identityResource)) }; await collection.InsertOneAsync(document); }
async public Task LoadCurrentIdentityResourceAsync(string id) { this.CurrentIdentityResource = await _resourceDb.FindIdentityResource(id); }
public IActionResult Create() { var model = new IdentityResourceModel(); return(View(model)); }
public static void ToEntity(this IdentityResourceModel model, IdentityResource identityResource) { Mapper.Map(model, identityResource); }
public static IdentityResource ToEntity(this IdentityResourceModel resource) { return(resource == null ? null : Mapper.Map <IdentityResource>(resource)); }
static public string RowKey(this IdentityResourceModel identityResource) { return(identityResource.Name); }