blob: 2eafb7c7c5ac97059dffd221da452deb9ccfe8f2 [file] [log] [blame]
Changhoon Yoon23dee8f2015-05-18 22:19:49 +09001/*
2 * Copyright 2015 Open Networking Laboratory
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 Yoon541ef712015-05-23 17:18:34 +090017package org.onosproject.security;
Changhoon Yoon23dee8f2015-05-18 22:19:49 +090018
Thomas Vachuska4c571ae2015-09-10 16:31:59 -070019import com.google.common.annotations.Beta;
20
Changhoon Yoon23dee8f2015-05-18 22:19:49 +090021import java.security.BasicPermission;
22
23/**
24 * Implementation of API access permission.
25 */
Thomas Vachuska4c571ae2015-09-10 16:31:59 -070026@Beta
Changhoon Yoon23dee8f2015-05-18 22:19:49 +090027public class AppPermission extends BasicPermission {
28
Changhoon Yoonb856b812015-08-10 03:47:19 +090029 public enum Type {
30 APP_READ,
31 APP_EVENT,
32 CONFIG_READ,
33 CONFIG_WRITE,
34 CLUSTER_READ,
35 CLUSTER_WRITE,
36 CLUSTER_EVENT,
Brian Stankeca93d9a2016-02-10 09:17:35 -050037 DEVICE_KEY_EVENT,
38 DEVICE_KEY_READ,
39 DEVICE_KEY_WRITE,
Changhoon Yoonb856b812015-08-10 03:47:19 +090040 DEVICE_READ,
41 DEVICE_EVENT,
42 DRIVER_READ,
43 DRIVER_WRITE,
44 FLOWRULE_READ,
45 FLOWRULE_WRITE,
46 FLOWRULE_EVENT,
47 GROUP_READ,
48 GROUP_WRITE,
49 GROUP_EVENT,
50 HOST_READ,
51 HOST_WRITE,
52 HOST_EVENT,
53 INTENT_READ,
54 INTENT_WRITE,
55 INTENT_EVENT,
56 LINK_READ,
57 LINK_WRITE,
58 LINK_EVENT,
59 PACKET_READ,
60 PACKET_WRITE,
61 PACKET_EVENT,
62 STATISTIC_READ,
63 TOPOLOGY_READ,
64 TOPOLOGY_EVENT,
65 TUNNEL_READ,
66 TUNNEL_WRITE,
67 TUNNEL_EVENT,
68 STORAGE_WRITE
69 }
70
71 protected Type type;
Changhoon Yoon541ef712015-05-23 17:18:34 +090072 /**
73 * Creates new application permission using the supplied data.
74 * @param name permission name
75 */
Changhoon Yoon23dee8f2015-05-18 22:19:49 +090076 public AppPermission(String name) {
77 super(name.toUpperCase(), "");
Changhoon Yoonb856b812015-08-10 03:47:19 +090078 try {
79 type = Type.valueOf(name);
80 } catch (IllegalArgumentException e) {
81 type = null;
82 }
Changhoon Yoon23dee8f2015-05-18 22:19:49 +090083 }
84
Changhoon Yoon541ef712015-05-23 17:18:34 +090085 /**
86 * Creates new application permission using the supplied data.
87 * @param name permission name
88 * @param actions permission action
89 */
Changhoon Yoon23dee8f2015-05-18 22:19:49 +090090 public AppPermission(String name, String actions) {
91 super(name.toUpperCase(), actions);
Changhoon Yoonb856b812015-08-10 03:47:19 +090092 try {
93 type = Type.valueOf(name);
94 } catch (IllegalArgumentException e) {
95 type = null;
96 }
97 }
98
99 /**
100 * Crates new application permission using the supplied data.
101 * @param type permission type
102 */
103 public AppPermission(Type type) {
104 super(type.name(), "");
105 this.type = type;
106 }
107
108 /**
109 * Returns type of permission.
110 * @return application permission type
111 */
112 public Type getType() {
113 return this.type;
Changhoon Yoon23dee8f2015-05-18 22:19:49 +0900114 }
115
116}