Package org.syncany.chunk
Class CipherTransformer
- java.lang.Object
-
- org.syncany.chunk.Transformer
-
- org.syncany.chunk.CipherTransformer
-
public class CipherTransformer extends Transformer
The CipherTransformer can be used to encrypt/decrypt files (typicallyMultiChunk
s) using theMultiCipherOutputStream
andMultiCipherInputStream
. A CipherTransformer requires a list ofCipherSpec
s and the master key. It can be instantiated using a property list (from a config file) or by passing the dependencies to the constructor.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
PROPERTY_CIPHER_SPECS
static java.lang.String
PROPERTY_MASTER_KEY
static java.lang.String
PROPERTY_MASTER_KEY_SALT
static java.lang.String
TYPE
-
Fields inherited from class org.syncany.chunk.Transformer
nextTransformer
-
-
Constructor Summary
Constructors Constructor Description CipherTransformer()
CipherTransformer(java.util.List<CipherSpec> cipherSpecs, SaltedSecretKey masterKey)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.InputStream
createInputStream(java.io.InputStream in)
Creates a strea-transformingInputStream
.java.io.OutputStream
createOutputStream(java.io.OutputStream out)
Create a stream-transformingOutputStream
.void
init(java.util.Map<java.lang.String,java.lang.String> settings)
Initializes the cipher transformer using a settings map.java.lang.String
toString()
An implementation of a transformer must override this method to identify the type of transformer and/or its settings.-
Methods inherited from class org.syncany.chunk.Transformer
getInstance, setNextTransformer
-
-
-
-
Field Detail
-
TYPE
public static final java.lang.String TYPE
- See Also:
- Constant Field Values
-
PROPERTY_CIPHER_SPECS
public static final java.lang.String PROPERTY_CIPHER_SPECS
- See Also:
- Constant Field Values
-
PROPERTY_MASTER_KEY
public static final java.lang.String PROPERTY_MASTER_KEY
- See Also:
- Constant Field Values
-
PROPERTY_MASTER_KEY_SALT
public static final java.lang.String PROPERTY_MASTER_KEY_SALT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CipherTransformer
public CipherTransformer()
-
CipherTransformer
public CipherTransformer(java.util.List<CipherSpec> cipherSpecs, SaltedSecretKey masterKey)
-
-
Method Detail
-
init
public void init(java.util.Map<java.lang.String,java.lang.String> settings) throws java.lang.Exception
Initializes the cipher transformer using a settings map. Required settings are:PROPERTY_CIPHER_SPECS
,PROPERTY_MASTER_KEY
andPROPERTY_MASTER_KEY_SALT
.- Specified by:
init
in classTransformer
- Parameters:
settings
- Implementation-specific setting map- Throws:
java.lang.Exception
- If the given settings are invalid or insufficient for instantiation
-
createOutputStream
public java.io.OutputStream createOutputStream(java.io.OutputStream out) throws java.io.IOException
Description copied from class:Transformer
Create a stream-transformingOutputStream
. Depending on the implementation, the bytes written to the output stream might be encrypted, compressed, etc.- Specified by:
createOutputStream
in classTransformer
- Parameters:
out
- Original output stream which is transformed by this transformer- Returns:
- Returns a transformed output stream
- Throws:
java.io.IOException
- If an exception occurs when instantiating or writing to the stream
-
createInputStream
public java.io.InputStream createInputStream(java.io.InputStream in) throws java.io.IOException
Description copied from class:Transformer
Creates a strea-transformingInputStream
. Depending on the implementation, the bytes read from the input stream are uncompressed, decrypted, etc.- Specified by:
createInputStream
in classTransformer
- Parameters:
in
- Original input stream which is transformed by this transformer- Returns:
- Returns a transformed input stream
- Throws:
java.io.IOException
- If an exception occurs when instantiating or reading from the stream
-
toString
public java.lang.String toString()
Description copied from class:Transformer
An implementation of a transformer must override this method to identify the type of transformer and/or its settings.- Specified by:
toString
in classTransformer
-
-