* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
import org.onap.aaf.auth.layer.Result;
/**
- * PermLookup is a Storage class for the various pieces of looking up Permission
+ * PermLookup is a Storage class for the various pieces of looking up Permission
* during Transactions to avoid duplicate processing
- *
+ *
* @author Jonathan
*
*/
private Result<List<RoleDAO.Data>> roles = null;
private Result<Set<String>> permNames = null;
private Result<List<PermDAO.Data>> perms = null;
-
+
private PermLookup() {}
-
+
public static PermLookup get(AuthzTrans trans, Question q, String user) {
PermLookup lp=null;
Map<String, PermLookup> permMap = trans.get(Question.PERMS, null);
}
return lp;
}
-
+
public Result<List<UserRoleDAO.Data>> getUserRoles() {
if (userRoles==null) {
userRoles = q.userRoleDAO().readByUser(trans,user);
return permNames;
}
}
-
+
public Result<List<PermDAO.Data>> getPerms(boolean lookup) {
if (perms==null) {
// Note: It should be ok for a Valid user to have no permissions -
List<PermDAO.Data> lpdd = new ArrayList<>();
for (String perm : rss.value) {
if (lookup) {
- Map<String,PermDAO.Data> mspdd = new TreeMap<>();
+ Map<String,PermDAO.Data> mspdd = new TreeMap<>();
Result<String[]> ap = PermDAO.Data.decodeToArray(trans, q, perm);
if (ap.isOK()) {
-
+
Result<List<PermDAO.Data>> rlpd = q.permDAO().read(perm,trans,ap.value);
if (rlpd.isOKhasData()) {
for (PermDAO.Data pData : rlpd.value) {
- // ONLY add perms/roles which are related to this lookup
- for(String pdr : pData.roles(false)) {
- for(RoleDAO.Data r : roles.value) {
- if(pdr.equals(r.encode())) {
- PermDAO.Data pdd = mspdd.get(pData.fullPerm());
- if(pdd==null) {
- pdd = new PermDAO.Data();
- pdd.ns = pData.ns;
- pdd.type = pData.type;
- pdd.instance = pData.instance;
- pdd.action = pData.action;
- pdd.description = pData.description;
+ // ONLY add perms/roles which are related to this lookup
+ for(String pdr : pData.roles(false)) {
+ for(RoleDAO.Data r : roles.value) {
+ if(pdr.equals(r.encode())) {
+ PermDAO.Data pdd = mspdd.get(pData.fullPerm());
+ if(pdd==null) {
+ pdd = new PermDAO.Data();
+ pdd.ns = pData.ns;
+ pdd.type = pData.type;
+ pdd.instance = pData.instance;
+ pdd.action = pData.action;
+ pdd.description = pData.description;
lpdd.add(pdd);
- }
- pdd.roles(true).add(pdr);
- break;
- }
- }
- }
+ }
+ pdd.roles(true).add(pdr);
+ break;
+ }
+ }
+ }
}
}
} else {