Merge "Cred delete fixes"
authorSai Gandham <sai.gandham@att.com>
Tue, 9 Jul 2019 00:32:27 +0000 (00:32 +0000)
committerGerrit Code Review <gerrit@onap.org>
Tue, 9 Jul 2019 00:32:27 +0000 (00:32 +0000)
auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/Function.java
cadi/aaf/src/main/java/org/onap/aaf/cadi/oauth/TokenClientFactory.java
misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutJson.java

index 3fde512..c59312c 100644 (file)
@@ -628,7 +628,12 @@ public class Function {
                 return Result.err(Status.ERR_DependencyExists, sb.toString());
             }
 
-            if (move && (parent == null || parent.type == NsType.COMPANY.type)) {
+            if (move && parent == null) {
+                return Result
+                        .err(Status.ERR_DependencyExists,
+                                "Cannot move users, roles or permissions - parent is missing.\nDelete dependencies and try again");
+            }
+            else if (move && parent.type == NsType.COMPANY.type) {
                 return Result
                         .err(Status.ERR_DependencyExists,
                                 "Cannot move users, roles or permissions to [%s].\nDelete dependencies and try again",
index b3cf266..14cf0f6 100644 (file)
@@ -152,15 +152,17 @@ public class TokenClientFactory extends Persist<Token,TimedToken> {
             }
             sb.append('_');
             sb.append(tokenSource);
-            byte[] tohash=scope.getBytes();
-            if (hash!=null && hash.length>0) {
-                byte temp[] = new byte[hash.length+tohash.length];
-                System.arraycopy(tohash, 0, temp, 0, tohash.length);
-                System.arraycopy(hash, 0, temp, tohash.length, hash.length);
-                tohash = temp;
-            }
-            if (scope!=null && scope.length()>0) {
-                sb.append(Hash.toHexNo0x(Hash.hashSHA256(tohash)));
+            if (scope!=null) {
+                byte[] tohash=scope.getBytes();
+                if (hash!=null && hash.length>0) {
+                    byte temp[] = new byte[hash.length+tohash.length];
+                    System.arraycopy(tohash, 0, temp, 0, tohash.length);
+                    System.arraycopy(hash, 0, temp, tohash.length, hash.length);
+                    tohash = temp;
+                }
+                if (scope.length()>0) {
+                    sb.append(Hash.toHexNo0x(Hash.hashSHA256(tohash)));
+                }
             }
             return sb.toString();
         } catch (NoSuchAlgorithmException e) {
index 6c86837..2d93bb4 100644 (file)
@@ -39,13 +39,13 @@ public class OutJson extends Out {
         } else {
             ipw = null;
         }
-        
+
         // If it's a fragment, print first Object Name.  If root Object, skip first name
         Stack<LevelStack> jsonLevel = new Stack<LevelStack>();
         jsonLevel.push(new LevelStack(options.length>1 && options[1]));
         boolean print = true, hadData=false;
         char afterName=0, beforeName=0, maybe = 0, prev=0;
-        
+
         int count = 0;
         while ((p = prs.parse(in,p.reuse())).valid()) {
             ++count;
@@ -112,18 +112,20 @@ public class OutJson extends Out {
                 default:
                     print = true;
             }
-        
+
             if (maybe!=0) {
                 if (ipw==null)writer.append(maybe); 
                 else ipw.println(maybe);
                 maybe = 0;
             }
-            
-            if (beforeName!=0) {
-                if (ipw==null)writer.append(beforeName);
-                else ipw.println(beforeName);
-                beforeName = 0;
-            }
+
+            // commented out unreachable code (as it is, beforeName is never
+            // assigned any value except 0
+            //if (beforeName!=0) {
+            //    if (ipw==null)writer.append(beforeName);
+            //    else ipw.println(beforeName);
+            //    beforeName = 0;
+            //}
             if (print) {
                 if (p.hasName()) {
                     writer.append('"');