2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 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====================================================
22 package org.onap.aaf.auth.dao.hl;
24 import org.onap.aaf.auth.dao.cass.NsSplit;
25 import org.onap.aaf.auth.dao.cass.NsDAO.Data;
26 import org.onap.aaf.auth.env.AuthzTrans;
27 import org.onap.aaf.auth.layer.Result;
28 import org.onap.aaf.auth.org.Executor;
30 public class CassExecutor implements Executor {
34 private AuthzTrans trans;
36 public CassExecutor(AuthzTrans trans, Function f) {
43 public boolean hasPermission(String user, String ns, String type, String instance, String action) {
44 return isGranted(user, ns, type, instance, action);
48 public boolean inRole(String name) {
49 Result<NsSplit> nss = q.deriveNsSplit(trans, name);
50 if(nss.notOK())return false;
51 return q.roleDAO.read(trans, nss.value.ns,nss.value.name).isOKhasData();
54 public boolean isGranted(String user, String ns, String type, String instance, String action) {
55 return q.isGranted(trans, user, ns, type, instance,action);
59 public String namespace() throws Exception {
60 Result<Data> res = q.validNSOfDomain(trans,trans.user());
62 String user[] = trans.user().split("\\.");
63 return user[user.length-1] + '.' + user[user.length-2];
65 throw new Exception(res.status + ' ' + res.details);