public class OpenPGPKeyBasedEncryptor extends Object implements EncryptContent.Encryptor
Modifier and Type | Class and Description |
---|---|
private static class |
OpenPGPKeyBasedEncryptor.OpenPGPDecryptCallback |
private static class |
OpenPGPKeyBasedEncryptor.OpenPGPEncryptCallback |
Modifier and Type | Field and Description |
---|---|
private String |
algorithm |
private Integer |
cipher |
private String |
filename |
private String |
keyring |
private static org.slf4j.Logger |
logger |
private char[] |
passphrase |
private String |
provider |
private String |
userId |
Constructor and Description |
---|
OpenPGPKeyBasedEncryptor(String algorithm,
Integer cipher,
String provider,
String keyring,
String userId,
char[] passphrase,
String filename) |
Modifier and Type | Method and Description |
---|---|
private static org.bouncycastle.openpgp.PGPPrivateKey |
getDecryptedPrivateKey(String provider,
String secretKeyringFile,
char[] passphrase) |
private static org.bouncycastle.openpgp.PGPPrivateKey |
getDecryptedPrivateKey(String provider,
String secretKeyringFile,
long keyId,
char[] passphrase) |
StreamCallback |
getDecryptionCallback() |
StreamCallback |
getEncryptionCallback() |
static org.bouncycastle.openpgp.PGPPublicKey |
getPublicKey(String userId,
String publicKeyringFile) |
void |
updateAttributes(Map<String,String> attributes) |
static boolean |
validateKeyring(String provider,
String secretKeyringFile,
char[] passphrase)
Returns true if the passphrase is valid.
|
private static final org.slf4j.Logger logger
private String algorithm
private Integer cipher
private String provider
private String keyring
private String userId
private char[] passphrase
private String filename
public void updateAttributes(Map<String,String> attributes) throws ProcessException
updateAttributes
in interface EncryptContent.Encryptor
ProcessException
public StreamCallback getEncryptionCallback() throws Exception
getEncryptionCallback
in interface EncryptContent.Encryptor
Exception
public StreamCallback getDecryptionCallback() throws Exception
getDecryptionCallback
in interface EncryptContent.Encryptor
Exception
public static boolean validateKeyring(String provider, String secretKeyringFile, char[] passphrase) throws IOException, org.bouncycastle.openpgp.PGPException, NoSuchProviderException
This is used in the EncryptContent custom validation to check if the passphrase can extract a private key from the secret key ring. After BC was upgraded from 1.46 to 1.53, the API changed so this is performed differently but the functionality is equivalent.
provider
- the provider namesecretKeyringFile
- the file path to the keyringpassphrase
- the passphraseIOException
- if there is a problem reading the keyring fileorg.bouncycastle.openpgp.PGPException
- if there is a problem parsing/extracting the private keyNoSuchProviderException
- if the provider is not availableprivate static org.bouncycastle.openpgp.PGPPrivateKey getDecryptedPrivateKey(String provider, String secretKeyringFile, char[] passphrase) throws IOException, org.bouncycastle.openpgp.PGPException
IOException
org.bouncycastle.openpgp.PGPException
private static org.bouncycastle.openpgp.PGPPrivateKey getDecryptedPrivateKey(String provider, String secretKeyringFile, long keyId, char[] passphrase) throws IOException, org.bouncycastle.openpgp.PGPException
IOException
org.bouncycastle.openpgp.PGPException
public static org.bouncycastle.openpgp.PGPPublicKey getPublicKey(String userId, String publicKeyringFile) throws IOException, org.bouncycastle.openpgp.PGPException
IOException
org.bouncycastle.openpgp.PGPException
Copyright © 2020 Apache NiFi Project. All rights reserved.