01: /*******************************************************************************
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: *******************************************************************************/package org.ofbiz.service;
19:
20: import java.util.List;
21: import java.util.Iterator;
22: import java.util.LinkedList;
23: import java.util.Map;
24: import java.io.Serializable;
25:
26: /**
27: * Service Permission Group Model Class
28: */
29: public class ModelPermGroup implements Serializable {
30:
31: public static final String module = ModelPermGroup.class.getName();
32:
33: public static final String PERM_JOIN_AND = "AND";
34: public static final String PERM_JOIN_OR = "OR";
35:
36: public List permissions = new LinkedList();
37: public String joinType;
38:
39: public boolean evalPermissions(DispatchContext dctx, Map context) {
40: if (permissions != null && permissions.size() > 0) {
41: boolean foundOne = false;
42: Iterator i = permissions.iterator();
43: while (i.hasNext()) {
44: ModelPermission perm = (ModelPermission) i.next();
45: if (perm.evalPermission(dctx, context)) {
46: foundOne = true;
47: } else {
48: if (joinType.equals(PERM_JOIN_AND)) {
49: return false;
50: }
51: }
52: }
53: return foundOne;
54: } else {
55: return true;
56: }
57: }
58: }
|