Class PGPDataFormat
java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.converter.crypto.PGPKeyAccessDataFormat
org.apache.camel.converter.crypto.PGPDataFormat
- All Implemented Interfaces:
AutoCloseable,PGPPublicKeyAccessor,PGPSecretKeyAccessor,org.apache.camel.Service,org.apache.camel.ShutdownableService,org.apache.camel.spi.DataFormat,org.apache.camel.spi.DataFormatName,org.apache.camel.StatefulService,org.apache.camel.SuspendableService
@Dataformat("pgp")
public class PGPDataFormat
extends PGPKeyAccessDataFormat
implements PGPPublicKeyAccessor, PGPSecretKeyAccessor
PGPDataFormat uses the bouncy castle libraries to
enable encryption and decryption in the PGP format.
See also PGPKeyAccessDataFormat.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class org.apache.camel.converter.crypto.PGPKeyAccessDataFormat
COMPRESSION_ALGORITHM, ENCRYPTION_ALGORITHM, KEY_USERID, KEY_USERIDS, NUMBER_OF_ENCRYPTION_KEYS, NUMBER_OF_SIGNING_KEYS, SIGNATURE_HASH_ALGORITHM, SIGNATURE_KEY_USERID, SIGNATURE_KEY_USERIDS, SIGNATURE_VERIFICATION_OPTION_IGNORE, SIGNATURE_VERIFICATION_OPTION_NO_SIGNATURE_ALLOWED, SIGNATURE_VERIFICATION_OPTION_OPTIONAL, SIGNATURE_VERIFICATION_OPTION_REQUIREDFields inherited from class org.apache.camel.support.service.BaseService
BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondetermineSecretKeysWithPrivateKeyAndUserId(org.apache.camel.Exchange exchange, String sigKeyFileName, List<String> sigKeyUserids, String sigKeyPassword, byte[] sigKeyRing) determineSignatureKeyUserId2Password(List<String> sigKeyUserids, String sigKeyPassword) protected byte[]findEncryptionKeyRing(org.apache.camel.Exchange exchange) protected StringfindKeyFileName(org.apache.camel.Exchange exchange) protected StringfindKeyPassword(org.apache.camel.Exchange exchange) protected StringfindSignatureKeyFileName(org.apache.camel.Exchange exchange) protected StringfindSignatureKeyPassword(org.apache.camel.Exchange exchange) protected byte[]findSignatureKeyRing(org.apache.camel.Exchange exchange) byte[]List<org.bouncycastle.openpgp.PGPPublicKey> getEncryptionKeys(org.apache.camel.Exchange exchange, List<String> useridParts) Returns the encryption keys for the given user ID parts.org.bouncycastle.openpgp.PGPPrivateKeygetPrivateKey(org.apache.camel.Exchange exchange, long keyId) Returns the private key with a certain key ID.org.bouncycastle.openpgp.PGPPublicKeygetPublicKey(org.apache.camel.Exchange exchange, long keyId, List<String> userIdParts) Returns the public key with a certain key ID.byte[]getSignerKeys(org.apache.camel.Exchange exchange, List<String> useridParts) Returns the signer keys for the given user ID parts.voidsetEncryptionKeyRing(byte[] encryptionKeyRing) Keyring used for encryption/decryption as byte array.voidsetKeyFileName(String keyFileName) Filename of the keyring that will be used for the encryption/decryption, classpathResource.voidsetPassphraseAccessor(PGPPassphraseAccessor passphraseAccessor) Alternative way to provide the passphrases.voidsetPassword(String password) Password used to open the private key in secret keyring for decryption (unmarshaling).voidsetPublicKeyAccessor(PGPPublicKeyAccessor publicKeyAccessor) voidsetSecretKeyAccessor(PGPSecretKeyAccessor secretKeyAccessor) voidsetSignatureKeyFileName(String signatureKeyFileName) Filename of the signature keyring that will be used, classpathResource.voidsetSignatureKeyRing(byte[] signatureKeyRing) Keyring used for signing/verifying as byte array.voidsetSignaturePassword(String signaturePassword) Password used to open the signature private key during marshaling.Methods inherited from class org.apache.camel.converter.crypto.PGPKeyAccessDataFormat
createSignatureGenerator, determineEncryptionUserIds, determineSignaturenUserIds, doStart, doStop, findAlgorithm, findCompressionAlgorithm, findFileName, findHashAlgorithm, findKeyUserid, findKeyUserids, findSignatureKeyUserid, findSignatureKeyUserids, getAlgorithm, getArmored, getCompressionAlgorithm, getDataFormatName, getFileName, getHashAlgorithm, getIntegrity, getKeyUserid, getKeyUserids, getProvider, getPublicKeyAccessor, getSecretKeyAccessor, getSignature, getSignatureKeyUserid, getSignatureKeyUserids, getSignatureVerificationOption, getSignatureWithKeyId, isWithCompressedDataPacket, marshal, setAlgorithm, setArmored, setCompressionAlgorithm, setFileName, setHashAlgorithm, setIntegrity, setKeyUserid, setKeyUserids, setProvider, setSignatureKeyUserid, setSignatureKeyUserids, setSignatureVerificationOption, setWithCompressedDataPacket, unmarshalMethods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doInit, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getInternalLock, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspendMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.camel.spi.DataFormat
unmarshalMethods inherited from interface org.apache.camel.Service
build, close, init, start, stopMethods inherited from interface org.apache.camel.ShutdownableService
shutdownMethods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspendingMethods inherited from interface org.apache.camel.SuspendableService
isSuspended, resume, suspend
-
Field Details
-
KEY_FILE_NAME
- See Also:
-
ENCRYPTION_KEY_RING
- See Also:
-
KEY_PASSWORD
- See Also:
-
SIGNATURE_KEY_FILE_NAME
- See Also:
-
SIGNATURE_KEY_RING
- See Also:
-
SIGNATURE_KEY_PASSWORD
- See Also:
-
-
Constructor Details
-
PGPDataFormat
public PGPDataFormat()
-
-
Method Details
-
findKeyFileName
-
findEncryptionKeyRing
protected byte[] findEncryptionKeyRing(org.apache.camel.Exchange exchange) -
findKeyPassword
-
findSignatureKeyFileName
-
findSignatureKeyRing
protected byte[] findSignatureKeyRing(org.apache.camel.Exchange exchange) -
findSignatureKeyPassword
-
determineSecretKeysWithPrivateKeyAndUserId
public List<PGPSecretKeyAndPrivateKeyAndUserId> determineSecretKeysWithPrivateKeyAndUserId(org.apache.camel.Exchange exchange, String sigKeyFileName, List<String> sigKeyUserids, String sigKeyPassword, byte[] sigKeyRing) throws IOException, org.bouncycastle.openpgp.PGPException - Throws:
IOExceptionorg.bouncycastle.openpgp.PGPException
-
determineSignatureKeyUserId2Password
-
setKeyFileName
Filename of the keyring that will be used for the encryption/decryption, classpathResource. Alternatively you can provide the keyring also as byte array; see methodsetEncryptionKeyRing(byte[]). -
getKeyFileName
-
setPassword
Password used to open the private key in secret keyring for decryption (unmarshaling). See alsosetPassphraseAccessor(PGPPassphraseAccessor). -
getPassword
-
setSignatureKeyFileName
Filename of the signature keyring that will be used, classpathResource. -
getSignatureKeyFileName
-
setSignaturePassword
Password used to open the signature private key during marshaling. -
getSignaturePassword
-
getEncryptionKeyRing
public byte[] getEncryptionKeyRing() -
setEncryptionKeyRing
public void setEncryptionKeyRing(byte[] encryptionKeyRing) Keyring used for encryption/decryption as byte array. Alternatively you can also provide the keyring as a file; see methodsetKeyFileName(String). -
getSignatureKeyRing
public byte[] getSignatureKeyRing() -
setSignatureKeyRing
public void setSignatureKeyRing(byte[] signatureKeyRing) Keyring used for signing/verifying as byte array. Alternatively you can also provide the keyring as a file; see methodsetSignatureKeyFileName(String). -
getPassphraseAccessor
-
setPassphraseAccessor
Alternative way to provide the passphrases. Especially useful for the unmarshal (decryption) case . If no passphrase can be found from the parameter password or signaturePassword or from the headerSIGNATURE_KEY_PASSWORDorKEY_PASSWORDthen we try to get the password from the passphrase accessor. This is especially useful in the decrypt case, where we chose the private key according to the key Id stored in the encrypted data. -
getEncryptionKeys
public List<org.bouncycastle.openpgp.PGPPublicKey> getEncryptionKeys(org.apache.camel.Exchange exchange, List<String> useridParts) throws Exception Description copied from interface:PGPPublicKeyAccessorReturns the encryption keys for the given user ID parts. This method is used for encryption.- Specified by:
getEncryptionKeysin interfacePGPPublicKeyAccessor- Parameters:
exchange- exchange, can benulluseridParts- parts of User IDs, must not benull- Returns:
- list of public keys, must not be
null - Throws:
Exception
-
getSignerKeys
public List<PGPSecretKeyAndPrivateKeyAndUserId> getSignerKeys(org.apache.camel.Exchange exchange, List<String> useridParts) throws Exception Description copied from interface:PGPSecretKeyAccessorReturns the signer keys for the given user ID parts. This method is used for signing.- Specified by:
getSignerKeysin interfacePGPSecretKeyAccessor- Parameters:
exchange- exchange, can benulluseridParts- parts of User IDs, can benullor empty, then an empty list must be returned- Returns:
- list of secret keys with their private keys and User Ids which corresponds to one of the
useridParts, must not be
null, can be empty - Throws:
Exception
-
getPrivateKey
public org.bouncycastle.openpgp.PGPPrivateKey getPrivateKey(org.apache.camel.Exchange exchange, long keyId) throws Exception Description copied from interface:PGPSecretKeyAccessorReturns the private key with a certain key ID. This method is used for decrypting.- Specified by:
getPrivateKeyin interfacePGPSecretKeyAccessor- Parameters:
exchange- exchange, can benullkeyId- key ID- Returns:
- private key or
nullif the key cannot be found - Throws:
Exception
-
getPublicKey
public org.bouncycastle.openpgp.PGPPublicKey getPublicKey(org.apache.camel.Exchange exchange, long keyId, List<String> userIdParts) throws Exception Description copied from interface:PGPPublicKeyAccessorReturns the public key with a certain key ID. This method is used for verifying the signature. The given User IDs are provided to filter the public key, further. If the User ID parts list is empty, then any public key can be returned which has the specified key ID. If the User ID parts list is not empty then the returned key must have a User ID which contains at least one User ID part.- Specified by:
getPublicKeyin interfacePGPPublicKeyAccessor- Parameters:
exchange- exchangekeyId- key IDuserIdParts- parts of User IDs, must not benull, but can be empty- Returns:
- public key or
nullif the key cannot be found - Throws:
Exception
-
setPublicKeyAccessor
- Overrides:
setPublicKeyAccessorin classPGPKeyAccessDataFormat
-
setSecretKeyAccessor
- Overrides:
setSecretKeyAccessorin classPGPKeyAccessDataFormat
-