Class SymmetricKeyCryptographyService
- java.lang.Object
-
- com.adaptris.core.ServiceImp
-
- com.adaptris.core.security.SymmetricKeyCryptographyService
-
- All Implemented Interfaces:
AdaptrisComponent
,ComponentLifecycle
,ComponentLifecycleExtension
,MessageEventGenerator
,Service
,StateManagedComponent
@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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SymmetricKeyCryptographyService.OpMode
-
Field Summary
-
Fields inherited from class com.adaptris.core.ServiceImp
log
-
-
Constructor Summary
Constructors Constructor Description SymmetricKeyCryptographyService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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 appliedvoid
setInitialVector(DataInputParameter<java.lang.String> initialVector)
Set the initial vector for the algorithmvoid
setKey(DataInputParameter<java.lang.String> key)
Set the initial key the servicevoid
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)
-
Methods inherited from class com.adaptris.core.ServiceImp
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsTrackingEndpoint, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setUniqueId, start, stop
-
-
-
-
Method Detail
-
doService
public void doService(AdaptrisMessage msg) throws ServiceException
Description copied from interface:Service
Apply the service to the message.
- Parameters:
msg
- theAdaptrisMessage
to process- Throws:
ServiceException
- wrapping any underlyingException
s
-
initService
protected void initService() throws CoreException
- Specified by:
initService
in classServiceImp
- Throws:
CoreException
-
closeService
protected void closeService()
- Specified by:
closeService
in classServiceImp
-
prepare
public void prepare() throws CoreException
Description copied from interface:ComponentLifecycleExtension
Prepare for initialisation.- Throws:
CoreException
-
setAlgorithm
public void setAlgorithm(java.lang.String algorithm)
Set the name of the secret-key algorithm.This value is passed in as one of the parameters to
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.- Parameters:
algorithm
- the name of the secret-key algorithm to be associated with the given key.
-
getAlgorithm
public java.lang.String getAlgorithm()
-
withAlgorithm
public SymmetricKeyCryptographyService withAlgorithm(java.lang.String algorithm)
-
setCipherTransformation
public void setCipherTransformation(java.lang.String cipherTransformation)
Set the cipher transformation to be appliedThis 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.- Parameters:
cipherTransformation
- the name of the transformation, e.g.AES/CBC/PKCS5Padding
.
-
getCipherTransformation
public java.lang.String getCipherTransformation()
-
withCipherTransformation
public SymmetricKeyCryptographyService withCipherTransformation(java.lang.String cipherTransformation)
-
setInitialVector
public void setInitialVector(DataInputParameter<java.lang.String> initialVector)
Set the initial vector for the algorithmDepending on the algorithm you have chosen, then size of the initial vector will vary. For instance, for AES, it needs to be 16 bytes
- Parameters:
initialVector
- the Base64 encoded string of initial vector bytes.
-
getInitialVector
public DataInputParameter<java.lang.String> getInitialVector()
-
withInitialVector
public SymmetricKeyCryptographyService withInitialVector(DataInputParameter<java.lang.String> initialVector)
-
setKey
public void setKey(DataInputParameter<java.lang.String> key)
Set the initial key the serviceDepending on the algorithm you have chosen, then size of the key will vary. For instance, for AES, it needs to be 32 bytes
- Parameters:
key
- Base64 encoded string of key bytes.
-
getKey
public DataInputParameter<java.lang.String> getKey()
-
withKey
public SymmetricKeyCryptographyService withKey(DataInputParameter<java.lang.String> key)
-
setOperationMode
public void setOperationMode(SymmetricKeyCryptographyService.OpMode mode)
- Parameters:
mode
- the operation mode of the cipher: ENCRYPT or DECRYPT (default: DECRYPT)
-
getOperationMode
public SymmetricKeyCryptographyService.OpMode getOperationMode()
-
getSource
public MessageWrapper<java.io.InputStream> getSource()
-
setSource
public void setSource(MessageWrapper<java.io.InputStream> source)
Set the source for the input of the crypto service.- Parameters:
source
- the source.
-
withSource
public SymmetricKeyCryptographyService withSource(MessageWrapper<java.io.InputStream> source)
-
getTarget
public MessageWrapper<java.io.OutputStream> getTarget()
-
setTarget
public void setTarget(MessageWrapper<java.io.OutputStream> target)
Set the target for the output of the crypto service.- Parameters:
target
- the target.
-
withTarget
public SymmetricKeyCryptographyService withTarget(MessageWrapper<java.io.OutputStream> target)
-
-