2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package org.openecomp.sdc.be.components.impl.aaf;
22 import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
23 import org.openecomp.sdc.be.config.ConfigurationManager;
24 import org.openecomp.sdc.be.dao.api.ActionStatus;
26 public enum AafPermission {
27 READ(PermNames.READ_VALUE), WRITE(PermNames.WRITE_VALUE), DELETE(PermNames.DELETE_VALUE), INTERNAL_ALL(PermNames.INTERNAL_ALL_VALUE);
28 private String permission;
29 private String permissionSuffix;
31 AafPermission(String permissionSuffix) {
32 this.permissionSuffix = permissionSuffix;
33 this.permission = String
34 .format("%s.%s", ConfigurationManager.getConfigurationManager().getConfiguration().getAafNamespace(), permissionSuffix);
37 public static AafPermission getEnumByString(String perm) {
38 for (AafPermission e : AafPermission.values()) {
39 if (perm.equals(e.getPermissionSuffix())) {
43 throw new ByActionStatusComponentException(ActionStatus.INVALID_PROPERTY, perm);
46 public String getFullPermission() {
50 public String getPermissionSuffix() {
51 return this.permissionSuffix;
54 public static class PermNames {
56 public static final String READ_VALUE = "endpoint.api.access|*|read";
57 public static final String WRITE_VALUE = "endpoint.api.access|*|write";
58 public static final String DELETE_VALUE = "endpoint.api.access|*|delete";
59 public static final String INTERNAL_ALL_VALUE = "endpoint.api.internal.access|*|all";