link to remote host hsqldb

This commit is contained in:
René Zubcevic 2021-12-23 09:10:43 +01:00
parent f1f5c352df
commit 833e09fced
2 changed files with 13 additions and 1 deletions

View File

@ -65,13 +65,24 @@ public class DataSourceResolver {
@Value("${webgoat.actuator.configprops.path:/configprops}")
private String configPropsPath;
@Value("${hsqldb.address}")
private String hsqlHost;
@Autowired
ApplicationContext ctx;
@Bean
@DependsOn("dsConfigDiscovery")
public DataSource dataSource(DataSourceProperties dataSourceProperties) {
DriverManagerDataSource driverManagerDataSource = new DriverManagerDataSource(dataSourceProperties.getUrl());
String connectString = dataSourceProperties.getUrl();
/**
* Replace the server address as reported by webgoat by the one that is given
* to WebWolf as the address of WebGoat. In case it doesn't run locally.
*/
if (connectString!=null) {
connectString = connectString.replace("0.0.0.0", hsqlHost);
}
DriverManagerDataSource driverManagerDataSource = new DriverManagerDataSource(connectString);
driverManagerDataSource.setDriverClassName(dataSourceProperties.getDriverClassName());
return driverManagerDataSource;
}

View File

@ -6,6 +6,7 @@ server.port=${WEBWOLF_PORT:9090}
server.address=${WEBWOLF_HOST:127.0.0.1}
server.servlet.session.cookie.name=WEBWOLFSESSION
server.servlet.session.timeout=6000
hsqldb.address=${WEBGOAT_HOST:127.0.0.1}
spring.jpa.properties.hibernate.default_schema=CONTAINER
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.HSQLDialect