forked from WebGoat/WebGoat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Users shared now between WebGoat and WebWolf by starting HSQLDB
as standalone database
- Loading branch information
Showing
8 changed files
with
63 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
webgoat-server/src/main/java/org/owasp/webgoat/HSQLDBDatabaseConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package org.owasp.webgoat; | ||
|
||
import org.hsqldb.server.Server; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.DependsOn; | ||
import org.springframework.context.annotation.Primary; | ||
|
||
import javax.sql.DataSource; | ||
|
||
|
||
/** | ||
* Rationale for this class: when the HSQLDB is started with jdbc:file:// it is only accessible from within the same | ||
* JVM. This can only be done if you start a standalone HSQLDB. We need both WebWolf and WebGoat to use the same database | ||
*/ | ||
@Configuration | ||
@ConditionalOnProperty(prefix = "webgoat.start", name = "hsqldb", havingValue = "true") | ||
public class HSQLDBDatabaseConfig { | ||
|
||
@Value("${hsqldb.port:9001}") | ||
private int hsqldbPort; | ||
|
||
@Bean(initMethod = "start", destroyMethod = "stop") | ||
public Server hsqlStandalone(@Value("${webgoat.server.directory}") String directory, | ||
@Value("${hsqldb.silent:true}") boolean silent, | ||
@Value("${hsqldb.trace:false}") boolean trace) { | ||
|
||
Server server = new Server(); | ||
server.setDatabaseName(0, "webgoat"); | ||
server.setDatabasePath(0, directory + "/data/webgoat"); | ||
server.setDaemon(true); | ||
server.setTrace(trace); | ||
server.setSilent(silent); | ||
server.setPort(hsqldbPort); | ||
return server; | ||
} | ||
|
||
@Primary | ||
@Bean | ||
@DependsOn("hsqlStandalone") | ||
public DataSource dataSource(@Value("${spring.datasource.driver-class-name}") String driverClass, | ||
@Value("${spring.datasource.url}") String url) { | ||
return DataSourceBuilder.create() | ||
.driverClassName(driverClass) | ||
.url(url) | ||
.build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters