package com.emc.ecs.serviceBroker.config;

import java.net.URL;

import org.cloudfoundry.community.servicebroker.model.BrokerApiVersion;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

import com.emc.ecs.managementClient.Connection;
import com.emc.ecs.serviceBroker.repository.EcsRepositoryCredentials;

@Configuration
@ComponentScan(basePackages = "com.emc.ecs.serviceBroker")
public class BrokerConfig {
	
	@Value("${endpoint}")
	private String endpoint;
	
	@Value("${port}:4443")
	private String port;
	
	@Value("${username}:root")
	private String username;
	
	@Value("${password}:ChangeMe")
	private String password;
	
	@Value("${replicationGroup}")
	private String replicationGroup;
	
	@Value("${namespace}")
	private String namespace;
	
	@Value("${repositoryUser}")
	private String repositoryUser;
	
	@Value("${repositoryBucket}")
	private String repositoryBucket;
	
	@Value("${prefix}:ecs-cf-broker-")
	private String prefix;

	@Bean
	public Connection ecsConnection() {
		URL certificate = getClass().getClassLoader().getResource("localhost.pem");
		return new Connection("https://" + endpoint + ":" + port, username, password, certificate);
	}
	
	@Bean
	public BrokerApiVersion brokerApiVersion() {
		return new BrokerApiVersion("2.7");
	}
	
	@Bean
	public EcsRepositoryCredentials getRepositoryCredentials() {
		return new EcsRepositoryCredentials(repositoryBucket, repositoryUser, namespace, replicationGroup, prefix);
	}
}
@@ -653,18 +653,18 @@
 (%22$%7B
-port%7D:4443
+namespace%7D
 %22)%0A%09
@@ -678,20 +678,25 @@
  String 
-port
+namespace
 ;%0A%09%0A%09@Va
@@ -706,22 +706,25 @@
 (%22$%7B
-username%7D:root
+replicationGroup%7D
 %22)%0A%09
@@ -742,49 +742,59 @@
 ing 
-username;%0A%09%0A%09@Value(%22$%7Bpassword%7D:ChangeMe
+replicationGroup;%0A%09%0A%09@Value(%22$%7BrepositoryUser%7D:user
 %22)%0A%09
@@ -808,24 +808,30 @@
  String 
-password
+repositoryUser
 ;%0A%09%0A%09@Va
@@ -837,33 +837,26 @@
 alue(%22$%7B
-replicationGroup%7D
+port%7D:4443
 %22)%0A%09priv
@@ -866,32 +866,20 @@
  String 
-replicationGroup
+port
 ;%0A%09%0A%09@Va
@@ -881,34 +881,38 @@
 %0A%09@Value(%22$%7B
-namespace%7D
+username%7D:root
 %22)%0A%09private 
@@ -914,32 +914,31 @@
 vate String 
-namespac
+usernam
 e;%0A%09%0A%09@Value
@@ -941,31 +941,34 @@
 alue(%22$%7B
-repositoryUser%7D
+password%7D:ChangeMe
 %22)%0A%09priv
@@ -974,38 +974,32 @@
 vate String 
-repositoryUser
+password
 ;%0A%09%0A%09@Value(
@@ -1018,16 +1018,27 @@
 yBucket%7D
+:repository
 %22)%0A%09priv

Add more environment defaults