01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
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
34: PortletActionSecurityBehavior {
35: protected Log log = LogFactory
36: .getLog(PortletActionSecurityPathBehavior.class);
37: protected List roles;
38:
39: public RolesSecurityBehavior(List roles) {
40: this .roles = roles;
41: }
42:
43: public boolean checkAccess(RequestContext context, String action) {
44: Iterator iterator = roles.iterator();
45: while (iterator.hasNext()) {
46: String role = (String) iterator.next();
47: if (context.getRequest().isUserInRole(role))
48: return true;
49: }
50: return false;
51: }
52:
53: public boolean isCreateNewPageOnEditEnabled() {
54: return false;
55: }
56:
57: public boolean isPageQualifiedForCreateNewPageOnEdit(
58: RequestContext context) {
59: return false;
60: }
61:
62: public boolean createNewPageOnEdit(RequestContext context) {
63: return false;
64: }
65: }
|