List of usage examples for java.security Certificate getPublicKey
public abstract PublicKey getPublicKey();
From source file:cloudeventbus.pki.CertificateUtils.java
public static Certificate signCertificate(Certificate issuer, PrivateKey issuerPrivateKey, Certificate certificate) { if (issuer.getSerialNumber() != certificate.getIssuer()) { throw new CertificateIssuerMismatchException( "The authority certificate serial number doesn't much the certificate issuer."); }//from ww w . j a v a2 s . c o m validatePermissions(issuer, certificate); final byte[] hash = certificate.hash(); try { Cipher cipher = Cipher.getInstance("RSA"); cipher.init(Cipher.ENCRYPT_MODE, issuerPrivateKey); final byte[] signature = cipher.doFinal(hash); return new Certificate(certificate.getType(), certificate.getSerialNumber(), certificate.getIssuer(), certificate.getExpirationDate(), certificate.getPublicKey(), certificate.getSubscribePermissions(), certificate.getPublishPermissions(), certificate.getComment(), signature); } catch (GeneralSecurityException e) { throw new CertificateSecurityException(e); } }