Skip to content

Commit

Permalink
Added configurable system properties (issue #497)
Browse files Browse the repository at this point in the history
- with sun.java2d.noddraw=true
- can be changed by editing config file
- any property possible
- could also overwrite some hardcoded settings
  • Loading branch information
kaikramer committed Jan 3, 2025
1 parent c67ca52 commit 3d2a063
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
16 changes: 10 additions & 6 deletions kse/src/main/java/org/kse/KSE.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle;

import javax.swing.JFrame;
Expand Down Expand Up @@ -95,10 +96,12 @@ public static void main(String[] args) {
Locale.setDefault(new Locale(language));
}

initialiseSecurity();
Security.addProvider(BC);

Pkcs12Util.setEncryptionStrength(preferences.getPkcs12EncryptionSetting());

setProperties(preferences.getProperties());

// list of files to open after start
List<File> parameterFiles = new ArrayList<>();
for (String arg : args) {
Expand All @@ -117,6 +120,12 @@ public static void main(String[] args) {
}
}

private static void setProperties(Map<String, String> properties) {
for (Map.Entry<String, String> entry : properties.entrySet()) {
System.setProperty(entry.getKey(), entry.getValue());
}
}

private static void fixAppClassName() {
// Fix application name in Gnome top bar, see http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6528430
// TODO Bug is not fixed yet, but the workaround causes an "Illegal reflective access" warning since Java 9...
Expand Down Expand Up @@ -155,11 +164,6 @@ private static void setCurrentDirectory(String currentDir) {
}
}

private static void initialiseSecurity() {
// Add BouncyCastle provider
Security.addProvider(BC);
}

/**
* Get application name.
*
Expand Down
13 changes: 13 additions & 0 deletions kse/src/main/java/org/kse/gui/preferences/data/KsePreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@

import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.swing.JTabbedPane;

Expand Down Expand Up @@ -66,6 +68,9 @@ public class KsePreferences {
private boolean nativeFileChooserEnabled = false;
private Pkcs12EncryptionSetting pkcs12EncryptionSetting = Pkcs12EncryptionSetting.strong;
private int serialNumberLengthInBytes = 20;
private Map<String, String> properties = new HashMap<>() {{
put("sun.java2d.noddraw", "true");
}};

// auto-generated getters/setters

Expand Down Expand Up @@ -300,4 +305,12 @@ public PasswordGeneratorSettings getPasswordGeneratorSettings() {
public void setPasswordGeneratorSettings(PasswordGeneratorSettings passwordGeneratorSettings) {
this.passwordGeneratorSettings = passwordGeneratorSettings;
}

public Map<String, String> getProperties() {
return properties;
}

public void setProperties(Map<String, String> properties) {
this.properties = properties;
}
}

0 comments on commit 3d2a063

Please sign in to comment.