The documentation of the Mac class requires that every Java platform supports the following algorithms:
HmacMD5
HmacSHA1
HmacSHA256
What do you think about adding static factory methods (or changing the existing constructors) to catch NoSuchAlgorithmException for these algorithms and wrap them inside some unchecked exceptions? Since these algorithms will always be available (unless the JVM is incorrectly configured?) the user currently has to deal with exceptions which can never occur.
Notably, SHA-512 is absent from that list, and that's an algorithm allowed by the TOTP standard. Your point is taken, but I think what we have now is correct.
The documentation of the
Mac
class requires that every Java platform supports the following algorithms:What do you think about adding static factory methods (or changing the existing constructors) to catch
NoSuchAlgorithmException
for these algorithms and wrap them inside some unchecked exceptions? Since these algorithms will always be available (unless the JVM is incorrectly configured?) the user currently has to deal with exceptions which can never occur.