Skip to content

Commit

Permalink
admin check moved to UserUtils. issue #2268
Browse files Browse the repository at this point in the history
  • Loading branch information
j-dimension committed Jan 5, 2024
1 parent 4f5c68f commit a3be719
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,7 @@
import com.jdimension.jlawyer.client.settings.UserSettings;
import com.jdimension.jlawyer.client.utils.FrameUtils;
import com.jdimension.jlawyer.client.utils.ThreadUtils;
import com.jdimension.jlawyer.client.utils.UserUtils;
import com.jdimension.jlawyer.client.utils.VersionUtils;
import com.jdimension.jlawyer.persistence.AppOptionGroupBean;
import com.jdimension.jlawyer.persistence.AppUserBean;
Expand Down Expand Up @@ -1065,9 +1066,7 @@ public void run() {

private void openProfileInformationDialog() {
try {
JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties());
boolean currentlyAdmin = locator.lookupSecurityServiceRemote().isAdmin();
if (currentlyAdmin) {
if (UserUtils.isCurrentUserAdmin()) {
ProfileDialog dlg = new ProfileDialog(EditorsRegistry.getInstance().getMainWindow(), true);
FrameUtils.centerDialog(dlg, EditorsRegistry.getInstance().getMainWindow());
dlg.setVisible(true);
Expand All @@ -1082,9 +1081,7 @@ private void openProfileInformationDialog() {

private void openBackupConfigurationDialog() {
try {
JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties());
boolean currentlyAdmin = locator.lookupSecurityServiceRemote().isAdmin();
if (currentlyAdmin) {
if (UserUtils.isCurrentUserAdmin()) {
BackupConfigurationDialog dlg = new BackupConfigurationDialog(EditorsRegistry.getInstance().getMainWindow(), true);
FrameUtils.centerDialog(dlg, EditorsRegistry.getInstance().getMainWindow());
dlg.setVisible(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,7 @@ You should also get your employer (if you work as a programmer) or school,
import com.jdimension.jlawyer.client.settings.ClientSettings;
import com.jdimension.jlawyer.client.settings.ServerSettings;
import com.jdimension.jlawyer.client.utils.FileUtils;
import com.jdimension.jlawyer.client.utils.UserUtils;
import com.jdimension.jlawyer.persistence.ArchiveFileDocumentsBean;
import com.jdimension.jlawyer.services.ArchiveFileServiceRemote;
import com.jdimension.jlawyer.services.JLawyerServiceLocator;
Expand Down Expand Up @@ -705,10 +706,7 @@ public DocumentsBinDialog(java.awt.Frame parent, boolean modal) {


try {
ClientSettings settings = ClientSettings.getInstance();
JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties());
boolean currentlyAdmin = locator.lookupSecurityServiceRemote().isAdmin();
this.cmbRetentionDays.setEnabled(currentlyAdmin);
this.cmbRetentionDays.setEnabled(UserUtils.isCurrentUserAdmin());

} catch (Throwable t) {
log.error("Could not determine retention days for documents bin", t);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,7 @@

import com.jdimension.jlawyer.client.settings.ClientSettings;
import com.jdimension.jlawyer.client.settings.ServerSettings;
import com.jdimension.jlawyer.client.utils.UserUtils;
import com.jdimension.jlawyer.server.services.MonitoringSnapshot;
import com.jdimension.jlawyer.services.JLawyerServiceLocator;
import java.awt.Color;
Expand Down Expand Up @@ -692,12 +693,10 @@ public ServerMonitoringDialog(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();

boolean currentlyAdmin = false;
boolean currentlyAdmin = UserUtils.isCurrentUserAdmin();

ClientSettings settings = ClientSettings.getInstance();
try {
JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties());
currentlyAdmin = locator.lookupSecurityServiceRemote().isAdmin();
if (!currentlyAdmin) {
this.cmdSave.setEnabled(false);
this.cmbCpuError.setEnabled(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,7 @@

import com.jdimension.jlawyer.client.settings.ClientSettings;
import com.jdimension.jlawyer.client.settings.ServerSettings;
import com.jdimension.jlawyer.client.utils.UserUtils;
import com.jdimension.jlawyer.server.services.MonitoringSnapshot;
import com.jdimension.jlawyer.services.JLawyerServiceLocator;
import com.jdimension.jlawyer.services.SystemManagementRemote;
Expand Down Expand Up @@ -692,13 +693,9 @@ public SystemMailboxDialog(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();

boolean currentlyAdmin = false;

ClientSettings settings = ClientSettings.getInstance();
try {
JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties());
currentlyAdmin = locator.lookupSecurityServiceRemote().isAdmin();
if (!currentlyAdmin) {
if (!UserUtils.isCurrentUserAdmin()) {
this.cmdSave.setEnabled(false);
this.cmdTestMail.setEnabled(false);
this.txtPassword.setEnabled(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6082,9 +6082,7 @@ private void cmbFormTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
private void cmdFormsManagerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdFormsManagerActionPerformed
ClientSettings settings = ClientSettings.getInstance();
try {
JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties());
boolean currentlyAdmin = locator.lookupSecurityServiceRemote().isAdmin();
if (currentlyAdmin) {
if (UserUtils.isCurrentUserAdmin()) {
FormsManagementDialog dlg = new FormsManagementDialog(EditorsRegistry.getInstance().getMainWindow(), true);
FrameUtils.centerDialog(dlg, EditorsRegistry.getInstance().getMainWindow());
dlg.setVisible(true);
Expand Down

0 comments on commit a3be719

Please sign in to comment.