Example usage for java.security Signature equals

List of usage examples for java.security Signature equals

Introduction

In this page you can find the example usage for java.security Signature equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Indicates whether some other object is "equal to" this one.

Usage

From source file:org.eclipse.licensing.base.LicenseKey.java

public boolean isAuthentic(PublicKey publicKey) {
    try {/*from   w w w .  ja  va 2s .  c o m*/
        Signature signature = Signature.getInstance("SHA1withDSA", "SUN");
        signature.initVerify(publicKey);

        String[] propKeys = properties.keySet().toArray(new String[0]);
        Arrays.sort(propKeys);
        for (String propKey : propKeys) {
            if (!SIGNATURE.equals(propKey)) {
                String propValue = getProperty(propKey);
                signature.update(propValue.getBytes("UTF-8"));
            }
        }

        byte[] encodedSignature = getSignature();
        if (encodedSignature == null) {
            return false;
        }

        return signature.verify(getSignature());
    } catch (GeneralSecurityException | UnsupportedEncodingException e) {
        e.printStackTrace();
        return false;
    }
}