Moved null ref check to line before dereferencing 26/89326/1
authorOleksandr Moliavko <o.moliavko@samsung.com>
Wed, 5 Jun 2019 07:23:34 +0000 (10:23 +0300)
committerOleksandr Moliavko <o.moliavko@samsung.com>
Wed, 5 Jun 2019 07:27:47 +0000 (10:27 +0300)
Issue-ID: AAF-837
Change-Id: I67d258a1b585eaa683dc75cfcd18bbbe41a34743
Signed-off-by: AlexMolyavko <o.moliavko@samsung.com>
cadi/aaf/src/main/java/org/onap/aaf/cadi/oauth/TokenClientFactory.java

index 772040c..b0c3294 100644 (file)
@@ -141,15 +141,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) {