2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END============================================
20 * ===================================================================
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
24 package org.onap.clamp.clds.service;
27 * Permission class that can be instantiated easily using constructor or factory methods.
29 public class SecureServicePermission {
30 public final static String ALL = "*";
33 private String instance;
34 private String action;
37 * Factory method to create permission given type, instance, and action.
44 public static SecureServicePermission create(String type, String instance, String action) {
45 return new SecureServicePermission(type, instance, action);
49 * Factory method to create permission given type and instance. Default action to ALL/*.
55 public static SecureServicePermission create(String type, String instance) {
56 return new SecureServicePermission(type, instance);
60 * Factory method to create permission given type. Default instance and action to ALL/*.
65 public static SecureServicePermission create(String type) {
66 return new SecureServicePermission(type);
70 * Instantiate permission given type, instance, and action.
76 public SecureServicePermission(String type, String instance, String action) {
78 this.instance = instance;
83 * Instantiate permission given type and instance. Default action to ALL/*.
88 public SecureServicePermission(String type, String instance) {
90 this.instance = instance;
95 * Instantiate permission given type. Default instance and action to ALL/*.
99 public SecureServicePermission(String type) {
106 * Override toString - return permission in key format
108 public String toString() {
113 * Return Permission in Key format = type, instance, and action separate by pipe character.
117 public String getKey() {
118 return type + "|" + instance + "|" + action;
122 * Return Permission in Key format = type, all instance, and action separate by pipe character.
126 public String getKeyAllInstance() {
127 return type + "|" + ALL + "|" + action;
131 * Return Permission in Key format = type, all instance, and all action separate by pipe character.
135 public String getKeyAllInstanceAction() {
136 return type + "|" + ALL + "|" + ALL;
140 * Return Permission in Key format = type, instance, and all action separate by pipe character.
144 public String getKeyAllAction() {
145 return type + "|" + instance + "|" + ALL;
151 public String getType() {
156 * @param type the type to set
158 public void setType(String type) {
163 * @return the instance
165 public String getInstance() {
170 * @param instance the instance to set
172 public void setInstance(String instance) {
173 this.instance = instance;
179 public String getAction() {
184 * @param action the action to set
186 public void setAction(String action) {
187 this.action = action;