@Test public void getTokenTest() throws Exception { final Date date = DateUtilities.parseDate("08/04/2014 10:03 PM") ; assertEquals(getToken("53dd860e1b72ff0467030003", "pXeTVcmdbU9XxH6fPcPlq8Y9D9G3Cdo5Eh2nMSgKj/DWqeSFFXDdmpz5Trv+L2hQNM+nGa704Rf8Z22W9O1jdQ==", date), "SharedAccessSignature uid=53dd860e1b72ff0467030003&ex=2014-08-04T22:03:00.0000000Z&sn=FWBrF2PBYVEZgpoyaPWNKIBIGLQxbJAw6A3Lu4EB78aooaZldHXZTZBkqyMWlLdrpK5/q3BFDgj9vqX1vrR0ww=="); assertEquals(getToken("123", "321", date), "SharedAccessSignature uid=123&ex=2014-08-04T22:03:00.0000000Z&sn=q6hTggdd9OCV+1sdVPDl88VzYyN9XZWegp/s3ApX1szHOI5eDuMkoqC43v25uL8xvNPfU0VtzrJQj/balAlxvw=="); }
@NotNull public static String getToken(@NotNull final String identifier, @NotNull final String primaryOrSecondaryKey, @NotNull final Date expiryDate) { final Mac sha512Hmac = HmacUtils.getHmacSha512(primaryOrSecondaryKey.getBytes(UTF_8)); final String dataToSign = String.format("%s\n%s", identifier, DateUtilities.formatDate(expiryDate)); final byte[] encodedBytes = Base64.encodeBase64(sha512Hmac.doFinal(dataToSign.getBytes(UTF_8))); final String encodedString = new String(encodedBytes, UTF_8); return String.format(SHARED_ACCESS_SIGNATURE, identifier, DateUtilities.formatDate(expiryDate), encodedString); }
AuthorizationTokenImpl { @NotNull public static String getToken(@NotNull final String identifier, @NotNull final String primaryOrSecondaryKey, @NotNull final Date expiryDate) { final Mac sha512Hmac = HmacUtils.getHmacSha512(primaryOrSecondaryKey.getBytes(UTF_8)); final String dataToSign = String.format("%s\n%s", identifier, DateUtilities.formatDate(expiryDate)); final byte[] encodedBytes = Base64.encodeBase64(sha512Hmac.doFinal(dataToSign.getBytes(UTF_8))); final String encodedString = new String(encodedBytes, UTF_8); return String.format(SHARED_ACCESS_SIGNATURE, identifier, DateUtilities.formatDate(expiryDate), encodedString); } }
AuthorizationTokenImpl { @NotNull public static String getToken(@NotNull final String identifier, @NotNull final String primaryOrSecondaryKey, @NotNull final Date expiryDate) { final Mac sha512Hmac = HmacUtils.getHmacSha512(primaryOrSecondaryKey.getBytes(UTF_8)); final String dataToSign = String.format("%s\n%s", identifier, DateUtilities.formatDate(expiryDate)); final byte[] encodedBytes = Base64.encodeBase64(sha512Hmac.doFinal(dataToSign.getBytes(UTF_8))); final String encodedString = new String(encodedBytes, UTF_8); return String.format(SHARED_ACCESS_SIGNATURE, identifier, DateUtilities.formatDate(expiryDate), encodedString); }  }
AuthorizationTokenImpl { @NotNull public static String getToken(@NotNull final String identifier, @NotNull final String primaryOrSecondaryKey, @NotNull final Date expiryDate) { final Mac sha512Hmac = HmacUtils.getHmacSha512(primaryOrSecondaryKey.getBytes(UTF_8)); final String dataToSign = String.format("%s\n%s", identifier, DateUtilities.formatDate(expiryDate)); final byte[] encodedBytes = Base64.encodeBase64(sha512Hmac.doFinal(dataToSign.getBytes(UTF_8))); final String encodedString = new String(encodedBytes, UTF_8); return String.format(SHARED_ACCESS_SIGNATURE, identifier, DateUtilities.formatDate(expiryDate), encodedString); }  @NotNull static String getToken(@NotNull final String identifier, @NotNull final String primaryOrSecondaryKey, @NotNull final Date expiryDate); @NotNull static AuthenticationResult getToken(@NotNull final AuthorizationTokenInputs inputs); }
AuthorizationTokenImpl { @NotNull public static String getToken(@NotNull final String identifier, @NotNull final String primaryOrSecondaryKey, @NotNull final Date expiryDate) { final Mac sha512Hmac = HmacUtils.getHmacSha512(primaryOrSecondaryKey.getBytes(UTF_8)); final String dataToSign = String.format("%s\n%s", identifier, DateUtilities.formatDate(expiryDate)); final byte[] encodedBytes = Base64.encodeBase64(sha512Hmac.doFinal(dataToSign.getBytes(UTF_8))); final String encodedString = new String(encodedBytes, UTF_8); return String.format(SHARED_ACCESS_SIGNATURE, identifier, DateUtilities.formatDate(expiryDate), encodedString); }  @NotNull static String getToken(@NotNull final String identifier, @NotNull final String primaryOrSecondaryKey, @NotNull final Date expiryDate); @NotNull static AuthenticationResult getToken(@NotNull final AuthorizationTokenInputs inputs);  }