Examples of PGPPublicKey


Examples of org.bouncycastle.openpgp.PGPPublicKey

            NoSuchProviderException {
        PGPPublicKeyRingCollection pgpSec = new PGPPublicKeyRingCollection(PGPUtil.getDecoderStream(input));

        for (Iterator<PGPPublicKeyRing> keyRingIter = pgpSec.getKeyRings(); keyRingIter.hasNext();) {
            PGPPublicKeyRing keyRing = keyRingIter.next();
            PGPPublicKey key = keyRing.getPublicKey(keyid);
            if (key != null) {
                return key;
            }

        }
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPPublicKey

        for (Iterator<PGPPublicKeyRing> keyRingIter = pgpSec.getKeyRings(); keyRingIter.hasNext();) {
            PGPPublicKeyRing keyRing = keyRingIter.next();
            Set<String> keyUserIds = getUserIds(keyRing);
            for (Iterator<PGPPublicKey> keyIter = keyRing.getPublicKeys(); keyIter.hasNext();) {
                PGPPublicKey key = keyIter.next();
                for (String useridPart : userids) {
                    for (String keyUserId : keyUserIds) {
                        if (keyUserId != null && keyUserId.contains(useridPart)) {
                            if (forEncryption) {
                                if (isEncryptionKey(key)) {
                                    LOG.debug(
                                            "Public encryption key with key user ID {} and key ID {} found for specified user ID part {}",
                                            new Object[] {keyUserId, Long.toString(key.getKeyID()), useridPart });
                                    result.add(key);
                                }
                            } else if (!forEncryption && isSignatureKey(key)) {
                                // not used!
                                result.add(key);
                                LOG.debug("Public key with key user ID {} and key ID {} found for specified user ID part {}", new Object[] {
                                    keyUserId, Long.toString(key.getKeyID()), useridPart });
                            }
                        }
                    }
                }
            }
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPPublicKey

    // http://bouncy-castle.1462172.n4.nabble.com/How-to-find-PGP-subkeys-td1465289.html
    @SuppressWarnings("unchecked")
    private static Set<String> getUserIds(PGPPublicKeyRing keyRing) {
        Set<String> userIds = new LinkedHashSet<String>(3);
        for (Iterator<PGPPublicKey> keyIter = keyRing.getPublicKeys(); keyIter.hasNext();) {
            PGPPublicKey key = keyIter.next();
            for (Iterator<String> iterator = key.getUserIDs(); iterator.hasNext();) {
                userIds.add(iterator.next());
            }
        }
        return userIds;
    }
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPPublicKey

            PGPPublicKeyRing keyRing = (PGPPublicKeyRing) keyRingIter.next();

            @SuppressWarnings("rawtypes")
            Iterator keyIter = keyRing.getPublicKeys();
            while (keyIter.hasNext()) {
                PGPPublicKey key = (PGPPublicKey) keyIter.next();

                if (key.isEncryptionKey()) {
                    return key;
                }
            }
        }
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPPublicKey

        }
        List<String> allowedUserIds = determineSignaturenUserIds(exchange);
        for (int i = 0; i < signatureList.size(); i++) {
            PGPOnePassSignature signature = signatureList.get(i);
            // Determine public key from signature keyId
            PGPPublicKey sigPublicKey = publicKeyAccessor.getPublicKey(exchange, signature.getKeyID(), allowedUserIds);
            if (sigPublicKey == null) {
                continue;
            }
            // choose that signature for which a public key exists!
            signature.init(new JcaPGPContentVerifierBuilderProvider().setProvider(getProvider()), sigPublicKey);
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPPublicKey

    public static PGPPublicKey findPublicKey(CamelContext context, String filename, String userid) throws IOException, PGPException,
            NoSuchProviderException {

        InputStream is = ResourceHelper.resolveMandatoryResourceAsInputStream(context.getClassResolver(), filename);
        PGPPublicKey privKey;
        try {
            privKey = findPublicKey(context, is, userid);
        } finally {
            IOHelper.close(is);
        }
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPPublicKey

            PGPPublicKeyRing keyRing = keyRingIter.next();

            Iterator<PGPPublicKey> keyIter = (Iterator<PGPPublicKey>) keyRing.getPublicKeys();
            String keyUserId = null;
            while (keyIter.hasNext()) {
                PGPPublicKey key = keyIter.next();
                for (Iterator<String> iterator = (Iterator<String>) key.getUserIDs(); iterator.hasNext();) {
                    keyUserId = iterator.next();
                }
                if (key.isEncryptionKey() && keyUserId != null && keyUserId.contains(userid)) {
                    return key;
                }
            }
        }
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPPublicKey

            Security.addProvider(new BouncyCastleProvider());
        }
    }

    public void marshal(Exchange exchange, Object graph, OutputStream outputStream) throws Exception {
        PGPPublicKey key = PGPDataFormatUtil.findPublicKey(exchange.getContext(), this.keyFileName, this.keyUserid);
        if (key == null) {
            throw new IllegalArgumentException("Public key is null, cannot proceed");
        }

        byte[] plaintextData;
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPPublicKey

            return;
        }

        MuleMessage message = event.getMessage();

        PGPPublicKey userKeyBundle = keyManager.getPublicKey((String)getCredentialsAccessor().getCredentials(
            event));

        final PGPCryptInfo cryptInfo = new PGPCryptInfo(userKeyBundle, signRequired);

        try
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPPublicKey

        if (userId == null)
        {
            throw new UnauthorisedException(CoreMessages.objectIsNull("UserId"));
        }

        PGPPublicKey publicKey = keyManager.getPublicKey(userId);

        if (publicKey == null)
        {
            throw new UnauthorisedException(PGPMessages.noPublicKeyForUser(userId));
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.