[Git][java-team/jameica][upstream] New upstream version 2.8.3+dfsg
Jochen Sprickerhof
gitlab at salsa.debian.org
Wed Jan 30 20:30:01 GMT 2019
Jochen Sprickerhof pushed to branch upstream at Debian Java Maintainers / jameica
Commits:
ddf3c9b1 by Jochen Sprickerhof at 2019-01-29T19:27:53Z
New upstream version 2.8.3+dfsg
- - - - -
22 changed files:
- .classpath
- .gitignore
- build.gradle
- build/BUILD
- build/ChangeLog
- build/build.properties
- build/jameica.sh
- build/launch4j-win32.xml
- build/launch4j-win64.xml
- plugin.xml
- src/de/willuhn/jameica/gui/SplashScreen.java
- src/de/willuhn/jameica/gui/internal/action/Print.java
- src/de/willuhn/jameica/gui/internal/parts/PluginDetailPart.java
- src/de/willuhn/jameica/gui/internal/parts/PluginListPart.java
- src/de/willuhn/jameica/gui/parts/PanelButton.java
- src/de/willuhn/jameica/gui/util/Color.java
- src/de/willuhn/jameica/gui/util/Popup.java
- src/de/willuhn/jameica/messaging/PopupMessageConsumer.java
- src/de/willuhn/jameica/services/inject/InjectHandlerResource.java
- src/de/willuhn/jameica/system/AbstractApplicationCallback.java
- src/de/willuhn/jameica/system/Platform.java
- src/de/willuhn/jameica/transport/HttpTransport.java
Changes:
=====================================
.classpath
=====================================
@@ -42,5 +42,6 @@
<classpathentry kind="lib" path="lib/java_ee/jaxb-runtime-2.4.0-b180725.0644.jar"/>
<classpathentry kind="lib" path="lib/java_ee/activation-1.1.1.jar"/>
<classpathentry kind="lib" path="lib/java_ee/txw2-20110809.jar"/>
+ <classpathentry kind="lib" path="lib/velocity/oro-2.0.8.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
=====================================
.gitignore
=====================================
@@ -1,4 +1,5 @@
bin
releases
plugins
-/test-bin
\ No newline at end of file
+/test-bin
+/.gradle/
=====================================
build.gradle
=====================================
@@ -27,9 +27,11 @@ dependencies {
compile 'mysql:mysql-connector-java:5.+'
compile 'be.cyberelf.nanoxml:nanoxml:+'
compile 'org.apache.velocity:velocity:+'
+ compile 'oro:oro:+'
+
}
task download(type: Copy) {
- into "lib"
+ into "lib/download"
from configurations.runtime
}
=====================================
build/BUILD
=====================================
@@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
-#Fri Jul 13 12:04:31 CEST 2018
-build.number=450
+#Mon Sep 17 11:59:35 CEST 2018
+build.number=451
=====================================
build/ChangeLog
=====================================
@@ -1,3 +1,18 @@
+2019-01-30 Version 2.8.3
+
+ * CHG: Popups verwenden jetzt als Fallback eigene Farben fr Vorder- und Hintergrund, wenn keine Systemfarben vorgegeben sind oder Vorder- und Hintergrund identisch wren
+ * CHG: Jameica verwendet jetzt unter Linux per Default GTK3 (siehe "SWT_GTK3=1" in jameica.sh)
+ * NEW: Update auf SWT 4.9 (in 4.10 gibt es keine 32Bit-Untersttzung mehr)
+ * NEW: Hostname fr das beim ersten Start zu erstellende System-Zertifikat kann jetzt per Konfigurationsdatei vorgegeben werden (Parameter "jameica.hostname" in "de.willuhn.jameica.system.ApplicationCallback.properties") - siehe https://homebanking-hilfe.de/forum/topic.php?p=141994#real141994
+ * CHG: JVM-Parameter "-Dswt.autoScale=quarter" bei den Windows-Launchern hinzugefuegt - siehe https://github.com/willuhn/jameica/commit/82d253c0e1aec918b98eb378027ebf2d2e5fb411
+ * BUG: Kleiner Darstellungsfehler: Beim mehrfachen berfahren der Panelbuttons mit der Maus oben rechts wurde unter dem Button eine 1 Pixel schmale dunkle Linie angezeigt
+ * BUG: Die Bibliothek "oro" fehlte im Ordner "lib/velocity". Dadurch kam es zu einer ClassNotFoundException in SynTAX beim Erstellen der IDEA-Auswertung
+ * BUG: Zoom-Faktor bei HiDPI-Displays wurde beim Druck von Dokumenten via de.willuhn.jameica.gui.internal.action.Print nicht deaktiviert, sodass Dokumente zu gross gedruckt wurden
+ * NEW: MySQL-Treiber von 5.1.41 auf 5.1.47 aktualisiert
+ * CHG: Settings nur noch maximal 1 mal pro Sekunde neu laden
+ * NEW: Annotation "@Resource" untersttzt jetzt auch Services des Typs "Bootable".
+ * NEW: 0102 BUGZILLA 1867 - HTTP-Redirects (fr Wechsel von HTTP auf HTTPS) bercksichtigen
+
2018-09-17 Version 2.8.2
* NEW: 0101 Support fr Java 11 (Umgebungsvariable "JDK_JAVA_OPTIONS='--add-modules=java.se.ee'" entfernt, Jameica liefert die ntigen JAR-Dateien in lib/java_ee jetzt selbst mit)
=====================================
build/build.properties
=====================================
@@ -42,6 +42,7 @@ define.commonlibs = lib/bouncycastle/bcpkix-jdk15on-1.56.jar \
lib/swt/com.ibm.icu_52.1.0.v201404241930.jar \
lib/swtcalendar/swtcalendar.jar \
lib/velocity/velocity-1.7.jar \
+ lib/velocity/oro-2.0.8.jar \
lib/splash.jar \
lib/mckoi/mckoisqldb-1.0.5.jar \
img \
=====================================
build/jameica.sh
=====================================
@@ -18,4 +18,6 @@ else
archsuffix=""
fi
-LIBOVERLAY_SCROLLBAR=0 GDK_NATIVE_WINDOWS=1 SWT_GTK3=0 exec java -Djava.net.preferIPv4Stack=true -Xmx512m -Xss64m $_JCONSOLE -jar jameica-linux${archsuffix}.jar $@
+# Zur Anpassung der Skalierung auf HiDPI-Displays kann der Parameter "-Dswt.autoScale" verwendet werden.
+# Siehe https://www.willuhn.de/wiki/doku.php?id=develop:highdpi
+LIBOVERLAY_SCROLLBAR=0 GDK_NATIVE_WINDOWS=1 SWT_GTK3=1 exec java -Djava.net.preferIPv4Stack=true -Xmx512m -Xss64m $_JCONSOLE -jar jameica-linux${archsuffix}.jar $@
=====================================
build/launch4j-win32.xml
=====================================
@@ -22,15 +22,15 @@
<maxVersion></maxVersion>
<jdkPreference>preferJre</jdkPreference>
<runtimeBits>64/32</runtimeBits>
- <opt>-Xmx512m -Djava.net.preferIPv4Stack=true</opt>
+ <opt>-Xmx512m -Djava.net.preferIPv4Stack=true -Dswt.autoScale=quarter</opt>
</jre>
<versionInfo>
- <fileVersion>2.6.6.0</fileVersion>
- <txtFileVersion>2.6.6</txtFileVersion>
+ <fileVersion>2.8.2.0</fileVersion>
+ <txtFileVersion>2.8.2</txtFileVersion>
<fileDescription>Jameica</fileDescription>
<copyright>Olaf Willuhn</copyright>
- <productVersion>2.6.6.0</productVersion>
- <txtProductVersion>2.6.6</txtProductVersion>
+ <productVersion>2.8.2.0</productVersion>
+ <txtProductVersion>2.8.2</txtProductVersion>
<productName>Jameica</productName>
<companyName>Olaf Willuhn</companyName>
<internalName>jameica-win32</internalName>
=====================================
build/launch4j-win64.xml
=====================================
@@ -22,15 +22,15 @@
<maxVersion></maxVersion>
<jdkPreference>preferJre</jdkPreference>
<runtimeBits>64/32</runtimeBits>
- <opt>-Xmx512m -Xss64m -Djava.net.preferIPv4Stack=true</opt>
+ <opt>-Xmx512m -Xss64m -Djava.net.preferIPv4Stack=true -Dswt.autoScale=quarter</opt>
</jre>
<versionInfo>
- <fileVersion>2.6.6.0</fileVersion>
- <txtFileVersion>2.6.6</txtFileVersion>
+ <fileVersion>2.8.2.0</fileVersion>
+ <txtFileVersion>2.8.2</txtFileVersion>
<fileDescription>Jameica</fileDescription>
<copyright>Olaf Willuhn</copyright>
- <productVersion>2.6.6.0</productVersion>
- <txtProductVersion>2.6.6</txtProductVersion>
+ <productVersion>2.8.2.0</productVersion>
+ <txtProductVersion>2.8.2</txtProductVersion>
<productName>Jameica</productName>
<companyName>Olaf Willuhn</companyName>
<internalName>jameica-win64</internalName>
=====================================
plugin.xml
=====================================
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-<system name="Jameica" version="2.8.2">
+<system name="Jameica" version="2.8.3">
<description>Jameica - Java based messages interchange</description>
- <url>https://www.willuhn.de/products/jameica/releases/2.8/jameica/jameica-2.8.2.zip</url>
+ <url>https://www.willuhn.de/products/jameica/releases/2.8/jameica/jameica-2.8.3.zip</url>
<homepage>https://www.willuhn.de/projects/jameica</homepage>
<license>GPL - http://www.gnu.org/copyleft/gpl.html</license>
=====================================
src/de/willuhn/jameica/gui/SplashScreen.java
=====================================
@@ -21,6 +21,7 @@ import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.SWTException;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Rectangle;
@@ -302,10 +303,19 @@ public class SplashScreen implements ProgressMonitor, Runnable
{
if (bar == null || bar.isDisposed() || display == null || display.isDisposed())
return;
- Logger.trace("startup completed: " + percentComplete + " %");
- bar.setSelection(percentComplete);
- bar.update();
- display.readAndDispatch();
+ try
+ {
+ Logger.trace("startup completed: " + percentComplete + " %");
+ bar.setSelection(percentComplete);
+ bar.update();
+ display.readAndDispatch();
+ }
+ catch (SWTException e)
+ {
+ // Falls genau in dem Moment das Display disposed wird
+ // Siehe https://jverein-forum.de/viewtopic.php?f=5&t=4513
+ Logger.debug("display already disposed");
+ }
}
});
}
=====================================
src/de/willuhn/jameica/gui/internal/action/Print.java
=====================================
@@ -10,20 +10,20 @@
package de.willuhn.jameica.gui.internal.action;
-import net.sf.paperclips.PaperClips;
-import net.sf.paperclips.PrintJob;
-
import org.eclipse.swt.SWT;
import org.eclipse.swt.printing.PrintDialog;
import org.eclipse.swt.printing.PrinterData;
import de.willuhn.jameica.gui.Action;
import de.willuhn.jameica.gui.GUI;
+import de.willuhn.jameica.gui.util.SWTUtil;
import de.willuhn.jameica.messaging.StatusBarMessage;
import de.willuhn.jameica.print.PrintSupport;
import de.willuhn.jameica.system.Application;
import de.willuhn.logging.Logger;
import de.willuhn.util.ApplicationException;
+import net.sf.paperclips.PaperClips;
+import net.sf.paperclips.PrintJob;
/**
* Aktion zum Drucken von Daten.
@@ -41,20 +41,33 @@ public class Print implements Action
Application.getMessagingFactory().sendMessage(new StatusBarMessage(Application.getI18n().tr("Bitte whlen Sie die zu druckenden Daten aus"),StatusBarMessage.TYPE_ERROR));
return;
}
-
- PrintJob job = ((PrintSupport) context).print();
-
- PrintDialog dialog = new PrintDialog(GUI.getShell(), SWT.NONE);
- dialog.setText(Application.getI18n().tr("Drucken"));
- PrinterData printerData = dialog.open();
- if (printerData == null)
+
+ final String key = "swt.autoScale";
+ final String backup = System.getProperty(key);
+ final int zoom = SWTUtil.getDeviceZoom();
+ try
{
- Logger.info("no printer choosen");
- return;
+ PrintJob job = ((PrintSupport) context).print();
+
+ PrintDialog dialog = new PrintDialog(GUI.getShell(), SWT.NONE);
+ dialog.setText(Application.getI18n().tr("Drucken"));
+ PrinterData printerData = dialog.open();
+ if (printerData == null)
+ {
+ Logger.info("no printer choosen");
+ return;
+ }
+
+ if (zoom > 100)
+ System.setProperty(key,"100"); // Scaling kurz auf 100% setzen
+ PaperClips.print(job, printerData);
+ Application.getMessagingFactory().sendMessage(new StatusBarMessage(Application.getI18n().tr("Gedruckt an \"{0}\"",printerData.name),StatusBarMessage.TYPE_SUCCESS));
+ }
+ finally
+ {
+ if (zoom > 100 && backup != null)
+ System.setProperty(key,backup); // Jetzt wieder auf den vorherigen Wert setzen
}
-
- PaperClips.print(job, printerData);
- Application.getMessagingFactory().sendMessage(new StatusBarMessage(Application.getI18n().tr("Gedruckt an \"{0}\"",printerData.name),StatusBarMessage.TYPE_SUCCESS));
}
}
=====================================
src/de/willuhn/jameica/gui/internal/parts/PluginDetailPart.java
=====================================
@@ -137,7 +137,7 @@ public class PluginDetailPart extends InfoPanel
// Checken, ob es installiert/deinstalliert werden kann
if (this.type == Type.INSTALLED)
{
- Button update = new Button(i18n.tr("Plugin aktualisieren..."),new PluginUpdate(),this.manifest,false,"emblem-package.png");
+ Button update = new Button(i18n.tr("Manuell aktualisieren..."),new PluginUpdate(),this.manifest,false,"emblem-package.png");
// Update und oeffnen gibt es nicht bei neuen Installationen
update.setEnabled(manifest.isInstalled() || error != null); // Update auch bei Fehler erlauben
@@ -165,7 +165,7 @@ public class PluginDetailPart extends InfoPanel
super.handleAction(getSelectedVersion());
}
};
- Button install = new Button(i18n.tr("Installieren..."),download,null,false,"document-save.png");
+ Button install = new Button(i18n.tr(Application.getPluginLoader().getManifest(this.manifest.getPluginClass()) != null ? "Aktualisieren..." : "Installieren..."),download,null,false,"document-save.png");
this.addButton(install);
}
else if (this.type == Type.UPDATE && this.plugins != null && this.plugins.size() > 0)
=====================================
src/de/willuhn/jameica/gui/internal/parts/PluginListPart.java
=====================================
@@ -261,7 +261,7 @@ public class PluginListPart implements Part
c.addText("",true);
}
ButtonArea buttons = new ButtonArea();
- buttons.addButton(new Button(i18n.tr("Neues Plugin installieren..."),new PluginInstall(),null,false,"emblem-package.png"));
+ buttons.addButton(new Button(i18n.tr("Plugin manuell installieren..."),new PluginInstall(),null,false,"emblem-package.png"));
buttons.addButton(new Button(i18n.tr("Repositories bearbeiten..."),new RepositoryEdit(),null,false,"document-properties.png"));
buttons.addButton(new Button(i18n.tr("Automatische Updates konfigurieren..."),new UpdateEdit(),null,false,"view-refresh.png"));
buttons.paint(comp);
=====================================
src/de/willuhn/jameica/gui/parts/PanelButton.java
=====================================
@@ -211,8 +211,7 @@ public class PanelButton implements Part
// Einmal mit weiss dahinter malen, weil das Bild Transparenz besitzt
gc.setBackground(GUI.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
- gc.fillRectangle(size);
-
+ gc.fillRectangle(0,0,this.width,this.height);
gc.drawImage(image,0,0,size.width,size.height,0,0,this.width,this.height);
}
=====================================
src/de/willuhn/jameica/gui/util/Color.java
=====================================
@@ -96,6 +96,11 @@ public class Color {
*/
public final static Color MANDATORY_BG = new Color("color.mandatory.bg", new RGB(255,240,220));
+ /**
+ * Hintergrundfarbe von eigenen Tooltips.
+ */
+ public final static Color TOOLTIP_BG = new Color("color.tooltip.bg", new RGB(239,230,159));
+
private String name;
private RGB value;
private RGB defaultValue;
=====================================
src/de/willuhn/jameica/gui/util/Popup.java
=====================================
@@ -13,6 +13,7 @@ package de.willuhn.jameica.gui.util;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
@@ -34,7 +35,7 @@ import de.willuhn.logging.Logger;
public class Popup
{
private final static int ALIGN_DEFAULT = SWT.BOTTOM | SWT.RIGHT;
- private final static int ALPHA = 210;
+ private final static int ALPHA = 180;
private Shell shell = null;
private String title = null;
@@ -43,6 +44,9 @@ public class Popup
private int align = ALIGN_DEFAULT;
private int timeout = -1;
+ private Color bg = null;
+ private Color fg = null;
+
/**
* ct
* @param text anzuzeigender Text.
@@ -109,12 +113,24 @@ public class Popup
// Schliessen, wenn schon eines offen ist.
if (this.shell != null)
this.close();
-
- Display display = GUI.getDisplay();
+
+ final Display display = GUI.getDisplay();
+
+ // Wenn die konfigurierten Vorder- und Hintergrundfarben fehlen oder identisch sind,
+ // verwenden wir eigene
+ this.bg = display.getSystemColor(SWT.COLOR_INFO_BACKGROUND);
+ this.fg = display.getSystemColor(SWT.COLOR_INFO_FOREGROUND);
+ if (this.bg == null || this.fg == null || this.bg.equals(this.fg))
+ {
+ this.bg = de.willuhn.jameica.gui.util.Color.TOOLTIP_BG.getSWTColor();
+ this.fg = de.willuhn.jameica.gui.util.Color.BLACK.getSWTColor();
+ }
this.shell = new Shell(GUI.getShell(), SWT.ON_TOP | SWT.TOOL);
this.shell.setAlpha(ALPHA);
- this.shell.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
+
+ if (this.bg != null)
+ this.shell.setBackground(this.bg);
GridLayout gl = new GridLayout(2,false);
gl.horizontalSpacing = 5;
@@ -123,13 +139,13 @@ public class Popup
Composite comp = new Composite(this.shell,SWT.NONE);
comp.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
- comp.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
+ if (this.bg != null) comp.setBackground(this.bg);
comp.setBackgroundMode(SWT.INHERIT_FORCE);
paint(comp);
Button ok = new Button(this.shell,SWT.BORDER);
ok.setLayoutData(new GridData(GridData.END));
- ok.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
+ if (this.bg != null) ok.setBackground(this.bg);
ok.setText(" OK ");
ok.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e)
@@ -208,14 +224,14 @@ public class Popup
Label label = new Label(comp, SWT.NONE);
label.setLayoutData(new RowData());
label.setFont(Font.BOLD.getSWTFont());
- label.setForeground(GUI.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
- label.setBackground(GUI.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
+ if (this.fg != null) label.setForeground(this.fg);
+ if (this.bg != null) label.setBackground(this.bg);
label.setText(this.title);
}
Label label = new Label(comp, SWT.NONE);
label.setLayoutData(new RowData());
- label.setForeground(GUI.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
- label.setBackground(GUI.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
+ if (this.fg != null) label.setForeground(this.fg);
+ if (this.bg != null) label.setBackground(this.bg);
label.setText(text == null ? "" : text);
}
}
=====================================
src/de/willuhn/jameica/messaging/PopupMessageConsumer.java
=====================================
@@ -43,12 +43,16 @@ public class PopupMessageConsumer implements MessageConsumer
s1 = msg.getTitle();
s2 = msg.getText();
}
- else
+ else if (message instanceof QueryMessage)
{
QueryMessage msg = (QueryMessage) message;
s1 = msg.getName();
s2 = msg.getData() != null ? msg.getData().toString() : null;
}
+ else
+ {
+ s2 = message.toString();
+ }
final String title = StringUtils.trimToEmpty(s1);
final String text = StringUtils.trimToEmpty(s2);
=====================================
src/de/willuhn/jameica/services/inject/InjectHandlerResource.java
=====================================
@@ -19,6 +19,7 @@ import javax.annotation.Resource;
import de.willuhn.annotation.Inject;
import de.willuhn.annotation.Injector;
+import de.willuhn.boot.Bootable;
import de.willuhn.jameica.plugin.Plugin;
import de.willuhn.jameica.services.BeanService;
import de.willuhn.jameica.system.Application;
@@ -108,9 +109,17 @@ public class InjectHandlerResource implements InjectHandler
// Anhand des Typs suchen - aber nur, wenn wir die Abhaengigkeit nicht schon haben
if (dep == null && c != null)
{
- Logger.trace(" inject bean " + c.getSimpleName() + " into " + name);
- BeanService service = Application.getBootLoader().getBootable(BeanService.class);
- dep = service.get(c); // aufloesen
+ if (isBootable(c))
+ {
+ Logger.trace(" inject bootable " + c.getSimpleName() + " into " + name);
+ dep = Application.getBootLoader().getBootable(c); // direkt als Bootable laden
+ }
+ else
+ {
+ Logger.trace(" inject bean " + c.getSimpleName() + " into " + name);
+ BeanService service = Application.getBootLoader().getBootable(BeanService.class);
+ dep = service.get(c); // aufloesen per Beanservice
+ }
}
if (dep == null) // nichts gefunden
@@ -132,6 +141,27 @@ public class InjectHandlerResource implements InjectHandler
}
},Resource.class);
}
+
+ /**
+ * Prueft, ob die Klasse ein Bootable ist.
+ * Die Funktion sucht nur direkt in der Klasse. Nicht in den Elternklassen.
+ * @param type der Typ.
+ * @return true, wenn es ein Bootable ist.
+ */
+ private static boolean isBootable(Class type)
+ {
+ Class[] interfaces = type.getInterfaces();
+ if (interfaces == null || interfaces.length == 0)
+ return false;
+
+ for (Class c:interfaces)
+ {
+ if (c.equals(Bootable.class))
+ return true;
+ }
+
+ return false;
+ }
}
=====================================
src/de/willuhn/jameica/system/AbstractApplicationCallback.java
=====================================
@@ -32,20 +32,6 @@ public abstract class AbstractApplicationCallback implements ApplicationCallback
Settings settings = new Settings(ApplicationCallback.class);
private String hostname = null;
- /**
- * ct.
- */
- public AbstractApplicationCallback()
- {
- // Migration: Loeschen der Checksummen - werden nicht mehr gebraucht
- if (settings.getString("jameica.system.callback.checksum",null) != null)
- {
- Logger.info("removing obsolete checksums");
- settings.setAttribute("jameica.system.callback.checksum",(String) null);
- settings.setAttribute("jameica.system.callback.checksum.salt",(String) null);
- }
- }
-
/**
* @see de.willuhn.jameica.system.ApplicationCallback#getHostname()
*/
@@ -53,7 +39,15 @@ public abstract class AbstractApplicationCallback implements ApplicationCallback
{
if (StringUtils.trimToNull(this.hostname) != null)
return this.hostname;
-
+
+ // Checken, ob wir einen gespeicherten Hostnamen haben
+ this.hostname = this.settings.getString("jameica.hostname",null);
+ if (this.hostname != null && this.hostname.length() > 0)
+ {
+ Logger.info("using manually configured hostname: " + this.hostname);
+ return this.hostname;
+ }
+
try
{
InetAddress a = InetAddress.getLocalHost();
@@ -76,11 +70,6 @@ public abstract class AbstractApplicationCallback implements ApplicationCallback
Logger.write(Level.DEBUG,"stacktrace for debugging purpose",e);
}
- // Checken, ob wir einen gespeicherten Hostnamen haben
- this.hostname = this.settings.getString("jameica.hostname",null);
- if (this.hostname != null && this.hostname.length() > 0)
- return this.hostname;
-
// BUGZILLA 26 http://www.willuhn.de/bugzilla/show_bug.cgi?id=26
String question =
Application.getI18n().tr("Der Hostname Ihres Computers konnte nicht ermittelt werden.\n" +
=====================================
src/de/willuhn/jameica/system/Platform.java
=====================================
@@ -161,7 +161,7 @@ public class Platform
{
Logger.warn("resetting \"ask\" flag in .jameica.properties");
BootstrapSettings.setAskWorkdir(true);
- throw new ApplicationException("Bitte versuchen Sie, Jameica erneut zu starten und wählen Sie einen anderen Benuzterordner.",e);
+ throw new ApplicationException("Bitte versuchen Sie, Jameica erneut zu starten und wählen Sie einen anderen Benutzerordner.",e);
}
}
=====================================
src/de/willuhn/jameica/transport/HttpTransport.java
=====================================
@@ -11,17 +11,22 @@
package de.willuhn.jameica.transport;
import java.io.File;
+import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
+import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.List;
+import org.apache.commons.lang.StringUtils;
+
import de.willuhn.annotation.Lifecycle;
import de.willuhn.annotation.Lifecycle.Type;
import de.willuhn.io.IOUtil;
+import de.willuhn.jameica.messaging.StatusBarMessage;
import de.willuhn.jameica.system.Application;
import de.willuhn.logging.Logger;
import de.willuhn.util.ApplicationException;
@@ -43,6 +48,7 @@ public class HttpTransport implements Transport
}
private URL url = null;
+ private URL target = null;
/**
* @see de.willuhn.jameica.transport.Transport#init(java.net.URL)
@@ -66,7 +72,7 @@ public class HttpTransport implements Transport
return file.exists();
}
- HttpURLConnection conn = (HttpURLConnection) this.url.openConnection();
+ HttpURLConnection conn = this.getConnection();
conn.connect();
return conn.getResponseCode() == HttpURLConnection.HTTP_OK;
}
@@ -91,7 +97,7 @@ public class HttpTransport implements Transport
return file.length();
}
- URLConnection conn = this.url.openConnection();
+ URLConnection conn = this.getConnection();
conn.connect();
return conn.getContentLength();
}
@@ -114,7 +120,7 @@ public class HttpTransport implements Transport
if (os == null)
throw new ApplicationException(i18n.tr("Kein Download-Ziel angegeben"));
- URLConnection conn = this.url.openConnection();
+ URLConnection conn = this.getConnection();
conn.connect();
if (monitor != null) monitor.setStatusText(i18n.tr("Download von {0}",this.url.toString()));
@@ -189,6 +195,67 @@ public class HttpTransport implements Transport
IOUtil.close(is,os);
}
}
+
+ /**
+ * Liefert die HTTP-Connection.
+ * @return die HTTP-Connection.
+ * @throws Exception
+ */
+ private HttpURLConnection getConnection() throws Exception
+ {
+ // Wir machen die URL-Aufloesung der Redirects nicht jedesmal neu.
+ if (this.target != null)
+ return (HttpURLConnection) this.target.openConnection();
+
+
+ URL curr = this.url;
+
+ // BUGZILLA 1867 Maximal 10 Redirects
+ for (int i=0;i<10;++i)
+ {
+ HttpURLConnection conn = (HttpURLConnection) curr.openConnection();
+ conn.setInstanceFollowRedirects(false); // Wir machen die Redirects selbst
+
+ int code = conn.getResponseCode();
+
+ if (code != HttpURLConnection.HTTP_MOVED_PERM && code != HttpURLConnection.HTTP_MOVED_TEMP)
+ {
+ // Wir haben eine finale URL
+ this.target = curr;
+ return conn;
+ }
+
+ // Wir haben einen HTTP-Code fuer eine Umleitung. Checken, ob wir eine neue Redirect-Ziel haben
+ String loc = StringUtils.trimToNull(conn.getHeaderField("Location"));
+
+ // Wir haben zwar einen HTTP-Code fuer eine Umleitung. Wir haben aber gar keine
+ // neue URL erhalten. Dann koennen wir auch nichts machen.
+ if (loc == null)
+ {
+ Logger.warn("got http status moved (" + code + ") but no location");
+ return conn;
+ }
+
+ URL prev = curr;
+ loc = URLDecoder.decode(loc, "UTF-8");
+ curr = new URL(this.url, loc); // fuer relative Location-Header
+
+ // Wir akzeptieren die Umleitung nur dann, wenn der Hostname identisch geblieben ist.
+ // Umleitungen auf andere Server akzeptieren wir aus Sicherheitsgruenden nicht
+ String s1 = this.url.getHost();
+ String s2 = curr.getHost();
+ if (!StringUtils.equalsIgnoreCase(s1,s2))
+ {
+ Application.getMessagingFactory().sendMessage(new StatusBarMessage(Application.getI18n().tr("Umleitung von {0} auf {1} aus Sicherheitsgrnden nicht erlaubt",s1,s2),StatusBarMessage.TYPE_ERROR));
+ throw new SecurityException("got http redirect with change to another host, not permitted for security reasons [source: " + s1 + ", target: " + s2 + "]");
+ }
+
+ // naechster Versuch.
+ Logger.info("got redirect from " + prev + " to " + curr);
+ }
+
+ throw new IOException("too many redirects for url: " + this.url);
+ }
/**
* @see de.willuhn.jameica.transport.Transport#getProtocols()
View it on GitLab: https://salsa.debian.org/java-team/jameica/commit/ddf3c9b19924f483029c803fd85e9a507fd6f082
--
View it on GitLab: https://salsa.debian.org/java-team/jameica/commit/ddf3c9b19924f483029c803fd85e9a507fd6f082
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20190130/ecf6a10e/attachment.html>
More information about the pkg-java-commits
mailing list