Properties amazonProperties,
Properties nirvanixProperties,
Properties rackspaceProperties,
Properties localProperties )
{
CloudloopConfig config = new CloudloopConfig( );
Adapters adapters = new Adapters( );
config.setAdapters( adapters );
List<Adapter> adapterList = adapters.getAdapter( );
Adapter s3Adapter = new Adapter( );
s3Adapter.setImpl( AmazonS3CloudStore.class.getName( ) );
s3Adapter.setName( "amazonS3" );
s3Adapter.setType( AdapterType.STORAGE );
adapterList.add( s3Adapter );
Adapter nirvanixAdapter = new Adapter( );
nirvanixAdapter.setImpl( NirvanixCloudStore.class.getName( ) );
nirvanixAdapter.setName( "nirvanix" );
nirvanixAdapter.setType( AdapterType.STORAGE );
adapterList.add( nirvanixAdapter );
Adapter rackspaceAdapter = new Adapter( );
rackspaceAdapter.setImpl( RackspaceCloudStore.class.getName( ) );
rackspaceAdapter.setName( "rackspace" );
rackspaceAdapter.setType( AdapterType.STORAGE );
adapterList.add( rackspaceAdapter );
Adapter localAdapter = new Adapter( );
localAdapter.setImpl( LocalCloudStore.class.getName( ) );
localAdapter.setName( "local" );
localAdapter.setType( AdapterType.STORAGE );
adapterList.add( localAdapter );
Adapter jcloudsS3Adapter = new Adapter( );
jcloudsS3Adapter.setImpl( JS3CloudStore.class.getName( ) );
jcloudsS3Adapter.setName( "jS3" );
jcloudsS3Adapter.setType( AdapterType.STORAGE );
adapterList.add( jcloudsS3Adapter );
Stores stores = new Stores( );
config.setStores( stores );
List<Store> storeList = stores.getStore( );
Store s3Store = new Store( );
s3Store.setAdapter( "amazonS3" );
s3Store.setEncrypted( Boolean.TRUE );
s3Store.setName( "s3" );
List<PropertyType> s3Props = s3Store.getProperty( );
for ( Object propName : amazonProperties.keySet( ) )
{
PropertyType prop = new PropertyType( );
prop.setName( (String) propName );
prop.setValue( amazonProperties.getProperty( (String) propName ) );
s3Props.add( prop );
}
storeList.add( s3Store );
Store jS3Store = new Store( );
jS3Store.setAdapter( "jS3" );
jS3Store.setEncrypted( Boolean.TRUE );
jS3Store.setName( "s3" );
List<PropertyType> jS3Props = jS3Store.getProperty( );
for ( Object propName : amazonProperties.keySet( ) )
{
PropertyType prop = new PropertyType( );
prop.setName( (String) propName );
prop.setValue( amazonProperties.getProperty( (String) propName ) );
jS3Props.add( prop );
}
storeList.add( jS3Store );
Store nirvanixStore = new Store( );
nirvanixStore.setAdapter( "nirvanix" );
nirvanixStore.setEncrypted( Boolean.TRUE );
nirvanixStore.setName( "nirvanix" );
List<PropertyType> nirvanixProps = nirvanixStore.getProperty( );
for ( Object propName : nirvanixProperties.keySet( ) )
{
PropertyType prop = new PropertyType( );
prop.setName( (String) propName );
prop.setValue( nirvanixProperties.getProperty( (String) propName ) );
nirvanixProps.add( prop );
}
storeList.add( nirvanixStore );
Store rackspaceStore = new Store( );
rackspaceStore.setAdapter( "rackspace" );
rackspaceStore.setEncrypted( Boolean.TRUE );
rackspaceStore.setName( "rackspace" );
List<PropertyType> rackspaceProps = rackspaceStore.getProperty( );
for ( Object propName : rackspaceProperties.keySet( ) )
{
PropertyType prop = new PropertyType( );
prop.setName( (String) propName );
prop
.setValue( rackspaceProperties
.getProperty( (String) propName ) );
rackspaceProps.add( prop );
}
storeList.add( rackspaceStore );
Store localStore = new Store( );
localStore.setAdapter( "local" );
localStore.setEncrypted( Boolean.FALSE );
localStore.setName( "local" );
List<PropertyType> localProps = localStore.getProperty( );
PropertyType localRoot = new PropertyType( );
for ( Object propName : localProperties.keySet( ) )
{
PropertyType prop = new PropertyType( );
prop.setName( (String) propName );
prop.setValue( localProperties.getProperty( (String) propName ) );
localProps.add( prop );
}
localProps.add( localRoot );
storeList.add( localStore );
Encryption encryption = new Encryption( );
encryption.setCipher( EncryptionUtil.DEFAULT_CIPHER );
File currDir = new File( "./test-keys/" );
FileUtil.mkdir( currDir );
encryption.setKeyDirectory( currDir.getAbsolutePath( ) );
encryption.setKeyLength( 128 );
File keyFile = new File( currDir, TimeUtil.getConciseTimestamp( )
+ ".key" );
EncryptionUtil
.generateKey( EncryptionUtil.DEFAULT_CIPHER, 128, keyFile );
encryption.setPreferredKey( keyFile.getName( ) );
config.setEncryption( encryption );
return config;
}