summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPrabanand Sivasamy <prabanand.sivasamy@att.com>2020-07-30 15:16:33 -0400
committerPrabanand Sivasamy <prabanand.sivasamy@att.com>2020-07-30 15:16:33 -0400
commita06268eb4fec6c245815f33335f807474e024ab7 (patch)
treee667ffa9e8e290c385e912b1410205683e53276e
parentbdb54b7c8a5df0e686490658067c9013ee43dd7a (diff)
Committing the changes of Locate cred tags to Gerrit.
Issue-ID: AAF-1186 Change-Id: I764109ebb202a12d4b55158a9bbe9f003b934691 Signed-off-by: Prabanand Sivasamy <prabanand.sivasamy@att.com>
-rw-r--r--auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/AAF_Locate.java6
-rw-r--r--auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/api/API_Proxy.java31
2 files changed, 34 insertions, 3 deletions
diff --git a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/AAF_Locate.java b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/AAF_Locate.java
index ff538269..5c5f9a6c 100644
--- a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/AAF_Locate.java
+++ b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/AAF_Locate.java
@@ -33,6 +33,7 @@ import org.onap.aaf.auth.cache.Cache.Dated;
import org.onap.aaf.auth.dao.CassAccess;
import org.onap.aaf.auth.dao.cass.ConfigDAO;
import org.onap.aaf.auth.dao.cass.LocateDAO;
+import org.onap.aaf.auth.dao.hl.Question;
import org.onap.aaf.auth.direct.DirectLocatorCreator;
import org.onap.aaf.auth.direct.DirectRegistrar;
import org.onap.aaf.auth.env.AuthzEnv;
@@ -81,7 +82,7 @@ public class AAF_Locate extends AbsService<AuthzEnv, AuthzTrans> {
public final ConfigDAO configDAO;
private Locator<URI> dal;
-
+ public final Question question;
/**
* Construct AuthzAPI with all the Context Supporting Routes that Authz needs
*
@@ -121,6 +122,7 @@ public class AAF_Locate extends AbsService<AuthzEnv, AuthzTrans> {
}
}
+ question = new Question(trans, cluster, CassAccess.KEYSPACE);
////////////////////////////////////////////////////////////////////////////
// Time Critical
@@ -128,7 +130,7 @@ public class AAF_Locate extends AbsService<AuthzEnv, AuthzTrans> {
////////////////////////////////////////////////////////////////////////
API_AAFAccess.init(this,facade);
API_Find.init(this, facade);
- API_Proxy.init(this, facade);
+ API_Proxy.init(this, facade, question);
////////////////////////////////////////////////////////////////////////
// Management APIs
diff --git a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/api/API_Proxy.java b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/api/API_Proxy.java
index c77e9a85..8d56dc96 100644
--- a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/api/API_Proxy.java
+++ b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/api/API_Proxy.java
@@ -27,6 +27,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.http.HttpStatus;
+import org.onap.aaf.auth.dao.hl.Question;
import org.onap.aaf.auth.env.AuthzTrans;
import org.onap.aaf.auth.locate.AAF_Locate;
import org.onap.aaf.auth.locate.BasicAuthCode;
@@ -35,6 +36,7 @@ import org.onap.aaf.auth.locate.facade.LocateFacade;
import org.onap.aaf.auth.locate.mapper.Mapper.API;
import org.onap.aaf.auth.rserv.HttpMethods;
import org.onap.aaf.cadi.CadiException;
+import org.onap.aaf.cadi.Symm;
import org.onap.aaf.cadi.client.Future;
import org.onap.aaf.cadi.client.Rcli;
import org.onap.aaf.cadi.client.Retryable;
@@ -42,6 +44,7 @@ import org.onap.aaf.cadi.config.Config;
import org.onap.aaf.cadi.oauth.OAuth2Principal;
import org.onap.aaf.misc.env.APIException;
import org.onap.aaf.misc.env.Env;
+import org.onap.aaf.misc.env.LogTarget;
import org.onap.aaf.misc.env.TimeTaken;
/**
@@ -59,7 +62,7 @@ public class API_Proxy {
* @param facade
* @throws Exception
*/
- public static void init(final AAF_Locate gwAPI, LocateFacade facade) {
+ public static void init(final AAF_Locate gwAPI, LocateFacade facade, final Question question) {
String aafurl = gwAPI.access.getProperty(Config.AAF_URL,null);
if (aafurl!=null) {
@@ -72,6 +75,7 @@ public class API_Proxy {
gwAPI.routeAll(HttpMethods.GET,"/proxy/:path*",API.VOID,new LocateCode(facade,"Proxy GET", true) {
@Override
public void handle(final AuthzTrans trans, final HttpServletRequest req, final HttpServletResponse resp) throws Exception {
+ populateCredentialTag(trans, req, question);
if ("/proxy/authn/basicAuth".equals(req.getPathInfo()) && !(req.getUserPrincipal() instanceof OAuth2Principal)) {
bac.handle(trans, req, resp);
} else {
@@ -159,4 +163,29 @@ public class API_Proxy {
});
}
}
+
+ /**
+ * Populates TAG value for the user from DB
+ *
+ * @param trans
+ * @param req
+ * @param question
+ */
+ private static void populateCredentialTag(AuthzTrans trans, HttpServletRequest req, Question question) {
+
+ try {
+ String authz = req.getHeader("Authorization");
+ String decoded = Symm.base64noSplit.decode(authz.substring(6));
+ int colon = decoded.indexOf(':');
+ // Update transaction object with TAG information from DB
+ question.doesUserCredMatch(trans, decoded.substring(0, colon), decoded.substring(colon + 1).getBytes());
+ String tag = trans.getTag();
+ if (null != tag) {
+ req.setAttribute("CRED_TAG", tag);
+ }
+ } catch (Exception e) {
+ LogTarget lt = trans.error();
+ lt.log("Exception occured while fetching TAG details from DB :" + e.getMessage());
+ }
+ }
}