Skip to content

Commit

Permalink
Fix dependencies, migrated H2 to HSQLDB
Browse files Browse the repository at this point in the history
H2 2.x is not compatible with 1.4.x, but 1.4.x has some vulnerabilities.
It's easier to migrate to HSQLDB altogether. The H2 console is removed
because HSQLDB does not have a console.
  • Loading branch information
blootsvoets committed Jan 19, 2022
1 parent c72b61d commit d559376
Show file tree
Hide file tree
Showing 26 changed files with 52 additions and 90 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ dependencies {
implementation "org.hibernate:hibernate-validator:7.0.1.Final"

implementation "org.postgresql:postgresql:${postgresql_version}"
implementation "com.h2database:h2"
implementation "org.hsqldb:hsqldb:${hsqldb_version}"

implementation "org.springframework.boot:spring-boot-starter-security"
implementation "org.springframework.security:spring-security-data"
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ logback_version=1.2.10
oauth_jwt_version=3.18.3
junit_version=5.8.2
okhttp_version=4.9.3
hsqldb_version=2.6.1

kotlin.code.style=official
org.gradle.vfs.watch=true
Expand Down
3 changes: 1 addition & 2 deletions proxy.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"/management",
"/api-docs",
"/swagger-ui.html",
"/swagger-ui",
"/h2-console"
"/swagger-ui"
],
"target": "http://127.0.0.1:8080",
"secure": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module;
import liquibase.integration.spring.SpringLiquibase;
import org.h2.tools.Server;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.liquibase.LiquibaseProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.core.env.Environment;
import org.springframework.core.env.Profiles;
import org.springframework.data.envers.repository.support.EnversRevisionRepositoryFactoryBean;
Expand All @@ -19,7 +17,6 @@
import tech.jhipster.config.JHipsterConstants;

import javax.sql.DataSource;
import java.sql.SQLException;

@Configuration
@EnableJpaRepositories(basePackages = "org.radarbase.management.repository",
Expand All @@ -33,18 +30,6 @@ public class DatabaseConfiguration {
@Autowired
private Environment env;

/**
* Open the TCP port for the H2 database, so it is available remotely.
*
* @return the H2 database TCP server
* @throws SQLException if the server failed to start
*/
@Bean(initMethod = "start", destroyMethod = "stop")
@Profile(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)
public Server h2TCPServer() throws SQLException {
return Server.createTcpServer("-tcp", "-tcpAllowOthers");
}

@Bean
public SpringLiquibase liquibase(DataSource dataSource,
LiquibaseProperties liquibaseProperties) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ public void configure(WebSecurity web) {
.antMatchers("/api/account/reset_password/init")
.antMatchers("/api/account/reset_password/finish")
.antMatchers("/test/**")
.antMatchers("/h2-console/**")
.antMatchers("/management/health")
.antMatchers(HttpMethod.GET, "/api/meta-token/**");
}
Expand Down
17 changes: 0 additions & 17 deletions src/main/java/org/radarbase/management/config/WebConfigurer.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import javax.servlet.DispatcherType;
import javax.servlet.FilterRegistration;
import javax.servlet.ServletContext;
import javax.servlet.ServletRegistration;
import java.io.File;
import java.nio.file.Paths;
import java.util.Arrays;
Expand Down Expand Up @@ -55,9 +54,6 @@ public void onStartup(ServletContext servletContext) {
.of(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.ASYNC);
initCachingHttpHeadersFilter(servletContext, disps);
}
if (env.acceptsProfiles(Profiles.of(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT))) {
initH2Console(servletContext);
}
log.info("Web application fully configured");
}

Expand Down Expand Up @@ -132,17 +128,4 @@ public CorsFilter corsFilter() {
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}

/**
* Initializes H2 console.
*/
private void initH2Console(ServletContext servletContext) {
log.debug("Initialize H2 console");
ServletRegistration.Dynamic h2ConsoleServlet = servletContext
.addServlet("H2Console", new org.h2.server.web.WebServlet());
h2ConsoleServlet.addMapping("/h2-console/*");
h2ConsoleServlet.setInitParameter("-properties", "src/main/resources/");
h2ConsoleServlet.setLoadOnStartup(1);
}

}
6 changes: 0 additions & 6 deletions src/main/resources/.h2.server.properties

This file was deleted.

9 changes: 4 additions & 5 deletions src/main/resources/config/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,15 @@ spring:
jackson:
serialization.indent_output: true
datasource:
url: jdbc:h2:mem:managementportal;DB_CLOSE_DELAY=-1
url: jdbc:hsqldb:mem:managementportal;DB_CLOSE_DELAY=-1
username: ManagementPortal
password:
h2:
console:
enabled: true
path: /h2-console
enabled: false
jpa:
database-platform: org.hibernate.dialect.H2Dialect
database: H2
database-platform: org.hibernate.dialect.HSQLDialect
database: HSQL
show-sql: true
properties:
hibernate.id.new_generator_mappings: true
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/config/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ spring:
jdbc:
lob:
non_contextual_creation: true
main:
allow-circular-references: true
messages:
basename: i18n/messages
thymeleaf:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">

<property name="now" value="now()" dbms="h2"/>
<property name="now" value="now()" dbms="hsqldb"/>
<property name="now" value="current_timestamp" dbms="postgresql"/>
<property name="autoIncrement" value="true"/>

<changeSet id="00000000000000" author="jhipster" dbms="postgresql,oracle,h2">
<changeSet id="00000000000000" author="jhipster" dbms="postgresql,oracle,hsqldb">
<createSequence sequenceName="hibernate_sequence" startValue="1000" incrementBy="50"/>
</changeSet>
<!--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">

<property name="now" value="now()" dbms="h2"/>
<property name="now" value="now()" dbms="hsqldb"/>

<property name="now" value="now()" dbms="mysql"/>
<property name="autoIncrement" value="true"/>

<property name="floatType" value="float4" dbms="postgresql, h2"/>
<property name="floatType" value="float4" dbms="postgresql,hsqldb"/>
<property name="floatType" value="float" dbms="mysql, oracle, mssql"/>

<!--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">

<property name="now" value="now()" dbms="h2"/>
<property name="now" value="now()" dbms="hsqldb"/>

<property name="now" value="now()" dbms="mysql"/>
<property name="autoIncrement" value="true"/>

<property name="floatType" value="float4" dbms="postgresql, h2"/>
<property name="floatType" value="float4" dbms="postgresql,hsqldb"/>
<property name="floatType" value="float" dbms="mysql, oracle, mssql"/>

<property name="uuid_type" value="uuid" dbms="postgresql, h2"/>
<property name="uuid_type" value="uuid" dbms="postgresql,hsqldb"/>
<property name="uuid_type" value="uniqueidentifier" dbms="mssql"/>
<property name="uuid_type" value="RAW(32)" dbms="oracle"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">

<property name="now" value="now()" dbms="h2"/>
<property name="now" value="now()" dbms="hsqldb"/>

<property name="now" value="now()" dbms="mysql"/>
<property name="autoIncrement" value="true"/>

<property name="floatType" value="float4" dbms="postgresql, h2"/>
<property name="floatType" value="float4" dbms="postgresql,hsqldb"/>
<property name="floatType" value="float" dbms="mysql, oracle, mssql"/>

<!--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">

<property name="now" value="now()" dbms="h2"/>
<property name="now" value="now()" dbms="hsqldb"/>

<property name="now" value="now()" dbms="mysql"/>
<property name="autoIncrement" value="true"/>

<property name="floatType" value="float4" dbms="postgresql, h2"/>
<property name="floatType" value="float4" dbms="postgresql,hsqldb"/>
<property name="floatType" value="float" dbms="mysql, oracle, mssql"/>

<!--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">

<property name="now" value="now()" dbms="mysql,h2"/>
<property name="now" value="now()" dbms="mysql,hsqldb"/>
<property name="now" value="current_timestamp" dbms="postgresql"/>
<property name="now" value="sysdate" dbms="oracle"/>
<property name="now" value="GETDATE()" dbms="mssql"/>

<property name="autoIncrement" value="true" dbms="mysql,h2,postgresql,oracle,mssql"/>

<property name="floatType" value="float4" dbms="postgresql, h2"/>
<property name="floatType" value="float4" dbms="postgresql,hsqldb"/>
<property name="floatType" value="float" dbms="mysql, oracle, mssql"/>

<!--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">

<property name="now" value="now()" dbms="mysql,h2"/>
<property name="now" value="now()" dbms="mysql,hsqldb"/>
<property name="now" value="current_timestamp" dbms="postgresql"/>
<property name="now" value="sysdate" dbms="oracle"/>
<property name="now" value="GETDATE()" dbms="mssql"/>

<property name="autoIncrement" value="true" dbms="mysql,h2,postgresql,oracle,mssql"/>

<property name="floatType" value="float4" dbms="postgresql, h2"/>
<property name="floatType" value="float4" dbms="postgresql,hsqldb"/>
<property name="floatType" value="float" dbms="mysql, oracle, mssql"/>

<!--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">

<property name="now" value="now()" dbms="mysql,h2"/>
<property name="now" value="now()" dbms="mysql,hsqldb"/>
<property name="now" value="current_timestamp" dbms="postgresql"/>
<property name="now" value="sysdate" dbms="oracle"/>
<property name="now" value="GETDATE()" dbms="mssql"/>

<property name="autoIncrement" value="true" dbms="mysql,h2,postgresql,oracle,mssql"/>

<property name="floatType" value="float4" dbms="postgresql, h2"/>
<property name="floatType" value="float4" dbms="postgresql,hsqldb"/>
<property name="floatType" value="float" dbms="mysql, oracle, mssql"/>

<!--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">

<property name="now" value="now()" dbms="mysql,h2"/>
<property name="now" value="now()" dbms="mysql,hsqldb"/>
<property name="now" value="current_timestamp" dbms="postgresql"/>
<property name="now" value="sysdate" dbms="oracle"/>
<property name="now" value="GETDATE()" dbms="mssql"/>

<property name="autoIncrement" value="true" dbms="mysql,h2,postgresql,oracle,mssql"/>

<property name="floatType" value="float4" dbms="postgresql, h2"/>
<property name="floatType" value="float4" dbms="postgresql,hsqldb"/>
<property name="floatType" value="float" dbms="mysql, oracle, mssql"/>

<!--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">

<property name="now" value="now()" dbms="mysql,h2"/>
<property name="now" value="now()" dbms="mysql,hsqldb"/>
<property name="now" value="current_timestamp" dbms="postgresql"/>
<property name="now" value="sysdate" dbms="oracle"/>
<property name="now" value="GETDATE()" dbms="mssql"/>

<property name="autoIncrement" value="true" dbms="mysql,h2,postgresql,oracle,mssql"/>

<property name="floatType" value="float4" dbms="postgresql, h2"/>
<property name="floatType" value="float4" dbms="postgresql,hsqldb"/>
<property name="floatType" value="float" dbms="mysql, oracle, mssql"/>

<!--
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">
<property name="now" value="now()" dbms="h2"/>
<property name="now" value="now()" dbms="hsqldb"/>
<property name="now" value="current_timestamp" dbms="postgresql"/>
<property name="revtype" value="tinyint" dbms="h2"/>
<property name="revtype" value="tinyint" dbms="hsqldb"/>
<property name="revtype" value="smallint" dbms="postgresql"/>

<changeSet id="set hsqldb regular names to false" author="[email protected]" dbms="hsqldb">
<sql>
SET DATABASE SQL REGULAR NAMES FALSE;
</sql>
</changeSet>

<!-- First we add the necessary tables, then we initialize a base revision which sets all
currently existing entities in the database as being created by the system at the point
of migration. Finally, we drop the old auditing columns. -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
http://www.liquibase.org/xml/ns/dbchangelog-ext https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">

<property name="autoIncrement" value="true" dbms="mysql,h2,postgresql,oracle,mssql"/>
<property name="revtype" value="tinyint" dbms="h2"/>
<property name="revtype" value="tinyint" dbms="hsqldb"/>
<property name="revtype" value="smallint" dbms="postgresql"/>

<!--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,17 @@
-->

<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.7.xsd">

<changeSet id="20211026-1" author="[email protected]">
<loadData encoding="UTF-8"
file="config/liquibase/group.csv"
separator=";"
tableName="radar_group">
</loadData>
<!--
<!--
We can add group_id to subject.csv, but I assume
we'll switch to many-to-many subject-group relationship later on,
and I want to keep the old 201708301031-2 changeset intact.
Expand All @@ -31,7 +29,8 @@
file="config/liquibase/subject_group.csv"
primaryKey="id"
separator=";"
tableName="subject">
tableName="subject"
onlyUpdate="true">
</loadUpdateData>
</changeSet>
</databaseChangeLog>
2 changes: 1 addition & 1 deletion src/main/resources/config/liquibase/organization_roles.csv
Original file line number Diff line number Diff line change
@@ -1 +1 @@
id;authority_name;project_id;organization_id;created_by
id;authority_name;project_id;organization_id
2 changes: 1 addition & 1 deletion src/main/resources/config/liquibase/organization_user.csv
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"ID";"LOGIN";"PASSWORD_HASH";"FIRST_NAME";"LAST_NAME";"EMAIL";"ACTIVATED";"LANG_KEY";"CREATED_BY";"LAST_MODIFIED_BY"
"ID";"LOGIN";"PASSWORD_HASH";"FIRST_NAME";"LAST_NAME";"EMAIL";"ACTIVATED";"LANG_KEY"
7 changes: 0 additions & 7 deletions src/main/webapp/app/layouts/navbar/navbar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,6 @@
<span [translate]="'global.menu.admin.apidocs'"></span>
</a>
</li>
<!-- jhipster-needle-add-element-to-admin-menu - JHipster will add entities to the admin menu here -->
<li *ngIf="!inProduction">
<a class="dropdown-item" href='/h2-console' target="_tab" (click)="collapseNavbar()">
<i class="fa fa-fw fa-hdd-o" aria-hidden="true"></i>
<span [translate]="'global.menu.admin.database'"></span>
</a>
</li>
</ul>
</li>

Expand Down
Loading

0 comments on commit d559376

Please sign in to comment.