Merge "DirectAAFLur.java-sonar fix"
authorJonathan Gathman <jonathan.gathman@att.com>
Wed, 6 Nov 2019 12:51:42 +0000 (12:51 +0000)
committerGerrit Code Review <gerrit@onap.org>
Wed, 6 Nov 2019 12:51:42 +0000 (12:51 +0000)
17 files changed:
auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/ExpireRange.java
auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/AbsCassDAO.java
auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/OAuthTokenDAO.java
auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/Function.java
auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/ca/JscepCA.java
auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/service/CMService.java
auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/AAFcli.java
auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/perm/Create.java
auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/user/ListApprovals.java
auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Route.java
auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/TypedCode.java
auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/CMArtiChangeAction.java
auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/LoginLandingAction.java
auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/PassDeleteAction.java
auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/PendingRequestsShow.java
auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/service/LocateServiceImpl.java
auth/auth-oauth/src/main/java/org/onap/aaf/auth/oauth/service/OAuthService.java

index bb3a3e9..3c246db 100644 (file)
@@ -77,10 +77,6 @@ public class ExpireRange {
                 lcred.add(new Range(TWO_MONTH,1,-1,-1,GregorianCalendar.MONTH,1,GregorianCalendar.MONTH,2));
 
                 lur.add(  new Range(ONE_MONTH,1,-1,-1,0,0,GregorianCalendar.MONTH,1));
-                // Comment out until we can get some more clear actions in place for GUI
-                // lur.add(  new Range(ONE_MONTH,1,-1,-1,GregorianCalendar.WEEK_OF_MONTH,2,GregorianCalendar.MONTH,1));
-                // lur.add(  new Range(ONE_WEEK,2,-1,1,0,0,GregorianCalendar.WEEK_OF_MONTH,1));
-
                 lx509.add(new Range(ONE_MONTH,1,-1,-1,GregorianCalendar.WEEK_OF_MONTH,2,GregorianCalendar.MONTH,1));
             }
     }
index de0efdf..c68768e 100644 (file)
@@ -73,7 +73,7 @@ public abstract class AbsCassDAO<TRANS extends TransStore,DATA> {
 //    private static Slot sessionSlot; // not used since 2015
     private static final ArrayList<AbsCassDAO<? extends TransStore,?>.PSInfo> psinfos = new ArrayList<>();
     private static final List<Object> EMPTY = new ArrayList<>(0);
-    private static final Deque<ResetRequest> resetDeque = new ConcurrentLinkedDeque<ResetRequest>();
+    private static final Deque<ResetRequest> resetDeque = new ConcurrentLinkedDeque<>();
     private static boolean resetTrigger = false;
     private static long nextAvailableReset = 0;
 
@@ -96,10 +96,6 @@ public abstract class AbsCassDAO<TRANS extends TransStore,DATA> {
         this.dataClass = dataClass;
     }
 
-// Not used since 2015
-//    public static void setSessionSlot(Slot slot) {
-//        sessionSlot = slot;
-//    }
 
     //Note: Lower case ON PURPOSE. These names used to create History Messages
     public enum CRUD {
index a84490d..bda7ef0 100644 (file)
@@ -3,6 +3,7 @@
  * org.onap.aaf
  * ===========================================================================
  * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 IBM.
  * ===========================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -100,7 +101,7 @@ public class OAuthTokenDAO extends CassDAOImpl<AuthzTrans,OAuthTokenDAO.Data> {
         }
 
         public String toString() {
-            return user.toString() + ' ' + id.toString() + ' ' + Chrono.dateTime(expires) + (active?"":"in") + "active";
+            return user + ' ' + id + ' ' + Chrono.dateTime(expires) + (active?"":"in") + "active";
         }
     }
 
index d809618..89643c4 100644 (file)
@@ -297,7 +297,8 @@ public class Function {
         }
 
         // VALIDATIONS done... Add NS
-        if ((rq = q.nsDAO().create(trans, namespace.data())).notOK()) {
+        rq = q.nsDAO().create(trans, namespace.data());
+        if (rq.notOK()) {
             return Result.err(rq);
         }
 
index 51b962c..e7b4ef4 100644 (file)
@@ -225,10 +225,7 @@ public class JscepCA extends CA {
             try {
                 String[] info = Split.split('/', urlinfo);
                 Client c = new Client(new URL(JscepCA.CA_PREFIX + info[0] + JscepCA.CA_POSTFIX),
-                        cert -> {
-                            //TODO checkIssuer
-                            return true;
-                        }
+                        cert -> true
                 );
                 // Map URL to Client, because Client doesn't expose Connection
                 mxcwiC.put(c, mxcwiS.get(urlinfo));
index 8810943..c85b4ca 100644 (file)
@@ -3,7 +3,7 @@
  * org.onap.aaf
  * ===========================================================================
  * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2018 IBM.
+ * Modifications Copyright (C) 2019 IBM.
  * ===========================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -334,12 +334,10 @@ public class CMService {
                             trans.error().log("CMService var primary is null");
                         } else {
                             String fg = fqdns.get(i);
-                            if (fg!=null && primary!=null && fg.equals(primary.getHostName())) {
-                                if (i != 0) {
+                            if ((fg!=null && primary!=null && fg.equals(primary.getHostName()))&&(i != 0)) {
                                     String tmp = fqdns.get(0);
                                     fqdns.set(0, primary.getHostName());
                                     fqdns.set(i, tmp);
-                                }
                             }
                         }
                     }
index 2c08442..9de4e34 100644 (file)
@@ -549,15 +549,15 @@ public class AAFcli {
                                     while ((line = reader.readLine()) != null) {
                                         showDetails = (line.contains("-d"));
 
-                                        if (line.equalsIgnoreCase("quit") || line.equalsIgnoreCase("q") || line.equalsIgnoreCase("exit")) {
+                                        if ("quit".equalsIgnoreCase(line) || "q".equalsIgnoreCase(line) || "exit".equalsIgnoreCase(line)) {
                                             break;
-                                        } else if (line.equalsIgnoreCase("--help -d") || line.equalsIgnoreCase("help -d")
-                                                || line.equalsIgnoreCase("help")) {
+                                        } else if ("--help -d".equalsIgnoreCase(line) || "help -d".equalsIgnoreCase(line)
+                                                || "help".equalsIgnoreCase(line)) {
                                             line = "--help";
-                                        } else if (line.equalsIgnoreCase("cls")) {
+                                        } else if ("cls".equalsIgnoreCase(line)) {
                                             reader.clearScreen();
                                             continue;
-                                        } else if (line.equalsIgnoreCase("?")) {
+                                        } else if ("?".equalsIgnoreCase(line)) {
                                             keyboardHelp();
                                             continue;
                                         }
index 559ae07..c444722 100644 (file)
@@ -3,6 +3,7 @@
  * org.onap.aaf
  * ===========================================================================
  * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 IBM.
  * ===========================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -149,7 +150,8 @@ public class Create extends Cmd {
     public void detailedHelp(int _indent, StringBuilder sb) {
             int indent = _indent;
         detailLine(sb,indent,"Create a Permission with:");
-        detailLine(sb,indent+=2,"type     - A Namespace qualified identifier identifying the kind of");
+        indent=indent+2;
+        detailLine(sb,indent,"type     - A Namespace qualified identifier identifying the kind of");
         detailLine(sb,indent+11,"resource to be protected");
         detailLine(sb,indent,"instance - A name that distinguishes a particular instance of resource");
         detailLine(sb,indent,"action   - What kind of action is allowed");
index 828cdcb..765bd0a 100644 (file)
@@ -41,7 +41,7 @@ import aaf.v2_0.Approvals;
  */
 public class ListApprovals extends Cmd {
     private static final String HEADER = "List Approvals";
-    private final static String[] options = {"user","approver","ticket"};
+    private static final String[] options = {"user","approver","ticket"};
     public ListApprovals(List parent) {
         super(parent,"approvals",
                 new Param(optionsToString(options),true),
index a328284..f8c5ae1 100644 (file)
@@ -56,7 +56,7 @@ public class Route<TRANS extends Trans> {
         content.add(code, others);
     }
 
-    public HttpCode<TRANS,?> getCode(TRANS trans, HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {
+    public HttpCode<TRANS,?> getCode(TRANS trans, HttpServletRequest req, HttpServletResponse resp) {
         // Type is associated with Accept for GET (since it is what is being returned
         // We associate the rest with ContentType.
         // FYI, thought about this a long time before implementing this way.
index c292fae..6af2835 100644 (file)
 
 package org.onap.aaf.auth.rserv;
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 
-import javax.servlet.ServletException;
+
 
 import org.onap.aaf.misc.env.Env;
 import org.onap.aaf.misc.env.TimeTaken;
index 8f3fe95..c19820d 100644 (file)
@@ -149,7 +149,8 @@ public class CMArtiChangeAction extends Page {
                                                     break;
                                                 case CMArtiChangeForm.UPDATE:
                                                     Future<Artifacts> fu = client.update("/cert/artifacts", gui.artifactsDF, artifacts);
-                                                    if ((rv=fu).get(AAFcli.timeout())) {
+                                                    rv=fu;
+                                                    if(rv.get(AAFcli.timeout())) {
                                                         hgen.p("Artifact " + arti.getMechid() + " on " + arti.getMachine() + " is updated");
                                                         ok.set(true);
                                                     }
index 0c5979e..88ee139 100644 (file)
@@ -40,7 +40,6 @@ public class LoginLandingAction extends Page {
             new BreadCrumbs(breadcrumbs),
             new NamedCode(true,"content") {
                 final Slot sID = gui.env.slot(LoginLanding.NAME+'.'+LoginLanding.fields[0]);
-//                final Slot sPassword = gui.env.slot(LoginLanding.NAME+'.'+LoginLanding.fields[1]);
 
                 @Override
                 public void code(final Cache<HTMLGen> cache, final HTMLGen hgen) throws APIException, IOException {
index 76aef6e..817f3e8 100644 (file)
@@ -3,6 +3,7 @@
  * org.onap.aaf
  * ===========================================================================
  * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 IBM.
  * ===========================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -43,14 +44,14 @@ import org.onap.aaf.misc.xgen.html.HTMLGen;
 import aaf.v2_0.CredRequest;
 
 public class PassDeleteAction extends Page {
-    public static final String NAME = "PassDeleteAction";
+    public static final String CLASS = "PassDeleteAction";
     public static final String HREF = "/gui/passdelete";
-    private static enum Params{id,date,ns,type};
+    private enum Params{id,date,ns,type};
 
     public PassDeleteAction(final AAF_GUI gui, final Page ... breadcrumbs) throws APIException, IOException {
-        super(gui.env,NAME,HREF,Params.values(),
+        super(gui.env,CLASS,HREF,Params.values(),
             new BreadCrumbs(breadcrumbs),
-            new SlotCode<AuthzTrans>(true,gui.env,NAME,Params.values()) {
+            new SlotCode<AuthzTrans>(true,gui.env,CLASS,Params.values()) {
                 @Override
                 public void code(final Cache<HTMLGen> cache, final HTMLGen hgen) throws APIException, IOException {
                     cache.dynamic(hgen, new DynamicCode<HTMLGen,AAF_GUI, AuthzTrans>() {
index b528b24..694fefd 100644 (file)
@@ -125,7 +125,7 @@ public class PendingRequestsShow extends Page {
      *
      */
     private static class Model extends TableData<AAF_GUI,AuthzTrans> {
-        final long NUM_100NS_INTERVALS_SINCE_UUID_EPOCH = 0x01b21dd213814000L;
+        final static long NUM_100NS_INTERVALS_SINCE_UUID_EPOCH = 0x01b21dd213814000L;
         private final Slot sAsUser;
         private static final String[] headers = new String[] {"Request Date","Status","Memo","Approver"};
 
@@ -167,7 +167,6 @@ public class PendingRequestsShow extends Page {
                                     String prevTicket = null;
                                     for (Approval a : approvals) {
                                         String approver = a.getApprover();
-//                                        String approverShort = approver.substring(0,approver.indexOf('@'));
 
                                         AbsCell tsCell = null;
                                         String ticket = a.getTicket();
index 0e12ebb..afaef83 100644 (file)
@@ -32,7 +32,6 @@ import org.onap.aaf.auth.locate.AAF_Locate;
 import org.onap.aaf.auth.locate.mapper.Mapper;
 import org.onap.aaf.auth.locate.validation.LocateValidator;
 import org.onap.aaf.cadi.aaf.AAFPermission;
-import org.onap.aaf.misc.env.APIException;
 
 import locate.v1_0.Endpoints;
 import locate.v1_0.MgmtEndpoint;
index 4e1dd5b..a13959f 100644 (file)
@@ -128,7 +128,8 @@ public class OAuthService {
         odd.refresh = AAFToken.toToken(UUID.randomUUID());
         odd.active = true;
         long exp;
-        odd.expires = new Date(exp=(System.currentTimeMillis()+TOK_EXP));
+        exp=(System.currentTimeMillis()+TOK_EXP);
+        odd.expires = new Date(exp);
         odd.exp_sec = exp/1000;
         odd.req_ip = trans.ip();