Skip to content

Commit

Permalink
Merge branch 'v2_11_0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins committed Aug 24, 2022
2 parents 41253c3 + 00a83cb commit 6c18225
Show file tree
Hide file tree
Showing 174 changed files with 8,424 additions and 1,746 deletions.
2 changes: 1 addition & 1 deletion BudgetMasterDatabaseMigrator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>BudgetMaster</artifactId>
<groupId>de.deadlocker8</groupId>
<version>2.10.0</version>
<version>2.11.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void afterEach()
}

@Container
static PostgreSQLContainer<?> postgresDB = new PostgreSQLContainer<>("postgres:14.3")
static PostgreSQLContainer<?> postgresDB = new PostgreSQLContainer<>("postgres:14.5")
.withDatabaseName("budgetmaster-tests-db")
.withUsername("budgetmaster")
.withPassword("BudgetMaster");
Expand Down
38 changes: 6 additions & 32 deletions BudgetMasterServer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>BudgetMaster</artifactId>
<groupId>de.deadlocker8</groupId>
<version>2.10.0</version>
<version>2.11.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -29,18 +29,17 @@
<webjars-locator.version>0.45</webjars-locator.version>
<jquery.version>3.6.0</jquery.version>
<materializecss.version>1.0.0</materializecss.version>
<fontawesome.version>6.1.0</fontawesome.version>
<sortablejs.version>1.14.0</sortablejs.version>
<fontawesome.version>6.1.2</fontawesome.version>
<sortablejs.version>1.15.0</sortablejs.version>
<mousetrap.version>1.6.5</mousetrap.version>
<codemirror.version>5.62.2</codemirror.version>
<selenium.version>4.1.4</selenium.version>
<assertj-core.version>3.22.0</assertj-core.version>
<jgit.version>6.1.0.202203080745-r</jgit.version>
<selenium.version>4.4.0</selenium.version>
<assertj-core.version>3.23.1</assertj-core.version>
<jgit.version>6.2.0.202206071550-r</jgit.version>
<natorder.version>1.1.2</natorder.version>
<itextpdf.version>5.5.13.3</itextpdf.version>
<vanilla-picker.version>2.12.1</vanilla-picker.version>
<jacoco-maven-plugin.version>0.8.8</jacoco-maven-plugin.version>
<dependency-check-maven.version>7.1.0</dependency-check-maven.version>

<project.outputDirectory>${project.build.directory}/../build/${project.version}</project.outputDirectory>
<project.artifactName>${project.artifactId}-v${project.version}</project.artifactName>
Expand Down Expand Up @@ -284,31 +283,6 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
<version>${dependency-check-maven.version}</version>
<inherited>false</inherited>
<configuration>
<skip>false</skip>
<cveValidForHours>48</cveValidForHours>
<assemblyAnalyzerEnabled>false</assemblyAnalyzerEnabled>
<failOnError>false</failOnError>
<formats>
<format>HTML</format>
<format>XML</format>
</formats>
</configuration>
<executions>
<execution>
<goals>
<goal>aggregate</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public boolean useMultipleResourceBundles()
ProgramArgs.setArgs(Arrays.asList(args));
LOGGER.debug(MessageFormat.format("Starting with ProgramArgs: {0}", ProgramArgs.getArgs()));

Path applicationSupportFolder = getApplicationSupportFolder();
Path applicationSupportFolder = getApplicationSupportFolder(false);
PathUtils.createDirectoriesIfNotExists(applicationSupportFolder);

Path settingsPath = applicationSupportFolder.resolve("settings.properties");
Expand All @@ -92,7 +92,7 @@ public boolean useMultipleResourceBundles()
return applicationSupportFolder;
}

public static Path getApplicationSupportFolder()
public static Path getApplicationSupportFolder(boolean suppressLog)
{
if(System.getProperties().containsKey("testProfile"))
{
Expand All @@ -119,27 +119,50 @@ else if(ProgramArgs.isDebug())
}
}

savePath = determineFolder(savePath);
LOGGER.info(MessageFormat.format("Used save path: {0}", savePath));
savePath = determineFolder(savePath, suppressLog);
if(!suppressLog)
{
LOGGER.info(MessageFormat.format("Used save path: {0}", savePath));
}
return savePath;
}

private static Path determineFolder(Path baseFolder)
private static Path determineFolder(Path baseFolder, boolean suppressLog)
{
switch(RunMode.currentRunMode)
{
case NORMAL:
LOGGER.info("Starting in NORMAL Mode");
case NORMAL ->
{
if(!suppressLog)
{
LOGGER.info("Starting in NORMAL Mode");
}
return baseFolder;
case DEBUG:
LOGGER.info("Starting in DEBUG Mode");
}
case DEBUG ->
{
if(!suppressLog)
{
LOGGER.info("Starting in DEBUG Mode");
}
return baseFolder.resolve("debug");
case TEST:
LOGGER.info("Starting in TEST Mode");
}
case TEST ->
{
if(!suppressLog)
{
LOGGER.info("Starting in TEST Mode");
}
return baseFolder.resolve("test");
default:
LOGGER.warn("Mode not supported! Starting in NORMAL Mode");
}
default ->
{
if(!suppressLog)
{
LOGGER.warn("Mode not supported! Starting in NORMAL Mode");
}
return baseFolder;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
@Entity
public class Account implements ProvidesID, Iconizable
{
private static final String ACCOUNT_FONT_COLOR = "#2E79B9";
private static final String FONT_COLOR_LIGHT_THEME = "#212121";
private static final String FONT_COLOR_DARK_THEME = "#FFFFFF";

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down Expand Up @@ -162,13 +163,13 @@ public String getFontColor(boolean isDarkTheme)
final Icon icon = getIconReference();
if(icon == null)
{
return ACCOUNT_FONT_COLOR;
return getDefaultFontColor(isDarkTheme);
}

final String fontColor = icon.getFontColor();
if(fontColor == null)
{
return ACCOUNT_FONT_COLOR;
return getDefaultFontColor(isDarkTheme);
}

return fontColor;
Expand All @@ -177,7 +178,12 @@ public String getFontColor(boolean isDarkTheme)
@Override
public String getDefaultFontColor(boolean isDarkTheme)
{
return ACCOUNT_FONT_COLOR;
if(isDarkTheme)
{
return FONT_COLOR_DARK_THEME;
}

return FONT_COLOR_LIGHT_THEME;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ private static class ReturnValues
public static final String REDIRECT_SHOW_ALL = "redirect:/accounts";
public static final String NEW_ENTITY = "accounts/newAccount";
public static final String DELETE_ENTITY = "accounts/deleteAccountModal";
public static final String IMPORT_STEP_2 = "redirect:/settings/database/import/step2";
public static final String SETTINGS = "redirect:/settings";
public static final String GLOBAL_ACCOUNT_SELECT_MODAL = "globalAccountSelectModal";
}
Expand Down Expand Up @@ -79,6 +78,10 @@ public String selectAccount(HttpServletRequest request, @PathVariable("ID") Inte
{
return MessageFormat.format("redirect:{0}", referer);
}
else if(referer.contains("?"))
{
return MessageFormat.format("redirect:{0}&{1}", referer, ACCOUNT_SELECTED_INDICATOR);
}
else
{
return MessageFormat.format("redirect:{0}?{1}", referer, ACCOUNT_SELECTED_INDICATOR);
Expand Down Expand Up @@ -214,11 +217,6 @@ public String post(HttpServletRequest request, WebRequest webRequest, Model mode
accountService.updateExistingAccount(account);
}

if(request.getSession().getAttribute("accountMatchList") != null)
{
return ReturnValues.IMPORT_STEP_2;
}

final String link = NotificationLinkBuilder.buildEditLink(request, account.getName(), Mappings.ACCOUNTS, account.getID());
WebRequestUtils.putNotification(webRequest, new Notification(Localization.getString("notification.account.save.success", link), NotificationType.SUCCESS));
return ReturnValues.REDIRECT_SHOW_ALL;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,49 +1,35 @@
package de.deadlocker8.budgetmaster.authentication;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.web.DefaultRedirectStrategy;
import org.springframework.security.web.RedirectStrategy;
import org.springframework.security.web.SecurityFilterChain;

@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class WebSecurityConfig extends WebSecurityConfigurerAdapter
public class WebSecurityConfig
{
private final RedirectStrategy redirectStrategy = new DefaultRedirectStrategy();
private final UserDetailsService userDetailsService;
private final PreLoginUrlBlacklist preLoginUrlBlacklist;

@Autowired
public WebSecurityConfig(UserDetailsServiceImpl userDetailsService)
{
this.userDetailsService = userDetailsService;
this.preLoginUrlBlacklist = new PreLoginUrlBlacklist();
}
private final PreLoginUrlBlacklist preLoginUrlBlacklist = new PreLoginUrlBlacklist();

@Bean
public BCryptPasswordEncoder bCryptPasswordEncoder()
public BCryptPasswordEncoder passwordEncoder()
{
return new BCryptPasswordEncoder();
}

@Override
protected void configure(HttpSecurity http) throws Exception

@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception
{
http
.csrf()
.and()

.authorizeRequests()
.antMatchers("/css/**", "/js/**", "/images/**", "/webjars/**", "/favicon.ico", "/touch_icon.png").permitAll()
.antMatchers("/css/**", "/js/**", "/images/**", "/webjars/**", "/favicon.ico", "/touch_icon.png").permitAll()
.antMatchers("/login").permitAll()
.antMatchers("/**").authenticated()
.and()
Expand All @@ -62,11 +48,7 @@ protected void configure(HttpSecurity http) throws Exception

.logout()
.permitAll();
}

@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception
{
auth.userDetailsService(userDetailsService).passwordEncoder(bCryptPasswordEncoder());
return http.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected BackupTask(DatabaseService databaseService, SettingsService settingsSe
this.databaseService = databaseService;
this.settingsService = settingsService;

final Path applicationSupportFolder = BudgetMasterServerMain.getApplicationSupportFolder();
final Path applicationSupportFolder = BudgetMasterServerMain.getApplicationSupportFolder(true);
this.backupFolder = applicationSupportFolder.resolve("backups");

this.backupStatus = BackupStatus.UNKNOWN;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@ public String index(Model model)
public String whatsNewModal(Model model)
{
final List<NewsEntry> newsEntries = new ArrayList<>();
newsEntries.add(NewsEntry.createWithLocalizationKey("databaseBackend"));
newsEntries.add(NewsEntry.createWithLocalizationKey("linkToItem"));
newsEntries.add(NewsEntry.createWithLocalizationKey("newHotkey"));
newsEntries.add(NewsEntry.createWithLocalizationKey("suggestions"));
newsEntries.add(NewsEntry.createWithLocalizationKey("chartsShowDateRange"));
newsEntries.add(NewsEntry.createWithLocalizationKey("fix.sortTags"));
newsEntries.add(NewsEntry.createWithLocalizationKey("fix.deleteAccounts"));
newsEntries.add(NewsEntry.createWithLocalizationKey("simplifiedImport"));
newsEntries.add(NewsEntry.createWithLocalizationKey("newSettingsPage"));
newsEntries.add(NewsEntry.createWithLocalizationKey("transactionKeywords"));
newsEntries.add(NewsEntry.createWithLocalizationKey("groupTransactionsByDate"));
newsEntries.add(NewsEntry.createWithLocalizationKey("dateMandatory"));
newsEntries.add(NewsEntry.createWithLocalizationKey("autoCloseDatePicker"));
newsEntries.add(NewsEntry.createWithLocalizationKey("search"));
newsEntries.add(NewsEntry.createWithLocalizationKey("fix.accountSelect"));

model.addAttribute(ModelAttributes.NEWS_ENTRIES, newsEntries);
return ReturnValues.WHATS_NEW;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import de.deadlocker8.budgetmaster.database.model.v6.BackupDatabase_v6;
import de.deadlocker8.budgetmaster.database.model.v7.BackupDatabase_v7;
import de.deadlocker8.budgetmaster.database.model.v8.BackupDatabase_v8;
import de.deadlocker8.budgetmaster.database.model.v9.BackupDatabase_v9;
import de.thecodelabs.utils.util.Localization;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -19,7 +20,7 @@ public class DatabaseParser
final Logger LOGGER = LoggerFactory.getLogger(this.getClass());

private static final int MINIMUM_VERSION = 4;
public static final int LATEST_VERSION = 8;
public static final int LATEST_VERSION = 9;

private final String jsonString;

Expand Down Expand Up @@ -74,6 +75,13 @@ public InternalDatabase parseDatabaseFromJSON() throws IllegalArgumentException
importedDatabase = parsedDatabase;
}

if(version == 9)
{
BackupDatabase_v9 parsedDatabase = new DatabaseParser_v9(jsonString).parseDatabaseFromJSON();
LOGGER.debug(MessageFormat.format("Parsed database with {0} transactions, {1} categories, {2} accounts, {3} templates {4} charts {5} images {6} icons and {7} transaction name keywords", parsedDatabase.getTransactions().size(), parsedDatabase.getCategories().size(), parsedDatabase.getAccounts().size(), parsedDatabase.getTemplates().size(), parsedDatabase.getCharts().size(), parsedDatabase.getImages().size(), parsedDatabase.getIcons().size(), parsedDatabase.getTransactionNameKeywords().size()));
importedDatabase = parsedDatabase;
}

if(importedDatabase == null)
{
throw new IllegalArgumentException(Localization.getString("error.database.import.unknown.version"));
Expand Down
Loading

0 comments on commit 6c18225

Please sign in to comment.