private String generateHmac ( ) throws HawkException { String baseString = getBaseString ( ) ; Mac mac ; try { mac = Mac . getInstance ( getAlgorithm ( ) . getMacName ( ) ) ; } catch ( NoSuchAlgorithmException e ) { throw new HawkException ( "Unknown algorithm " + getAlgorithm ( ) . getMacName ( ) , e ) ; } SecretKeySpec secret_key = new SecretKeySpec ( getKey ( ) . getBytes ( Charsets . UTF_8 ) , getAlgorithm ( ) . getMacName ( ) ) ; try { mac . init ( secret_key ) ; } catch ( InvalidKeyException e ) { throw new HawkException ( "Key is invalid " , e ) ; } return new String ( Base64 . encodeBase64 ( mac . doFinal ( baseString . getBytes ( Charsets . UTF_8 ) ) ) , Charsets . UTF_8 ) ; }
Generate an HMAC from the context ts parameter .