本文整理汇总了Java中org.bouncycastle.util.Store类的典型用法代码示例。如果您正苦于以下问题:Java Store类的具体用法?Java Store怎么用?Java Store使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Store类属于org.bouncycastle.util包,在下文中一共展示了Store类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSignersCertificates
import org.bouncycastle.util.Store; //导入依赖的package包/类
private Collection<X509Certificate> getSignersCertificates(CMSSignedData previewSignerData) {
Collection<X509Certificate> result = new HashSet<X509Certificate>();
Store<?> certStore = previewSignerData.getCertificates();
SignerInformationStore signers = previewSignerData.getSignerInfos();
Iterator<?> it = signers.getSigners().iterator();
while (it.hasNext()) {
SignerInformation signer = (SignerInformation) it.next();
@SuppressWarnings("unchecked")
Collection<?> certCollection = certStore.getMatches(signer.getSID());
Iterator<?> certIt = certCollection.iterator();
X509CertificateHolder certificateHolder = (X509CertificateHolder) certIt.next();
try {
result.add(new JcaX509CertificateConverter().getCertificate(certificateHolder));
} catch (CertificateException error) {
}
}
return result;
}
示例2: generateP7B
import org.bouncycastle.util.Store; //导入依赖的package包/类
public CMSSignedData generateP7B(X509CertificateHolder caCertificate, PrivateKey caPrivateKey) {
try {
List<X509CertificateHolder> certChain = new ArrayList<X509CertificateHolder>();
certChain.add(caCertificate);
Store certs = new JcaCertStore(certChain);
CMSSignedDataGenerator cmsSignedDataGenerator = new CMSSignedDataGenerator();
ContentSigner sha1Signer = new JcaContentSignerBuilder("SHA1withRSA").setProvider(BouncyCastleProvider.PROVIDER_NAME).build(caPrivateKey);
cmsSignedDataGenerator.addSignerInfoGenerator(new JcaSignerInfoGeneratorBuilder(
new JcaDigestCalculatorProviderBuilder().setProvider(BouncyCastleProvider.PROVIDER_NAME).build())
.build(sha1Signer, caCertificate));
cmsSignedDataGenerator.addCertificates(certs);
CMSTypedData chainMessage = new CMSProcessableByteArray("chain".getBytes());
CMSSignedData sigData = cmsSignedDataGenerator.generate(chainMessage, false);
return sigData;
} catch(Exception e) {
throw new RuntimeException("Error while generating certificate chain: " + e.getMessage(), e);
}
}
示例3: publicationFileBasedVerification
import org.bouncycastle.util.Store; //导入依赖的package包/类
private VerificationResult publicationFileBasedVerification(String signatureFile, String publicationFile, boolean extendingAllowed, KSIExtenderClient extenderClient) throws Exception {
KSISignature signature = TestUtil.loadSignature(signatureFile);
VerificationContextBuilder build = new VerificationContextBuilder();
if (publicationFile != null) {
build.setPublicationsFile(new InMemoryPublicationsFileFactory(new PKITrustStore() {
public boolean isTrusted(X509Certificate certificate, Store certStore) throws CryptoException {
return true;
}
}).create(load(publicationFile)));
} else {
build.setPublicationsFile(ksi.getPublicationsFile());
}
build.setSignature(signature).setExtenderClient(extenderClient);
build.setExtendingAllowed(extendingAllowed);
return ksi.verify(build.build(), policy);
}
开发者ID:guardtime,项目名称:ksi-java-sdk,代码行数:17,代码来源:PublicationsFileBasedVerificationPolicyIntegrationTest.java
示例4: setStores
import org.bouncycastle.util.Store; //导入依赖的package包/类
/**
* Sets the Bouncy Castle Stores for finding CRLs, certificates, attribute
* certificates or cross certificates.
* <p>
* The <code>List</code> is cloned.
*
* @param stores A list of stores to use.
* @see #getStores
* @throws ClassCastException if an element of <code>stores</code> is not
* a {@link Store}.
*/
public void setStores(List stores)
{
if (stores == null)
{
this.stores = new ArrayList();
}
else
{
for (Iterator i = stores.iterator(); i.hasNext();)
{
if (!(i.next() instanceof Store))
{
throw new ClassCastException(
"All elements of list must be "
+ "of type org.bouncycastle.util.Store.");
}
}
this.stores = new ArrayList(stores);
}
}
示例5: getCertificates
import org.bouncycastle.util.Store; //导入依赖的package包/类
Store getCertificates(ASN1Set certSet)
{
if (certSet != null)
{
List certList = new ArrayList(certSet.size());
for (Enumeration en = certSet.getObjects(); en.hasMoreElements();)
{
ASN1Primitive obj = ((ASN1Encodable)en.nextElement()).toASN1Primitive();
if (obj instanceof ASN1Sequence)
{
certList.add(new X509CertificateHolder(Certificate.getInstance(obj)));
}
}
return new CollectionStore(certList);
}
return new CollectionStore(new ArrayList());
}
示例6: getAttributeCertificates
import org.bouncycastle.util.Store; //导入依赖的package包/类
Store getAttributeCertificates(ASN1Set certSet)
{
if (certSet != null)
{
List certList = new ArrayList(certSet.size());
for (Enumeration en = certSet.getObjects(); en.hasMoreElements();)
{
ASN1Primitive obj = ((ASN1Encodable)en.nextElement()).toASN1Primitive();
if (obj instanceof ASN1TaggedObject)
{
certList.add(new X509AttributeCertificateHolder(AttributeCertificate.getInstance(((ASN1TaggedObject)obj).getObject())));
}
}
return new CollectionStore(certList);
}
return new CollectionStore(new ArrayList());
}
示例7: getCRLs
import org.bouncycastle.util.Store; //导入依赖的package包/类
Store getCRLs(ASN1Set crlSet)
{
if (crlSet != null)
{
List crlList = new ArrayList(crlSet.size());
for (Enumeration en = crlSet.getObjects(); en.hasMoreElements();)
{
ASN1Primitive obj = ((ASN1Encodable)en.nextElement()).toASN1Primitive();
if (obj instanceof ASN1Sequence)
{
crlList.add(new X509CRLHolder(CertificateList.getInstance(obj)));
}
}
return new CollectionStore(crlList);
}
return new CollectionStore(new ArrayList());
}
示例8: getCertificatesFromStore
import org.bouncycastle.util.Store; //导入依赖的package包/类
static List getCertificatesFromStore(Store certStore)
throws CMSException
{
List certs = new ArrayList();
try
{
for (Iterator it = certStore.getMatches(null).iterator(); it.hasNext();)
{
X509CertificateHolder c = (X509CertificateHolder)it.next();
certs.add(c.toASN1Structure());
}
return certs;
}
catch (ClassCastException e)
{
throw new CMSException("error processing certs", e);
}
}
示例9: getAttributeCertificatesFromStore
import org.bouncycastle.util.Store; //导入依赖的package包/类
static List getAttributeCertificatesFromStore(Store attrStore)
throws CMSException
{
List certs = new ArrayList();
try
{
for (Iterator it = attrStore.getMatches(null).iterator(); it.hasNext();)
{
X509AttributeCertificateHolder attrCert = (X509AttributeCertificateHolder)it.next();
certs.add(new DERTaggedObject(false, 2, attrCert.toASN1Structure()));
}
return certs;
}
catch (ClassCastException e)
{
throw new CMSException("error processing certs", e);
}
}
示例10: getCRLsFromStore
import org.bouncycastle.util.Store; //导入依赖的package包/类
static List getCRLsFromStore(Store crlStore)
throws CMSException
{
List certs = new ArrayList();
try
{
for (Iterator it = crlStore.getMatches(null).iterator(); it.hasNext();)
{
X509CRLHolder c = (X509CRLHolder)it.next();
certs.add(c.toASN1Structure());
}
return certs;
}
catch (ClassCastException e)
{
throw new CMSException("error processing certs", e);
}
}
示例11: getOthersFromStore
import org.bouncycastle.util.Store; //导入依赖的package包/类
static Collection getOthersFromStore(ASN1ObjectIdentifier otherRevocationInfoFormat, Store otherRevocationInfos)
{
List others = new ArrayList();
for (Iterator it = otherRevocationInfos.getMatches(null).iterator(); it.hasNext();)
{
ASN1Encodable info = (ASN1Encodable)it.next();
if (CMSObjectIdentifiers.id_ri_ocsp_response.equals(otherRevocationInfoFormat))
{
OCSPResponse resp = OCSPResponse.getInstance(info);
if (resp.getResponseStatus().getValue().intValue() != OCSPResponseStatus.SUCCESSFUL)
{
throw new IllegalArgumentException("cannot add unsuccessful OCSP response to CMS SignedData");
}
}
others.add(new DERTaggedObject(false, 1, new OtherRevocationInfoFormat(otherRevocationInfoFormat, info)));
}
return others;
}
示例12: getCertificates
import org.bouncycastle.util.Store; //导入依赖的package包/类
/**
* Return the certificates stored in the underlying OriginatorInfo object.
*
* @return a Store of X509CertificateHolder objects.
*/
public Store getCertificates()
{
ASN1Set certSet = originatorInfo.getCertificates();
if (certSet != null)
{
List certList = new ArrayList(certSet.size());
for (Enumeration en = certSet.getObjects(); en.hasMoreElements();)
{
ASN1Primitive obj = ((ASN1Encodable)en.nextElement()).toASN1Primitive();
if (obj instanceof ASN1Sequence)
{
certList.add(new X509CertificateHolder(Certificate.getInstance(obj)));
}
}
return new CollectionStore(certList);
}
return new CollectionStore(new ArrayList());
}
示例13: getCRLs
import org.bouncycastle.util.Store; //导入依赖的package包/类
/**
* Return the CRLs stored in the underlying OriginatorInfo object.
*
* @return a Store of X509CRLHolder objects.
*/
public Store getCRLs()
{
ASN1Set crlSet = originatorInfo.getCRLs();
if (crlSet != null)
{
List crlList = new ArrayList(crlSet.size());
for (Enumeration en = crlSet.getObjects(); en.hasMoreElements();)
{
ASN1Primitive obj = ((ASN1Encodable)en.nextElement()).toASN1Primitive();
if (obj instanceof ASN1Sequence)
{
crlList.add(new X509CRLHolder(CertificateList.getInstance(obj)));
}
}
return new CollectionStore(crlList);
}
return new CollectionStore(new ArrayList());
}
示例14: getOthersFromStore
import org.bouncycastle.util.Store; //导入依赖的package包/类
static Collection getOthersFromStore(ASN1ObjectIdentifier otherRevocationInfoFormat, Store otherRevocationInfos)
{
List others = new ArrayList();
for (Iterator it = otherRevocationInfos.getMatches(null).iterator(); it.hasNext();)
{
ASN1Encodable info = (ASN1Encodable)it.next();
OtherRevocationInfoFormat infoFormat = new OtherRevocationInfoFormat(otherRevocationInfoFormat, info);
validateInfoFormat(infoFormat);
others.add(new DERTaggedObject(false, 1, infoFormat));
}
return others;
}
示例15: addBasicOcspRespFrom_id_ri_ocsp_response
import org.bouncycastle.util.Store; //导入依赖的package包/类
private void addBasicOcspRespFrom_id_ri_ocsp_response(final List<BasicOCSPResp> basicOCSPResps) {
final Store otherRevocationInfo = cmsSignedData.getOtherRevocationInfo(CMSObjectIdentifiers.id_ri_ocsp_response);
final Collection otherRevocationInfoMatches = otherRevocationInfo.getMatches(null);
for (final Object object : otherRevocationInfoMatches) {
if (object instanceof DERSequence) {
final DERSequence otherRevocationInfoMatch = (DERSequence) object;
final BasicOCSPResp basicOCSPResp;
if (otherRevocationInfoMatch.size() == 4) {
basicOCSPResp = CMSUtils.getBasicOcspResp(otherRevocationInfoMatch);
} else {
final OCSPResp ocspResp = CMSUtils.getOcspResp(otherRevocationInfoMatch);
basicOCSPResp = CMSUtils.getBasicOCSPResp(ocspResp);
}
addBasicOcspResp(basicOCSPResps, basicOCSPResp);
} else {
LOG.warn("Unsupported object type for id_ri_ocsp_response (SHALL be DER encoding) : " + object.getClass().getSimpleName());
}
}
}