Esempio n. 1
0
        public UpdateAuthorityGroupResponse UpdateAuthorityGroup(UpdateAuthorityGroupRequest request)
        {
            Platform.CheckForNullReference(request, "request");
            Platform.CheckMemberIsSet(request.AuthorityGroupDetail, "AuthorityGroupDetail");

            var authorityGroup = PersistenceContext.Load <AuthorityGroup>(request.AuthorityGroupDetail.AuthorityGroupRef);

            if (authorityGroup.BuiltIn || request.AuthorityGroupDetail.BuiltIn)
            {
                throw new RequestValidationException(SR.MessageCannotManageBuiltInAuthorityGroups);
            }

            if (authorityGroup.DataGroup && !request.AuthorityGroupDetail.DataGroup)
            {
                var user = GetUser(Thread.CurrentPrincipal.Identity.Name, PersistenceContext);
                if (!user.Password.Verify(request.Password))
                {
                    // the error message is deliberately vague
                    throw new UserAccessDeniedException();
                }
            }

            // set properties from request
            var assembler = new AuthorityGroupAssembler();

            assembler.UpdateAuthorityGroup(authorityGroup, request.AuthorityGroupDetail, PersistenceContext);

            PersistenceContext.SynchState();

            return(new UpdateAuthorityGroupResponse(assembler.CreateAuthorityGroupSummary(authorityGroup)));
        }
        public UpdateAuthorityGroupResponse UpdateAuthorityGroup(UpdateAuthorityGroupRequest request)
        {
            var authorityGroup = PersistenceContext.Load <AuthorityGroup>(request.AuthorityGroupDetail.AuthorityGroupRef);

            if (authorityGroup.DataGroup && !request.AuthorityGroupDetail.DataGroup)
            {
                var user = GetUser(Thread.CurrentPrincipal.Identity.Name, PersistenceContext);
                if (!user.Password.Verify(request.Password))
                {
                    // the error message is deliberately vague
                    throw new UserAccessDeniedException();
                }
            }

            // set properties from request
            var assembler = new AuthorityGroupAssembler();

            assembler.UpdateAuthorityGroup(authorityGroup, request.AuthorityGroupDetail, PersistenceContext);

            PersistenceContext.SynchState();

            return(new UpdateAuthorityGroupResponse(assembler.CreateAuthorityGroupSummary(authorityGroup)));
        }
Esempio n. 3
0
        public void Accept()
        {
            if (HasValidationErrors)
            {
                ShowValidation(true);
                return;
            }

            try
            {
                bool closeAborted = false;

                Platform.GetService <IAuthorityGroupAdminService>(
                    delegate(IAuthorityGroupAdminService service)
                {
                    if (_isNew)
                    {
                        AddAuthorityGroupResponse response = service.AddAuthorityGroup(new AddAuthorityGroupRequest(_authorityGroupDetail));
                        _authorityGroupSummary             = response.AuthorityGroupSummary;
                    }
                    else
                    {
                        UpdateAuthorityGroupRequest request = new UpdateAuthorityGroupRequest(_authorityGroupDetail);
                        if (DataGroupModified && DataGroup == false)
                        {
                            var optionsComponent = new PasswordConfirmComponent
                            {
                                Description = SR.DescriptionDataAccessGroupChange
                            };
                            if (ApplicationComponentExitCode.Accepted == LaunchAsDialog(Host.DesktopWindow, optionsComponent, SR.TitlePasswordConfirm))
                            {
                                request.Password = optionsComponent.Password;
                            }
                            else
                            {
                                closeAborted = true;
                                return;
                            }
                        }

                        UpdateAuthorityGroupResponse response = service.UpdateAuthorityGroup(request);
                        _authorityGroupSummary = response.AuthorityGroupSummary;
                    }
                });
                if (closeAborted)
                {
                    return;
                }
                Exit(ApplicationComponentExitCode.Accepted);
            }
            catch (FaultException <UserAccessDeniedException> )
            {
                Host.ShowMessageBox(SR.ExceptionUserAccessDenied, MessageBoxActions.Ok);
            }
            catch (Exception e)
            {
                ExceptionHandler.Report(e, SR.ExceptionSaveAuthorityGroup, Host.DesktopWindow,
                                        delegate
                {
                    ExitCode = ApplicationComponentExitCode.Error;
                    Host.Exit();
                });
            }
        }