From 66133dce1ad626fb76c867b55506316b512ce174 Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Tue, 13 Jan 2015 13:57:43 +0100 Subject: [PATCH 1/3] =?UTF-8?q?Opravena=20kontrola=20pr=C3=A1v=20p=C5=99i?= =?UTF-8?q?=20=C3=BAprav=C4=9B=20objedn=C3=A1vky.=20Opraveno=20vyhodnocen?= =?UTF-8?q?=C3=AD=20pr=C3=A1v=20pro=20zobrazen=C3=AD=20po=C5=BEadavk=C5=AF?= =?UTF-8?q?=20st=C5=99ediska/komise.=20closes=20#187?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WorkgroupAwareServiceEvaluator.java | 17 +++++++++++++++-- .../services/orders/OrderServiceImpl.java | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/info/bukova/isspst/security/WorkgroupAwareServiceEvaluator.java b/src/main/java/info/bukova/isspst/security/WorkgroupAwareServiceEvaluator.java index b03f8738..a5bd2e8d 100644 --- a/src/main/java/info/bukova/isspst/security/WorkgroupAwareServiceEvaluator.java +++ b/src/main/java/info/bukova/isspst/security/WorkgroupAwareServiceEvaluator.java @@ -1,6 +1,7 @@ package info.bukova.isspst.security; import info.bukova.isspst.Constants; +import info.bukova.isspst.Module; import info.bukova.isspst.data.Permission; import info.bukova.isspst.data.PermissionType; import info.bukova.isspst.data.Role; @@ -39,11 +40,22 @@ public class WorkgroupAwareServiceEvaluator implements Evaluator { } User user = (User)authentication.getPrincipal(); + String moduleId = ""; + + // TODO - v master větvi je na toto pomocná třída + for (Module m : Constants.MODULES) { + if (m.getServiceClass() != null && m.getServiceClass().isAssignableFrom(targetDomainObject.getClass())) { + moduleId = m.getId(); + break; + } + } Permission appPermission = null; for (Permission p : Constants.SPECIAL_PERMISSIONS) { - if (p.getAuthority().equals(permission)) { + if (p.getAuthority().equals(permission) + && p.getModule().equals(moduleId)) { appPermission = p; + break; } } @@ -66,7 +78,8 @@ public class WorkgroupAwareServiceEvaluator implements Evaluator { for (Role r : wgRoles) { for (Permission p : r.getPermissions()) { - if (p.getAuthority().equals(appPermission.getAuthority())) { + if (p.getAuthority().equals(appPermission.getAuthority()) + && p.getModule().equals(appPermission.getModule())) { return true; } } diff --git a/src/main/java/info/bukova/isspst/services/orders/OrderServiceImpl.java b/src/main/java/info/bukova/isspst/services/orders/OrderServiceImpl.java index 52a37706..42f5ab84 100644 --- a/src/main/java/info/bukova/isspst/services/orders/OrderServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/orders/OrderServiceImpl.java @@ -181,6 +181,7 @@ public class OrderServiceImpl extends AbstractOwnedService implements } @Transactional + @PreAuthorize("hasPermission(this, 'PERM_EDIT') or hasPermission(#entity, this.getUpdateEntityPermission())") public void updateApprovedItems(Order order, boolean orderedChanged) { if (orderedChanged) From 6ff69c932c86cc98fda9d1128250e0bc25ff522a Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Thu, 15 Jan 2015 10:04:00 +0100 Subject: [PATCH 2/3] =?UTF-8?q?Do=20agendy=20po=C5=BEadavk=C5=AF=20bylo=20?= =?UTF-8?q?p=C5=99id=C3=A1no=20nov=C3=A9=20opr=C3=A1vn=C4=9Bn=C3=AD=20pro?= =?UTF-8?q?=20maz=C3=A1n=C3=AD=20neschv=C3=A1len=C3=BDch=20po=C5=BEadavk?= =?UTF-8?q?=C5=AF.=20closes=20#183?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/info/bukova/isspst/Constants.java | 3 +++ .../isspst/security/AbstractRequirementEvaluator.java | 4 ++++ .../java/info/bukova/isspst/services/AbstractService.java | 6 +++++- .../services/requirement/RequirementBaseServiceImpl.java | 5 +++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/info/bukova/isspst/Constants.java b/src/main/java/info/bukova/isspst/Constants.java index 875514c2..4ec1b8db 100644 --- a/src/main/java/info/bukova/isspst/Constants.java +++ b/src/main/java/info/bukova/isspst/Constants.java @@ -102,15 +102,18 @@ public class Constants { public final static String PERM_SHOW_ALL_REQ = "PERM_SHOW_ALL_REQ"; public final static String PERM_EDIT_NEW = "PERM_EDIT_NEW"; public final static String PERM_EDIT_OWN = "PERM_EDIT_OWN"; + public final static String PERM_DELETE_NEW = "PERM_DELETE_NEW"; public final static Permission SPECIAL_PERMISSIONS[] = { new Permission(PERM_EDIT_NEW, "Upravit neschválené", MOD_REQUIREMENTS, PermissionType.GLOBAL), + new Permission(PERM_DELETE_NEW, "Mazat neschválené", MOD_REQUIREMENTS, PermissionType.GLOBAL), new Permission(PERM_SHOW_WORKGROUP_REQ, "Zobrazení požadavků komise", MOD_REQUIREMENTS, PermissionType.WORKGROUP), new Permission(PERM_SHOW_CENTRE_REQ, "Zobrazení požadavků střediska", MOD_REQUIREMENTS, PermissionType.CENTRE), new Permission(PERM_SHOW_ALL_REQ, "Zobrazení všech požadavků", MOD_REQUIREMENTS, PermissionType.GLOBAL), new Permission(PERM_APPROVE, "Schválení", MOD_REQUIREMENTS, PermissionType.WORKGROUP), new Permission(PERM_EDIT_NEW, "Upravit neschválené", MOD_TRIPREQUIREMENTS, PermissionType.GLOBAL), + new Permission(PERM_DELETE_NEW, "Mazat neschválené", MOD_TRIPREQUIREMENTS, PermissionType.GLOBAL), new Permission(PERM_SHOW_WORKGROUP_REQ, "Zobrazení požadavků komise", MOD_TRIPREQUIREMENTS, PermissionType.WORKGROUP), new Permission(PERM_SHOW_CENTRE_REQ, "Zobrazení požadavků střediska", MOD_TRIPREQUIREMENTS, PermissionType.CENTRE), new Permission(PERM_SHOW_ALL_REQ, "Zobrazení všech požadavků", MOD_TRIPREQUIREMENTS, PermissionType.GLOBAL), diff --git a/src/main/java/info/bukova/isspst/security/AbstractRequirementEvaluator.java b/src/main/java/info/bukova/isspst/security/AbstractRequirementEvaluator.java index 4becbafb..4fff0edc 100644 --- a/src/main/java/info/bukova/isspst/security/AbstractRequirementEvaluator.java +++ b/src/main/java/info/bukova/isspst/security/AbstractRequirementEvaluator.java @@ -30,6 +30,10 @@ public abstract class AbstractRequirementEvaluator extends AbstractModuleEvaluat return req.getState() == RequirementState.NEW; } + if (permission.equals(Constants.PERM_DELETE_NEW)) { + return req.getState() == RequirementState.NEW; + } + return true; } diff --git a/src/main/java/info/bukova/isspst/services/AbstractService.java b/src/main/java/info/bukova/isspst/services/AbstractService.java index 5289e9e2..5be4e64e 100644 --- a/src/main/java/info/bukova/isspst/services/AbstractService.java +++ b/src/main/java/info/bukova/isspst/services/AbstractService.java @@ -59,6 +59,10 @@ public abstract class AbstractService implements Service return ""; } + public String getDeleteEntityPermission() { + return ""; + } + @Override @PreAuthorize("hasPermission(this, 'PERM_ADD')") public final T create() { @@ -93,7 +97,7 @@ public abstract class AbstractService implements Service @Override @Transactional - @PreAuthorize("hasPermission(this, 'PERM_DELETE')") + @PreAuthorize("hasPermission(this, 'PERM_DELETE') or hasPermission(#entity, this.getDeleteEntityPermission())") public void delete(T entity) { if (dao == null) { throw new IsspstException("DAO is null"); diff --git a/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java b/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java index 7a40b444..4587eab5 100644 --- a/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java @@ -382,5 +382,10 @@ public abstract class RequirementBaseServiceImpl exte public String getUpdateEntityPermission() { return Constants.PERM_EDIT_NEW; } + + @Override + public String getDeleteEntityPermission() { + return Constants.PERM_DELETE_NEW; + } } From 4cd2f5b5e668ccaa02319c8fe2f290ce355edf5d Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Thu, 15 Jan 2015 10:40:46 +0100 Subject: [PATCH 3/3] =?UTF-8?q?V=20agnd=C4=9B=20Fakturace=20po=C5=BEadavk?= =?UTF-8?q?=C5=AF=20p=C5=99id=C3=A1n=20sloupec=20s=20=C5=BEadatelem.=20V?= =?UTF-8?q?=C3=BDchoz=C3=AD=20t=C5=99=C3=ADd=C4=9Bn=C3=AD=20gridu=20je=20n?= =?UTF-8?q?yn=C3=AD=20podle=20=C4=8D=C3=ADsla=20po=C5=BEadavku.=20closes?= =?UTF-8?q?=20#182=20refs=20#189?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../services/invoicing/InvoicingServiceImpl.java | 11 +++++++++++ src/main/webapp/WEB-INF/locales/zk-label.properties | 1 + src/main/webapp/main/invoicing/invoicingGrid.zul | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/src/main/java/info/bukova/isspst/services/invoicing/InvoicingServiceImpl.java b/src/main/java/info/bukova/isspst/services/invoicing/InvoicingServiceImpl.java index 001fb6b1..9fb504b9 100644 --- a/src/main/java/info/bukova/isspst/services/invoicing/InvoicingServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/invoicing/InvoicingServiceImpl.java @@ -7,9 +7,11 @@ import info.bukova.isspst.services.AbstractOwnedService; import info.bukova.isspst.services.LazyLoader; import java.math.BigDecimal; +import java.util.List; import org.hibernate.Hibernate; import org.hibernate.Query; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.transaction.annotation.Transactional; public class InvoicingServiceImpl extends AbstractOwnedService implements @@ -54,4 +56,13 @@ public class InvoicingServiceImpl extends AbstractOwnedService implem invoicing.setTotalInvoiced(total); } + @SuppressWarnings("unchecked") + @Override + @Transactional + @PreAuthorize("hasPermission(this, 'PERM_READ')") + public List getAll() { + Query q = dao.getQuery("select inv from Invoicing as inv join fetch inv.requirement rq join fetch rq.ownedBy order by rq.numser"); + return q.list(); + } + } diff --git a/src/main/webapp/WEB-INF/locales/zk-label.properties b/src/main/webapp/WEB-INF/locales/zk-label.properties index 93457367..116bb1a8 100644 --- a/src/main/webapp/WEB-INF/locales/zk-label.properties +++ b/src/main/webapp/WEB-INF/locales/zk-label.properties @@ -346,6 +346,7 @@ InvoicingInvoiceNumber=Číslo faktury InvoicingAmount=Částka InvoicingDescription=Popis InvoicingInvoiced=Fakturováno +InvoicingApplicant=Žadatel HandleComboKeyFilter=#del HandleComboKey=$#del diff --git a/src/main/webapp/main/invoicing/invoicingGrid.zul b/src/main/webapp/main/invoicing/invoicingGrid.zul index 7daee89e..57737c84 100644 --- a/src/main/webapp/main/invoicing/invoicingGrid.zul +++ b/src/main/webapp/main/invoicing/invoicingGrid.zul @@ -29,6 +29,9 @@ label="${labels.RequirementsGridWorkgroup}" width="180px"/> + +