summaryrefslogtreecommitdiffstats
path: root/cadi
diff options
context:
space:
mode:
authorOleksandr Moliavko <o.moliavko@samsung.com>2019-06-05 10:23:34 +0300
committerOleksandr Moliavko <o.moliavko@samsung.com>2019-06-05 10:27:47 +0300
commit8a400f444aa99722505a6219142ffb5588983cc1 (patch)
treea6a545d161a9a65c8ec6d089788d0057b05a0f48 /cadi
parentae776a1394b7edc9c42db471b48b330d6789643b (diff)
Moved null ref check to line before dereferencing
Issue-ID: AAF-837 Change-Id: I67d258a1b585eaa683dc75cfcd18bbbe41a34743 Signed-off-by: AlexMolyavko <o.moliavko@samsung.com>
Diffstat (limited to 'cadi')
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/oauth/TokenClientFactory.java20
1 files changed, 11 insertions, 9 deletions
diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/oauth/TokenClientFactory.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/oauth/TokenClientFactory.java
index 772040c3..b0c32942 100644
--- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/oauth/TokenClientFactory.java
+++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/oauth/TokenClientFactory.java
@@ -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) {