private byte [ ] hmac ( byte [ ] key , byte [ ] data ) { try { final Mac mac = Mac . getInstance ( hmacAlgorithm ) ; mac . init ( new SecretKeySpec ( key , mac . getAlgorithm ( ) ) ) ; return mac . doFinal ( data ) ; } catch ( InvalidKeyException e ) { if ( key . length == 0 ) { throw new UnsupportedOperationException ( "This JVM does not support empty HMAC keys (empty passwords). " + "Please set a bucket password or upgrade your JVM." ) ; } else { throw new RuntimeException ( "Failed to generate HMAC hash for password" , e ) ; } } catch ( Throwable t ) { throw new RuntimeException ( t ) ; } }
Generate the HMAC with the given SHA algorithm