private void RemoveCertificate()
 {
     _thumbprint = null;
     Model.EncryptionCertificate = null;
     HandleModificationState.EntityUpdated(Model);
     StateHasChanged();
 }
        private async Task SetThrumprint(byte[] content)
        {
            var client = _factory.CreateClient("oidc");

            using var putContent = new ByteArrayContent(content);
            try
            {
                var response = await client.PutAsync("api/certificate", putContent).ConfigureAwait(false);

                if (!response.IsSuccessStatusCode)
                {
                    _thumbprint = new[] { Localizer["Invalid file"].Value };
                    await InvokeAsync(StateHasChanged).ConfigureAwait(false);

                    return;
                }

                Model.EncryptionCertificate = content;
                _thumbprint = await JsonSerializer.DeserializeAsync <IEnumerable <string> >(await response.Content.ReadAsStreamAsync()).ConfigureAwait(false);

                HandleModificationState.EntityUpdated(Model);
                await InvokeAsync(StateHasChanged).ConfigureAwait(false);
            }
            catch (CryptographicException)
            {
                _thumbprint = new[] { Localizer["Invalid file"].Value };
                await InvokeAsync(StateHasChanged).ConfigureAwait(false);
            }
        }
Esempio n. 3
0
 protected EntityModel()
 {
     HandleModificationState = new HandleModificationState
     {
         OnStateChange = OnStateChange
     };
 }
Esempio n. 4
0
 private void AddValue()
 {
     if (_value == null)
     {
         return;
     }
     Collection.Add(_value);
     HandleModificationState.EntityUpdated(Model);
     _value = null;
 }
Esempio n. 5
0
        private Task AddResource(Entity.EntityResourceKind kind)
        {
            var entity = new Entity.ApiScopeLocalizedResource
            {
                ResourceKind = kind
            };

            Model.Resources.Add(entity);
            HandleModificationState.EntityCreated(entity);
            return(Task.CompletedTask);
        }
Esempio n. 6
0
        protected override async Task OnInitializedAsync()
        {
            Localizer.OnResourceReady              = () => InvokeAsync(StateHasChanged);
            HandleModificationState                = new HandleModificationState(Logger);
            HandleModificationState.OnStateChange += HandleModificationState_OnStateChange;

            if (Id == null)
            {
                IsNew = true;
                var newModel = await Create().ConfigureAwait(false);

                CreateEditContext(newModel);
                EntityCreated(Model);
                return;
            }

            var model = await GetModelAsync()
                        .ConfigureAwait(false);

            CreateEditContext(model);
        }
        protected override Task <Entity.RelyingParty> Create()
        {
            var claimMappingList = new List <Entity.RelyingPartyClaimMapping>
            {
                new Entity.RelyingPartyClaimMapping
                {
                    FromClaimType = JwtClaimTypes.Name,
                    ToClaimType   = ClaimTypes.Name
                },
                new Entity.RelyingPartyClaimMapping
                {
                    FromClaimType = JwtClaimTypes.Subject,
                    ToClaimType   = ClaimTypes.NameIdentifier
                },
                new Entity.RelyingPartyClaimMapping
                {
                    FromClaimType = JwtClaimTypes.Email,
                    ToClaimType   = ClaimTypes.Email
                },
                new Entity.RelyingPartyClaimMapping
                {
                    FromClaimType = JwtClaimTypes.GivenName,
                    ToClaimType   = ClaimTypes.GivenName
                },
                new Entity.RelyingPartyClaimMapping
                {
                    FromClaimType = JwtClaimTypes.FamilyName,
                    ToClaimType   = ClaimTypes.Surname
                },
                new Entity.RelyingPartyClaimMapping
                {
                    FromClaimType = JwtClaimTypes.BirthDate,
                    ToClaimType   = ClaimTypes.DateOfBirth
                },
                new Entity.RelyingPartyClaimMapping
                {
                    FromClaimType = JwtClaimTypes.WebSite,
                    ToClaimType   = ClaimTypes.Webpage
                },
                new Entity.RelyingPartyClaimMapping
                {
                    FromClaimType = JwtClaimTypes.Gender,
                    ToClaimType   = ClaimTypes.Gender
                },
                new Entity.RelyingPartyClaimMapping
                {
                    FromClaimType = JwtClaimTypes.Role,
                    ToClaimType   = ClaimTypes.Role
                }
            };

            foreach (var item in claimMappingList)
            {
                HandleModificationState.EntityCreated(item);
            }

            return(Task.FromResult(new Entity.RelyingParty
            {
                TokenType = TOKENTYPELIST.First(),
                DigestAlgorithm = DIGESTLIST.First(),
                SamlNameIdentifierFormat = NAMEIDENTIFIERFORMATLIST.First(),
                SignatureAlgorithm = SIGNATUREALGORITHMLIST.First(),
                ClaimMappings = claimMappingList
            }));
        }
Esempio n. 8
0
 private void OnDelete(string item)
 {
     Collection.Remove(item);
     HandleModificationState.EntityUpdated(Model);
 }
Esempio n. 9
0
 private void OnDeleteClaimClicked(UserClaim claim)
 {
     Collection.Remove(claim);
     HandleModificationState.EntityDeleted(claim);
 }