本文整理匯總了Java中org.bouncycastle.cms.SignerInformation.verify方法的典型用法代碼示例。如果您正苦於以下問題:Java SignerInformation.verify方法的具體用法?Java SignerInformation.verify怎麽用?Java SignerInformation.verify使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bouncycastle.cms.SignerInformation的用法示例。
在下文中一共展示了SignerInformation.verify方法的30個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。
示例1: verifySignature
點讚 4
import org.bouncycastle.cms.SignerInformation; //導入方法依賴的package包/類
public static boolean verifySignature(CMSSignedData cmsSignedData, X509Certificate cert) {
try {
if (Security.getProvider(“BC”) == null)
Security.addProvider(new BouncyCastleProvider());
Collection signers = cmsSignedData.getSignerInfos().getSigners();
X509CertificateHolder ch = new X509CertificateHolder(cert.getEncoded());
for (SignerInformation si : signers)
if (si.getSID().match(ch))
if (si.verify(new JcaSimpleSignerInfoVerifierBuilder().setProvider(“BC”).build(ch)))
return true;
} catch (Exception e) {}
return false;
}
開發者ID:damianofalcioni,項目名稱:Websocket-Smart-Card-Signer,代碼行數:15,
示例2: isValid
點讚 3
import org.bouncycastle.cms.SignerInformation; //導入方法依賴的package包/類
/**
* Take a CMS SignedData message and a trust anchor and determine if
* the message is signed with a valid signature from a end entity
* certificate recognized by the trust anchor rootCert.
*/
public static boolean isValid(CMSSignedData signedData,
X509Certificate rootCert)
throws Exception
{
CertStore certsAndCRLs = signedData.getCertificatesAndCRLs(“Collection”, “BC”);
SignerInformationStore signers = signedData.getSignerInfos();
Iterator> it = signers.getSigners().iterator();
while (it.hasNext())
{
SignerInformation signer = (SignerInformation)it.next();
X509CertSelector signerConstraints = signer.getSID();
signerConstraints.setKeyUsage(getKeyUsageForSignature());
PKIXCertPathBuilderResult result = buildPath(rootCert, signer.getSID(), certsAndCRLs);
if (signer.verify(result.getPublicKey(), “BC”))
return true;
}
return false;
}
開發者ID:edeoliveira,項目名稱:Mailster,代碼行數:28,
示例3: verifyAllSignatures
點讚 3
import org.bouncycastle.cms.SignerInformation; //導入方法依賴的package包/類
public static boolean verifyAllSignatures(CMSSignedData cmsSignedData) {
try {
if (Security.getProvider(“BC”) == null)
Security.addProvider(new BouncyCastleProvider());
Collection signers = cmsSignedData.getSignerInfos().getSigners();
for (SignerInformation si : signers) {
@SuppressWarnings(“unchecked”)
Collection certList = cmsSignedData.getCertificates().getMatches(si.getSID());
if (certList.size() == 0)
throw new Exception(“ERROR: Impossible to find a Certificate using the Signer ID: ” + si.getSID());
X509CertificateHolder cert = certList.iterator().next(); // Take only the first certificate of the chain
if (!si.verify(new JcaSimpleSignerInfoVerifierBuilder().setProvider(“BC”).build(cert)))
throw new Exception(“ATTENTION: At least a signature is invalid!”);
boolean certOK = true;
String msg = “”;
try {
X509Utils.checkAllOnCertificate(X509Utils.getX509Certificate(cert.getEncoded()));
} catch (Exception ex) {
msg = ex.getMessage();
certOK = false;
}
if (!certOK)
throw new Exception(“ATTENTION: The certificate is invalid:\n” + msg);
}
return true;
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
開發者ID:damianofalcioni,項目名稱:Websocket-Smart-Card-Signer,代碼行數:38,
示例4: signatureVerified
點讚 3
import org.bouncycastle.cms.SignerInformation; //導入方法依賴的package包/類
/**
* Verify the passed in CMS signed data, return false on failure.
*
* @param cmsData a CMSSignedData object.
* @return true if signature checks out, false if there is a problem with the signature or the path to its verifying certificate.
*/
public boolean signatureVerified(CMSSignedData cmsData)
{
Store certs = cmsData.getCertificates();
SignerInformationStore signers = cmsData.getSignerInfos();
Collection c = signers.getSigners();
Iterator it = c.iterator();
SignerInformation signer = (SignerInformation)it.next();
try
{
PKIXCertPathBuilderResult result = checkCertPath(signer.getSID(), certs);
X509Certificate cert = (X509Certificate)result.getCertPath().getCertificates().get(0);
return signer.verify(new JcaSimpleSignerInfoVerifierBuilder().setProvider(“BC”).build(cert));
}
catch (Exception e)
{
return false;
}
}
開發者ID:cwgit,項目名稱:ximix,代碼行數:30,
示例5: unsignData
點讚 2
import org.bouncycastle.cms.SignerInformation; //導入方法依賴的package包/類
public static String unsignData(String data) {
byte[] dataBytes = Base64.decode(data);
try {
CMSSignedData s = new CMSSignedData(dataBytes);
Store certs = s.getCertificates();
SignerInformationStore signers = s.getSignerInfos();
@SuppressWarnings(“unchecked”)
Collection c = signers.getSigners();
Iterator it = c.iterator();
while (it.hasNext()) {
X509CertificateHolder cert = null;
SignerInformation signer = it.next();
Collection certCollection = certs.getMatches(signer.getSID());
@SuppressWarnings(“unchecked”)
Iterator certIt = certCollection.iterator();
cert = certIt.next();
if (!signer.verify(new JcaSimpleSignerInfoVerifierBuilder().setProvider(“BC”).build(cert))) throw new Exception(“Doesn’t verify”);
}
CMSProcessableByteArray cpb = (CMSProcessableByteArray) s.getSignedContent();
byte[] signedContent = (byte[]) cpb.getContent();
String content = new String(signedContent);
return content;
} catch (Exception e) {
MiscUtils.getLogger().error(“error”, e);
}
return null;
}
開發者ID:williamgrosset,項目名稱:OSCAR-ConCert,代碼行數:34,
示例6: verifyRSASignatures
點讚 2
import org.bouncycastle.cms.SignerInformation; //導入方法依賴的package包/類
private void verifyRSASignatures(CMSSignedData s, byte[] contentDigest)
throws Exception
{
Store certStore = s.getCertificates();
SignerInformationStore signers = s.getSignerInfos();
Collection c = signers.getSigners();
Iterator it = c.iterator();
while (it.hasNext())
{
SignerInformation signer = (SignerInformation)it.next();
Collection certCollection = certStore.getMatches(signer.getSID());
Iterator certIt = certCollection.iterator();
X509CertificateHolder cert = (X509CertificateHolder)certIt.next();
if (!signer.verify(new BcRSASignerInfoVerifierBuilder(new DefaultCMSSignatureAlgorithmNameGenerator(), new DefaultSignatureAlgorithmIdentifierFinder(), new DefaultDigestAlgorithmIdentifierFinder(), new BcDigestCalculatorProvider()).build(cert)))
{
fail(“signature verification failed”);
}
if (contentDigest != null)
{
if (!Arrays.areEqual(contentDigest, signer.getContentDigest()))
{
fail(“digest verification failed”);
}
}
}
}
開發者ID:ttt43ttt,項目名稱:gwt-crypto,代碼行數:32,
示例7: verify
點讚 2
import org.bouncycastle.cms.SignerInformation; //導入方法依賴的package包/類
public void verify(X509Certificate cert) throws SFRMException {
try {
SMIMESigned signed = new SMIMESigned((MimeMultipart)bodyPart.getContent());
SignerInformationStore signers = signed.getSignerInfos();
Iterator signerInfos = signers.getSigners().iterator();
while (signerInfos.hasNext()) {
SignerInformation signerInfo = (SignerInformation)signerInfos.next();
SignerInformationVerifier verifier =
new BcRSASignerInfoVerifierBuilder(new DefaultCMSSignatureAlgorithmNameGenerator(),
new DefaultSignatureAlgorithmIdentifierFinder(),
new DefaultDigestAlgorithmIdentifierFinder(),
new BcDigestCalculatorProvider())
.build(new JcaX509CertificateHolder(cert));
if (!signerInfo.verify(verifier)) {
throw new SFRMMessageException(“Verification failed”);
}
}
MimeBodyPart signedPart = signed.getContent();
if (signedPart == null) {
throw new SFRMMessageException(“Unable to extract signed part”);
}
else {
this.bodyPart = signedPart;
this.setIsSigned(true);
}
} catch (org.bouncycastle.cms.CMSException ex) {
throw new SFRMException(“Unable to verify body part”, ex.getUnderlyingException());
} catch (Exception e) {
throw new SFRMException(“Unable to verify body part”, e);
}
}
開發者ID:cecid,項目名稱:hermes,代碼行數:35,
示例8: testValidateSignatureVlidationTest
點讚 2
import org.bouncycastle.cms.SignerInformation; //導入方法依賴的package包/類
/**
* PDF Signature Validation
*
*
* SignatureVlidationTest.pdf
*
*
* The code completely ignores the
SubFilter
of the signature.
* It is appropriate for signatures with
SubFilter
values
*
adbe.pkcs7.detached
and
ETSI.CAdES.detached
* but will fail for signatures with
SubFilter
values
*
adbe.pkcs7.sha1
and
adbe.x509.rsa.sha1
.
*
*
* The example document has been signed with a signatures with
*
SubFilter
value
adbe.pkcs7.sha1
.
*
*/
@Test
public void testValidateSignatureVlidationTest() throws Exception
{
System.out.println(“\nValidate signature in SignatureVlidationTest.pdf; original code.”);
byte[] pdfByte;
PDDocument pdfDoc = null;
SignerInformationVerifier verifier = null;
try
{
pdfByte