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 *
19 *
20 */
21 package org.apache.qpid.server.security.access;
22
23 public class AccessRights
24 {
25 public enum Rights
26 {
27 ANY,
28 READ,
29 WRITE,
30 READWRITE
31 }
32
33 Rights _right;
34
35 public AccessRights(Rights right)
36 {
37 _right = right;
38 }
39
40 public boolean allows(Rights rights)
41 {
42 switch (_right)
43 {
44 case ANY:
45 return (rights.equals(Rights.WRITE)
46 || rights.equals(Rights.READ)
47 || rights.equals(Rights.READWRITE)
48 || rights.equals(Rights.ANY));
49 case READ:
50 return rights.equals(Rights.READ) || rights.equals(Rights.ANY);
51 case WRITE:
52 return rights.equals(Rights.WRITE) || rights.equals(Rights.ANY);
53 case READWRITE:
54 return true;
55 }
56 return false;
57 }
58
59 public Rights getRights()
60 {
61 return _right;
62 }
63 }
|