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


Java PGPPublicKey.getSignaturesForID方法代码示例

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


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

示例1: rememberKey

import org.bouncycastle.openpgp.PGPPublicKey; //导入方法依赖的package包/类
/**
 * Simply stores the key ID in {@link #discoveredKeyIds} for future
 * reference of all Key IDs we've come across. This method uses a
 * {@link PGPPublicKeyRing} to ensure the input is actually a valid key,
 * plus locating any key IDs that have signed the key.
 * <p>
 * Please note {@link #discoveredKeyIds} is not used for any key functions
 * of this class. It is simply for user interface convenience.
 * 
 * @param keyRing the key ID to store (required)
 */
@SuppressWarnings("unchecked")
private void rememberKey(final PGPPublicKeyRing keyRing) {
    final PGPPublicKey key = keyRing.getPublicKey();
    if (key != null) {
        final PgpKeyId keyId = new PgpKeyId(key);
        discoveredKeyIds.add(keyId);
        final Iterator<String> userIdIterator = key.getUserIDs();
        while (userIdIterator.hasNext()) {
            final String userId = userIdIterator.next();
            final Iterator<PGPSignature> signatureIterator = key
                    .getSignaturesForID(userId);
            while (signatureIterator.hasNext()) {
                final PGPSignature signature = signatureIterator.next();
                final PgpKeyId signatureKeyId = new PgpKeyId(signature);
                discoveredKeyIds.add(signatureKeyId);
            }
        }
    }
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:31,代码来源:PgpServiceImpl.java

示例2: formatKeyRing

import org.bouncycastle.openpgp.PGPPublicKey; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void formatKeyRing(final StringBuilder sb,
        final PGPPublicKeyRing keyRing) {
    final SimpleDateFormat sdf = new SimpleDateFormat(
            "yyyy-MMM-dd HH:mm:ss Z");
    sdf.setTimeZone(TimeZone.getTimeZone("GMT"));

    final Iterator<PGPPublicKey> it = keyRing.getPublicKeys();
    boolean first = true;
    while (it.hasNext()) {
        final PGPPublicKey pgpKey = it.next();
        if (first) {
            appendLine(sb, ">>>> KEY ID: " + new PgpKeyId(pgpKey) + " <<<<");
            appendLine(
                    sb,
                    "     More Info: "
                            + pgpService
                                    .getKeyServerUrlToRetrieveKeyInformation(new PgpKeyId(
                                            pgpKey)));
            appendLine(sb,
                    "     Created: " + sdf.format(pgpKey.getCreationTime()));
            appendLine(
                    sb,
                    "     Fingerprint: "
                            + new String(
                                    Hex.encode(pgpKey.getFingerprint())));
            appendLine(sb,
                    "     Algorithm: "
                            + getAlgorithm(pgpKey.getAlgorithm()));
            final Iterator<String> userIdIterator = pgpKey.getUserIDs();
            while (userIdIterator.hasNext()) {
                final String userId = userIdIterator.next();
                appendLine(sb, "     User ID: " + userId);
                final Iterator<PGPSignature> signatureIterator = pgpKey
                        .getSignaturesForID(userId);
                while (signatureIterator.hasNext()) {
                    final PGPSignature signature = signatureIterator.next();
                    appendLine(sb, "          Signed By: "
                            + getKeySummaryIfPossible(new PgpKeyId(
                                    signature)));
                }
            }

            first = false;
        }
        else {
            appendLine(sb, "     Subkey ID: " + new PgpKeyId(pgpKey) + " ["
                    + getAlgorithm(pgpKey.getAlgorithm()) + "]");
        }
    }
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:52,代码来源:PgpCommands.java


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