KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jaspersoft > jasperserver > api > engine > scheduling > security > ReportJobAclDao


1 /*
2  * Copyright (C) 2006 JasperSoft http://www.jaspersoft.com
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed WITHOUT ANY WARRANTY; and without the
10  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  * See the GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
15  * or write to:
16  *
17  * Free Software Foundation, Inc.,
18  * 59 Temple Place - Suite 330,
19  * Boston, MA USA 02111-1307
20  */

21 package com.jaspersoft.jasperserver.api.engine.scheduling.security;
22
23 import org.acegisecurity.acl.basic.AclObjectIdentity;
24 import org.acegisecurity.acl.basic.BasicAclDao;
25 import org.acegisecurity.acl.basic.BasicAclEntry;
26 import org.acegisecurity.acl.basic.NamedEntityObjectIdentity;
27 import org.acegisecurity.acl.basic.SimpleAclEntry;
28 import org.apache.commons.logging.Log;
29 import org.apache.commons.logging.LogFactory;
30
31 import com.jaspersoft.jasperserver.api.engine.scheduling.ReportJobsInternalService;
32
33 /**
34  * @author Lucian Chirita (lucianc@users.sourceforge.net)
35  * @version $Id: ReportJobAclDao.java 3784 2006-06-21 17:52:11Z lucian $
36  */

37 public class ReportJobAclDao implements BasicAclDao {
38
39     private static final Log log = LogFactory.getLog(ReportJobAclDao.class);
40     
41     private ReportJobsInternalService reportJobsInternalService;
42     private String JavaDoc administratorRole;
43     
44     public BasicAclEntry[] getAcls(AclObjectIdentity objectIdentity) {
45         if (log.isDebugEnabled()) {
46             log.debug("Retrieving ACLs for " + objectIdentity);
47         }
48
49         NamedEntityObjectIdentity namedId = (NamedEntityObjectIdentity) objectIdentity;
50         long jobId = Long.parseLong(namedId.getId());
51         String JavaDoc jobOwner = getReportJobsInternalService().getJobOwner(jobId);
52         SimpleAclEntry userReadEntry = new SimpleAclEntry(jobOwner, objectIdentity, null, SimpleAclEntry.READ_WRITE_DELETE);
53         
54         SimpleAclEntry admReadEntry = new SimpleAclEntry(getAdministratorRole(), objectIdentity, null, SimpleAclEntry.ADMINISTRATION);
55         
56         return new BasicAclEntry[]{userReadEntry, admReadEntry};
57     }
58
59     public String JavaDoc getAdministratorRole() {
60         return administratorRole;
61     }
62
63     public void setAdministratorRole(String JavaDoc administratorRole) {
64         this.administratorRole = administratorRole;
65     }
66
67     public ReportJobsInternalService getReportJobsInternalService() {
68         return reportJobsInternalService;
69     }
70
71     public void setReportJobsInternalService(
72             ReportJobsInternalService reportJobsInternalService) {
73         this.reportJobsInternalService = reportJobsInternalService;
74     }
75
76 }
77
Popular Tags