package com.youcruit.billogram.objects.response.callback;

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import javax.xml.bind.DatatypeConverter;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.youcruit.billogram.objects.response.billogram.CallbackBillogram;
import com.youcruit.billogram.objects.response.event.CallbackEvent;

public class CallbackPost {

    @Expose
    private CallbackBillogram billogram = new CallbackBillogram();
    @Expose
    private CallbackEvent event = new CallbackEvent();
    @SerializedName("callback_id")
    @Expose
    private String callbackId;
    @Expose
    private String custom;
    @Expose
    private String signature;

    public CallbackBillogram getBillogram() {
	return billogram;
    }

    public void setBillogram(CallbackBillogram billogram) {
	this.billogram = billogram;
    }

    public CallbackEvent getEvent() {
	return event;
    }

    public void setEvent(CallbackEvent event) {
	this.event = event;
    }

    public String getCallbackId() {
	return callbackId;
    }

    public void setCallbackId(String callbackId) {
	this.callbackId = callbackId;
    }

    public String getCustom() {
	return custom;
    }

    public void setCustom(String custom) {
	this.custom = custom;
    }

    public String getSignature() {
	return signature;
    }

    public void setSignature(String signature) {
	this.signature = signature;
    }

    public boolean verifySignature(byte[] key) {
        try {
            MessageDigest digest = MessageDigest.getInstance("MD5");
            digest.update(callbackId.getBytes("UTF-8"));
            final String md5Digest = DatatypeConverter.printHexBinary(digest.digest(key));
            return md5Digest.equals(signature);
        } catch (UnsupportedEncodingException |NoSuchAlgorithmException e) {
            // If UTF-8 or MD5 doesn't exist, JVM is broken
            throw new Error(e);
        }
    }
}
@@ -52,16 +52,52 @@
 lback;%0A%0A
+import static java.util.Locale.US;%0A%0A
 import j
@@ -1841,16 +1841,32 @@
 st(key))
+.toLowerCase(US)
 ;%0A      
@@ -1904,16 +1904,32 @@
 ignature
+.toLowerCase(US)
 );%0A     

Compare with lowercase