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


Java PGPPublicKey.removeCertification方法代码示例

本文整理汇总了Java中org.bouncycastle.openpgp.PGPPublicKey.removeCertification方法的典型用法代码示例。如果您正苦于以下问题:Java PGPPublicKey.removeCertification方法的具体用法?Java PGPPublicKey.removeCertification怎么用?Java PGPPublicKey.removeCertification使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bouncycastle.openpgp.PGPPublicKey的用法示例。


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

示例1: removeSignature

import org.bouncycastle.openpgp.PGPPublicKey; //导入方法依赖的package包/类
public static PGPPublicKeyRing removeSignature( PGPPublicKeyRing keyToRemoveFrom, String id ) throws PGPException
{
    try
    {
        PGPPublicKey oldKey = keyToRemoveFrom.getPublicKey();
        PGPPublicKey newKey = PGPPublicKey.removeCertification( oldKey, id );

        PGPPublicKeyRing newPublicKeyRing = PGPPublicKeyRing.removePublicKey( keyToRemoveFrom, oldKey );
        return PGPPublicKeyRing.insertPublicKey( newPublicKeyRing, newKey );
    }
    catch ( Exception e )
    {
        //throw custom  exception
        throw new PGPException( "Error removing signature", e );
    }
}
 
开发者ID:subutai-io,项目名称:base,代码行数:17,代码来源:PGPEncryptionUtil.java

示例2: embeddedJpegTest

import org.bouncycastle.openpgp.PGPPublicKey; //导入方法依赖的package包/类
private void embeddedJpegTest()
    throws Exception
{
    PGPPublicKeyRing pgpPub = new PGPPublicKeyRing(testPubKey, new BcKeyFingerprintCalculator());
    PGPSecretKeyRing pgpSec = new PGPSecretKeyRing(testPrivKey, new BcKeyFingerprintCalculator());

    PGPPublicKey pubKey = pgpPub.getPublicKey();

    PGPUserAttributeSubpacketVectorGenerator vGen = new PGPUserAttributeSubpacketVectorGenerator();

    vGen.setImageAttribute(ImageAttribute.JPEG, jpegImage);

    PGPUserAttributeSubpacketVector uVec = vGen.generate();

    PGPSignatureGenerator sGen = new PGPSignatureGenerator(new BcPGPContentSignerBuilder(PublicKeyAlgorithmTags.RSA_GENERAL, HashAlgorithmTags.SHA1));

    sGen.init(PGPSignature.POSITIVE_CERTIFICATION, pgpSec.getSecretKey().extractPrivateKey(new BcPBESecretKeyDecryptorBuilder(new BcPGPDigestCalculatorProvider()).build(pass)));

    PGPSignature sig = sGen.generateCertification(uVec, pubKey);

    PGPPublicKey nKey = PGPPublicKey.addCertification(pubKey, uVec, sig);

    Iterator it = nKey.getUserAttributes();
    int count = 0;
    while (it.hasNext())
    {
        PGPUserAttributeSubpacketVector attributes = (PGPUserAttributeSubpacketVector)it.next();

        Iterator    sigs = nKey.getSignaturesForUserAttribute(attributes);
        int sigCount = 0;
        while (sigs.hasNext())
        {
            PGPSignature s = (PGPSignature)sigs.next();

            s.init(new BcPGPContentVerifierBuilderProvider(), pubKey);

            if (!s.verifyCertification(attributes, pubKey))
            {
                fail("added signature failed verification");
            }

            sigCount++;
        }

        if (sigCount != 1)
        {
            fail("Failed added user attributes signature check");
        }
        count++;
    }

    if (count != 1)
    {
        fail("didn't find added user attributes");
    }

    nKey = PGPPublicKey.removeCertification(nKey, uVec);
    count = 0;
    for (it = nKey.getUserAttributes(); it.hasNext();)
    {
        count++;
    }
    if (count != 0)
    {
        fail("found attributes where none expected");
    }
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:68,代码来源:BcPGPRSATest.java


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