Search in sources :

Example 6 with TransformerTO

use of org.syncany.config.to.RepoTO.TransformerTO in project syncany by syncany.

the class DefaultRepoTOFactory method getTransformersTO.

public List<TransformerTO> getTransformersTO(boolean gzipEnabled, List<CipherSpec> cipherSpecs) {
    List<TransformerTO> transformersTO = new ArrayList<TransformerTO>();
    if (gzipEnabled) {
        transformersTO.add(getGzipTransformerTO());
    }
    if (cipherSpecs.size() > 0) {
        TransformerTO cipherTransformerTO = getCipherTransformerTO(cipherSpecs);
        transformersTO.add(cipherTransformerTO);
    }
    return transformersTO;
}
Also used : TransformerTO(org.syncany.config.to.RepoTO.TransformerTO) ArrayList(java.util.ArrayList)

Example 7 with TransformerTO

use of org.syncany.config.to.RepoTO.TransformerTO in project syncany by syncany.

the class DefaultRepoTOFactory method getCipherTransformerTO.

protected TransformerTO getCipherTransformerTO(List<CipherSpec> cipherSpec) {
    String cipherSuitesIdStr = StringUtil.join(cipherSpec, ",", new StringJoinListener<CipherSpec>() {

        @Override
        public String getString(CipherSpec cipherSpec) {
            return "" + cipherSpec.getId();
        }
    });
    Map<String, String> cipherTransformerSettings = new HashMap<String, String>();
    cipherTransformerSettings.put(CipherTransformer.PROPERTY_CIPHER_SPECS, cipherSuitesIdStr);
    // Note: Property 'password' is added dynamically by CommandLineClient
    TransformerTO cipherTransformerTO = new TransformerTO();
    cipherTransformerTO.setType(CipherTransformer.TYPE);
    cipherTransformerTO.setSettings(cipherTransformerSettings);
    return cipherTransformerTO;
}
Also used : HashMap(java.util.HashMap) TransformerTO(org.syncany.config.to.RepoTO.TransformerTO) CipherSpec(org.syncany.crypto.CipherSpec)

Example 8 with TransformerTO

use of org.syncany.config.to.RepoTO.TransformerTO in project syncany by syncany.

the class ConfigTest method testConfigCipherTransformersCipherFound.

@Test
@SuppressWarnings("serial")
public void testConfigCipherTransformersCipherFound() throws Exception {
    // Setup
    File localDir = new File("/some/folder");
    ConfigTO configTO = new ConfigTO();
    RepoTO repoTO = new RepoTO();
    // <<< valid
    configTO.setMachineName("somevalidmachinename");
    // <<< valid
    repoTO.setChunkerTO(TestConfigUtil.createFixedChunkerTO());
    // <<< valid
    repoTO.setMultiChunker(TestConfigUtil.createZipMultiChunkerTO());
    // <<< valid
    repoTO.setRepoId(new byte[] { 0x01, 0x02 });
    // <<< valid
    configTO.setMasterKey(createDummyMasterKey());
    // Set invalid transformer
    TransformerTO invalidTransformerTO = new TransformerTO();
    invalidTransformerTO.setType("cipher");
    invalidTransformerTO.setSettings(new HashMap<String, String>() {

        {
            put("cipherspecs", "1,2");
        }
    });
    List<TransformerTO> transformers = new ArrayList<TransformerTO>();
    transformers.add(invalidTransformerTO);
    // <<< valid
    repoTO.setTransformers(transformers);
    // Run!
    Config config = new Config(localDir, configTO, repoTO);
    // Test
    assertNotNull(config.getChunker());
    assertNotNull(config.getMultiChunker());
    assertNotNull(config.getTransformer());
    assertEquals("CipherTransformer", config.getTransformer().getClass().getSimpleName());
}
Also used : TransformerTO(org.syncany.config.to.RepoTO.TransformerTO) Config(org.syncany.config.Config) ArrayList(java.util.ArrayList) ConfigTO(org.syncany.config.to.ConfigTO) RepoTO(org.syncany.config.to.RepoTO) File(java.io.File) Test(org.junit.Test)

Example 9 with TransformerTO

use of org.syncany.config.to.RepoTO.TransformerTO in project syncany by syncany.

the class TestConfigUtil method createRepoTO.

public static RepoTO createRepoTO() {
    // Create Repo TO
    RepoTO repoTO = new RepoTO();
    repoTO.setRepoId(new byte[] { 0x01, 0x02, 0x03 });
    // Create ChunkerTO and MultiChunkerTO
    MultiChunkerTO multiChunkerTO = createZipMultiChunkerTO();
    ChunkerTO chunkerTO = createFixedChunkerTO();
    // TODO [low] Chunker not configurable right now. Not used.
    repoTO.setChunkerTO(chunkerTO);
    repoTO.setMultiChunker(multiChunkerTO);
    // Create TransformerTO
    List<TransformerTO> transformerTOs = createTransformerTOs();
    repoTO.setTransformers(transformerTOs);
    return repoTO;
}
Also used : ChunkerTO(org.syncany.config.to.RepoTO.ChunkerTO) MultiChunkerTO(org.syncany.config.to.RepoTO.MultiChunkerTO) MultiChunkerTO(org.syncany.config.to.RepoTO.MultiChunkerTO) TransformerTO(org.syncany.config.to.RepoTO.TransformerTO) RepoTO(org.syncany.config.to.RepoTO)

Aggregations

TransformerTO (org.syncany.config.to.RepoTO.TransformerTO)9 ArrayList (java.util.ArrayList)5 RepoTO (org.syncany.config.to.RepoTO)4 File (java.io.File)3 Test (org.junit.Test)3 Config (org.syncany.config.Config)3 ConfigTO (org.syncany.config.to.ConfigTO)3 HashMap (java.util.HashMap)2 ConfigException (org.syncany.config.ConfigException)2 CipherTransformer (org.syncany.chunk.CipherTransformer)1 NoTransformer (org.syncany.chunk.NoTransformer)1 Transformer (org.syncany.chunk.Transformer)1 ChunkerTO (org.syncany.config.to.RepoTO.ChunkerTO)1 MultiChunkerTO (org.syncany.config.to.RepoTO.MultiChunkerTO)1 CipherSpec (org.syncany.crypto.CipherSpec)1