Prepare for release 2.7.4
[aaf/authz.git] / cadi / aaf / src / main / java / org / onap / aaf / cadi / aaf / v2_0 / AAFAuthn.java
index f74306f..e16782f 100644 (file)
@@ -34,6 +34,7 @@ import org.onap.aaf.cadi.User;
 import org.onap.aaf.cadi.aaf.AAFPermission;
 import org.onap.aaf.cadi.client.Future;
 import org.onap.aaf.cadi.client.Rcli;
+import org.onap.aaf.cadi.locator.SingleEndpointLocator;
 import org.onap.aaf.cadi.lur.ConfigPrincipal;
 
 import aaf.v2_0.CredRequest;
@@ -143,10 +144,14 @@ public class AAFAuthn<CLIENT> extends AbsUserCache<AAFPermission> {
 
         public Resp revalidate(Object state) {
             int maxRetries = 15;
-            try { // these SHOULD be AAFConHttp and AAFLocator objects, but put in a try anyway to be safe
+            try { // these SHOULD be an AAFConHttp and a AAFLocator or SingleEndpointLocator objects, but put in a try to be safe
                 AAFConHttp forceCastCon = (AAFConHttp) con;
-                AAFLocator forceCastLoc = (AAFLocator) forceCastCon.hman().loc;
-                maxRetries = forceCastLoc.maxIters();
+                if (forceCastCon.hman().loc instanceof SingleEndpointLocator) {
+                    maxRetries = 1; // we cannot retry the single LGW gateway!
+                } else {
+                    AAFLocator forceCastLoc = (AAFLocator) forceCastCon.hman().loc;
+                    maxRetries = forceCastLoc.maxIters();
+                }
             } catch (Exception e) {
                 access.log(Access.Level.DEBUG, e);
             }
@@ -156,17 +161,12 @@ public class AAFAuthn<CLIENT> extends AbsUserCache<AAFPermission> {
                 try {
                     Miss missed = missed(getName(), getCred());
                     if (missed == null || missed.mayContinue()) {
-                        CredRequest cr = new CredRequest();
-                        cr.setId(getName());
-                        cr.setPassword(new String(getCred()));
-                        Rcli<CLIENT> client = con.clientIgnoreAlreadyAttempted(attemptedUris);
+                        Rcli<CLIENT> client = con.clientIgnoreAlreadyAttempted(attemptedUris).forUser(con.basicAuth(getName(), new String(getCred())));
                         thisUri = client.getURI();
-                        Future<String> fp = client.readPost("/authn/validate", con.credReqDF, cr);
-                        //Rcli<CLIENT> client = con.client().forUser(con.basicAuth(getName(), new String(getCred())));
-                        //Future<String> fp = client.read(
-                        //        "/authn/basicAuth",
-                        //        "text/plain"
-                        //       );
+                        Future<String> fp = client.read(
+                                "/authn/basicAuth",
+                                "text/plain"
+                               );
                         if (fp.get(con.timeout)) {
                             expires = System.currentTimeMillis() + timeToLive;
                             addUser(new User<AAFPermission>(this, timeToLive));