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=========================================================
21 package org.openecomp.sdc.be.components.impl.aaf;
23 import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
24 import org.openecomp.sdc.be.config.ConfigurationManager;
25 import org.openecomp.sdc.be.dao.api.ActionStatus;
27 public enum AafPermission {
29 READ(PermNames.READ_VALUE),
30 WRITE(PermNames.WRITE_VALUE),
31 DELETE(PermNames.DELETE_VALUE),
32 INTERNAL_ALL(PermNames.INTERNAL_ALL_VALUE);
34 private String permission;
35 private String permissionSuffix;
37 AafPermission(String permissionSuffix) {
38 this.permissionSuffix = permissionSuffix;
39 this.permission = String.format("%s.%s",
40 ConfigurationManager.getConfigurationManager().getConfiguration().getAafNamespace(),
44 public String getFullPermission() {
48 public static AafPermission getEnumByString(String perm) {
49 for (AafPermission e : AafPermission.values()) {
50 if (perm.equals(e.getPermissionSuffix()))
53 throw new ByActionStatusComponentException(ActionStatus.INVALID_PROPERTY, perm);
56 public String getPermissionSuffix() {
57 return this.permissionSuffix;
60 public static class PermNames {
61 public static final String READ_VALUE = "endpoint.api.access|*|read";
62 public static final String WRITE_VALUE = "endpoint.api.access|*|write";
63 public static final String DELETE_VALUE = "endpoint.api.access|*|delete";
64 public static final String INTERNAL_ALL_VALUE = "endpoint.api.internal.access|*|all";