1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.layout.impl;
18
19 import java.util.Iterator;
20 import java.util.List;
21
22 import org.apache.commons.logging.Log;
23 import org.apache.commons.logging.LogFactory;
24 import org.apache.jetspeed.layout.PortletActionSecurityBehavior;
25 import org.apache.jetspeed.request.RequestContext;
26
27 /***
28 * Abstracted behavior of security checks for portlet actions
29 *
30 * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
31 * @version $Id: $
32 */
33 public class RolesSecurityBehavior implements PortletActionSecurityBehavior
34 {
35 protected Log log = LogFactory.getLog(PortletActionSecurityPathBehavior.class);
36 protected List roles;
37
38 public RolesSecurityBehavior(List roles)
39 {
40 this.roles = roles;
41 }
42
43 public boolean checkAccess(RequestContext context, String action)
44 {
45 Iterator iterator = roles.iterator();
46 while (iterator.hasNext())
47 {
48 String role = (String)iterator.next();
49 if (context.getRequest().isUserInRole(role))
50 return true;
51 }
52 return false;
53 }
54
55 public boolean isCreateNewPageOnEditEnabled()
56 {
57 return false;
58 }
59 public boolean isPageQualifiedForCreateNewPageOnEdit(RequestContext context)
60 {
61 return false ;
62 }
63
64 public boolean createNewPageOnEdit(RequestContext context)
65 {
66 return false;
67 }
68 }