Changhoon Yoon | b856b81 | 2015-08-10 03:47:19 +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 | b856b81 | 2015-08-10 03:47:19 +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 | |
| 17 | package org.onosproject.security; |
| 18 | |
Thomas Vachuska | 4c571ae | 2015-09-10 16:31:59 -0700 | [diff] [blame] | 19 | import com.google.common.annotations.Beta; |
| 20 | |
| 21 | @Beta |
Changhoon Yoon | b856b81 | 2015-08-10 03:47:19 +0900 | [diff] [blame] | 22 | public class Permission { |
| 23 | |
| 24 | protected String classname; |
| 25 | protected String name; |
| 26 | protected String actions; |
| 27 | |
| 28 | public Permission(String classname, String name, String actions) { |
| 29 | this.classname = classname; |
| 30 | this.name = name; |
| 31 | if (actions == null) { |
| 32 | this.actions = ""; |
| 33 | } else { |
| 34 | this.actions = actions; |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | public Permission(String classname, String name) { |
| 39 | this.classname = classname; |
| 40 | this.name = name; |
| 41 | this.actions = ""; |
| 42 | } |
| 43 | |
| 44 | public String getClassName() { |
| 45 | return classname; |
| 46 | } |
| 47 | |
| 48 | public String getName() { |
| 49 | return name; |
| 50 | } |
| 51 | |
| 52 | public String getActions() { |
| 53 | return actions; |
| 54 | } |
| 55 | |
| 56 | @Override |
| 57 | public int hashCode() { |
| 58 | return 0; |
| 59 | } |
| 60 | |
| 61 | @Override |
| 62 | public boolean equals(Object thatPerm) { |
| 63 | if (this == thatPerm) { |
| 64 | return true; |
| 65 | } |
| 66 | |
| 67 | if (!(thatPerm instanceof Permission)) { |
| 68 | return false; |
| 69 | } |
| 70 | |
| 71 | Permission that = (Permission) thatPerm; |
| 72 | return (this.classname.equals(that.classname)) && (this.name.equals(that.name)) |
| 73 | && (this.actions.equals(that.actions)); |
| 74 | } |
| 75 | |
| 76 | @Override |
| 77 | public String toString() { |
| 78 | return String.format("(%s, %s, %s)", classname, name, actions); |
| 79 | } |
| 80 | } |