blob: 21a70d2b1bb84728343dcaddf4b6f0593177a80e [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
19import java.security.BasicPermission;
20
21/**
22 * Implementation of API access permission.
23 */
24public class AppPermission extends BasicPermission {
25
Changhoon Yoonb856b812015-08-10 03:47:19 +090026 public enum Type {
27 APP_READ,
28 APP_EVENT,
29 CONFIG_READ,
30 CONFIG_WRITE,
31 CLUSTER_READ,
32 CLUSTER_WRITE,
33 CLUSTER_EVENT,
34 DEVICE_READ,
35 DEVICE_EVENT,
36 DRIVER_READ,
37 DRIVER_WRITE,
38 FLOWRULE_READ,
39 FLOWRULE_WRITE,
40 FLOWRULE_EVENT,
41 GROUP_READ,
42 GROUP_WRITE,
43 GROUP_EVENT,
44 HOST_READ,
45 HOST_WRITE,
46 HOST_EVENT,
47 INTENT_READ,
48 INTENT_WRITE,
49 INTENT_EVENT,
50 LINK_READ,
51 LINK_WRITE,
52 LINK_EVENT,
53 PACKET_READ,
54 PACKET_WRITE,
55 PACKET_EVENT,
56 STATISTIC_READ,
57 TOPOLOGY_READ,
58 TOPOLOGY_EVENT,
59 TUNNEL_READ,
60 TUNNEL_WRITE,
61 TUNNEL_EVENT,
62 STORAGE_WRITE
63 }
64
65 protected Type type;
Changhoon Yoon541ef712015-05-23 17:18:34 +090066 /**
67 * Creates new application permission using the supplied data.
68 * @param name permission name
69 */
Changhoon Yoon23dee8f2015-05-18 22:19:49 +090070 public AppPermission(String name) {
71 super(name.toUpperCase(), "");
Changhoon Yoonb856b812015-08-10 03:47:19 +090072 try {
73 type = Type.valueOf(name);
74 } catch (IllegalArgumentException e) {
75 type = null;
76 }
Changhoon Yoon23dee8f2015-05-18 22:19:49 +090077 }
78
Changhoon Yoon541ef712015-05-23 17:18:34 +090079 /**
80 * Creates new application permission using the supplied data.
81 * @param name permission name
82 * @param actions permission action
83 */
Changhoon Yoon23dee8f2015-05-18 22:19:49 +090084 public AppPermission(String name, String actions) {
85 super(name.toUpperCase(), actions);
Changhoon Yoonb856b812015-08-10 03:47:19 +090086 try {
87 type = Type.valueOf(name);
88 } catch (IllegalArgumentException e) {
89 type = null;
90 }
91 }
92
93 /**
94 * Crates new application permission using the supplied data.
95 * @param type permission type
96 */
97 public AppPermission(Type type) {
98 super(type.name(), "");
99 this.type = type;
100 }
101
102 /**
103 * Returns type of permission.
104 * @return application permission type
105 */
106 public Type getType() {
107 return this.type;
Changhoon Yoon23dee8f2015-05-18 22:19:49 +0900108 }
109
110}