no need of catching UnsupportedEncodingException
*/
package org.apache.wiki.auth.user;
-import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
@@ -260,10 +259,6 @@ public abstract class AbstractUserDatabase implements UserDatabase
{
log.error( "Unsupported algorithm: " + e.getMessage() );
}
- catch( UnsupportedEncodingException e )
- {
- log.fatal( "You do not have UTF-8!?!" );
- }
catch( WikiSecurityException e )
{
log.error( "Could not upgrade SHA password to SSHA because profile could not be saved. Reason: " + e.getMessage(), e );
@@ -312,17 +307,13 @@ public abstract class AbstractUserDatabase implements UserDatabase
String hash = null;
try
{
- hash = CryptoUtil.getSaltedPassword( text.getBytes("UTF-8") );
+ hash = CryptoUtil.getSaltedPassword( text.getBytes(StandardCharsets.UTF_8) );
}
catch( NoSuchAlgorithmException e )
{
log.error( "Error creating salted SHA password hash:" + e.getMessage() );
hash = text;
}
- catch( UnsupportedEncodingException e )
- {
- log.fatal("You do not have UTF-8!?!");
- }
return hash;
}
@@ -339,7 +330,7 @@ public abstract class AbstractUserDatabase implements UserDatabase
try
{
MessageDigest md = MessageDigest.getInstance( "SHA" );
- md.update( text.getBytes("UTF-8") );
+ md.update( text.getBytes(StandardCharsets.UTF_8) );
byte[] digestedBytes = md.digest();
hash = ByteUtils.bytes2hex( digestedBytes );
}
@@ -348,10 +339,6 @@ public abstract class AbstractUserDatabase implements UserDatabase
log.error( "Error creating SHA password hash:" + e.getMessage() );
hash = text;
}
- catch (UnsupportedEncodingException e)
- {
- log.fatal("UTF-8 not supported!?!");
- }
return hash;
}
