示例#1
0
        public ActionResult Add(ClientCertificate newCertificate, ClientCertificateInputModel file)
        {
            if (String.IsNullOrEmpty(newCertificate.Thumbprint) && file != null && file.Cert != null)
            {
                newCertificate.Thumbprint = file.Cert.Thumbprint;
                if (newCertificate.Thumbprint != null)
                {
                    ModelState["newCertificate.Thumbprint"].Errors.Clear();
                    ModelState["newCertificate.Thumbprint"].Value = new ValueProviderResult(newCertificate.Thumbprint, newCertificate.Thumbprint, ModelState["newCertificate.Thumbprint"].Value.Culture);
                }
            }

            if (ModelState.IsValid)
            {
                try
                {
                    this.clientCertificatesRepository.Add(newCertificate);
                    TempData["Message"] = Resources.ClientCertificateController.CertificateAdded;
                    return(RedirectToAction("Configure", new { id = newCertificate.UserName }));
                }
                catch (ValidationException ex)
                {
                    ModelState.AddModelError("", ex.Message);
                }
                catch
                {
                    ModelState.AddModelError("", Resources.ClientCertificateController.ErrorAddingClientCertificate);
                }
            }

            var vm = new ClientCertificatesForUserViewModel(this.clientCertificatesRepository, this.userManagementRepository, newCertificate.UserName);

            vm.NewCertificate = newCertificate;
            return(View("Configure", vm));
        }
示例#2
0
        public ActionResult Remove(ClientCertificate model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    this.clientCertificatesRepository.Delete(model);
                    TempData["Message"] = Resources.ClientCertificateController.CertificateRemoved;
                    return(RedirectToAction("Configure", new { id = model.UserName }));
                }
                catch (ValidationException ex)
                {
                    ModelState.AddModelError("", ex.Message);
                }
                catch
                {
                    ModelState.AddModelError("", Resources.ClientCertificateController.ErrorRemovingClientCertificate);
                }
            }

            var vm = new ClientCertificatesForUserViewModel(this.clientCertificatesRepository, this.userManagementRepository, model.UserName);

            return(View("Configure", vm));
        }
示例#3
0
        public ActionResult Configure(string id = null)
        {
            var vm = new ClientCertificatesForUserViewModel(this.clientCertificatesRepository, this.userManagementRepository, id);

            return(View("Configure", vm));
        }