+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cadi.aaf;\r
-\r
-import org.onap.aaf.cadi.Permission;\r
-\r
-/**\r
- * A Class that understands the AAF format of Permission (name/type/action)\r
- * or String "name|type|action"\r
- * \r
- *\r
- */\r
-public class AAFPermission implements Permission {\r
- protected String type,instance,action,key;\r
-\r
- protected AAFPermission() {}\r
-\r
- public AAFPermission(String type, String instance, String action) {\r
- this.type = type;\r
- this.instance = instance;\r
- this.action = action;\r
- key = type + '|' + instance + '|' + action;\r
- }\r
- \r
- /**\r
- * Match a Permission\r
- * if Permission is Fielded type "Permission", we use the fields\r
- * otherwise, we split the Permission with '|'\r
- * \r
- * when the type or action starts with REGEX indicator character ( ! ),\r
- * then it is evaluated as a regular expression.\r
- * \r
- * If you want a simple field comparison, it is faster without REGEX\r
- */\r
- public boolean match(Permission p) {\r
- if(p instanceof AAFPermission) {\r
- AAFPermission ap = (AAFPermission)p;\r
- // Note: In AAF > 1.0, Accepting "*" from name would violate multi-tenancy\r
- // Current solution is only allow direct match on Type.\r
- // 8/28/2014 - added REGEX ability\r
- if(type.equals(ap.getName())) \r
- if(PermEval.evalInstance(instance,ap.getInstance()))\r
- if(PermEval.evalAction(action,ap.getAction()))\r
- return true;\r
- } else {\r
- // Permission is concatenated together: separated by |\r
- String[] aaf = p.getKey().split("[\\s]*\\|[\\s]*",3);\r
- if(aaf.length>0 && type.equals(aaf[0]))\r
- if(PermEval.evalInstance(instance,aaf.length>1?aaf[1]:"*"))\r
- if(PermEval.evalAction(action,aaf.length>2?aaf[2]:"*"))\r
- return true;\r
- } \r
- return false;\r
- }\r
-\r
- public String getName() {\r
- return type;\r
- }\r
- \r
- public String getInstance() {\r
- return instance;\r
- }\r
- \r
- public String getAction() {\r
- return action;\r
- }\r
- \r
- public String getKey() {\r
- return key;\r
- }\r
-\r
- /* (non-Javadoc)\r
- * @see com.att.cadi.Permission#permType()\r
- */\r
- public String permType() {\r
- return "AAF";\r
- }\r
-\r
- public String toString() {\r
- return "AAFPermission:\n\tType: " + type + \r
- "\n\tInstance: " + instance +\r
- "\n\tAction: " + action +\r
- "\n\tKey: " + key;\r
- }\r
-}\r