@ComponentProfile(summary="Encrypts or Decrypts payload using key and initial vector", tag="service,cryptography") public class SymmetricKeyCryptographyService extends ServiceImp
In the adapter configuration file this class is aliased as symmetric-key-cryptography-service which is the preferred alternative to the fully qualified classname when building your configuration.
Modifier and Type | Class and Description |
---|---|
static class |
SymmetricKeyCryptographyService.OpMode |
log
CONFIRMATION_ID_KEY
Constructor and Description |
---|
SymmetricKeyCryptographyService() |
Modifier and Type | Method and Description |
---|---|
protected void |
closeService() |
void |
doService(AdaptrisMessage msg)
Apply the service to the message.
|
java.lang.String |
getAlgorithm() |
java.lang.String |
getCipherTransformation() |
DataInputParameter<java.lang.String> |
getInitialVector() |
DataInputParameter<java.lang.String> |
getKey() |
SymmetricKeyCryptographyService.OpMode |
getOperationMode() |
MessageWrapper<java.io.InputStream> |
getSource() |
MessageWrapper<java.io.OutputStream> |
getTarget() |
protected void |
initService() |
void |
prepare()
Prepare for initialisation.
|
void |
setAlgorithm(java.lang.String algorithm)
Set the name of the secret-key algorithm.
|
void |
setCipherTransformation(java.lang.String cipherTransformation)
Set the cipher transformation to be applied
|
void |
setInitialVector(DataInputParameter<java.lang.String> initialVector)
Set the initial vector for the algorithm
|
void |
setKey(DataInputParameter<java.lang.String> key)
Set the initial key the service
|
void |
setOperationMode(SymmetricKeyCryptographyService.OpMode mode) |
void |
setSource(MessageWrapper<java.io.InputStream> source)
Set the source for the input of the crypto service.
|
void |
setTarget(MessageWrapper<java.io.OutputStream> target)
Set the target for the output of the crypto service.
|
SymmetricKeyCryptographyService |
withAlgorithm(java.lang.String algorithm) |
SymmetricKeyCryptographyService |
withCipherTransformation(java.lang.String cipherTransformation) |
SymmetricKeyCryptographyService |
withInitialVector(DataInputParameter<java.lang.String> initialVector) |
SymmetricKeyCryptographyService |
withKey(DataInputParameter<java.lang.String> key) |
SymmetricKeyCryptographyService |
withSource(MessageWrapper<java.io.InputStream> source) |
SymmetricKeyCryptographyService |
withTarget(MessageWrapper<java.io.OutputStream> target) |
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsTrackingEndpoint, getLookupName, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setLookupName, setUniqueId, start, stop
public void doService(AdaptrisMessage msg) throws ServiceException
Service
Apply the service to the message.
msg
- the AdaptrisMessage
to processServiceException
- wrapping any underlying Exception
sprotected void initService() throws CoreException
initService
in class ServiceImp
CoreException
protected void closeService()
closeService
in class ServiceImp
public void prepare() throws CoreException
ComponentLifecycleExtension
CoreException
public void setAlgorithm(java.lang.String algorithm)
This value is passed in as one of the parameters to
SecretKeySpec.SecretKeySpec(byte[], String)
; while it is free text, the correct value
will depend on what you have agreed with the remote party and support within your JVM.
algorithm
- the name of the secret-key algorithm to be associated with the given key.public java.lang.String getAlgorithm()
public SymmetricKeyCryptographyService withAlgorithm(java.lang.String algorithm)
public void setCipherTransformation(java.lang.String cipherTransformation)
This value is passed into Cipher.getInstance(String)
; while it is free text, the
correct value will depend on what you have agreed with the remote party and support within your
JVM.
cipherTransformation
- the name of the transformation, e.g. AES/CBC/PKCS5Padding
.public java.lang.String getCipherTransformation()
public SymmetricKeyCryptographyService withCipherTransformation(java.lang.String cipherTransformation)
public void setInitialVector(DataInputParameter<java.lang.String> initialVector)
Depending on the algorithm you have chosen, then size of the initial vector will vary. For instance, for AES, it needs to be 16 bytes
initialVector
- the Base64 encoded string of initial vector bytes.public DataInputParameter<java.lang.String> getInitialVector()
public SymmetricKeyCryptographyService withInitialVector(DataInputParameter<java.lang.String> initialVector)
public void setKey(DataInputParameter<java.lang.String> key)
Depending on the algorithm you have chosen, then size of the key will vary. For instance, for AES, it needs to be 32 bytes
key
- Base64 encoded string of key bytes.public DataInputParameter<java.lang.String> getKey()
public SymmetricKeyCryptographyService withKey(DataInputParameter<java.lang.String> key)
public void setOperationMode(SymmetricKeyCryptographyService.OpMode mode)
mode
- the operation mode of the cipher: ENCRYPT or DECRYPT (default: DECRYPT)public SymmetricKeyCryptographyService.OpMode getOperationMode()
public MessageWrapper<java.io.InputStream> getSource()
public void setSource(MessageWrapper<java.io.InputStream> source)
source
- the source.public SymmetricKeyCryptographyService withSource(MessageWrapper<java.io.InputStream> source)
public MessageWrapper<java.io.OutputStream> getTarget()
public void setTarget(MessageWrapper<java.io.OutputStream> target)
target
- the target.public SymmetricKeyCryptographyService withTarget(MessageWrapper<java.io.OutputStream> target)