当前位置: 首页>>代码示例>>Java>>正文


Java ContentVerifierProvider类代码示例

本文整理汇总了Java中org.bouncycastle.operator.ContentVerifierProvider的典型用法代码示例。如果您正苦于以下问题:Java ContentVerifierProvider类的具体用法?Java ContentVerifierProvider怎么用?Java ContentVerifierProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ContentVerifierProvider类属于org.bouncycastle.operator包,在下文中一共展示了ContentVerifierProvider类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isValidSigningKeyPOP

import org.bouncycastle.operator.ContentVerifierProvider; //导入依赖的package包/类
/**
 * Return whether or not a signing key proof-of-possession (POP) is valid.
 *
 * @param verifierProvider a provider that can produce content verifiers for the signature contained in this POP.
 * @return true if the POP is valid, false otherwise.
 * @throws CRMFException if there is a problem in verification or content verifier creation.
 * @throws IllegalStateException if POP not appropriate.
 */
public boolean isValidSigningKeyPOP(ContentVerifierProvider verifierProvider)
    throws CRMFException, IllegalStateException
{
    ProofOfPossession pop = certReqMsg.getPopo();

    if (pop.getType() == popSigningKey)
    {
        POPOSigningKey popoSign = POPOSigningKey.getInstance(pop.getObject());

        if (popoSign.getPoposkInput() != null && popoSign.getPoposkInput().getPublicKeyMAC() != null)
        {
            throw new IllegalStateException("verification requires password check");
        }

        return verifySignature(verifierProvider, popoSign);
    }
    else
    {
        throw new IllegalStateException("not Signing Key type of proof of possession");
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:30,代码来源:CertificateRequestMessage.java

示例2: verifySignature

import org.bouncycastle.operator.ContentVerifierProvider; //导入依赖的package包/类
private boolean verifySignature(ContentVerifierProvider verifierProvider, POPOSigningKey popoSign)
    throws CRMFException
{
    ContentVerifier verifier;

    try
    {
        verifier = verifierProvider.get(popoSign.getAlgorithmIdentifier());
    }
    catch (OperatorCreationException e)
    {
        throw new CRMFException("unable to create verifier: " + e.getMessage(), e);
    }

    if (popoSign.getPoposkInput() != null)
    {
        CRMFUtil.derEncodeToStream(popoSign.getPoposkInput(), verifier.getOutputStream());
    }
    else
    {
        CRMFUtil.derEncodeToStream(certReqMsg.getCertReq(), verifier.getOutputStream());
    }

    return verifier.verify(popoSign.getSignature().getBytes());
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:26,代码来源:CertificateRequestMessage.java

示例3: verify

import org.bouncycastle.operator.ContentVerifierProvider; //导入依赖的package包/类
/**
 * Verify a message with a public key based signature attached.
 *
 * @param verifierProvider a provider of signature verifiers.
 * @return true if the provider is able to create a verifier that validates
 * the signature, false otherwise.
 * @throws CMPException if an exception is thrown trying to verify the signature.
 */
public boolean verify(ContentVerifierProvider verifierProvider)
    throws CMPException
{
    ContentVerifier verifier;
    try
    {
        verifier = verifierProvider.get(pkiMessage.getHeader().getProtectionAlg());

        return verifySignature(pkiMessage.getProtection().getBytes(), verifier);
    }
    catch (Exception e)
    {
        throw new CMPException("unable to verify signature: " + e.getMessage(), e);
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:24,代码来源:ProtectedPKIMessage.java

示例4: isSignatureValid

import org.bouncycastle.operator.ContentVerifierProvider; //导入依赖的package包/类
/**
 * verify the signature against the TBSRequest object we contain.
 */
public boolean isSignatureValid(
    ContentVerifierProvider verifierProvider)
    throws OCSPException
{
    if (!this.isSigned())
    {
        throw new OCSPException("attempt to verify signature on unsigned object");
    }

    try
    {
        ContentVerifier verifier = verifierProvider.get(req.getOptionalSignature().getSignatureAlgorithm());
        OutputStream sOut = verifier.getOutputStream();

        sOut.write(req.getTbsRequest().getEncoded(ASN1Encoding.DER));

        return verifier.verify(this.getSignature());
    }
    catch (Exception e)
    {
        throw new OCSPException("exception processing signature: " + e, e);
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:27,代码来源:OCSPReq.java

示例5: isSignatureValid

import org.bouncycastle.operator.ContentVerifierProvider; //导入依赖的package包/类
/**
 * verify the signature against the tbsResponseData object we contain.
 */
public boolean isSignatureValid(
    ContentVerifierProvider verifierProvider)
    throws OCSPException
{
    try
    {
        ContentVerifier verifier = verifierProvider.get(resp.getSignatureAlgorithm());
        OutputStream vOut = verifier.getOutputStream();

        vOut.write(resp.getTbsResponseData().getEncoded(ASN1Encoding.DER));
        vOut.close();

        return verifier.verify(this.getSignature());
    }
    catch (Exception e)
    {
        throw new OCSPException("exception processing sig: " + e, e);
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:23,代码来源:BasicOCSPResp.java

示例6: build

import org.bouncycastle.operator.ContentVerifierProvider; //导入依赖的package包/类
public ContentVerifierProvider build(final AsymmetricKeyParameter publicKey)
    throws OperatorCreationException
{
    return new ContentVerifierProvider()
    {
        public boolean hasAssociatedCertificate()
        {
            return false;
        }

        public X509CertificateHolder getAssociatedCertificate()
        {
            return null;
        }

        public ContentVerifier get(AlgorithmIdentifier algorithm)
            throws OperatorCreationException
        {
            BcSignerOutputStream stream = createSignatureStream(algorithm, publicKey);

            return new SigVerifier(algorithm, stream);
        }
    };
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:25,代码来源:BcContentVerifierProviderBuilder.java

示例7: isSignatureValid

import org.bouncycastle.operator.ContentVerifierProvider; //导入依赖的package包/类
/**
 * Validate the signature on the PKCS10 certification request in this holder.
 *
 * @param verifierProvider a ContentVerifierProvider that can generate a verifier for the signature.
 * @return true if the signature is valid, false otherwise.
 * @throws PKCSException if the signature cannot be processed or is inappropriate.
 */
public boolean isSignatureValid(ContentVerifierProvider verifierProvider)
    throws PKCSException
{
    CertificationRequestInfo requestInfo = certificationRequest.getCertificationRequestInfo();

    ContentVerifier verifier;

    try
    {
        verifier = verifierProvider.get(certificationRequest.getSignatureAlgorithm());

        OutputStream sOut = verifier.getOutputStream();

        sOut.write(requestInfo.getEncoded(ASN1Encoding.DER));

        sOut.close();
    }
    catch (Exception e)
    {
        throw new PKCSException("unable to process signature: " + e.getMessage(), e);
    }

    return verifier.verify(certificationRequest.getSignature().getBytes());
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:32,代码来源:PKCS10CertificationRequest.java

示例8: verifySignature

import org.bouncycastle.operator.ContentVerifierProvider; //导入依赖的package包/类
private boolean verifySignature(ContentVerifierProvider verifierProvider, POPOSigningKey popoSign)
    throws CRMFException
{
    ContentVerifier verifier;

    try
    {
        verifier = verifierProvider.get(popoSign.getAlgorithmIdentifier());
    }
    catch (OperatorCreationException e)
    {
        throw new CRMFException("unable to create verifier: " + e.getMessage(), e);
    }

    if (popoSign.getPoposkInput() != null)
    {
        CRMFUtil.derEncodeToStream(popoSign.getPoposkInput(), verifier.getOutputStream());
    }
    else
    {
        CRMFUtil.derEncodeToStream(certReqMsg.getCertReq(), verifier.getOutputStream());
    }

    return verifier.verify(popoSign.getSignature().getOctets());
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:26,代码来源:CertificateRequestMessage.java

示例9: isSignatureValid

import org.bouncycastle.operator.ContentVerifierProvider; //导入依赖的package包/类
/**
 * Validate the signature on the PKCS10 certification request in this holder.
 *
 * @param verifierProvider a ContentVerifierProvider that can generate a verifier for the signature.
 * @return true if the signature is valid, false otherwise.
 * @throws PKCSException if the signature cannot be processed or is inappropriate.
 */
public boolean isSignatureValid(ContentVerifierProvider verifierProvider)
    throws PKCSException
{
    CertificationRequestInfo requestInfo = certificationRequest.getCertificationRequestInfo();

    ContentVerifier verifier;

    try
    {
        verifier = verifierProvider.get(certificationRequest.getSignatureAlgorithm());

        OutputStream sOut = verifier.getOutputStream();

        sOut.write(requestInfo.getEncoded(ASN1Encoding.DER));

        sOut.close();
    }
    catch (Exception e)
    {
        throw new PKCSException("unable to process signature: " + e.getMessage(), e);
    }

    return verifier.verify(this.getSignature());
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:32,代码来源:PKCS10CertificationRequest.java

示例10: loadCSR

import org.bouncycastle.operator.ContentVerifierProvider; //导入依赖的package包/类
/**
 * Load a CSR from the specified URL.
 * 
 * @param url The URL to load CSR from
 * @return The CSR
 * @throws CryptoException Problem encountered while loading the CSR
 * @throws FileNotFoundException If the CSR file does not exist, is a directory rather than a regular file, or for
 *             some other reason cannot be opened for reading
 * @throws IOException An I/O error occurred
 */
public static PKCS10CertificationRequest loadCSR(URL url)
    throws CryptoException, IOException
{
	// TODO: handle DER encoded requests too?
	try (PEMParser pr = new PEMParser(new InputStreamReader(NetUtil.openGetStream(url))))
	{
		PKCS10CertificationRequest csr = (PKCS10CertificationRequest) pr.readObject();
		ContentVerifierProvider prov = new JcaContentVerifierProviderBuilder().build(csr.getSubjectPublicKeyInfo());

		if (!csr.isSignatureValid(prov))
		{
			throw new CryptoException(RB.getString("NoVerifyCsr.exception.message"));
		}

		return csr;
	}
	catch (ClassCastException | OperatorCreationException | PKCSException ex)
	{
		throw new CryptoException(RB.getString("NoLoadCsr.exception.message"), ex);
	}
}
 
开发者ID:gavioto,项目名称:portecle,代码行数:32,代码来源:X509CertUtil.java

示例11: isSignedBy

import org.bouncycastle.operator.ContentVerifierProvider; //导入依赖的package包/类
@Override
public boolean isSignedBy(final CertificateToken issuerToken) {
	if (this.issuerToken != null) {
		return this.issuerToken.equals(issuerToken);
	}
	if (basicOCSPResp == null) {
		return false;
	}
	try {
		signatureInvalidityReason = "";
		JcaContentVerifierProviderBuilder jcaContentVerifierProviderBuilder = new JcaContentVerifierProviderBuilder();
		jcaContentVerifierProviderBuilder.setProvider(BouncyCastleProvider.PROVIDER_NAME);
		final PublicKey publicKey = issuerToken.getCertificate().getPublicKey();
		ContentVerifierProvider contentVerifierProvider = jcaContentVerifierProviderBuilder.build(publicKey);
		signatureValid = basicOCSPResp.isSignatureValid(contentVerifierProvider);
		if (signatureValid) {
			this.issuerToken = issuerToken;
		}
		issuerX500Principal = issuerToken.getSubjectX500Principal();
	} catch (Exception e) {
		signatureInvalidityReason = e.getClass().getSimpleName() + " - " + e.getMessage();
		signatureValid = false;
	}
	return signatureValid;
}
 
开发者ID:esig,项目名称:dss,代码行数:26,代码来源:OCSPToken.java

示例12: makeV3Certificate

import org.bouncycastle.operator.ContentVerifierProvider; //导入依赖的package包/类
private static X509CertificateHolder makeV3Certificate(KeyPair subKP, String _subDN, KeyPair issKP, String _issDN)
    throws GeneralSecurityException, IOException, OperatorCreationException, CertException
{

    PublicKey subPub  = subKP.getPublic();
    PrivateKey issPriv = issKP.getPrivate();
    PublicKey  issPub  = issKP.getPublic();

    X509v3CertificateBuilder v1CertGen = new JcaX509v3CertificateBuilder(
        new X500Name(_issDN),
        BigInteger.valueOf(System.currentTimeMillis()),
        new Date(System.currentTimeMillis()),
        new Date(System.currentTimeMillis() + (1000L * 60 * 60 * 24 * 100)),
        new X500Name(_subDN),
        subPub);

    ContentSigner signer = new JcaContentSignerBuilder("SHA1WithRSA").setProvider(BC).build(issPriv);

    X509CertificateHolder certHolder = v1CertGen.build(signer);

    ContentVerifierProvider verifier = new JcaContentVerifierProviderBuilder().setProvider(BC).build(issPub);

    assertTrue(certHolder.isSignatureValid(verifier));

    return certHolder;
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:27,代码来源:AllTests.java


注:本文中的org.bouncycastle.operator.ContentVerifierProvider类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。