1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package sample.contact;
17
18 import org.acegisecurity.acl.AclEntry;
19 import org.acegisecurity.acl.AclManager;
20
21 import org.springframework.beans.factory.InitializingBean;
22
23 import org.springframework.util.Assert;
24
25 import org.springframework.web.bind.RequestUtils;
26 import org.springframework.web.servlet.ModelAndView;
27 import org.springframework.web.servlet.mvc.Controller;
28
29 import java.io.IOException;
30
31 import java.util.HashMap;
32 import java.util.Map;
33
34 import javax.servlet.ServletException;
35 import javax.servlet.http.HttpServletRequest;
36 import javax.servlet.http.HttpServletResponse;
37
38
39 /***
40 * Controller for "administer" index page.
41 *
42 * @author Ben Alex
43 * @version $Id: AdminPermissionController.java,v 1.4 2005/11/17 00:56:08 benalex Exp $
44 */
45 public class AdminPermissionController implements Controller, InitializingBean {
46
47
48 private AclManager aclManager;
49 private ContactManager contactManager;
50
51
52
53 public void setAclManager(AclManager aclManager) {
54 this.aclManager = aclManager;
55 }
56
57 public AclManager getAclManager() {
58 return aclManager;
59 }
60
61 public void setContactManager(ContactManager contact) {
62 this.contactManager = contact;
63 }
64
65 public ContactManager getContactManager() {
66 return contactManager;
67 }
68
69 public void afterPropertiesSet() throws Exception {
70 Assert.notNull(contactManager,
71 "A ContactManager implementation is required");
72 Assert.notNull(aclManager, "An aclManager implementation is required");
73 }
74
75 public ModelAndView handleRequest(HttpServletRequest request,
76 HttpServletResponse response) throws ServletException, IOException {
77 int id = RequestUtils.getRequiredIntParameter(request, "contactId");
78
79 Contact contact = contactManager.getById(new Long(id));
80 AclEntry[] acls = aclManager.getAcls(contact);
81
82 Map model = new HashMap();
83 model.put("contact", contact);
84 model.put("acls", acls);
85
86 return new ModelAndView("adminPermission", "model", model);
87 }
88 }