Interface SecretKeyRingEditorInterface

  • All Known Implementing Classes:
    SecretKeyRingEditor

    public interface SecretKeyRingEditorInterface
    • Method Detail

      • addUserId

        SecretKeyRingEditorInterface addUserId​(java.lang.String userId,
                                               SecretKeyRingProtector secretKeyRingProtector)
                                        throws org.bouncycastle.openpgp.PGPException
        Add a user-id to the primary key of the key ring.
        Parameters:
        userId - user-id
        secretKeyRingProtector - protector to unlock the secret key
        Returns:
        the builder
        Throws:
        org.bouncycastle.openpgp.PGPException
      • deleteUserId

        SecretKeyRingEditorInterface deleteUserId​(java.lang.String userId,
                                                  SecretKeyRingProtector secretKeyRingProtector)
        Remove a user-id from the primary key of the key ring.
        Parameters:
        userId - exact user-id to be removed
        secretKeyRingProtector - protector to unlock the secret key
        Returns:
        the builder
      • addSubKey

        SecretKeyRingEditorInterface addSubKey​(@Nonnull
                                               KeySpec keySpec,
                                               @Nonnull
                                               Passphrase subKeyPassphrase,
                                               SecretKeyRingProtector secretKeyRingProtector)
                                        throws java.security.InvalidAlgorithmParameterException,
                                               java.security.NoSuchAlgorithmException,
                                               org.bouncycastle.openpgp.PGPException
        Add a subkey to the key ring. The subkey will be generated from the provided KeySpec.
        Parameters:
        keySpec - key specification
        subKeyPassphrase - passphrase to encrypt the sub key
        secretKeyRingProtector - protector to unlock the secret key of the key ring
        Returns:
        the builder
        Throws:
        java.security.InvalidAlgorithmParameterException
        java.security.NoSuchAlgorithmException
        org.bouncycastle.openpgp.PGPException
      • deleteSubKey

        SecretKeyRingEditorInterface deleteSubKey​(OpenPgpV4Fingerprint fingerprint,
                                                  SecretKeyRingProtector secretKeyRingProtector)
        Delete a subkey from the key ring. The subkey with the provided fingerprint will be remove from the key ring. If no suitable subkey is found, a NoSuchElementException will be thrown.
        Parameters:
        fingerprint - fingerprint of the subkey to be removed
        secretKeyRingProtector - protector to unlock the secret key ring
        Returns:
        the builder
      • deleteSubKey

        SecretKeyRingEditorInterface deleteSubKey​(long subKeyId,
                                                  SecretKeyRingProtector secretKeyRingProtector)
        Delete a subkey from the key ring. The subkey with the provided key-id will be removed from the key ring. If no suitable subkey is found, a NoSuchElementException will be thrown.
        Parameters:
        subKeyId - id of the subkey
        secretKeyRingProtector - protector to unlock the secret key ring
        Returns:
        the builder
      • revoke

        default SecretKeyRingEditorInterface revoke​(SecretKeyRingProtector secretKeyRingProtector)
                                             throws org.bouncycastle.openpgp.PGPException
        Revoke the key ring.
        Parameters:
        secretKeyRingProtector - protector of the primary key
        Returns:
        the builder
        Throws:
        org.bouncycastle.openpgp.PGPException
      • revoke

        SecretKeyRingEditorInterface revoke​(SecretKeyRingProtector secretKeyRingProtector,
                                            RevocationAttributes revocationAttributes)
                                     throws org.bouncycastle.openpgp.PGPException
        Revoke the key ring.
        Parameters:
        secretKeyRingProtector - protector of the primary key
        revocationAttributes - reason for the revocation
        Returns:
        the builder
        Throws:
        org.bouncycastle.openpgp.PGPException
      • revokeSubKey

        default SecretKeyRingEditorInterface revokeSubKey​(OpenPgpV4Fingerprint fingerprint,
                                                          SecretKeyRingProtector secretKeyRingProtector)
                                                   throws org.bouncycastle.openpgp.PGPException
        Revoke the subkey binding signature of a subkey. The subkey with the provided fingerprint will be revoked. If no suitable subkey is found, a NoSuchElementException will be thrown.
        Parameters:
        fingerprint - fingerprint of the subkey to be revoked
        secretKeyRingProtector - protector to unlock the secret key ring
        Returns:
        the builder
        Throws:
        org.bouncycastle.openpgp.PGPException
      • revokeSubKey

        SecretKeyRingEditorInterface revokeSubKey​(OpenPgpV4Fingerprint fingerprint,
                                                  SecretKeyRingProtector secretKeyRingProtector,
                                                  RevocationAttributes revocationAttributes)
                                           throws org.bouncycastle.openpgp.PGPException
        Revoke the subkey binding signature of a subkey. The subkey with the provided fingerprint will be revoked. If no suitable subkey is found, a NoSuchElementException will be thrown.
        Parameters:
        fingerprint - fingerprint of the subkey to be revoked
        secretKeyRingProtector - protector to unlock the primary key
        revocationAttributes - reason for the revocation
        Returns:
        the builder
        Throws:
        org.bouncycastle.openpgp.PGPException
      • revokeSubKey

        default SecretKeyRingEditorInterface revokeSubKey​(long subKeyId,
                                                          SecretKeyRingProtector secretKeyRingProtector)
                                                   throws org.bouncycastle.openpgp.PGPException
        Revoke the subkey binding signature of a subkey. The subkey with the provided key-id will be revoked. If no suitable subkey is found, q NoSuchElementException will be thrown.
        Parameters:
        subKeyId - id of the subkey
        secretKeyRingProtector - protector to unlock the secret key ring
        Returns:
        the builder
        Throws:
        org.bouncycastle.openpgp.PGPException
      • revokeSubKey

        SecretKeyRingEditorInterface revokeSubKey​(long subKeyId,
                                                  SecretKeyRingProtector secretKeyRingProtector,
                                                  RevocationAttributes revocationAttributes)
                                           throws org.bouncycastle.openpgp.PGPException
        Revoke the subkey binding signature of a subkey. The subkey with the provided key-id will be revoked. If no suitable subkey is found, q NoSuchElementException will be thrown.
        Parameters:
        subKeyId - id of the subkey
        secretKeyRingProtector - protector to unlock the primary key
        revocationAttributes - reason for the revocation
        Returns:
        the builder
        Throws:
        org.bouncycastle.openpgp.PGPException
      • setExpirationDate

        SecretKeyRingEditorInterface setExpirationDate​(OpenPgpV4Fingerprint fingerprint,
                                                       java.util.Date expiration,
                                                       SecretKeyRingProtector secretKeyRingProtector)
                                                throws org.bouncycastle.openpgp.PGPException
        Set key expiration time.
        Parameters:
        fingerprint - key that will have its expiration date adjusted
        expiration - target expiration time or @{code null} for no expiration
        secretKeyRingProtector - protector to unlock the priary key
        Returns:
        the builder
        Throws:
        org.bouncycastle.openpgp.PGPException
      • createRevocationCertificate

        org.bouncycastle.openpgp.PGPSignature createRevocationCertificate​(OpenPgpV4Fingerprint fingerprint,
                                                                          SecretKeyRingProtector secretKeyRingProtector,
                                                                          RevocationAttributes revocationAttributes)
                                                                   throws org.bouncycastle.openpgp.PGPException
        Create a detached revocation certificate, which can be used to revoke the specified key.
        Parameters:
        fingerprint - fingerprint of the key to be revoked. Can be primary or sub key.
        secretKeyRingProtector - protector to unlock the primary key.
        revocationAttributes - reason for the revocation
        Returns:
        revocation certificate
        Throws:
        org.bouncycastle.openpgp.PGPException
      • createRevocationCertificate

        org.bouncycastle.openpgp.PGPSignature createRevocationCertificate​(long subKeyId,
                                                                          SecretKeyRingProtector secretKeyRingProtector,
                                                                          RevocationAttributes revocationAttributes)
                                                                   throws org.bouncycastle.openpgp.PGPException
        Create a detached revocation certificate, which can be used to revoke the specified key.
        Parameters:
        subKeyId - id of the key to be revoked. Can be primary or sub key.
        secretKeyRingProtector - protector to unlock the primary key.
        revocationAttributes - reason for the revocation
        Returns:
        revocation certificate
        Throws:
        org.bouncycastle.openpgp.PGPException
      • changeSubKeyPassphraseFromOldPassphrase

        default SecretKeyRingEditorInterface.WithKeyRingEncryptionSettings changeSubKeyPassphraseFromOldPassphrase​(@Nonnull
                                                                                                                   java.lang.Long keyId,
                                                                                                                   @Nullable
                                                                                                                   Passphrase oldPassphrase)
        Change the passphrase of a single subkey in the key ring. Note: While it is a valid use-case to have different passphrases per subKey, this is one of the reasons why OpenPGP sucks in practice.
        Parameters:
        keyId - id of the subkey
        oldPassphrase - old passphrase
        Returns:
        next builder step
      • done

        org.bouncycastle.openpgp.PGPSecretKeyRing done()
        Return the PGPSecretKeyRing.
        Returns:
        the key