use of com.github.zhenwei.pkix.cert.jcajce.JcaX509CertificateHolder in project LinLong-Java by zhenwei1108.
the class JcaSimpleSignerInfoGeneratorBuilder method build.
public SignerInfoGenerator build(String algorithmName, PrivateKey privateKey, X509Certificate certificate) throws OperatorCreationException, CertificateEncodingException {
privateKey = CMSUtils.cleanPrivateKey(privateKey);
ContentSigner contentSigner = helper.createContentSigner(algorithmName, privateKey);
return configureAndBuild().build(contentSigner, new JcaX509CertificateHolder(certificate));
}
use of com.github.zhenwei.pkix.cert.jcajce.JcaX509CertificateHolder in project LinLong-Java by zhenwei1108.
the class JcaContentVerifierProviderBuilder method build.
public ContentVerifierProvider build(final X509Certificate certificate) throws OperatorCreationException {
final X509CertificateHolder certHolder;
try {
certHolder = new JcaX509CertificateHolder(certificate);
} catch (CertificateEncodingException e) {
throw new OperatorCreationException("cannot process certificate: " + e.getMessage(), e);
}
return new ContentVerifierProvider() {
public boolean hasAssociatedCertificate() {
return true;
}
public X509CertificateHolder getAssociatedCertificate() {
return certHolder;
}
public ContentVerifier get(AlgorithmIdentifier algorithm) throws OperatorCreationException {
if (algorithm.getAlgorithm().equals(MiscObjectIdentifiers.id_alg_composite)) {
return createCompositeVerifier(algorithm, certificate.getPublicKey());
} else {
Signature sig;
try {
sig = helper.createSignature(algorithm);
sig.initVerify(certificate.getPublicKey());
} catch (GeneralSecurityException e) {
throw new OperatorCreationException("exception on setup: " + e, e);
}
Signature rawSig = createRawSig(algorithm, certificate.getPublicKey());
if (rawSig != null) {
return new RawSigVerifier(algorithm, sig, rawSig);
} else {
return new SigVerifier(algorithm, sig);
}
}
}
};
}
Aggregations