blob: 800135f413c127e2388a62dd62f493b04ea79b77 [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;
18
Changhoon Yoon23dee8f2015-05-18 22:19:49 +090019
20/**
Changhoon Yoon541ef712015-05-23 17:18:34 +090021 * Aids SM-ONOS to perform API-level permission checking.
Changhoon Yoon23dee8f2015-05-18 22:19:49 +090022 */
23public final class AppGuard {
24
25 private AppGuard() {
26 }
27
Changhoon Yoon541ef712015-05-23 17:18:34 +090028 /**
29 * Checks if the caller has the required permission only when security-mode is enabled.
30 * @param permission permission to be checked
31 */
Changhoon Yoonb856b812015-08-10 03:47:19 +090032 public static void checkPermission(AppPermission.Type permission) {
Changhoon Yoon23dee8f2015-05-18 22:19:49 +090033 SecurityManager sm = System.getSecurityManager();
34 if (sm != null) {
Changhoon Yoonb856b812015-08-10 03:47:19 +090035 System.getSecurityManager().checkPermission(new AppPermission(permission));
Changhoon Yoon23dee8f2015-05-18 22:19:49 +090036 }
Changhoon Yoon23dee8f2015-05-18 22:19:49 +090037 }
38}