Package org.utils.signature

Source Code of org.utils.signature.Validating

package org.utils.signature;

import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.Signature;
import java.security.SignatureException;

public class Validating {

  public static boolean validate(CertificateContainer certificate,
      String value, byte[] signature) throws NoSuchAlgorithmException,
      InvalidKeyException, SignatureException {
    Signature sign;

    sign = Signature.getInstance(certificate.getIdHash() + "with"
        + certificate.getIdAlg());
    sign.initVerify(certificate.getKey());
    sign.update(value.getBytes(), 0, value.getBytes().length);
    boolean result = sign.verify(signature);
    return result;

  }
}
TOP

Related Classes of org.utils.signature.Validating

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.