X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cadi%2Faaf%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fcadi%2Faaf%2Fv2_0%2FAAFLurPerm.java;h=caa1fcc1bc1d986b14f28e567c8f7a5f046360c1;hb=1296352d8eafee57f982a4342ad79ada4aa56d28;hp=dc0e2cae6b29ea8eed8677400328f104f1c98f6d;hpb=7e966914050e66219689001ff4ab601a49eef0ac;p=aaf%2Fauthz.git diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFLurPerm.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFLurPerm.java index dc0e2cae..caa1fcc1 100644 --- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFLurPerm.java +++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFLurPerm.java @@ -7,9 +7,9 @@ * 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. @@ -52,11 +52,11 @@ import aaf.v2_0.Perms; /** * Use AAF Service as Permission Service. - * + * * This Lur goes after AAF Permissions, which are elements of Roles, not the Roles themselves. - * + * * If you want a simple Role Lur, use AAFRoleLur - * + * * @author Jonathan * */ @@ -65,13 +65,13 @@ public class AAFLurPerm extends AbsAAFLur { /** * Need to be able to transmutate a Principal into either Person or AppID, which are the only ones accepted at this - * point by AAF. There is no "domain", aka, no "@att.com" in "ab1234@att.com". - * + * point by AAF. There is no "domain", aka, no "@att.com" in "ab1234@att.com". + * * The only thing that matters here for AAF is that we don't waste calls with IDs that obviously aren't valid. * Thus, we validate that the ID portion follows the rules before we waste time accessing AAF remotely - * @throws APIException - * @throws URISyntaxException - * @throws DME2Exception + * @throws APIException + * @throws URISyntaxException + * @throws DME2Exception */ // Package on purpose AAFLurPerm(AAFCon con) throws CadiException, APIException { @@ -84,7 +84,7 @@ public class AAFLurPerm extends AbsAAFLur { super(con,auc); attachOAuth2(con); } - + private void attachOAuth2(AAFCon con) throws APIException { String oauth2_url; Class tmcls = Config.loadClass(access,"org.osaaf.cadi.oauth.TokenMgr"); @@ -113,14 +113,19 @@ public class AAFLurPerm extends AbsAAFLur { final Holder remote = new Holder(0f); final boolean[] success = new boolean[]{false}; - + try { return aaf.best(new Retryable>() { @Override public User code(Rcli client) throws CadiException, ConnectException, APIException { final long remoteStart = System.nanoTime(); - Future fp = client.read("/authz/perms/user/"+name,aaf.permsDF); - + StringBuilder sb = new StringBuilder("/authz/perms/user/"); + sb.append(name); + if(details) { + sb.append("?force"); + } + Future fp = client.read(sb.toString(),aaf.permsDF); + // In the meantime, lookup User, create if necessary User user = getUser(principal); Principal p; @@ -134,11 +139,11 @@ public class AAFLurPerm extends AbsAAFLur { } else { p = principal; } - + if (user==null) { addUser(user = new User(p,aaf.userExpires)); // no password } - + // OK, done all we can, now get content boolean ok = fp.get(aaf.timeout); remote.set(Timing.millis(remoteStart)); @@ -190,17 +195,17 @@ public class AAFLurPerm extends AbsAAFLur { @Override public Resp code(Rcli client) throws CadiException, ConnectException, APIException { final long remoteStart = System.nanoTime(); - Future fp = aaf.client(Config.AAF_DEFAULT_VERSION).read( + Future fp = aaf.client().read( "/authz/perms/user/"+name, aaf.permsDF ); - + // OK, done all we can, now get content boolean ok = fp.get(aaf.timeout); remote.set(Timing.millis(remoteStart)); if (ok) { success.set(true); - Map newMap = user.newMap(); + Map newMap = user.newMap(); boolean willLog = aaf.access.willLog(Level.DEBUG); for (Perm perm : fp.value.getPerm()) { user.add(newMap, new AAFPermission(perm.getNs(),perm.getType(),perm.getInstance(),perm.getAction(),perm.getRoles())); @@ -253,5 +258,5 @@ public class AAFLurPerm extends AbsAAFLur { return new LocalPermission(p); } } - + }