PGPPublicKeyRing
Date: 2016-06-23

org.bouncycastle.openpgp

## Class PGPPublicKeyRing

- java.lang.Object
- - org.bouncycastle.openpgp.PGPKeyRing
  - - org.bouncycastle.openpgp.PGPPublicKeyRing

- All Implemented Interfaces:
    java.lang.Iterable<PGPPublicKey>
  Direct Known Subclasses:
    BcPGPPublicKeyRing, JcaPGPPublicKeyRing

      public class PGPPublicKeyRing
      extends PGPKeyRing
      implements org.bouncycastle.util.Iterable<PGPPublicKey>

  Class to hold a single master public key and its subkeys.

  Often PGP keyring files consist of multiple master keys, if you are trying to process or construct one of these you should use the PGPPublicKeyRingCollection class.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PGPPublicKeyRing(byte[] encoding, KeyFingerPrintCalculator fingerPrintCalculator)`
    `PGPPublicKeyRing(java.io.InputStream in, KeyFingerPrintCalculator fingerPrintCalculator)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `encode(java.io.OutputStream outStream)`
    `byte[]` | `getEncoded()`
    `PGPPublicKey` | `getPublicKey()` Return the first public key in the ring.
    `PGPPublicKey` | `getPublicKey(long keyID)` Return the public key referred to by the passed in keyID if it is present.
    `java.util.Iterator<PGPPublicKey>` | `getPublicKeys()` Return an iterator containing all the public keys.
    `static PGPPublicKeyRing` | `insertPublicKey(PGPPublicKeyRing pubRing, PGPPublicKey pubKey)` Returns a new key ring with the public key passed in either added or replacing an existing one.
    `java.util.Iterator<PGPPublicKey>` | `iterator()` Support method for Iterable where available.
    `static PGPPublicKeyRing` | `removePublicKey(PGPPublicKeyRing pubRing, PGPPublicKey pubKey)` Returns a new key ring with the public key passed in removed from the key ring.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### PGPPublicKeyRing

          public PGPPublicKeyRing(byte[] encoding,
                          KeyFingerPrintCalculator fingerPrintCalculator)
                           throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### PGPPublicKeyRing

          public PGPPublicKeyRing(java.io.InputStream in,
                          KeyFingerPrintCalculator fingerPrintCalculator)
                           throws java.io.IOException

      Throws:
        `java.io.IOException`

  - ### Method Detail

    - #### getPublicKey

          public PGPPublicKey getPublicKey()

      Return the first public key in the ring.
      Specified by:
        `getPublicKey` in class `PGPKeyRing`
      Returns:
        PGPPublicKey

    - #### getPublicKey

          public PGPPublicKey getPublicKey(long keyID)

      Return the public key referred to by the passed in keyID if it is present.
      Specified by:
        `getPublicKey` in class `PGPKeyRing`
      Parameters:
        `keyID` -
      Returns:
        PGPPublicKey

    - #### getPublicKeys

          public java.util.Iterator<PGPPublicKey> getPublicKeys()

      Return an iterator containing all the public keys.
      Specified by:
        `getPublicKeys` in class `PGPKeyRing`
      Returns:
        Iterator

    - #### iterator

          public java.util.Iterator<PGPPublicKey> iterator()

      Support method for Iterable where available.
      Specified by:
        `iterator` in interface `java.lang.Iterable<PGPPublicKey>`

    - #### getEncoded

          public byte[] getEncoded()
                            throws java.io.IOException

      Specified by:
        `getEncoded` in class `PGPKeyRing`
      Throws:
        `java.io.IOException`

    - #### encode

          public void encode(java.io.OutputStream outStream)
                      throws java.io.IOException

      Specified by:
        `encode` in class `PGPKeyRing`
      Throws:
        `java.io.IOException`

    - #### insertPublicKey

          public static PGPPublicKeyRing insertPublicKey(PGPPublicKeyRing pubRing,
                                         PGPPublicKey pubKey)

      Returns a new key ring with the public key passed in either added or replacing an existing one.
      Parameters:
        `pubRing` - the public key ring to be modified
        `pubKey` - the public key to be inserted.
      Returns:
        a new keyRing

    - #### removePublicKey

          public static PGPPublicKeyRing removePublicKey(PGPPublicKeyRing pubRing,
                                         PGPPublicKey pubKey)

      Returns a new key ring with the public key passed in removed from the key ring.
      Parameters:
        `pubRing` - the public key ring to be modified
        `pubKey` - the public key to be removed.
      Returns:
        a new keyRing, null if pubKey is not found.