<commit_before><commit_msg>PushService component for authenticating push<commit_after>component {

	property name="settings" inject="coldbox:setting:vindicia";

	public struct function authenticate(required string signature, required string rawbody, string secret=settings.callback_key) {
		var mac 		= createObject("java","javax.crypto.Mac").getInstance("HmacSHA256");
		var keyspec 	= createobject("java","javax.crypto.spec.SecretKeySpec").init(secret.getBytes(), "HmacSHA256");
		var Base64 		= createobject("java","org.apache.commons.codec.binary.Base64");
		
		mac.init( keyspec );

		var sig = Base64.encodeBase64String(mac.doFinal(arguments.rawbody.getBytes()));
		var result = {
			 "isAuthenticated":(sig == arguments.signature)
			,"signature":arguments.signature
			,"hash":sig
		}
		
		return result;
	}

}
{'fraction_non_alphanumeric': 0.13814180929095354, 'fraction_numerical': 0.017114914425427872, 'mean_word_length': 5.825, 'pattern_counts': {'":': 3, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1741907', 'n_tokens_mistral': 275, 'n_tokens_neox': 240, 'n_words': 42}