Changhoon Yoon | 23dee8f | 2015-05-18 22:19:49 +0900 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
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, |
slowr | 0a44fde | 2017-10-09 14:48:53 -0700 | [diff] [blame] | 85 | UI_WRITE, |
| 86 | UPGRADE_READ, |
| 87 | UPGRADE_WRITE, |
Laszlo Papp | 759f0d3 | 2018-03-05 13:24:30 +0000 | [diff] [blame] | 88 | UPGRADE_EVENT, |
| 89 | GLYPH_READ, |
| 90 | GLYPH_WRITE |
Changhoon Yoon | b856b81 | 2015-08-10 03:47:19 +0900 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | protected Type type; |
Changhoon Yoon | 541ef71 | 2015-05-23 17:18:34 +0900 | [diff] [blame] | 94 | /** |
| 95 | * Creates new application permission using the supplied data. |
| 96 | * @param name permission name |
| 97 | */ |
Changhoon Yoon | 23dee8f | 2015-05-18 22:19:49 +0900 | [diff] [blame] | 98 | public AppPermission(String name) { |
| 99 | super(name.toUpperCase(), ""); |
Changhoon Yoon | b856b81 | 2015-08-10 03:47:19 +0900 | [diff] [blame] | 100 | try { |
| 101 | type = Type.valueOf(name); |
| 102 | } catch (IllegalArgumentException e) { |
| 103 | type = null; |
| 104 | } |
Changhoon Yoon | 23dee8f | 2015-05-18 22:19:49 +0900 | [diff] [blame] | 105 | } |
| 106 | |
Changhoon Yoon | 541ef71 | 2015-05-23 17:18:34 +0900 | [diff] [blame] | 107 | /** |
| 108 | * Creates new application permission using the supplied data. |
| 109 | * @param name permission name |
| 110 | * @param actions permission action |
| 111 | */ |
Changhoon Yoon | 23dee8f | 2015-05-18 22:19:49 +0900 | [diff] [blame] | 112 | public AppPermission(String name, String actions) { |
| 113 | super(name.toUpperCase(), actions); |
Changhoon Yoon | b856b81 | 2015-08-10 03:47:19 +0900 | [diff] [blame] | 114 | try { |
| 115 | type = Type.valueOf(name); |
| 116 | } catch (IllegalArgumentException e) { |
| 117 | type = null; |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * Crates new application permission using the supplied data. |
| 123 | * @param type permission type |
| 124 | */ |
| 125 | public AppPermission(Type type) { |
| 126 | super(type.name(), ""); |
| 127 | this.type = type; |
| 128 | } |
| 129 | |
| 130 | /** |
| 131 | * Returns type of permission. |
| 132 | * @return application permission type |
| 133 | */ |
| 134 | public Type getType() { |
| 135 | return this.type; |
Changhoon Yoon | 23dee8f | 2015-05-18 22:19:49 +0900 | [diff] [blame] | 136 | } |
| 137 | |
| 138 | } |