From 9fd38c4da093e85564d2465d55292ee575abfb08 Mon Sep 17 00:00:00 2001 From: Rakesh Date: Tue, 29 Jun 2021 09:33:31 +0200 Subject: [PATCH] server: Display proper names in error message (#5140) Display the proper account and other names rather than the uuid representation of the object --- server/src/main/java/com/cloud/acl/DomainChecker.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/server/src/main/java/com/cloud/acl/DomainChecker.java b/server/src/main/java/com/cloud/acl/DomainChecker.java index 24b6b2a42b4..aba0d456bfa 100644 --- a/server/src/main/java/com/cloud/acl/DomainChecker.java +++ b/server/src/main/java/com/cloud/acl/DomainChecker.java @@ -105,7 +105,7 @@ public class DomainChecker extends AdapterBase implements SecurityChecker { @Override public boolean checkAccess(Account caller, Domain domain) throws PermissionDeniedException { if (caller.getState() != Account.State.enabled) { - throw new PermissionDeniedException(caller + " is disabled."); + throw new PermissionDeniedException("Account " + caller.getAccountName() + " is disabled."); } if (domain == null) { @@ -116,10 +116,10 @@ public class DomainChecker extends AdapterBase implements SecurityChecker { if (_accountService.isNormalUser(caller.getId())) { if (caller.getDomainId() != domainId) { - throw new PermissionDeniedException(caller + " does not have permission to operate within domain id=" + domain.getUuid()); + throw new PermissionDeniedException("Account " + caller.getAccountName() + " does not have permission to operate within domain id=" + domain.getUuid()); } } else if (!_domainDao.isChildDomain(caller.getDomainId(), domainId)) { - throw new PermissionDeniedException(caller + " does not have permission to operate within domain id=" + domain.getUuid()); + throw new PermissionDeniedException("Account " + caller.getAccountName() + " does not have permission to operate within domain id=" + domain.getUuid()); } return true; @@ -155,7 +155,8 @@ public class DomainChecker extends AdapterBase implements SecurityChecker { // account can launch a VM from this template LaunchPermissionVO permission = _launchPermissionDao.findByTemplateAndAccount(template.getId(), caller.getId()); if (permission == null) { - throw new PermissionDeniedException(caller + " does not have permission to launch instances from " + template); + throw new PermissionDeniedException("Account " + caller.getAccountName() + + " does not have permission to launch instances from template " + template.getName()); } } else { // Domain admin and regular user can delete/modify only templates created by them