Package org.pgpainless.key.protection
Class BaseSecretKeyRingProtector
- java.lang.Object
-
- org.pgpainless.key.protection.BaseSecretKeyRingProtector
-
- All Implemented Interfaces:
SecretKeyRingProtector
- Direct Known Subclasses:
PasswordBasedSecretKeyRingProtector
public class BaseSecretKeyRingProtector extends java.lang.Object implements SecretKeyRingProtector
BasicSecretKeyRingProtectorimplementation that respects the usersKeyRingProtectionSettingswhen encrypting keys.
-
-
Constructor Summary
Constructors Constructor Description BaseSecretKeyRingProtector(SecretKeyPassphraseProvider passphraseProvider)Constructor that uses the givenSecretKeyPassphraseProviderto retrieve passphrases and PGPainless' defaultKeyRingProtectionSettings.BaseSecretKeyRingProtector(SecretKeyPassphraseProvider passphraseProvider, KeyRingProtectionSettings protectionSettings)Constructor that uses the givenSecretKeyPassphraseProviderandKeyRingProtectionSettings.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.bouncycastle.openpgp.operator.PBESecretKeyDecryptorgetDecryptor(java.lang.Long keyId)Return a decryptor for the key of idkeyId.org.bouncycastle.openpgp.operator.PBESecretKeyEncryptorgetEncryptor(java.lang.Long keyId)Return an encryptor for the key of idkeyId.booleanhasPassphraseFor(java.lang.Long keyId)Returns true, if the protector has a passphrase for the key with the given key-id.
-
-
-
Constructor Detail
-
BaseSecretKeyRingProtector
public BaseSecretKeyRingProtector(SecretKeyPassphraseProvider passphraseProvider)
Constructor that uses the givenSecretKeyPassphraseProviderto retrieve passphrases and PGPainless' defaultKeyRingProtectionSettings.- Parameters:
passphraseProvider- provider for passphrases
-
BaseSecretKeyRingProtector
public BaseSecretKeyRingProtector(SecretKeyPassphraseProvider passphraseProvider, KeyRingProtectionSettings protectionSettings)
Constructor that uses the givenSecretKeyPassphraseProviderandKeyRingProtectionSettings.- Parameters:
passphraseProvider- provider for passphrasesprotectionSettings- protection settings
-
-
Method Detail
-
hasPassphraseFor
public boolean hasPassphraseFor(java.lang.Long keyId)
Description copied from interface:SecretKeyRingProtectorReturns true, if the protector has a passphrase for the key with the given key-id.- Specified by:
hasPassphraseForin interfaceSecretKeyRingProtector- Parameters:
keyId- key id- Returns:
- true if it has a passphrase, false otherwise
-
getDecryptor
@Nullable public org.bouncycastle.openpgp.operator.PBESecretKeyDecryptor getDecryptor(java.lang.Long keyId) throws org.bouncycastle.openpgp.PGPExceptionDescription copied from interface:SecretKeyRingProtectorReturn a decryptor for the key of idkeyId. This method returns null if the key is unprotected.- Specified by:
getDecryptorin interfaceSecretKeyRingProtector- Parameters:
keyId- id of the key- Returns:
- decryptor for the key
- Throws:
org.bouncycastle.openpgp.PGPException- if the decryptor cannot be created for some reason
-
getEncryptor
@Nullable public org.bouncycastle.openpgp.operator.PBESecretKeyEncryptor getEncryptor(java.lang.Long keyId) throws org.bouncycastle.openpgp.PGPExceptionDescription copied from interface:SecretKeyRingProtectorReturn an encryptor for the key of idkeyId. This method returns null if the key is unprotected.- Specified by:
getEncryptorin interfaceSecretKeyRingProtector- Parameters:
keyId- id of the key- Returns:
- encryptor for the key
- Throws:
org.bouncycastle.openpgp.PGPException- if the encryptor cannot be created for some reason
-
-