Package org.bouncycastle.openpgp

Examples of org.bouncycastle.openpgp.PGPPublicKeyRing


        byte[]        encodedRing,
        int           masterDays,
        int           subKeyDays)
        throws Exception
    {           
        PGPPublicKeyRing pubRing = new PGPPublicKeyRing(encodedRing);
        PGPPublicKey k = pubRing.getPublicKey();
       
        if (k.getValidDays() != masterDays)
        {
            fail("mismatch on master valid days.");
        }
       
        Iterator it = pubRing.getPublicKeys();
       
        it.next();
       
        k = (PGPPublicKey)it.next();
       
View Full Code Here


    }

    @CliCommand(value = "pgp key view", help = "Downloads a remote key and displays it to the user (does not change any trusts)")
    public String keyView(
            @CliOption(key = "keyId", mandatory = true, help = "The key ID to view (eg 00B5050F or 0x00B5050F)") final PgpKeyId keyId) {
        final PGPPublicKeyRing keyRing = pgpService.getPublicKey(keyId);
        final StringBuilder sb = new StringBuilder();
        formatKeyRing(sb, keyRing);
        return sb.toString();
    }
View Full Code Here

    }

    @CliCommand(value = "pgp trust", help = "Grants trust to a particular key ID")
    public String trust(
            @CliOption(key = "keyId", mandatory = true, help = "The key ID to trust (eg 00B5050F or 0x00B5050F)") final PgpKeyId keyId) {
        final PGPPublicKeyRing keyRing = pgpService.trust(keyId);
        final StringBuilder sb = new StringBuilder();
        appendLine(sb, "Added trust for key:");
        formatKeyRing(sb, keyRing);
        return sb.toString();
    }
View Full Code Here

    }

    @CliCommand(value = "pgp untrust", help = "Revokes your trust for a particular key ID")
    public String untrust(
            @CliOption(key = "keyId", mandatory = true, help = "The key ID to remove trust from (eg 00B5050F or 0x00B5050F)") final PgpKeyId keyId) {
        final PGPPublicKeyRing keyRing = pgpService.untrust(keyId);
        final StringBuilder sb = new StringBuilder();
        appendLine(sb, "Revoked trust from key:");
        formatKeyRing(sb, keyRing);
        return sb.toString();
    }
View Full Code Here

        catch (final Exception e) {
            throw new IllegalStateException(e);
        }

        if (obj instanceof PGPPublicKeyRing) {
            final PGPPublicKeyRing keyRing = (PGPPublicKeyRing) obj;
            rememberKey(keyRing);
            return keyRing;
        }

        throw new IllegalStateException("Pblic key not available");
View Full Code Here

            final PGPPublicKeyRingCollection pubRings = new PGPPublicKeyRingCollection(
                    PGPUtil.getDecoderStream(fis));
            final Iterator<PGPPublicKeyRing> rIt = pubRings.getKeyRings();
            final List<PGPPublicKeyRing> result = new ArrayList<PGPPublicKeyRing>();
            while (rIt.hasNext()) {
                final PGPPublicKeyRing pgpPub = rIt.next();
                rememberKey(pgpPub);
                result.add(pgpPub);
            }
            return result;
        }
View Full Code Here

            if (!(signature instanceof ArmoredInputStream)) {
                signature = new ArmoredInputStream(signature);
            }

            pgpSignature = isSignatureAcceptable(signature).getPgpSignature();
            final PGPPublicKeyRing keyRing = getPublicKey(new PgpKeyId(
                    pgpSignature));
            rememberKey(keyRing);
            publicKey = keyRing.getPublicKey();

            Validate.notNull(publicKey,
                    "Could not obtain public key for signer key ID '%s'",
                    pgpSignature);
View Full Code Here

        // return it)
        for (final PGPPublicKeyRing candidate : trusted) {
            final PGPPublicKey firstKey = candidate.getPublicKey();
            final PgpKeyId candidateKeyId = new PgpKeyId(firstKey);
            // Try to refresh
            PGPPublicKeyRing newKeyRing;
            try {
                newKeyRing = getPublicKey(candidateKeyId);
            }
            catch (final Exception e) {
                // Can't retrieve, so keep the old one for now
                stillTrusted.add(candidate);
                result.put(candidateKeyId,
                        "WARNING: Retained original (download issue)");
                continue;
            }
            // Do not store if the first key is revoked
            if (newKeyRing.getPublicKey().isRevoked()) {
                result.put(candidateKeyId,
                        "WARNING: Key revoked, so removed from trust list");
            }
            else {
                stillTrusted.add(newKeyRing);
View Full Code Here

        this.automaticTrust = automaticTrust;
    }

    public PGPPublicKeyRing trust(final PgpKeyId keyId) {
        Validate.notNull(keyId, "Key ID required");
        final PGPPublicKeyRing keyRing = getPublicKey(keyId);
        return trust(keyRing);
    }
View Full Code Here

        // ends
        final List<PGPPublicKeyRing> stillTrusted = new ArrayList<PGPPublicKeyRing>();

        // Locate the element to remove (we need to record it so the method can
        // return it)
        PGPPublicKeyRing removed = null;
        for (final PGPPublicKeyRing candidate : trusted) {
            boolean stillTrust = true;
            final Iterator<PGPPublicKey> it = candidate.getPublicKeys();
            while (it.hasNext()) {
                final PGPPublicKey pgpKey = it.next();
View Full Code Here

TOP

Related Classes of org.bouncycastle.openpgp.PGPPublicKeyRing

Copyright © 2018 www.massapicom. 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.