summaryrefslogtreecommitdiff
path: root/pdf-over-gui
diff options
context:
space:
mode:
authorJakob Heher <jakob.heher@iaik.tugraz.at>2022-03-22 13:52:29 +0100
committerJakob Heher <jakob.heher@iaik.tugraz.at>2022-03-22 13:52:29 +0100
commit0953f7cde8a2c09850f398790adc983ebf7f1b8b (patch)
tree60215d314905a71c545ff637061bb945f2eeee5f /pdf-over-gui
parent5cc1081113429add3b70887b47b4be4b8da8cf69 (diff)
downloadpdf-over-0953f7cde8a2c09850f398790adc983ebf7f1b8b.tar.gz
pdf-over-0953f7cde8a2c09850f398790adc983ebf7f1b8b.tar.bz2
pdf-over-0953f7cde8a2c09850f398790adc983ebf7f1b8b.zip
sanitize swt handling
Diffstat (limited to 'pdf-over-gui')
-rw-r--r--pdf-over-gui/pom.xml60
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java18
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SWTLoader.java109
-rw-r--r--pdf-over-gui/src/main/resources/izpack/install.xml8
-rw-r--r--pdf-over-gui/src/main/resources/scripts/pdf-over_linux.sh1
-rw-r--r--pdf-over-gui/src/main/resources/scripts/pdf-over_mac.sh1
-rw-r--r--pdf-over-gui/src/main/resources/scripts/pdf-over_win-cli.bat1
-rw-r--r--pdf-over-gui/src/main/resources/scripts/pdf-over_win.bat1
-rw-r--r--pdf-over-gui/src/main/resources/scripts/postInstall_linux.sh4
-rw-r--r--pdf-over-gui/src/main/resources/scripts/postInstall_win.bat2
-rw-r--r--pdf-over-gui/src/main/resources/scripts/postinstall_mac.sh1
11 files changed, 13 insertions, 193 deletions
diff --git a/pdf-over-gui/pom.xml b/pdf-over-gui/pom.xml
index 4815382e..62cbe410 100644
--- a/pdf-over-gui/pom.xml
+++ b/pdf-over-gui/pom.xml
@@ -173,30 +173,12 @@
<artifactItems>
<artifactItem>
<groupId>org.eclipse.swt</groupId>
- <artifactId>${swt.artifactId.64}</artifactId>
+ <artifactId>${swt.artifactId}</artifactId>
<version>${swt.version}</version>
<type>jar</type>
<overWrite>true</overWrite>
- <outputDirectory>${staging.dir}/lib-swt</outputDirectory>
- <destFileName>swt-${target.name}-32.jar</destFileName>
- </artifactItem>
- <artifactItem>
- <groupId>org.eclipse.swt</groupId>
- <artifactId>${swt.artifactId.64}</artifactId>
- <version>${swt.version}</version>
- <type>jar</type>
- <overWrite>true</overWrite>
- <outputDirectory>${staging.dir}/lib-swt</outputDirectory>
- <destFileName>swt-${target.name}-64.jar</destFileName>
- </artifactItem>
- <artifactItem>
- <groupId>at.a-sit</groupId>
- <artifactId>pdf-over-install-helper</artifactId>
- <version>${project.parent.version}</version>
- <type>jar</type>
- <overWrite>true</overWrite>
<outputDirectory>${staging.dir}/lib</outputDirectory>
- <destFileName>pdf-over-install-helper.jar</destFileName>
+ <destFileName>swt.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
@@ -321,6 +303,7 @@
<classPath>
<mainClass>at.asit.pdfover.gui.Main</mainClass>
<jarLocation>lib/</jarLocation>
+ <preCp>lib/swt.jar</preCp>
</classPath>
<chdir>.</chdir>
<icon>src/main/resources/icons/icon.ico</icon>
@@ -357,6 +340,7 @@
<classPath>
<mainClass>at.asit.pdfover.gui.Main</mainClass>
<jarLocation>lib/</jarLocation>
+ <preCp>lib/swt.jar</preCp>
</classPath>
<chdir>.</chdir>
<icon>src/main/resources/icons/icon.ico</icon>
@@ -478,9 +462,7 @@
</os>
</activation>
<properties>
-<!-- <swt.artifactId.32>org.eclipse.swt.gtk.linux.x86</swt.artifactId.32>-->
- <swt.artifactId.64>org.eclipse.swt.gtk.linux.x86_64</swt.artifactId.64>
- <swt.artifactId>${swt.artifactId.64}</swt.artifactId>
+ <swt.artifactId>org.eclipse.swt.gtk.linux.x86_64</swt.artifactId>
<target.name>linux</target.name>
</properties>
</profile>
@@ -493,9 +475,7 @@
</os>
</activation>
<properties>
-<!-- <swt.artifactId.32>org.eclipse.swt.win32.win32.x86</swt.artifactId.32>-->
- <swt.artifactId.64>org.eclipse.swt.win32.win32.x86_64</swt.artifactId.64>
- <swt.artifactId>${swt.artifactId.64}</swt.artifactId>
+ <swt.artifactId>org.eclipse.swt.win32.win32.x86_64</swt.artifactId>
<target.name>windows</target.name>
</properties>
</profile>
@@ -508,9 +488,7 @@
</os>
</activation>
<properties>
-<!-- <swt.artifactId.32>org.eclipse.swt.win32.win32.x86</swt.artifactId.32>-->
- <swt.artifactId.64>org.eclipse.swt.win32.win32.x86_64</swt.artifactId.64>
- <swt.artifactId>${swt.artifactId.64}</swt.artifactId>
+ <swt.artifactId>org.eclipse.swt.win32.win32.x86_64</swt.artifactId>
<target.name>windows</target.name>
</properties>
</profile>
@@ -523,9 +501,7 @@
</os>
</activation>
<properties>
-<!-- <swt.artifactId.32>org.eclipse.swt.gtk.linux.x86</swt.artifactId.32>-->
- <swt.artifactId.64>org.eclipse.swt.gtk.linux.x86_64</swt.artifactId.64>
- <swt.artifactId>${swt.artifactId.64}</swt.artifactId>
+ <swt.artifactId>org.eclipse.swt.gtk.linux.x86_64</swt.artifactId>
<target.name>linux</target.name>
</properties>
</profile>
@@ -541,9 +517,7 @@
</os>
</activation>
<properties>
-<!-- <swt.artifactId.32>org.eclipse.swt.cocoa.macosx</swt.artifactId.32>-->
- <swt.artifactId.64>org.eclipse.swt.cocoa.macosx.x86_64</swt.artifactId.64>
- <swt.artifactId>${swt.artifactId.64}</swt.artifactId>
+ <swt.artifactId>org.eclipse.swt.cocoa.macosx.x86_64</swt.artifactId>
<target.name>mac</target.name>
</properties>
</profile>
@@ -556,9 +530,7 @@
</os>
</activation>
<properties>
-<!-- <swt.artifactId.32>org.eclipse.swt.cocoa.macosx</swt.artifactId.32>-->
- <swt.artifactId.64>org.eclipse.swt.cocoa.macosx.x86_64</swt.artifactId.64>
- <swt.artifactId>${swt.artifactId.64}</swt.artifactId>
+ <swt.artifactId>org.eclipse.swt.cocoa.macosx.x86_64</swt.artifactId>
<target.name>mac</target.name>
</properties>
</profile>
@@ -571,9 +543,7 @@
</os>
</activation>
<properties>
-<!-- <swt.artifactId.32>org.eclipse.swt.cocoa.macosx</swt.artifactId.32>-->
- <swt.artifactId.64>org.eclipse.swt.cocoa.macosx.x86_64</swt.artifactId.64>
- <swt.artifactId>${swt.artifactId.64}</swt.artifactId>
+ <swt.artifactId>org.eclipse.swt.cocoa.macosx.x86_64</swt.artifactId>
<target.name>mac</target.name>
</properties>
</profile>
@@ -586,9 +556,7 @@
</os>
</activation>
<properties>
-<!-- <swt.artifactId.32>org.eclipse.swt.cocoa.macosx</swt.artifactId.32>-->
- <swt.artifactId.64>org.eclipse.swt.cocoa.macosx.x86_64</swt.artifactId.64>
- <swt.artifactId>${swt.artifactId.64}</swt.artifactId>
+ <swt.artifactId>org.eclipse.swt.cocoa.macosx.x86_64</swt.artifactId>
<target.name>mac</target.name>
</properties>
</profile>
@@ -601,9 +569,7 @@
</os>
</activation>
<properties>
-<!-- <swt.artifactId.32>org.eclipse.swt.cocoa.macosx</swt.artifactId.32>-->
- <swt.artifactId.64>org.eclipse.swt.cocoa.macosx.aarch64</swt.artifactId.64>
- <swt.artifactId>${swt.artifactId.64}</swt.artifactId>
+ <swt.artifactId>org.eclipse.swt.cocoa.macosx.aarch64</swt.artifactId>
<target.name>mac</target.name>
</properties>
</profile>
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java
index c2528adc..6af00889 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java
@@ -58,7 +58,6 @@ import at.asit.pdfover.gui.controls.MainBarRectangleButton;
import at.asit.pdfover.gui.controls.MainBarStartButton;
import at.asit.pdfover.gui.osx.CocoaUIEnhancer;
import at.asit.pdfover.commons.Messages;
-import at.asit.pdfover.gui.utils.SWTLoader;
import at.asit.pdfover.gui.workflow.StateMachine;
import at.asit.pdfover.gui.workflow.states.BKUSelectionState;
import at.asit.pdfover.gui.workflow.states.ConfigurationUIState;
@@ -212,23 +211,6 @@ public class MainWindow {
if (System.getProperty("os.name").contains("OS X")) { //$NON-NLS-1$ //$NON-NLS-2$
hookupOSXMenu();
}
- // Workaround for SWT bug on Mac: disable full screen mode
- try {
- Field field = Control.class.getDeclaredField("view"); //$NON-NLS-1$
- Object /*NSView*/ view = field.get(getShell());
- if (view != null)
- {
- Class<?> c = Class.forName("org.eclipse.swt.internal.cocoa.NSView"); //$NON-NLS-1$
- Object nswindow = c.getDeclaredMethod("window").invoke(view); //$NON-NLS-1$
- c = Class.forName("org.eclipse.swt.internal.cocoa.NSWindow"); //$NON-NLS-1$
- Method setCollectionBehavior = c.getDeclaredMethod(
- "setCollectionBehavior", //$NON-NLS-1$
- (SWTLoader.getArchBits() == 64) ? long.class : int.class);
- setCollectionBehavior.invoke(nswindow, 0);
- }
- } catch (Exception e) {
- log.error("Error disabling full screen mode", e); //$NON-NLS-1$
- }
}
try {
Display display = Display.getCurrent();
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SWTLoader.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SWTLoader.java
deleted file mode 100644
index 6184ebc7..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SWTLoader.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://joinup.ec.europa.eu/software/page/eupl
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- */
-package at.asit.pdfover.gui.utils;
-
-// Imports
-import java.io.File;
-import java.io.UnsupportedEncodingException;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.net.URLDecoder;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.gui.exceptions.InitializationException;
-
-/**
- *
- */
-@SuppressWarnings("nls")
-public class SWTLoader {
- /**
- * SLF4J Logger instance
- **/
- private static final Logger log = LoggerFactory.getLogger(SWTLoader.class);
-
- /**
- * Load the SWT library for this OS
- * @throws InitializationException Loading failed
- */
- public static void loadSWT() throws InitializationException {
- try {
- URLClassLoader cl = (URLClassLoader)SWTLoader.class.getClassLoader();
- Method addUrlMethod = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
- addUrlMethod.setAccessible(true);
-
- String swtLibPath = getSwtJarPath() + getSwtJarName();
- log.debug("loading " + swtLibPath);
- File swtLib = new File(swtLibPath);
- if (!swtLib.isFile())
- throw new SWTLoadFailedException("Library " + swtLibPath + " not found");
- log.debug("Adding " + swtLib + " to ClassLoader...");
- addUrlMethod.invoke(cl, swtLib.toURI().toURL());
- log.debug("Success.");
- } catch (Exception e) {
- throw new InitializationException("SWT loading failed", e);
- }
- }
-
- /**
- * Get bit-ness of the JVM
- * @return 32 or 64
- */
- public static int getArchBits() {
- String arch = System.getProperty("os.arch");
- return arch.contains("64") ? 64 : 32;
- }
-
- private static String getSwtJarName() throws SWTLoadFailedException {
- String os = System.getProperty("os.name").toLowerCase();
- if (os.contains("win"))
- os = "windows";
- else if (os.contains("mac"))
- os = "mac";
- else if (os.contains("linux") || os.contains("nix"))
- os = "linux";
- else {
- log.error("Unknown OS: " + os);
- throw new SWTLoadFailedException("Unknown OS: " + os);
- }
- return "swt-" + os + "-" + getArchBits() + ".jar";
- }
-
- private static String getSwtJarPath() {
- String path = "";
- try {
- path = URLDecoder.decode(SWTLoader.class.getProtectionDomain().getCodeSource().getLocation().getPath(), "UTF-8");
- int idx = path.lastIndexOf('/');
- idx = path.lastIndexOf('/', idx - 1);
- path = path.substring(0, idx + 1);
- } catch (UnsupportedEncodingException e) {
- // Ignore
- }
- return path + "lib-swt/";
- }
-
- private static class SWTLoadFailedException extends Exception {
- private static final long serialVersionUID = 1L;
-
- SWTLoadFailedException(String msg) {
- super(msg);
- }
- }
-
-}
diff --git a/pdf-over-gui/src/main/resources/izpack/install.xml b/pdf-over-gui/src/main/resources/izpack/install.xml
index 457fb083..f07da7ef 100644
--- a/pdf-over-gui/src/main/resources/izpack/install.xml
+++ b/pdf-over-gui/src/main/resources/izpack/install.xml
@@ -57,10 +57,8 @@
<description>Main Installation</description>
<updatecheck>
<include name="lib/**" />
- <include name="lib-swt/**" />
</updatecheck>
<file src="lib" targetdir="$INSTALL_PATH" />
- <file src="lib-swt" targetdir="$INSTALL_PATH" />
<file src="scripts" targetdir="$INSTALL_PATH" />
<file src="icons" targetdir="$INSTALL_PATH" />
<file src="ReadMe.txt" targetdir="$INSTALL_PATH" />
@@ -71,8 +69,6 @@
os="unix" stage="never"></executable>
<executable targetfile="$INSTALL_PATH/scripts/uninstall_linux.sh"
os="unix" stage="never"></executable>
- <executable targetfile="$INSTALL_PATH/lib/pdf-over-install-helper.jar"
- os="unix" stage="never"></executable>
<executable targetfile="$INSTALL_PATH/scripts/pdf-over_win.bat"
os="windows" stage="never"></executable>
<executable targetfile="$INSTALL_PATH/scripts/pdf-over_win-cli.bat"
@@ -81,12 +77,8 @@
os="windows" stage="never"></executable>
<executable targetfile="$INSTALL_PATH/scripts/pdf-over_mac.sh"
os="mac" stage="never"></executable>
-<!-- <executable targetfile="$INSTALL_PATH/scripts/postInstall_linux.sh"
- os="unix" stage="postinstall" ></executable>-->
<executable targetfile="$INSTALL_PATH/scripts/postinstall_mac.sh"
os="mac" stage="postinstall"></executable>
-<!-- <executable targetfile="$INSTALL_PATH/scripts/postInstall_win.bat"
- os="win" stage="postinstall" ></executable> -->
</pack>
</packs>
diff --git a/pdf-over-gui/src/main/resources/scripts/pdf-over_linux.sh b/pdf-over-gui/src/main/resources/scripts/pdf-over_linux.sh
index 438cec28..ca4e6279 100644
--- a/pdf-over-gui/src/main/resources/scripts/pdf-over_linux.sh
+++ b/pdf-over-gui/src/main/resources/scripts/pdf-over_linux.sh
@@ -1,5 +1,4 @@
#!/bin/sh
BASEDIR=`dirname $0`
export GDK_BACKEND=X11
-java -jar "$BASEDIR/../lib/pdf-over-install-helper.jar"
exec java -cp "$BASEDIR/../lib/*" at.asit.pdfover.gui.Main "$@"
diff --git a/pdf-over-gui/src/main/resources/scripts/pdf-over_mac.sh b/pdf-over-gui/src/main/resources/scripts/pdf-over_mac.sh
index 2c488544..dcb805ae 100644
--- a/pdf-over-gui/src/main/resources/scripts/pdf-over_mac.sh
+++ b/pdf-over-gui/src/main/resources/scripts/pdf-over_mac.sh
@@ -1,5 +1,4 @@
#!/bin/sh
BASEDIR=$(cd "$(dirname "$0")"; pwd)
export LC_CTYPE="UTF-8"
-#java -jar "$BASEDIR/../lib/pdf-over-install-helper.jar"
exec java -XstartOnFirstThread -cp "$BASEDIR/../lib/*" at.asit.pdfover.gui.Main "$@" &
diff --git a/pdf-over-gui/src/main/resources/scripts/pdf-over_win-cli.bat b/pdf-over-gui/src/main/resources/scripts/pdf-over_win-cli.bat
index fe9bad65..fb7b7c39 100644
--- a/pdf-over-gui/src/main/resources/scripts/pdf-over_win-cli.bat
+++ b/pdf-over-gui/src/main/resources/scripts/pdf-over_win-cli.bat
@@ -1,4 +1,3 @@
@echo off
-start /b javaw -jar "%~dp0\..\lib\pdf-over-install-helper.jar"
start /b /WAIT java -cp "%~dp0\..\lib\*" at.asit.pdfover.gui.Main %*
diff --git a/pdf-over-gui/src/main/resources/scripts/pdf-over_win.bat b/pdf-over-gui/src/main/resources/scripts/pdf-over_win.bat
index 5e336241..6468e582 100644
--- a/pdf-over-gui/src/main/resources/scripts/pdf-over_win.bat
+++ b/pdf-over-gui/src/main/resources/scripts/pdf-over_win.bat
@@ -1,3 +1,2 @@
@echo off
-start /b javaw -jar "%~dp0\..\lib\pdf-over-install-helper.jar"
start /b javaw -cp "%~dp0\..\lib\*" at.asit.pdfover.gui.Main %*
diff --git a/pdf-over-gui/src/main/resources/scripts/postInstall_linux.sh b/pdf-over-gui/src/main/resources/scripts/postInstall_linux.sh
deleted file mode 100644
index 7c8d9cf5..00000000
--- a/pdf-over-gui/src/main/resources/scripts/postInstall_linux.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-BASEDIR=`dirname $0`
-java -jar "$BASEDIR/../lib/pdf-over-install-helper.jar"
-
diff --git a/pdf-over-gui/src/main/resources/scripts/postInstall_win.bat b/pdf-over-gui/src/main/resources/scripts/postInstall_win.bat
deleted file mode 100644
index 78deb870..00000000
--- a/pdf-over-gui/src/main/resources/scripts/postInstall_win.bat
+++ /dev/null
@@ -1,2 +0,0 @@
-@echo off
-java -jar "%~dp0\..\lib\pdf-over-install-helper.jar"
diff --git a/pdf-over-gui/src/main/resources/scripts/postinstall_mac.sh b/pdf-over-gui/src/main/resources/scripts/postinstall_mac.sh
index 82e1add9..0b020ea3 100644
--- a/pdf-over-gui/src/main/resources/scripts/postinstall_mac.sh
+++ b/pdf-over-gui/src/main/resources/scripts/postinstall_mac.sh
@@ -3,7 +3,6 @@ SCRIPTDIR=$(cd "$(dirname "$0")"; pwd)
BASEDIR=$(cd "$(dirname "$0")/.."; pwd)
export LC_CTYPE="UTF-8"
cd "$SCRIPTDIR"
-java -jar "$BASEDIR/lib/pdf-over-install-helper.jar"
chmod a+x pdf-over_mac.sh
cd "$BASEDIR"
if [ -d "$BASEDIR.app" ]; then