You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by ju...@apache.org on 2022/07/12 20:39:14 UTC
[jspwiki] 01/02: Make final variable when is possible.
This is an automated email from the ASF dual-hosted git repository.
juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git
commit 8f50025a42cb282689626fd7889ab79593d0aaef
Author: Arturo Bernal <ar...@gmail.com>
AuthorDate: Fri Jun 24 22:38:16 2022 +0200
Make final variable when is possible.
---
jspwiki-util/src/main/java/org/apache/wiki/util/CryptoUtil.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/jspwiki-util/src/main/java/org/apache/wiki/util/CryptoUtil.java b/jspwiki-util/src/main/java/org/apache/wiki/util/CryptoUtil.java
index 52a19e1b9..ad44cf8b0 100644
--- a/jspwiki-util/src/main/java/org/apache/wiki/util/CryptoUtil.java
+++ b/jspwiki-util/src/main/java/org/apache/wiki/util/CryptoUtil.java
@@ -177,7 +177,7 @@ public final class CryptoUtil
//The term SSHA is used as a password prefix for backwards compatibility, but we use SHA-1 when fetching an instance
//of MessageDigest, as it is the guaranteed option. We also need to remove curly braces surrounding the string for
//backwards compatibility.
- String algorithmToUse = algorithm.equals(SSHA) ? SHA1 : algorithm;
+ final String algorithmToUse = algorithm.equals(SSHA) ? SHA1 : algorithm;
final MessageDigest digest = MessageDigest.getInstance( algorithmToUse.substring( 1, algorithmToUse.length() -1 ) );
digest.update( password );
final byte[] hash = digest.digest( salt );
@@ -205,7 +205,7 @@ public final class CryptoUtil
{
throw new IllegalArgumentException( "Hash not prefixed by expected algorithm; is it really a salted hash?" );
}
- String algorithm = entry.startsWith( SSHA ) ? SSHA : SHA256;
+ final String algorithm = entry.startsWith( SSHA ) ? SSHA : SHA256;
final byte[] challenge = Base64.getDecoder().decode( entry.substring( algorithm.length() )
.getBytes( StandardCharsets.UTF_8 ) );
@@ -218,7 +218,7 @@ public final class CryptoUtil
// The term SSHA is used as a password prefix for backwards compatibility, but we use SHA-1 when fetching an instance
// of MessageDigest, as it is the guaranteed option. We also need to remove curly braces surrounding the string for
// backwards compatibility.
- String algorithmToUse = algorithm.equals(SSHA) ? SHA1 : algorithm;
+ final String algorithmToUse = algorithm.equals(SSHA) ? SHA1 : algorithm;
final MessageDigest digest = MessageDigest.getInstance( algorithmToUse.substring( 1, algorithmToUse.length() -1 ) );
digest.update( password );
final byte[] hash = digest.digest( salt );