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


Java PGPSecretKey.getKeyID方法代码示例

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


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

示例1: keyShortId

import org.bouncycastle.openpgp.PGPSecretKey; //导入方法依赖的package包/类
public static Predicate<PGPSecretKey> keyShortId ( final String keyId )
{
    final long keyIdNum = Long.parseUnsignedLong ( keyId, 16 );

    return new Predicate<PGPSecretKey> () {

        @Override
        public boolean test ( final PGPSecretKey key )
        {
            final long shortId = key.getKeyID () & 0xFFFFFFFFL;

            if ( key.getKeyID () != keyIdNum && shortId != keyIdNum )
            {
                return false;
            }

            return true;
        }
    };
}
 
开发者ID:eclipse,项目名称:packagedrone,代码行数:21,代码来源:PgpHelper.java

示例2: OpenPGPSecretKey

import org.bouncycastle.openpgp.PGPSecretKey; //导入方法依赖的package包/类
public OpenPGPSecretKey(String keyId, InputStream secretKeyRing, char[] password) throws IOException {
	PGPObjectFactory pgpObjectFactory = new BcPGPObjectFactory(PGPUtil.getDecoderStream(secretKeyRing));

	for (Object it = pgpObjectFactory.nextObject(); it != null; it = pgpObjectFactory.nextObject()) {
		PGPSecretKeyRing pgpSecretKeyRing = (PGPSecretKeyRing) it;
		PGPSecretKey pgpSecretKey = pgpSecretKeyRing.getSecretKey();

		if (keyId == null || keyId.isEmpty() || Long.valueOf(keyId, 16) == (pgpSecretKey.getKeyID() & MASK)) {
			this.secretKey = pgpSecretKey;
			break;
		}
	}

	// sanity check
	if (secretKey == null) {
		throw new IllegalArgumentException("Secret key " + keyId + " not found");
	}

	this.password = password;
}
 
开发者ID:rednoah,项目名称:ant-spk,代码行数:21,代码来源:OpenPGPSecretKey.java

示例3: loadSecretKey

import org.bouncycastle.openpgp.PGPSecretKey; //导入方法依赖的package包/类
public static PGPSecretKey loadSecretKey ( final InputStream input, final String keyId ) throws IOException, PGPException
{
    final long keyIdNum = Long.parseUnsignedLong ( keyId, 16 );

    final BcPGPSecretKeyRingCollection keyrings = new BcPGPSecretKeyRingCollection ( PGPUtil.getDecoderStream ( input ) );

    final Iterator<?> keyRingIter = keyrings.getKeyRings ();
    while ( keyRingIter.hasNext () )
    {
        final PGPSecretKeyRing secretKeyRing = (PGPSecretKeyRing)keyRingIter.next ();

        final Iterator<?> secretKeyIterator = secretKeyRing.getSecretKeys ();
        while ( secretKeyIterator.hasNext () )
        {
            final PGPSecretKey key = (PGPSecretKey)secretKeyIterator.next ();

            if ( !key.isSigningKey () )
            {
                continue;
            }

            final long shortId = key.getKeyID () & 0xFFFFFFFFL;

            if ( key.getKeyID () != keyIdNum && shortId != keyIdNum )
            {
                continue;
            }

            return key;
        }
    }

    return null;
}
 
开发者ID:eclipse,项目名称:packagedrone,代码行数:35,代码来源:PgpHelper.java

示例4: readSecretKey

import org.bouncycastle.openpgp.PGPSecretKey; //导入方法依赖的package包/类
private PGPSecretKey readSecretKey(InputStream in) throws IOException, PGPException {
    in = PGPUtil.getDecoderStream(in);
    PGPSecretKeyRingCollection pgpSec = new PGPSecretKeyRingCollection(in,
            new BcKeyFingerprintCalculator());

    PGPSecretKey key = null;
    Iterator<PGPSecretKeyRing> it = pgpSec.getKeyRings();
    while (key == null && it.hasNext()) {
        PGPSecretKeyRing kRing = it.next();

        Iterator<PGPSecretKey> it2 = kRing.getSecretKeys();
        while (key == null && it2.hasNext()) {
            PGPSecretKey k = it2.next();
            if (keyId == null && k.isSigningKey()) {
                key = k;
            }
            if (keyId != null && Long.valueOf(keyId, 16) == (k.getKeyID() & MASK)) {
                key = k;
            }
        }
    }

    if (key == null) {
        throw new IllegalArgumentException("Can't find encryption key"
                + (keyId != null ? " '" + keyId + "' " : " ") + "in key ring.");
    }

    return key;
}
 
开发者ID:apache,项目名称:ant-ivy,代码行数:30,代码来源:OpenPGPSignatureGenerator.java

示例5: getSignature

import org.bouncycastle.openpgp.PGPSecretKey; //导入方法依赖的package包/类
private KeySignature getSignature(PGPSecretKey signingKey,
                                  SignatureType requiredSignatureType) {
    final Iterator<?> signatures = publicKey.getSignatures();
    while (signatures.hasNext()) {
        final KeySignature signature = new KeySignature((PGPSignature) signatures.next());
        if ((signature.getKeyID() == signingKey.getKeyID()) &&
                (signature.getSignatureType() == requiredSignatureType)) {
            return signature;
        }
    }
    return null;
}
 
开发者ID:codahale,项目名称:gpgj,代码行数:13,代码来源:AbstractKey.java

示例6: makeShortKey

import org.bouncycastle.openpgp.PGPSecretKey; //导入方法依赖的package包/类
public static String makeShortKey ( final PGPSecretKey key )
{
    final long shortId = key.getKeyID () & 0xFFFFFFFFL;
    return String.format ( "%08X", shortId );
}
 
开发者ID:eclipse,项目名称:packagedrone,代码行数:6,代码来源:PgpHelper.java


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