diff options
author | Jonathan Gathman <jonathan.gathman@att.com> | 2019-07-03 14:10:52 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-07-03 14:10:52 +0000 |
commit | 9f1388eb5ac3f9aab5fe617eae55b08fd2a57059 (patch) | |
tree | 8504f882df8e5c880bcb85e59b31efe85668b242 | |
parent | 078325f8ef05a6216292f5331ef0805a5bdd9ef1 (diff) | |
parent | 8a400f444aa99722505a6219142ffb5588983cc1 (diff) |
Merge "Moved null ref check to line before dereferencing"
-rw-r--r-- | cadi/aaf/src/main/java/org/onap/aaf/cadi/oauth/TokenClientFactory.java | 20 |
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 b3cf266e..14cf0f62 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 @@ -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) { |