本文整理汇总了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 );
}
}
示例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");
}
}