Changhoon Yoon | 23dee8f | 2015-05-18 22:19:49 +0900 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Changhoon Yoon | 23dee8f | 2015-05-18 22:19:49 +0900 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Changhoon Yoon | 541ef71 | 2015-05-23 17:18:34 +0900 | [diff] [blame] | 17 | package org.onosproject.security; |
Changhoon Yoon | 23dee8f | 2015-05-18 22:19:49 +0900 | [diff] [blame] | 18 | |
Thomas Vachuska | 4c571ae | 2015-09-10 16:31:59 -0700 | [diff] [blame] | 19 | import com.google.common.annotations.Beta; |
| 20 | |
Changhoon Yoon | 23dee8f | 2015-05-18 22:19:49 +0900 | [diff] [blame] | 21 | import java.security.BasicPermission; |
| 22 | |
| 23 | /** |
| 24 | * Implementation of API access permission. |
| 25 | */ |
Thomas Vachuska | 4c571ae | 2015-09-10 16:31:59 -0700 | [diff] [blame] | 26 | @Beta |
Changhoon Yoon | 23dee8f | 2015-05-18 22:19:49 +0900 | [diff] [blame] | 27 | public class AppPermission extends BasicPermission { |
| 28 | |
Changhoon Yoon | b856b81 | 2015-08-10 03:47:19 +0900 | [diff] [blame] | 29 | public enum Type { |
| 30 | APP_READ, |
| 31 | APP_EVENT, |
Heedo Kang | 4a47a30 | 2016-02-29 17:40:23 +0900 | [diff] [blame] | 32 | APP_WRITE, |
Changhoon Yoon | b856b81 | 2015-08-10 03:47:19 +0900 | [diff] [blame] | 33 | CONFIG_READ, |
| 34 | CONFIG_WRITE, |
Heedo Kang | 4a47a30 | 2016-02-29 17:40:23 +0900 | [diff] [blame] | 35 | CONFIG_EVENT, |
Changhoon Yoon | b856b81 | 2015-08-10 03:47:19 +0900 | [diff] [blame] | 36 | CLUSTER_READ, |
| 37 | CLUSTER_WRITE, |
| 38 | CLUSTER_EVENT, |
Heedo Kang | 4a47a30 | 2016-02-29 17:40:23 +0900 | [diff] [blame] | 39 | CODEC_READ, |
| 40 | CODEC_WRITE, |
| 41 | CLOCK_WRITE, |
Brian Stanke | ca93d9a | 2016-02-10 09:17:35 -0500 | [diff] [blame] | 42 | DEVICE_KEY_EVENT, |
| 43 | DEVICE_KEY_READ, |
| 44 | DEVICE_KEY_WRITE, |
Changhoon Yoon | b856b81 | 2015-08-10 03:47:19 +0900 | [diff] [blame] | 45 | DEVICE_READ, |
| 46 | DEVICE_EVENT, |
| 47 | DRIVER_READ, |
| 48 | DRIVER_WRITE, |
Heedo Kang | 4a47a30 | 2016-02-29 17:40:23 +0900 | [diff] [blame] | 49 | EVENT_READ, |
| 50 | EVENT_WRITE, |
Changhoon Yoon | b856b81 | 2015-08-10 03:47:19 +0900 | [diff] [blame] | 51 | FLOWRULE_READ, |
| 52 | FLOWRULE_WRITE, |
| 53 | FLOWRULE_EVENT, |
| 54 | GROUP_READ, |
| 55 | GROUP_WRITE, |
| 56 | GROUP_EVENT, |
| 57 | HOST_READ, |
| 58 | HOST_WRITE, |
| 59 | HOST_EVENT, |
| 60 | INTENT_READ, |
| 61 | INTENT_WRITE, |
| 62 | INTENT_EVENT, |
| 63 | LINK_READ, |
| 64 | LINK_WRITE, |
| 65 | LINK_EVENT, |
Heedo Kang | 4a47a30 | 2016-02-29 17:40:23 +0900 | [diff] [blame] | 66 | MUTEX_WRITE, |
Changhoon Yoon | b856b81 | 2015-08-10 03:47:19 +0900 | [diff] [blame] | 67 | PACKET_READ, |
| 68 | PACKET_WRITE, |
| 69 | PACKET_EVENT, |
Heedo Kang | 4a47a30 | 2016-02-29 17:40:23 +0900 | [diff] [blame] | 70 | PERSISTENCE_WRITE, |
| 71 | PARTITION_READ, |
| 72 | PARTITION_EVENT, |
| 73 | RESOURCE_READ, |
| 74 | RESOURCE_WRITE, |
| 75 | RESOURCE_EVENT, |
| 76 | REGION_READ, |
Changhoon Yoon | b856b81 | 2015-08-10 03:47:19 +0900 | [diff] [blame] | 77 | STATISTIC_READ, |
Heedo Kang | 4a47a30 | 2016-02-29 17:40:23 +0900 | [diff] [blame] | 78 | STORAGE_WRITE, |
Changhoon Yoon | b856b81 | 2015-08-10 03:47:19 +0900 | [diff] [blame] | 79 | TOPOLOGY_READ, |
| 80 | TOPOLOGY_EVENT, |
| 81 | TUNNEL_READ, |
| 82 | TUNNEL_WRITE, |
| 83 | TUNNEL_EVENT, |
Heedo Kang | 4a47a30 | 2016-02-29 17:40:23 +0900 | [diff] [blame] | 84 | UI_READ, |
| 85 | UI_WRITE |
Changhoon Yoon | b856b81 | 2015-08-10 03:47:19 +0900 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | protected Type type; |
Changhoon Yoon | 541ef71 | 2015-05-23 17:18:34 +0900 | [diff] [blame] | 89 | /** |
| 90 | * Creates new application permission using the supplied data. |
| 91 | * @param name permission name |
| 92 | */ |
Changhoon Yoon | 23dee8f | 2015-05-18 22:19:49 +0900 | [diff] [blame] | 93 | public AppPermission(String name) { |
| 94 | super(name.toUpperCase(), ""); |
Changhoon Yoon | b856b81 | 2015-08-10 03:47:19 +0900 | [diff] [blame] | 95 | try { |
| 96 | type = Type.valueOf(name); |
| 97 | } catch (IllegalArgumentException e) { |
| 98 | type = null; |
| 99 | } |
Changhoon Yoon | 23dee8f | 2015-05-18 22:19:49 +0900 | [diff] [blame] | 100 | } |
| 101 | |
Changhoon Yoon | 541ef71 | 2015-05-23 17:18:34 +0900 | [diff] [blame] | 102 | /** |
| 103 | * Creates new application permission using the supplied data. |
| 104 | * @param name permission name |
| 105 | * @param actions permission action |
| 106 | */ |
Changhoon Yoon | 23dee8f | 2015-05-18 22:19:49 +0900 | [diff] [blame] | 107 | public AppPermission(String name, String actions) { |
| 108 | super(name.toUpperCase(), actions); |
Changhoon Yoon | b856b81 | 2015-08-10 03:47:19 +0900 | [diff] [blame] | 109 | try { |
| 110 | type = Type.valueOf(name); |
| 111 | } catch (IllegalArgumentException e) { |
| 112 | type = null; |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * Crates new application permission using the supplied data. |
| 118 | * @param type permission type |
| 119 | */ |
| 120 | public AppPermission(Type type) { |
| 121 | super(type.name(), ""); |
| 122 | this.type = type; |
| 123 | } |
| 124 | |
| 125 | /** |
| 126 | * Returns type of permission. |
| 127 | * @return application permission type |
| 128 | */ |
| 129 | public Type getType() { |
| 130 | return this.type; |
Changhoon Yoon | 23dee8f | 2015-05-18 22:19:49 +0900 | [diff] [blame] | 131 | } |
| 132 | |
| 133 | } |