Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/master' into extract_com…
Browse files Browse the repository at this point in the history
…mon_xmlparser_functionality

# Conflicts:
#	common/pom.xml
#	core/src/main/java/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
#	core/src/main/java/net/sourceforge/jnlp/runtime/html/AppletExtractor.java
#	core/src/main/java/net/sourceforge/jnlp/security/dialogs/InetSecurity511Panel.java
#	core/src/main/java/net/sourceforge/jnlp/util/XDesktopEntry.java
#	core/src/test/java/net/sourceforge/jnlp/ServerAccess.java
#	xml-parser/src/main/java/net/adoptopenjdk/icedteaweb/xmlparser/MalformedXMLParser.java
#	xml-parser/src/main/java/net/adoptopenjdk/icedteaweb/xmlparser/ParseException.java
  • Loading branch information
AndreasEhret committed Apr 5, 2019
2 parents 266c0a5 + 58fd714 commit 940fbf8
Show file tree
Hide file tree
Showing 36 changed files with 507 additions and 181 deletions.
5 changes: 0 additions & 5 deletions common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@
<artifactId>slf4j-api</artifactId>
<version>1.7.26</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.26</version>
</dependency>
</dependencies>

</project>
5 changes: 5 additions & 0 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
<artifactId>js</artifactId>
<version>1.7R1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.26</version>
</dependency>

<dependency>
<groupId>junit</groupId>
Expand Down
20 changes: 12 additions & 8 deletions core/src/main/java/net/sourceforge/jnlp/AppletDesc.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import net.sourceforge.jnlp.config.DeploymentConfiguration;
import net.sourceforge.jnlp.runtime.JNLPRuntime;
import net.sourceforge.jnlp.util.logging.OutputController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.net.URL;
import java.util.HashMap;
Expand All @@ -32,6 +34,8 @@
*/
public class AppletDesc implements LaunchDesc {

private final static Logger LOG = LoggerFactory.getLogger(AppletDesc.class);

/** the applet name */
private final String name;

Expand Down Expand Up @@ -145,32 +149,32 @@ private Integer fixWidth() {
}

private Integer fixSize(String depKey, String... keys) {
OutputController.getLogger().log("Found to small applet!");
LOG.info("Found to small applet!");
try {
Integer depVal = Integer.valueOf(JNLPRuntime.getConfiguration().getProperty(depKey));
if (depVal == 0) {
OutputController.getLogger().log("using its size");
LOG.info("using its size");
return null;
}
if (depVal < 0) {
OutputController.getLogger().log("enforcing " + depVal);
LOG.info("enforcing {}", depVal);
return Math.abs(depVal);
}
for (String key : keys) {
for (final String key : keys) {
String sizeFromParam = parameters.get(key);
if (sizeFromParam != null) {
try {
OutputController.getLogger().log("using its "+key+"=" + sizeFromParam);
LOG.info("using its {}={}", key, sizeFromParam);
return Integer.valueOf(sizeFromParam);
} catch (NumberFormatException ex) {
OutputController.getLogger().log(ex);
}
}
}
OutputController.getLogger().log("defaulting to " + depVal);
LOG.info("defaulting to {}", depVal);
return depVal;
} catch (NumberFormatException | NullPointerException ex) {
OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ex);
} catch (final NumberFormatException | NullPointerException ex) {
LOG.error("ERROR", ex);
return null;
}
}
Expand Down
6 changes: 5 additions & 1 deletion core/src/main/java/net/sourceforge/jnlp/ExtensionDesc.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import net.adoptopenjdk.icedteaweb.xmlparser.ParseException;
import net.sourceforge.jnlp.util.logging.OutputController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.net.URL;
Expand All @@ -36,6 +38,8 @@
*/
public class ExtensionDesc {

private final static Logger LOG = LoggerFactory.getLogger(ExtensionDesc.class);

/** the extension name */
private final String name;

Expand Down Expand Up @@ -127,7 +131,7 @@ public void resolve() throws ParseException, IOException {
if (file == null) {
file = new JNLPFile(location);

OutputController.getLogger().log("Resolve: " + file.getInformation().getTitle());
LOG.info("Resolve: {}", file.getInformation().getTitle());

// check for it being an extension descriptor
if (!file.isComponent() && !file.isInstaller())
Expand Down
8 changes: 6 additions & 2 deletions core/src/main/java/net/sourceforge/jnlp/JNLPFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import net.sourceforge.jnlp.util.ClasspathMatcher;
import net.sourceforge.jnlp.util.UrlUtils;
import net.sourceforge.jnlp.util.logging.OutputController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.FileInputStream;
Expand Down Expand Up @@ -64,6 +66,8 @@
*/
public class JNLPFile {

private final static Logger LOG = LoggerFactory.getLogger(JNLPFile.class);

public static enum ManifestBoolean {
TRUE, FALSE, UNDEFINED;
}
Expand Down Expand Up @@ -349,7 +353,7 @@ public String getTitle(boolean kill) throws MissingTitleException {
title = R("PMissingMandatorySubstitution", R("PMissingTitle"));
OutputController.getLogger().log(OutputController.Level.WARNING_ALL, R("PMissingMandatoryWarning", R("PMissingTitle")) + ": " + title);
} else {
OutputController.getLogger().log("Acceptable title tag found, contains: " + title);
LOG.info("Acceptable title tag found, contains: {}", title);
}
return title;
}
Expand Down Expand Up @@ -414,7 +418,7 @@ public String getVendor(boolean kill) throws MissingVendorException {
vendor = R("PMissingMandatorySubstitution", R("PMissingVendor"));
OutputController.getLogger().log(OutputController.Level.WARNING_ALL, R("PMissingMandatoryWarning", R("PMissingVendor")) + ": " + vendor);
} else {
OutputController.getLogger().log("Acceptable vendor tag found, contains: " + vendor);
LOG.info("Acceptable vendor tag found, contains: {}", vendor);
}
return vendor;
}
Expand Down
14 changes: 9 additions & 5 deletions core/src/main/java/net/sourceforge/jnlp/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import net.sourceforge.jnlp.util.StreamUtils;
import net.sourceforge.jnlp.util.logging.OutputController;
import net.sourceforge.swing.SwingUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sun.awt.SunToolkit;

import javax.swing.text.html.parser.ParserDelegator;
Expand Down Expand Up @@ -61,6 +63,8 @@
*/
public class Launcher {

private final static Logger LOG = LoggerFactory.getLogger(Launcher.class);

// defines class Launcher.BgRunner, Launcher.TgThread

/** shared thread group */
Expand Down Expand Up @@ -505,8 +509,8 @@ protected ApplicationInstance launchApplication(JNLPFile file) throws LaunchExce

try {
ServiceUtil.checkExistingSingleInstance(file);
} catch (InstanceExistsException e) {
OutputController.getLogger().log("Single instance application is already running.");
} catch (final InstanceExistsException e) {
LOG.error("Single instance application is already running.", e);
return null;
}

Expand Down Expand Up @@ -570,7 +574,7 @@ public void run() {

main.setAccessible(true);

OutputController.getLogger().log("Invoking main() with args: " + Arrays.toString(args));
LOG.info("Invoking main() with args: {}", Arrays.toString(args));
main.invoke(null, new Object[] { args });

return app;
Expand Down Expand Up @@ -655,7 +659,7 @@ protected ApplicationInstance launchApplet(JNLPFile file, boolean enableCodeBase
applet.getAppletEnvironment().startApplet(); // this should be a direct call to applet instance
return applet;
} catch (InstanceExistsException ieex) {
OutputController.getLogger().log("Single instance applet is already running.");
LOG.error("Single instance applet is already running.", ieex);
throw launchError(new LaunchException(file, ieex, R("LSFatal"), R("LCLaunching"), R("LCouldNotLaunch"), R("LSingleInstanceExists")), applet);
} catch (LaunchException lex) {
throw launchError(lex, applet);
Expand Down Expand Up @@ -688,7 +692,7 @@ protected ApplicationInstance getApplet(JNLPFile file, boolean enableCodeBase, C
return applet;

} catch (InstanceExistsException ieex) {
OutputController.getLogger().log("Single instance applet is already running.");
LOG.info("Single instance applet is already running.");
throw launchError(new LaunchException(file, ieex, R("LSFatal"), R("LCLaunching"), R("LCouldNotLaunch"), R("LSingleInstanceExists")), applet);
} catch (LaunchException lex) {
throw launchError(lex, applet);
Expand Down
9 changes: 7 additions & 2 deletions core/src/main/java/net/sourceforge/jnlp/NetxPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import net.sourceforge.jnlp.splashscreen.SplashPanel;
import net.sourceforge.jnlp.splashscreen.SplashUtils;
import net.sourceforge.jnlp.util.logging.OutputController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sun.applet.AppletViewerPanelAccess;
import sun.awt.SunToolkit;

Expand All @@ -44,6 +46,9 @@
* @author Francis Kung &lt;[email protected]&gt;
*/
public class NetxPanel extends AppletViewerPanelAccess implements SplashController {

private final static Logger LOG = LoggerFactory.getLogger(NetxPanel.class);

private final PluginParameters parameters;
private PluginBridge bridge = null;
private AppletInstance appInst = null;
Expand Down Expand Up @@ -137,11 +142,11 @@ protected synchronized void createAppletThread() {
synchronized (JNLPRuntime.initMutex) {
//The custom NetX Policy and SecurityManager are set here.
if (!JNLPRuntime.isInitialized()) {
OutputController.getLogger().log("initializing JNLPRuntime...");
LOG.info("initializing JNLPRuntime...");

JNLPRuntime.initialize(false);
} else {
OutputController.getLogger().log("JNLPRuntime already initialized");
LOG.info("JNLPRuntime already initialized");
}
}

Expand Down
8 changes: 6 additions & 2 deletions core/src/main/java/net/sourceforge/jnlp/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import net.sourceforge.jnlp.UpdateDesc.Check;
import net.sourceforge.jnlp.UpdateDesc.Policy;
import net.sourceforge.jnlp.util.logging.OutputController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
Expand Down Expand Up @@ -50,6 +52,8 @@
*/
public final class Parser {

private final static Logger LOG = LoggerFactory.getLogger(Parser.class);

private static String CODEBASE = "codebase";
private static String MAINCLASS = "main-class";
private static final Pattern anyWhiteSpace = Pattern.compile("\\s");
Expand Down Expand Up @@ -493,8 +497,8 @@ private PackageDesc getPackage(Node node) throws ParseException {
* @throws RequiredElementException
*/
void checkForInformation() throws RequiredElementException {
OutputController.getLogger().log("Homepage: " + file.getInformation().getHomepage());
OutputController.getLogger().log("Description: " + file.getInformation().getDescription());
LOG.info("Homepage: {}", file.getInformation().getHomepage());
LOG.info("Description: {}", file.getInformation().getDescription());
file.getTitle(strict);
file.getVendor(strict);
}
Expand Down
30 changes: 17 additions & 13 deletions core/src/main/java/net/sourceforge/jnlp/PluginBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import net.sourceforge.jnlp.util.UrlUtils;
import net.sourceforge.jnlp.util.logging.OutputController;
import net.sourceforge.jnlp.util.replacements.BASE64Decoder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.ByteArrayInputStream;
import java.io.File;
Expand All @@ -50,6 +52,8 @@
*/
public final class PluginBridge extends JNLPFile {

private final static Logger LOG = LoggerFactory.getLogger(PluginBridge.class);

private final PluginParameters params;
final private Set<String> jars = new HashSet<>();
private List<ExtensionDesc> extensionJars = new ArrayList<>();
Expand Down Expand Up @@ -143,8 +147,8 @@ InputStream getStream() throws Exception {
}
}.readStream();
}
OutputController.getLogger().log("Loaded JNLPhref:");
OutputController.getLogger().log((debugJnlp == null) ? "null" : debugJnlp);
LOG.info("Loaded JNLPhref:");
LOG.info((debugJnlp == null) ? "null" : debugJnlp);

if (jnlpFile.isApplet())
main = jnlpFile.getApplet().getMainClass();
Expand Down Expand Up @@ -466,7 +470,7 @@ public boolean haveDebugJnlp() {

public String toJnlp(boolean needSecurity, boolean useHref, boolean fix) {
if (useJNLPHref && debugJnlp != null && useHref) {
OutputController.getLogger().log("Using debugjnlp as return value toJnlp");
LOG.info("Using debugjnlp as return value toJnlp");
if (fix) {
return fixCommonIsuses(needSecurity, debugJnlp);
} else {
Expand Down Expand Up @@ -501,8 +505,8 @@ public String toJnlp(boolean needSecurity, boolean useHref, boolean fix) {
}
s.append(" </applet-desc>\n"
+ "</jnlp>\n");
OutputController.getLogger().log("toJnlp generated:");
OutputController.getLogger().log(s.toString());
LOG.info("toJnlp generated:");
LOG.info(s.toString());
return s.toString();
}

Expand Down Expand Up @@ -548,7 +552,7 @@ private String fixCommonIsuses(boolean needSecurity, String orig) {
static String fixCommonIsuses(boolean needSecurity, String orig, String codebase, String title, String vendor) {
//no information element at all
if (!orig.matches(toMatcher(CLOSE_INFORMATION_REGEX))) {
OutputController.getLogger().log("no information element Found. Trying to fix");
LOG.info("no information element Found. Trying to fix");
if (orig.matches(toMatcher(SECURITY_REGEX))) {
orig = orig.replaceAll(SECURITY_REGEX, "\n<information>\n</information>\n<security>\n");
} else {
Expand All @@ -559,32 +563,32 @@ static String fixCommonIsuses(boolean needSecurity, String orig, String codebase
}
//some have missing codebase, thats fatal
if (!orig.matches(toMatcher(CODEBASE_REGEX1))) {
OutputController.getLogger().log("jnlphref did not had codebase. Fixing");
LOG.info("jnlphref did not had codebase. Fixing");
orig = orig.replaceAll("(?i)<\\s*jnlp\\s+", "<jnlp codebase='" + codebase + "' ");
} else {
//codebase="."
if (orig.matches(toMatcher(CODEBASE_REGEX2))) {
OutputController.getLogger().log("'.' codebase found. fixing");
LOG.info("'.' codebase found. fixing");
orig = orig.replaceAll(CODEBASE_REGEX2, " codebase='" + codebase + "'");
}
}
//surprisingly also title or vendor may be misisng
if (!orig.matches(toMatcher(TITLE_REGEX))) {
OutputController.getLogger().log("Missing title. Fixing");
LOG.info("Missing title. Fixing");
orig = orig.replaceAll(CLOSE_INFORMATION_REGEX, "\n<title>" + title + "</title>\n</information>\n");
}
if (!orig.matches(toMatcher(VENDOR_REGEX))) {
OutputController.getLogger().log("Missing vendor. Fixing");
LOG.info("Missing vendor. Fixing");
orig = orig.replaceAll(CLOSE_INFORMATION_REGEX, "\n<vendor>" + vendor + "</vendor>\n</information>\n");
}
//also all-security is not enforced via jnlpHref
if (needSecurity && !orig.matches(toMatcher(AP_REGEX))) {
OutputController.getLogger().log("all-permissions not found and app is signed.");
LOG.info("all-permissions not found and app is signed.");
if (orig.matches(SANDBOX_REGEX)) {
OutputController.getLogger().log("Replacing sandbox by all-permissions");
LOG.info("Replacing sandbox by all-permissions");
orig = orig.replaceAll(SANDBOX_REGEX, getAllPermissionsElement());
} else {
OutputController.getLogger().log("adding security element");
LOG.info("adding security element");
orig = orig.replaceAll(CLOSE_INFORMATION_REGEX, "</information>\n" + getSecurityElement());
}
}
Expand Down
8 changes: 6 additions & 2 deletions core/src/main/java/net/sourceforge/jnlp/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import net.sourceforge.jnlp.runtime.JNLPRuntime;
import net.sourceforge.jnlp.runtime.Translator;
import net.sourceforge.jnlp.util.logging.OutputController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.swing.JOptionPane;
import java.util.ArrayList;
Expand Down Expand Up @@ -46,7 +48,9 @@
* @version $Revision: 1.5 $
*/
public class Version {


private final static Logger LOG = LoggerFactory.getLogger(Version.class);

/**
* This is special case of version, used only for checking jre version. If
* jre do not match, in strict not-headless mode the dialog with
Expand Down Expand Up @@ -88,7 +92,7 @@ public JreVersion(String v, boolean strict) {
OutputController.getLogger().log(OutputController.Level.WARNING_ALL, s);
}
} else {
OutputController.getLogger().log("good - your JRE - " + getJreVersion() + " - match requested JRE - " + v);
LOG.info("good - your JRE - {} - match requested JRE - {}", getJreVersion(), v);
}
}

Expand Down
Loading

0 comments on commit 940fbf8

Please sign in to comment.