本文整理汇总了Java中org.bouncycastle.cms.SignerInformationVerifierProvider类的典型用法代码示例。如果您正苦于以下问题:Java SignerInformationVerifierProvider类的具体用法?Java SignerInformationVerifierProvider怎么用?Java SignerInformationVerifierProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SignerInformationVerifierProvider类属于org.bouncycastle.cms包,在下文中一共展示了SignerInformationVerifierProvider类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCPDRequest
import org.bouncycastle.cms.SignerInformationVerifierProvider; //导入依赖的package包/类
public void testCPDRequest()
throws Exception
{
CMSSignedData reqMsg = getWrappedCPDRequest();
assertTrue(reqMsg.verifySignatures(new SignerInformationVerifierProvider()
{
public SignerInformationVerifier get(SignerId sid)
throws OperatorCreationException
{
return new JcaSimpleSignerInfoVerifierBuilder().setProvider(BC).build(signCert);
}
}));
DVCSRequest request = new DVCSRequest(reqMsg);
CPDRequestData reqData = (CPDRequestData)request.getData();
assertTrue(Arrays.areEqual(new byte[100], reqData.getMessage()));
}
示例2: testVPKCRequest
import org.bouncycastle.cms.SignerInformationVerifierProvider; //导入依赖的package包/类
public void testVPKCRequest()
throws Exception
{
SignedDVCSMessageGenerator gen = getSignedDVCSMessageGenerator();
VPKCRequestBuilder reqBuilder = new VPKCRequestBuilder();
reqBuilder.addTargetChain(new JcaX509CertificateHolder(signCert));
CMSSignedData reqMsg = gen.build(reqBuilder.build());
assertTrue(reqMsg.verifySignatures(new SignerInformationVerifierProvider()
{
public SignerInformationVerifier get(SignerId sid)
throws OperatorCreationException
{
return new JcaSimpleSignerInfoVerifierBuilder().setProvider(BC).build(signCert);
}
}));
DVCSRequest request = new DVCSRequest(reqMsg);
VPKCRequestData reqData = (VPKCRequestData)request.getData();
assertEquals(new TargetEtcChain(new CertEtcToken(CertEtcToken.TAG_CERTIFICATE, new JcaX509CertificateHolder(signCert).toASN1Structure())), ((TargetChain)reqData.getCerts().get(0)).toASN1Structure());
}
示例3: testVSDRequest
import org.bouncycastle.cms.SignerInformationVerifierProvider; //导入依赖的package包/类
public void testVSDRequest()
throws Exception
{
CMSSignedData message = getWrappedCPDRequest();
SignedDVCSMessageGenerator gen = getSignedDVCSMessageGenerator();
VSDRequestBuilder reqBuilder = new VSDRequestBuilder();
CMSSignedData reqMsg = gen.build(reqBuilder.build(message));
assertTrue(reqMsg.verifySignatures(new SignerInformationVerifierProvider()
{
public SignerInformationVerifier get(SignerId sid)
throws OperatorCreationException
{
return new JcaSimpleSignerInfoVerifierBuilder().setProvider(BC).build(signCert);
}
}));
DVCSRequest request = new DVCSRequest(reqMsg);
VSDRequestData reqData = (VSDRequestData)request.getData();
assertEquals(message.toASN1Structure().getContentType(), reqData.getParsedMessage().toASN1Structure().getContentType());
}
示例4: testCCPDRequest
import org.bouncycastle.cms.SignerInformationVerifierProvider; //导入依赖的package包/类
public void testCCPDRequest()
throws Exception
{
SignedDVCSMessageGenerator gen = getSignedDVCSMessageGenerator();
CCPDRequestBuilder reqBuilder = new CCPDRequestBuilder();
MessageImprintBuilder imprintBuilder = new MessageImprintBuilder(new SHA1DigestCalculator());
MessageImprint messageImprint = imprintBuilder.build(new byte[100]);
CMSSignedData reqMsg = gen.build(reqBuilder.build(messageImprint));
assertTrue(reqMsg.verifySignatures(new SignerInformationVerifierProvider()
{
public SignerInformationVerifier get(SignerId sid)
throws OperatorCreationException
{
return new JcaSimpleSignerInfoVerifierBuilder().setProvider(BC).build(signCert);
}
}));
DVCSRequest request = new DVCSRequest(reqMsg);
CCPDRequestData reqData = (CCPDRequestData)request.getData();
assertEquals(messageImprint, reqData.getMessageImprint());
}
示例5: testCreateSimpleSignatureContainer
import org.bouncycastle.cms.SignerInformationVerifierProvider; //导入依赖的package包/类
/**
* For some tests I needed SHA256withRSAandMGF1 CMS signatures.
*/
@Test
public void testCreateSimpleSignatureContainer() throws CMSException, GeneralSecurityException, OperatorCreationException, IOException
{
byte[] message = "SHA256withRSAandMGF1".getBytes();
CMSTypedData msg = new CMSProcessableByteArray(message);
List<X509Certificate> certList = new ArrayList<X509Certificate>();
certList.add(origCert);
certList.add(signCert);
Store certs = new JcaCertStore(certList);
CMSSignedDataGenerator gen = new CMSSignedDataGenerator();
ContentSigner sha1Signer = new JcaContentSignerBuilder("SHA256withRSAandMGF1").setProvider("BC").build(signKP.getPrivate());
gen.addSignerInfoGenerator(
new JcaSignerInfoGeneratorBuilder(
new JcaDigestCalculatorProviderBuilder().setProvider("BC").build())
.build(sha1Signer, signCert));
gen.addCertificates(certs);
CMSSignedData sigData = gen.generate(msg, false);
Files.write(new File(RESULT_FOLDER, "simpleMessageSHA256withRSAandMGF1.bin").toPath(), message);
Files.write(new File(RESULT_FOLDER, "simpleMessageSHA256withRSAandMGF1.p7s").toPath(), sigData.getEncoded());
boolean verifies = sigData.verifySignatures(new SignerInformationVerifierProvider()
{
@Override
public SignerInformationVerifier get(SignerId sid) throws OperatorCreationException
{
if (sid.getSerialNumber().equals(origCert.getSerialNumber()))
{
System.out.println("SignerInformationVerifier requested for OrigCert");
return new JcaSignerInfoVerifierBuilder(new BcDigestCalculatorProvider()).build(origCert);
}
if (sid.getSerialNumber().equals(signCert.getSerialNumber()))
{
System.out.println("SignerInformationVerifier requested for SignCert");
return new JcaSignerInfoVerifierBuilder(new BcDigestCalculatorProvider()).build(signCert);
}
System.out.println("SignerInformationVerifier requested for unknown " + sid);
return null;
}
});
System.out.println("Verifies? " + verifies);
}