private DynamicTableEntity ConvertToTargetRoleEntity(DynamicTableEntity sourceEntity, IdentityCloudContext sourcesContext) { DynamicTableEntity targetEntity = null; //RoleClaim record if (sourceEntity.PartitionKey.StartsWith(Constants.RowKeyConstants.PreFixIdentityRole) && sourceEntity.RowKey.StartsWith(Constants.RowKeyConstants.PreFixIdentityRoleClaim)) { sourceEntity.Properties.TryGetValue("ClaimType", out EntityProperty claimTypeProperty); string claimType = claimTypeProperty.StringValue; sourceEntity.Properties.TryGetValue("ClaimValue", out EntityProperty claimValueProperty); string claimValue = claimValueProperty.StringValue; string roleName = GetRoleNameBySourceId(sourceEntity.PartitionKey, sourcesContext); targetEntity = new DynamicTableEntity(_keyHelper.GenerateRowKeyIdentityRole(roleName), _keyHelper.GenerateRowKeyIdentityRoleClaim(claimType, claimValue), Constants.ETagWildcard, sourceEntity.Properties); targetEntity.Properties["KeyVersion"] = new EntityProperty(_keyHelper.KeyVersion); } else if (sourceEntity.RowKey.StartsWith(Constants.RowKeyConstants.PreFixIdentityRole)) { sourceEntity.Properties.TryGetValue("Name", out EntityProperty roleNameProperty); string roleName = roleNameProperty.StringValue; targetEntity = new DynamicTableEntity(_keyHelper.GeneratePartitionKeyIdentityRole(roleName), _keyHelper.GenerateRowKeyIdentityRole(roleName), Constants.ETagWildcard, sourceEntity.Properties); targetEntity.Properties["KeyVersion"] = new EntityProperty(_keyHelper.KeyVersion); } return(targetEntity); }
/// <summary> /// Generates the RowKey without setting it on the object. /// </summary> /// <returns></returns> public string PeekRowKey(IKeyHelper keyHelper) { return(keyHelper.GenerateRowKeyIdentityRole(Name)); }